The toy CLI calculator writed as an exercies. It uses Pratt's Top Down Operator Precedence technique also described in this article.
✓ 1 + 1 => 2
✓ 2 - 1 => 1
✓ -1 => -1
✓ +1 => 1
✓ 2 + 3*3 => 11
✓ 4/2 => 2
✓ 4 / 2^2 => 1
✓ 2 * (1 + 1) => 4
✓ pow(2, 2)^2 => 16
✓ a = 10; b = a + 5 => 15
✔ 10 tests complete (9ms)
$ npm install https://github.com/eldargab/calc.js
To run tests first install dev dependencies
$ npm install -d
then run
$ make test
To start repl:
$ make repl
or simply invoke calc executable.
MIT