This is a commandline calculator that takes in an expression, stores the numbers/operators in an abstract syntax tree, and returns the result.
This can account for parentheses, modulus, adddition, subtraction, modulus, division (negative and positive numbers). This cannot yet take care of decimals, however.
To compile the program, do gcc evalexpr.c
and use ./a.out "EXPRESSION"
to see the answer.
E.g. ./a.out "3 + 5"
or ./a.out "(3 * 5) + 6"
.