Pest: Grammar Cheat Sheet
PEG Syntax Constraints
- Syntactic vs Lexical:
- Atomic rules (
rule @{ ... }) generally do NOT consume internal whitespace.
- Compound rules (
rule = { ... }) DO consume whitespace implicitly if WHITESPACE is defined.
- Special Rules:
WHITESPACE = _{ " " | "\t" | "\n" } (Underscore _ makes it silent).
COMMENT = _{ "//" ~ (!NEWLINE ~ ANY)* }
- Anchors:
- Always start the top-level rule with
SOI (Start of Input) and end with EOI.
- Example:
file = { SOI ~ (stmt)* ~ EOI }
- Greediness: -
* and + are eager. - Ordered choice | is first-match-wins. Put specific matches first (e.g., "<=" | "<").