3.0.2 Node Types
All AST nodes inherit SyntaxNode. SyntaxNode is an
abstract node type. It associates a semantic ID
(SyntaxNodeId) with a specific location in a
workspace source file.
The node types derived directly from SyntaxNode are as follows:
Every statement node derives from StatementNode, which implements
IExecutableNode. A statement node's Inputs are the
expressions evaluated immediately before the statement executes.
Expression Nodes
The following expression node types have their own semantics pages:
| Expression | Node type | Described in |
|---|---|---|
| A bare name | SimpleNameExpressionNode | RD-VBAL §5.6.10 Simple Name Expressions |
| Member access | MemberAccessExpressionNode | RD-VBAL §5.6.12 Member Access Expressions |
| Index | IndexExpressionNode | RD-VBAL §5.6.13 Index Expressions |
| Dictionary access | DictionaryAccessExpressionNode | RD-VBAL §5.6.14 Dictionary Access Expressions |
New <class> |
NewExpressionNode | RD-VBAL §5.6.8 New Expressions |
TypeOf <expr> Is <type> |
TypeOfIsExpressionNode | RD-VBAL §5.6.7 TypeOf...Is Expressions |
The target of an assignment statement draws from the first four: member access, index, dictionary access, or a bare name (RD-VBAL §3.4.2 Simple Statements).
Unbuilt Trivia Nodes
A grammar alternative that the parser recognizes but has no dedicated node type for is never silently dropped from the AST. It is never folded into an unrelated node either. It is preserved as an Unbuilt trivia node:
| Position | Node type |
|---|---|
| Expression | UnbuiltExpressionTriviaNode |
| Statement | UnbuiltStatementTriviaNode, the statement-position counterpart of UnbuiltExpressionTriviaNode |
An Unbuilt trivia node carries:
- the exact original source text of the construct;
- whatever sub-expression the parser's own walk already built underneath it.
The Unbuilt trivia fallback keeps the AST a faithful, lossless representation of the source, even where a proper semantic node does not exist. The fallback applies to any construct without a dedicated node type.
It also applies to code with a syntax error:
- A binary operator with no right operand at the end of its statement (
a = 1 -,Foo 1 Mod) is a syntax error, reported as a zero-width range at the operator: before a+,-,*,=,Like,Is,Mod,And,Or,Xor,EqvorImp, after a/,\,^,&,<>,<,>,<=or>=. The operation is kept as an Unbuilt expression of its text (1 -), with its left operand under it, so the statement keeps its operator. The statement ends at its own line end or colon, and the next statement is read on its own. - A statement that no grammar rule reads (
a = 1-, with no space before the operator, orIf x = 1 - Then) is kept as an Unbuilt statement of its text, at its place in the procedure. - So is a statement that begins with a word no statement begins with (
Mod = 1), in the body of a block too, and after a label or a line number (L1: Mod = 1), which stays its label. An operator keyword is a reserved identifier and names no variable (MS-VBAL §3.3.5.2). The syntax error is at that word, and the next statement is read on its own. - A declaration with a word that is no name where its name is written (
Dim For As Long,Dim 1 As Long,Dim Mod As Long) is a syntax error at that word. The statement is kept at its place, and the next statement is read on its own. - A parameter named with a reserved identifier (
Sub S(ByVal Mod As Long),Sub S(ByVal Scale As Long)) is a syntax error at the name (MS-VBAL §5.3.1.5). The procedure is still read whole. - A statement has one syntax error, the first one the parser finds in it. Two statements on one line (
a = 1 -: b = = 2) have one error each.