Expand description
The abstract syntax tree: the shape of a parsed lux program.
A program is a list of statements. Statements declare names, assign to
them, branch, loop, define functions, return, or evaluate an expression for
its effect (like print). Expressions produce values. Every node carries a
Span so the interpreter can blame the right place when something goes
wrong.
Structs§
- Field
Def - One field in a struct, or one labelled value carried by an enum case, like
the
x: intinstruct Point { x: int }or theradius: floatincircle(radius: float). Same shape as a parameter, but it names data rather than an argument, so it gets its own type for clarity. - Match
Arm - One arm of a
match: a pattern and the expression to evaluate when it fits. - Param
- One parameter in a function signature, like the
x: intinfunc f(x: int). - TypeAnn
- A written type annotation, like the
intinvar count: intor the[int]inlet primes: [int]. Types nest, so this is recursive. - Variant
Def - One case of an enum, like
circle(radius: float)or the payload-lessdot.