Abstract Syntax Tree
Abstract Syntax Tree
Section titled “Abstract Syntax Tree”AST stands for Abstract Syntax Tree.
It is the structured representation of NXL code.
The AST contains concepts such as:
ProgramStatementExpressionLiteralValueProgram
Section titled “Program”A program contains statements:
Program { statements: Vec<Statement>}For:
let x = 10let y = 20the structure is:
Program├── VariableDeclaration└── VariableDeclarationStatements
Section titled “Statements”Current statement concepts include:
VariableDeclarationExpressionBlockIfFunctionReturnExpressions
Section titled “Expressions”Current expression concepts include:
LiteralIdentifierBinaryUnaryAssignmentCallExample
Section titled “Example”Source:
let result = a + b * 2AST:
VariableDeclaration│├── name: result│└── initializer │ ▼ Binary(+) / a Binary(*) / b 2This tree is what the interpreter eventually walks.