This is a C implementation of an operator-precedence parser to evaluate mathematical equations.
The program executes the mathematical expression passed in via argv or stdin:
$ calc "1+2"
3
$ echo "1+2" | calc
3
Alternatively running the program without arguments enables REPL mode:
$ calc
= 1+2
3
= ans+5
8
Operator | Description |
---|---|
+ |
Addition |
- |
Subtraction / Unary Negative |
/ |
Division |
* |
Multiplication |
( |
Left Parenthesis |
) |
Right Parenthesis |
Name | Description |
---|---|
ans |
Previously Calculated Answer |
- No support for non-integer math
- No support for creating variables
- No builtin functions
- No history buffer