PLDB
Languages Features Calendar CSV Lists Blog About Sponsor Add Language
GitHub icon

PEG.js

PEG.js

PEG.js is a grammar language created in 2010 by David Majda.

#311on PLDB 12Years Old 5.7kUsers
0Books 0Papers 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 Example Token
Comments
// A comment
MultiLine Comments
/* A comment
*/
/* */
Line Comments
// A comment
//
Semantic Indentation ϴ
ioke.html · pegjs.html · halide.html

View source

PLDB - Build the next great programming language · v2022 · Day 32 · Docs · Build · Acknowledgements · Traffic Today · Traffic Trends · Mirrors · GitHub · feedback@pldb.com