Compilation of different programming
projects I amuse myself with.
Sunday, 10 November 2019
Arithmetic parser in Javascript
I just added an arithmetic parser in Javascript code sample on Github, check out the following repo:
JsSimpleParser
The parser is also available through Npm:
https://www.npmjs.com/package/simplejsparsermatharithmetic
Installation:
npm i simplejsparsermatharithmetic
Supported expressions (examples):
2+3 should evaluate to 5
12 * 5–(5 * (32 + 4)) + 3 should evalute to -117
This is a great example of how to write a parser of your own.
No comments:
Post a Comment