Expand description
The ECMAScript 2025 abstract syntax tree.
The tree is a straightforward Box/Vec tree: the compiler (M2) walks it once per function body and immediately lowers it to bytecode, so an arena or visitor infrastructure would not pay for itself yet.
Naming follows the specification: Script/Module bodies, StatementListItem
(a statement or a declaration), BindingIdentifier, AssignmentTarget,
PropertyDefinition, ClassStaticBlock, … Where the spec covers two
productions with one node (a function declaration and a function expression,
a script and a module), the node carries a discriminant instead of being
duplicated.
Structs§
- Catch
Clause - The
catchhalf of atrystatement. - Class
- A class body.
- Declarator
- One
pattern = initdeclarator. - Export
Decl export …- Export
Specifier - One entry of an
export { … }clause. - Expr
- An expression.
- Function
- A function in any of its forms (declaration, expression, arrow, method).
- Ident
- An identifier (binding, reference, label or private name).
- Import
Attribute with { key: "value" }- Import
Decl import …- Member
Pattern - A member expression used as an assignment target.
- Pattern
- A binding pattern or assignment target.
- Program
- A whole program: a script or a module.
- Stmt
- A statement or declaration.
- Switch
Case - One
case/defaultclause. - Template
Chunk - One chunk of a
TemplateLiteral. - Template
Literal - A template literal:
quasis.len() == expressions.len() + 1. - VarDecl
- A declaration statement, with all of its declarators.
Enums§
- Array
Element - One element of an array literal.
- Assign
Op - Assignment operators.
- Binary
Op - Non-short-circuiting binary operators.
- Class
Element - One member of a class body.
- Export
Kind - The variants of an export declaration.
- Expr
Kind - Expression payloads.
- ForHead
- The left-hand side of a
for-in/for-ofhead. - ForInit
- The
initslot of a classicforstatement. - Function
Body - The body of a
Function. - Import
Specifier - One entry of an import clause.
- Logical
Op - Short-circuiting operators.
- Member
Prop - Property selector of a member expression.
- Method
Kind - Which kind of method a class member or object literal property defines.
- Module
Name - The name on either side of a module binding, which may be a string.
- Object
Property - One property of an object literal.
- Pattern
Element - An element of an array or object pattern.
- Pattern
Kind - Pattern payloads.
- Program
Kind - Which grammar production a
Programis. - PropKey
- A literal property key.
- Prop
KeyRef - Borrowed view of a
PropKey, used by the compiler. - Prop
Name - A property key.
- Property
Kind - What an object-literal property does with its value.
- Rest
Element ...in a pattern.- Stmt
Kind - Statement and declaration nodes (
StatementListItem). - UnaryOp
- Unary operators.
- Update
Op ++/--.- VarDecl
Kind var/let/const.