PEG.js is a parser generator for JavaScript based on the parsing expression grammar formalism. It enables you to easily bulid fast parsers which process complex data or computer languages. You can use it as an underlying tool when writing various data processors, transformers, interpreters, or compilers.

PEG.js workflow scheme

Features

  • Usable from your browser, from JavaScript code, or from a command-line
  • Simple and expressive grammar syntax
  • No separate lexical analysis step — both lexical and syntactical analysis are handled by one tool
  • Handles wide class of grammars (superset of LL(k) and LR(k))
  • Precise and human-friendly error reporting