Quick exercise to learn Rust by writing a calculator.
Fundamentally, a calculator is the simplest form of compiler.
A very simple tokenizer & parser, no need for a symbol table or to handle scoping.
to setup, first install cargo, then run cargo run
to start the calculator
General execution is as follows:
- Listen to input in terminal
- Parse the parts of the input using regular expressions: a. left-hand side b. operator c. right-hand side
- Validate the input matches expectations
- Execute the action associated to the operator
- Log the output of the execution