This was done for my CS 480 class.
This does simple lexical analysis and building an Abstract Syntax Tree to evaluate simple mathematical expresssions
It currently handles PEMDAS, functions, and understanding parentheses back to back as multiplication
This requires NodeJS and npm.
Clone the repository.
npm install
npm run build
This will build the typescript code into executable NodeJS.
Once built, you can run it with:
./bin/calc <expression>
The entire expression must be the first argument so if you want to add spaces, you must use quotes.
Parantheses and other special characters confuse the shell so you will need to escape them with \
or use quotes.
Test can be ran with:
npm run test