Top 1K Features Creators Events Podcasts Books Extensions Interviews Blog Explorer CSV

PEG.js

< >

PEG.js is an open source grammar language created in 2010 by David Majda.

#181on PLDB 14Years Old 72Repos
Download source code:
git clone https://github.com/pegjs/pegjs
Homepage · REPL · Source Code · Twitter

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.


Example from the web:
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); }

Language features

Feature Supported Example Token
Comments ✓ // A comment
MultiLine Comments ✓ /* A comment */ /* */
Line Comments ✓ // A comment //
Semantic Indentation X

- Build the next great programming language · Add · Issues · About · Search · Keywords · Livestreams · Labs · Resources · Acknowledgements

Built with Scroll v146.1.0