Questions Concepts
GitHub icon

PEG.js

PEG.js - Grammar language

< >

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

Source code:
git clone https://github.com/pegjs/pegjs
#311on PLDB 13Years Old 72Repos

Try now: Web

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 Token Example
Comments
// A comment
MultiLine Comments /* */
/* A comment
*/
Line Comments //
// A comment
Semantic Indentation X

View source

- Build the next great programming language · Search · Add Language · Features · Creators · Resources · About · Blog · Acknowledgements · Queries · Stats · Sponsor · Traffic · Traffic Today · Day 305 · feedback@pldb.com · Logout