Created
October 18, 2016 10:05
-
-
Save DmitrySoshnikov/eb4d27e205516d491f0074300016657f to your computer and use it in GitHub Desktop.
using-calc-parser.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CalcParser = require('./CalcParser.js'); | |
console.log(CalcParser.parse('2 + 2 * 2')); // AST | |
/* | |
Result: | |
{ | |
type: "Binary", | |
left: { | |
type: "Primary", | |
value: 2 | |
}, | |
right: { | |
type: "Binary", | |
left: { | |
type: "Primary", | |
value: 2 | |
}, | |
right: { | |
type: "Primary", | |
value: 2 | |
}, | |
"op": "*" | |
}, | |
"op": "+" | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment