Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.
src/statements.x
X2c statement parsing.
Functions
| Function | Summary |
|---|---|
Compiler.begin_catch_arm | Opens a Sym scope for one catch arm and defines a nonempty filter’s definite pattern binders. |
Compiler.begin_match_arm | Opens a Sym scope for one match arm and optionally defines its definite pattern binders. |
Compiler.finish_return_statement | Builds a return node for an optional expression without consuming tokens. |
Compiler.parse_block_item | Parses one block-position declaration, statement, or macro insertion. |
Compiler.parse_block_items | Parses block items after an already-consumed opening brace through } and returns a (block ...) node. |
Compiler.parse_compound_statement | Parses a compound body after its opening brace and consumes the closing }, returning an origin-anchored (block ...) node. |
Compiler.parse_statement | Parses and binds one statement or statement-position macro at the current token. |
Compiler
Compiler.begin_catch_arm
void Compiler.begin_catch_arm(Compiler compiler, List pattern, Token start)
Opens a Sym scope for one catch arm and defines a nonempty filter’s
definite pattern binders. The caller must pop the scope after parsing or
binding the arm body; binder diagnostics use start.
Source: src/statements.x:180
Compiler.begin_match_arm
void Compiler.begin_match_arm( Compiler compiler, List pattern, Token start, int binds)
Opens a Sym scope for one match arm and optionally defines its definite
pattern binders. The caller must pop the scope after parsing or binding the
arm body; binder diagnostics use start.
Source: src/statements.x:170
Compiler.finish_return_statement
List Compiler.finish_return_statement(Compiler compiler, List expression)
Builds a return node for an optional expression without consuming tokens.
A present expression is resolved in the current Sym scope and includes
the current return_type for later conversion.
Source: src/statements.x:86
Compiler.parse_block_item
List Compiler.parse_block_item(Compiler compiler)
Parses one block-position declaration, statement, or macro insertion.
The caller owns the surrounding scope; a macro insertion may return a
(seq ...) node containing several block items.
Source: src/statements.x:323
Compiler.parse_block_items
List Compiler.parse_block_items(Compiler c, int anchor_items)
Parses block items after an already-consumed opening brace through } and
returns a (block ...) node. The call opens one lexical Sym scope;
anchor_items records statement origins and distributes a macro sequence’s
invocation origin over its inserted items.
Source: src/statements.x:455
Compiler.parse_compound_statement
List Compiler.parse_compound_statement(Compiler compiler)
Parses a compound body after its opening brace and consumes the closing
}, returning an origin-anchored (block ...) node.
Source: src/statements.x:497
Compiler.parse_statement
List Compiler.parse_statement(Compiler compiler)
Parses and binds one statement or statement-position macro at the current
token. On return, the cursor follows the complete statement and any
temporary Sym scopes opened by the statement have been closed.
Source: src/statements.x:353
Design notes
Parses control flow and block constructs: if/else, while/for/do,
switch/match/case/default, labels/goto, break/continue,
try/catch, raise, defer, return, empty statements, and compound
blocks. Return checking uses the return type that declaration parsing
recorded. Catch arms select Error records with %() match patterns.