Cheatsheet

Constructs

Construct name Syntax Semantics
Line comments /text Ignored by the parser
Inline & block comments ((text)) Ignored by the parser
Brackets [code] Like parenthesis
Definition identifier: body Defines a rule
Reference ruleName References / “calls” a named rule
Literal "text" or 'text' Matches exact text
Set <characters> Matches any single contained character
Sequences rule1 rule2 ... Matches several rules in order
Choice rule1 | rule2 | ...* Matches any of several rules
Optional ?rule Optionally matches a rule
Oneplus +rule Matches a rule once or more
Zeroplus *rule Matches a rule zero or more times
Lambda {rule} Makes a new state for rule
Result #rule Sets the state to value from rule
Adjoinment $rule Appends text from rule to state
Property key=rule Maps key on state to value from rule
Extension &rule Appends a node to the state

* Leading and trailing pipes are allowed

Builtins

Name Description or equivalent code
any Matches any single character except \0
newline +<\c\l>. Use in lieu of \n, which doesn’t exist.
whitespace Matches any single whitespace character
_ *whitespace
lower <abcdefghijklmnopqrstuvwxyz>
upper <ABCDEFGHIJKLMNOPQRSTUVWXYZ>
alpha lower | upper
digit <1234567890>
alphanum alpha | digit