Skip to main content

Module ast

Module ast 

Source
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§

FieldDef
One field in a struct, or one labelled value carried by an enum case, like the x: int in struct Point { x: int } or the radius: float in circle(radius: float). Same shape as a parameter, but it names data rather than an argument, so it gets its own type for clarity.
MatchArm
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: int in func f(x: int).
TypeAnn
A written type annotation, like the int in var count: int or the [int] in let primes: [int]. Types nest, so this is recursive.
VariantDef
One case of an enum, like circle(radius: float) or the payload-less dot.

Enums§

AssignOp
BinOp
Expr
Pattern
What a match arm tests for.
Stmt
TypeKind
UnOp