Parsing tokens into a source-shaped AST.
| Status | Active — §2.1 leaders + expressions (chumsky) |
| Owners | echo_parser, echo_ast |
| Library | chumsky 0.9 (ADR 0011) |
| Related | docs/syntax.md, docs/lexer.md, ADR 0003 |
echo_source → echo_lexer → echo_parser (chumsky) → echo_ast
↓
echo_diagnostics
echo_syntax (leader facts)
Hosts call echo_parser::parse (or xo ast); they do not reimplement grammar.
- Input is tokens from
echo_lexer(leaders already classified). - Output is
echo_ast::File(source-shaped; no types / resolution). - CLI:
xo ast [--kinds] [--diag-codes] <file> - Suite:
e26requires.astviaast --kinds --diag-codes - No trailing commas (matches
syntax.md); do not re-enableallow_trailingwithout a syntax change - Field assigns accept dotted chains:
~ a.b.c = e,~ .a.b = e(ASTAssignTarget::Fieldwith nestedExpr::Fieldbase) - Index assigns:
~ xs[i] = e,~ a.b[i] = e(AssignTarget::Indexwith index); list push:~ xs[] = e,~ a.b[] = e(AssignTarget::Indexwithindex: None; field path before[is allowed) - Edge cases must be justified (see
AGENTS.md— Justified edge cases only)
- Richer recovery strategies as the grammar grows (must not invent meaning)
- Pratt combinator vs layered expr when expr surface expands
- Multi-bind (
~ a = 1, b = 2/$ x = 1, y = 2) is locked and expanded to sequential binds after parse (no trailing comma)