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

PEG.js

< >

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

#320on PLDB 13Years 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 Token Example
Comments
// A comment
MultiLine Comments /* */
/* A comment
*/
Line Comments //
// A comment
Semantic Indentation X
autohotkey.html · pegjs.html · g-code.html

View source

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