Class PartialEk9StringToInstructionBlock

java.lang.Object
org.ek9lang.compiler.common.PartialEk9StringToInstructionBlock
All Implemented Interfaces:
Function<String, PartialEk9StringToInstructionBlock.Result>

public class PartialEk9StringToInstructionBlock extends Object implements Function<String, PartialEk9StringToInstructionBlock.Result>
Parses a bit of EK9 source as an instructionBlock — a contiguous run of block statements (the body of a method / function / loop / branch). This is the sub-rule counterpart to PartialEk9StringToTypeDef: instead of the whole compilation unit, ANTLR is entered at the instructionBlock rule.

Used by the extract-method analysis: the selected block's raw text is re-parsed here to (a) get an isolated tree to classify variable def/use on, and (b) validate the selection lands on statement boundaries — a snippet that does not parse cleanly as an instruction block is a mid-statement / unbalanced selection, surfaced through PartialEk9StringToInstructionBlock.Result.hasErrors().

Indentation: instructionBlock itself carries no enclosing INDENT/DEDENT (the grammar wraps it in block for that), so the snippet should be supplied left-trimmed to column 0; any nested if/for/ while bodies keep their relative indent and the indentation lexer emits their INDENT/DEDENT pairs. The text must end with a newline (the rule requires each statement be followed by NL+).