Skip to main content

Module parser

Module parser 

Source
Expand description

CRUDUI expression parser: Vec<Token> → AST (expressions.md §3/§4, JS/PHP Parser parity).

Recursive-descent grammar (EBNF, lowest precedence first):

  ternary    = or [ "?" ternary ":" ternary ]        (right-associative)
  or         = and { "||" and }
  and        = not { "&&" not }
  not        = "!" not | comparison
  comparison = primary [ cmp_op cmp_value | in_op value_list ]
  primary    = "(" or ")" | path | literal
  path       = [ "." | ".." ] identifier { "." (identifier | number | "*") }

Priority and right-associativity come from the grammar productions, not a heuristic. No eval, no split (GRAMMAR §10).

Structs§

Parser
Recursive-descent parser over a lexer’s token stream (must end in EOF).

Constants§

MAX_EXPRESSION_DEPTH
The most nodes on a path from the root of an expression’s syntax tree to a leaf. A deeper expression is a parse error in every runtime.