PEG.js is an open source grammar language created in 2010 by David Majda.
#181on PLDB | 14Years Old | 72Repos |
git clone https://github.com/pegjs/pegjs
PEG.js is a simple parser generator for JavaScript that produces fast parsers with excellent error reporting. You can use it to process complex data or computer languages and build transformers, interpreters, compilers and other tools easily.
start
= additive
additive
= left:multiplicative "+" right:additive { return left + right; }
/ multiplicative
multiplicative
= left:primary "*" right:multiplicative { return left * right; }
/ primary
primary
= integer
/ "(" additive:additive ")" { return additive; }
integer "integer"
= digits:[0-9]+ { return parseInt(digits.join(""), 10); }
Feature | Supported | Example | Token |
---|---|---|---|
Comments | ✓ | // A comment | |
MultiLine Comments | ✓ | /* A comment */ | /* */ |
Line Comments | ✓ | // A comment | // |
Semantic Indentation | X |