Implemented with function pointer style of command pattern. I used the
function pointer style of the command pattern rather than inheritance because
I originally intended to use this problem as an experiment in GO and RUST where
function pointers are first class citizens.
- Uses recursive descent parser to apply operator precedence
- function pointer operator interface makes adding new operators easy.
- V 0.001
- (C) Jan-2017, MIT Free Use, No promises, No Warranty
- Tested with Node version V4.4.1
- Install Node JS
- Download repository
- CD into install directory
- Ensure Node executable is in path
- Run using node command line.
How to run tests
Using Windows Shell
Run Test Harness: calcTest.bat Run REPL: calc.bat
Run Test Harness: node calcTest.bat Run REPL: node calcREPL.js
5 + 4 C + 8 =
3! / 11 A + 9 =
3! / 11 =
0.4 1/x * 3 =
807 * 807 =
Known improvements Needed
- Define a more formal operator precedence syntax.
- Define more formal support for immediate unary versus binary operators
- Support parameterized functions.
- Need more extensive set of tests.
- Remove need for grep pre processor requires improving next token to handle syntax variations directly.
Who do I talk to?
- Joe Ellsworth http://BayesAnalytic.com/contact