Skip to main content

Module ast

Module ast 

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

CatchClause
The catch half of a try statement.
Class
A class body.
Declarator
One pattern = init declarator.
ExportDecl
export …
ExportSpecifier
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).
ImportAttribute
with { key: "value" }
ImportDecl
import …
MemberPattern
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.
SwitchCase
One case/default clause.
TemplateChunk
One chunk of a TemplateLiteral.
TemplateLiteral
A template literal: quasis.len() == expressions.len() + 1.
VarDecl
A declaration statement, with all of its declarators.

Enums§

ArrayElement
One element of an array literal.
AssignOp
Assignment operators.
BinaryOp
Non-short-circuiting binary operators.
ClassElement
One member of a class body.
ExportKind
The variants of an export declaration.
ExprKind
Expression payloads.
ForHead
The left-hand side of a for-in/for-of head.
ForInit
The init slot of a classic for statement.
FunctionBody
The body of a Function.
ImportSpecifier
One entry of an import clause.
LogicalOp
Short-circuiting operators.
MemberProp
Property selector of a member expression.
MethodKind
Which kind of method a class member or object literal property defines.
ModuleName
The name on either side of a module binding, which may be a string.
ObjectProperty
One property of an object literal.
PatternElement
An element of an array or object pattern.
PatternKind
Pattern payloads.
ProgramKind
Which grammar production a Program is.
PropKey
A literal property key.
PropKeyRef
Borrowed view of a PropKey, used by the compiler.
PropName
A property key.
PropertyKind
What an object-literal property does with its value.
RestElement
... in a pattern.
StmtKind
Statement and declaration nodes (StatementListItem).
UnaryOp
Unary operators.
UpdateOp
++/--.
VarDeclKind
var/let/const.