Module parser

Module parser 

Source
Expand description

The Python surface: recursive descent for statements, Pratt for expressions.

docs/02-syntax.md §2.8: “hand-written recursive descent + Pratt for expressions. Not a parser generator. Rationale: error messages and error recovery are the top-two UX properties of a new language.”

The output is the same Node tree the S-expression reader produces — that equivalence is asserted directly in tests/surfaces.rs, and it is the whole claim of §2.2. Two surface rules carry most of the weight:

  • The block rule (§2.3): any call written f(args): followed by an indented block desugars to f(args, do=quote(block)). That single rule buys the entire Lisp special-form vocabulary with Python punctuation — ui:, atomically:, retry(times=3): are all ordinary calls.
  • Decorators are AST transforms (§2.3): @on(server) before a def becomes (decorate (on server) (def ...)), so the decorator receives the definition’s AST rather than a function object.

Structs§

Parser

Functions§

parse_expr_str
Parse a single expression — used by beck ast and by tests.
parse_module
Parse a whole module.