Skip to content

Instantly share code, notes, and snippets.

@DmitrySoshnikov
Created October 18, 2016 10:05
Show Gist options
  • Save DmitrySoshnikov/eb4d27e205516d491f0074300016657f to your computer and use it in GitHub Desktop.
Save DmitrySoshnikov/eb4d27e205516d491f0074300016657f to your computer and use it in GitHub Desktop.
using-calc-parser.js
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