A PEG parser generator language

Px is a grammar-description language and compiler for parsers and code generators. You write one grammar, in Px, and Px compiles it into whichever of these you need:

Px grammars are PEGs (Parsing Expression Grammars) written in a BNF-like notation, but with repetition operators (? * +) and lookahead assertions (& !) moved into prefix position, ahead of what they apply to, rather than trailing it. This copies the underlying Pegexp library, which doesn’t need to pre-compile the matching expressions in order to achieve good performance, as is the case with most regular expression implementations.

An example of a rule is this number rule from Px’s own JSON grammar:

number	= ?'-' (|'0' | [1-9] *[0-9]) ?('.' +[0-9]) ?([eE] ?[-+] +[0-9])

Read left to right: an optional -, then either a bare 0 or a non-zero digit followed by more digits, then an optional . followed by digits, then an optional exponent. It’s just a different way to write a regular expression. Or as we will see, a non-regular one, because a rule can call itself directly or through other rules.

Where to start