3.4.3 File Statements
MS-VBAL groups the file I/O statements under one umbrella section, MS-VBAL §5.4.5 File Statements. Each file statement is cross-referenced below to its MS-VBAL section and to the RD-VBAL page that describes its implementation; see also RD-VBAL §5.4.5 File Statements.
Open Statement
OpenStatementNode's Mode, Access and Lock are keyword choices, not expressions. They are typed VBFileMode, VBFileAccessMode and VBFileLockMode.
Lock and Unlock Statements
Lock and Unlock have an AST node of their own, FileLockStatementNode, because their record-range (MS-VBAL §5.4.5.4) has three shapes and a flat input list could tell only two of them apart:
record-range = start-record-number / ([start-record-number] "To" end-record-number)
Lock #1, 5 locks record 5, and Lock #1, To 5 locks records 1 through 5. Each carries one expression, so a flat input list cannot distinguish them. FileLockStatementNode's StartRecord and EndRecord are therefore named properties rather than positional inputs:
| Statement | StartRecord |
EndRecord |
|---|---|---|
Lock #1, 5 |
5 |
null |
Lock #1, 2 To 5 |
2 |
5 |
Lock #1, To 5 |
null |
5 |
An absent start-record-number stays absent in FileLockStatementNode: the node does not fill in 1. MS-VBAL says of an absent start-record-number: "the effect is as if <start-record-number> consisted of the integer number token 1". The implied start record 1 is a runtime semantic, not something the program wrote, so the node does not model it; see RD-VBAL §5.4.5.4 Lock Statement.
Output Lists
PrintStatementNode, ObjectPrintExpressionNode and DebugPrintStatementNode share one output-list shape (MS-VBAL §5.4.5.8.1 Output Lists):
| Node | Represents |
|---|---|
| PrintOutputItemNode | An output item: a value and/or a ; or , separator. |
| PrintSpcClauseNode | A Spc clause. |
| PrintTabClauseNode | A Tab clause. |
Tip
In a parsed output list, a value and its trailing separator are always two separate, alternating PrintOutputItemNodes: one value-only, one separator-only. MS-VBAL's outputItem grammar rule admits combining a value and its separator into one output item, but the generated parser never takes that alternative. A consumer of Items should walk the alternating list rather than assume (value, separator) pairs.
Note
Not implemented. The ? shorthand for Print has no lexer or grammar token.
⏮️ RD-VBAL §3.4.2 Simple Statements | ⏭️ RD-VBAL §3.5.0 Instructions