3.4.1 Block Statements
A block statement holds nested statements. The block statements belong to MS-VBAL §5.4.2 Control Statements; each is cross-referenced below to its MS-VBAL section and to the RD-VBAL page that describes its implementation.
Node Shape
Every block statement node follows the same shape:
- its header condition(s) and expression(s) are named properties of the node;
- its nested statements are held in a
Bodyproperty of type StatementBlock.
The uniform Body: StatementBlock shape is deliberate. It keeps the whole block-statement family (the block statements of MS-VBAL §5.4.2) consistent, rather than giving each node an undifferentiated list of children.
Three nodes hold their nested statements differently:
| Node | Nested statements |
|---|---|
InlineIfStatementNode |
One StatementBlock per branch: ThenBody and ElseBody. |
CaseExpressionStatementNode |
A StatementBlock named Block. |
SelectCaseStatementNode |
No StatementBlock of its own: it holds its Case and Case Else nodes, and each of those holds one. |
A block statement's StatementBlock is independent of the statement node's Inputs; see RD-VBAL §3.4.0 Statements.
Following MS-VBAL, Next, Loop and Wend have no AST node of their own. The whole construct is one node (ForStatementNode, DoLoopStatementNode, and so on) with a Body; see RD-VBAL §3.5.3 Lowering Block Statements.
Do Loop Forms
Do...Loop has five header shapes, each represented by its own node type (MS-VBAL §5.4.2.6):
| Header shape | Node type |
|---|---|
Do ... Loop |
DoLoopStatementNode |
Do While ... Loop |
DoWhileLoopStatementNode |
Do Until ... Loop |
DoUntilLoopStatementNode |
Do ... Loop While |
DoLoopWhileStatementNode |
Do ... Loop Until |
DoLoopUntilStatementNode |
Single-line If
InlineIfStatementNode's ThenBody and ElseBody may each hold several colon-separated statements instead of a full block (MS-VBAL §5.4.2.9).
Tip
A bare line-number target in either branch (If x Then 100) is not modelled as its own AST shape. MS-VBAL specifies such a target as equivalent to a GoTo statement targeting that line. The parser therefore synthesizes a GoToStatementNode as that branch's statement, typically its only one.
Case Clauses
Each Case line's comma-separated conditions form their own node hierarchy under the abstract CaseRangeClauseNode. The three condition forms of MS-VBAL §5.4.2.10 are modelled independently, as three node types:
| Condition form | Example | Node type |
|---|---|---|
| Single value | Case 5 |
CaseValueRangeClauseNode |
| Comparison | Case Is > 5 |
CaseComparisonRangeClauseNode |
| Inclusive range | Case 1 To 10 |
CaseToRangeClauseNode |
⏮️ RD-VBAL §3.4.0 Statements | ⏭️ RD-VBAL §3.4.2 Simple Statements