Class ProgramBlocks
- Namespace
- RDCore.SDK.Formatting
- Assembly
- RDCore.SDK.dll
The blocks of a program of the platform's BASIC (BasicProgramText) that a line is in and that the program does not close, as a shell offers to close them while the program is typed one numbered line at a time.
public static class ProgramBlocks
- Inheritance
-
ProgramBlocks
- Inherited Members
Remarks
What is a block, and which closer ends it, is what the program's syntax tree says, as ProgramIndenter has it: an If block
(MS-VBAL §5.4.2.8), a Select Case (§5.4.2.10), a For or For Each loop (§5.4.2.3, §5.4.2.4), a Do loop (§5.4.2.6), a
While loop (§5.4.2.2) and a With block (§5.4.2.21). A single-line If (§5.4.2.9) is not a block.
A block is closed by a statement that starts with its closer on the line it ends on, the last statement of its lines or one after a colon
(x = 1: End If); a closer that ends a block within it does not close it as well. A Next that lists names closes one loop for each name.
Methods
OpenAt(IReadOnlyList<string>, int, Func<string, ModuleParseResult>)
The blocks a line of a program is in that the program has no closer for: the line's own block when it opens one, and each block it is in.
public static IReadOnlyList<ProgramBlock> OpenAt(IReadOnlyList<string> statements, int index, Func<string, ModuleParseResult> parse)
Parameters
statementsIReadOnlyList<string>The statements of the program, in the order of their line numbers, without their numbers.
indexintThe index of the line in
statements.parseFunc<string, ModuleParseResult>Parses the text of a module: the program's statements as the body of its procedure.
Returns
- IReadOnlyList<ProgramBlock>
The open blocks, the innermost first; none when the line is in no open block, or when a statement has a line end in it.
Exceptions
- ArgumentNullException
statementsorparseis null.- ArgumentOutOfRangeException
indexis not that of a statement ofstatements.