Skip to main content

Module parser

Module parser 

Source
Expand description

A Pratt (precedence-climbing) parser turning a token stream into an Expr. Tolerant: on a syntax error it returns Err(BaseError::Expr); callers render that as an inline error rather than failing the build.

Constants§

MAX_PARSE_DEPTH
Maximum expression nesting depth. Guards against a stack overflow from adversarial input (e.g. a .base filter of thousands of nested (/!/-): past this depth parse returns an error rather than recursing to a crash. The evaluator enforces a matching cap (see eval::MAX_EVAL_DEPTH).
MAX_PARSE_NODES
Maximum total AST nodes in one expression. Bounds a long postfix chain (a.a.a… / f()()()…), which is built iteratively and so escapes the depth guard — an unbounded chain would overflow both the evaluator and the recursive Box<Expr> drop. Real base expressions are tiny; this is a generous ceiling.

Functions§

parse
Parse a whole expression string. Trailing tokens after a complete expression are an error.