Languages Features Creators Calendar CSV Resources Blog About Pricing Add Language
GitHub icon

PEG.js

PEG.js - Grammar language

< >

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

#318on 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

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