A simple math interpreter written in C++ using the Shunting-yard algorithm.
Watch the demo video.
crusade first tokenizes the given input and classifies them into numbers, operators, parentheses and so on. During this operation, it also validates the input and checks for invalid expressions like missing operators/operands/parentheses and so on.
The next step is to use the shunting yard algorithm to convert the infix expression to the reverse polish notation (aka postfix expression, eg. 1 + 2 - 3
=> 1 2 + 3 -
). I've also added a slight modification by providing unary operators with the highest precedence and right associativity. The evaluation of the postfix expression is pretty easy.
make
Just launch the executable file and you'd see a prompt. Enter your expressions here and press enter.
You can type /q
, exit
or quit
to exit the application.
You can also toggle the debug mode using the /debug
command. It will show your given expression in a parenthesized manner.
You can autocomplete these commands by pressing tab.
- Support for unary operators
- Pretty output
- Input history
- Tab Completions
- Functions
- The awesome linenoise library.