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.
Share this article on LinkedIn.
No comments:
Post a Comment