pub const DEFAULT_MAX_AST_DEPTH: usize = 128;Expand description
The DEFAULT maximum AST nesting depth.
The budget, measured: the parser’s own descent costs ~7 KiB of stack per
nesting level in debug builds (the fattest case — release and the
downstream walkers are far leaner), and the tightest standard
environments give ~2 MiB (worker threads) or ~1 MiB (browser wasm).
128 levels keeps the worst case inside the smallest stack with margin,
while being ~3× deeper than any hand-written program observed in the
corpus. Machines with deep stacks raise it via LOGOS_MAX_AST_DEPTH
(see max_ast_depth) — the limit protects the environment, so the
environment gets to size it. Enforced at parse time (recursion guard)
AND on the built tree, covering parenthesis towers, block pyramids, and
iteratively-built operator chains alike.