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_governed | Parses the statement a control keyword or statement macro governs, or a block item at AST_BLOCK. |
Compiler.parse_statement | Parses and binds one statement or statement-position macro at the current token. |
Compiler.with_binding | Returns the binding of the current identifier when it names a live with expression, or NULL. |
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:260
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:250
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:163
Compiler.parse_block_item
List Compiler.parse_block_item(Compiler c)
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:506
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:621
Compiler.parse_compound_statement
List Compiler.parse_compound_statement(Compiler c)
Parses a compound body after its opening brace and consumes the closing
}, returning an origin-anchored (block ...) node.
Source: src/statements.x:662
Compiler.parse_governed
List Compiler.parse_governed(Compiler c, AstPos position)
Parses the statement a control keyword or statement macro governs, or a
block item at AST_BLOCK. Directives written before it stay in front of
it in a (group DIRECTIVE... STATEMENT), which emits without braces, so
each directive stays where C read it. A conditional group they open also
takes the statement of each later arm and the closing directive, so a
statement macro that wraps its body in braces keeps the whole group
inside them. A later statement in the same arm follows the governed one,
as in C.
Source: src/statements.x:70
Compiler.parse_statement
List Compiler.parse_statement(Compiler c)
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:533
Compiler.with_binding
List Compiler.with_binding(Compiler c)
Returns the binding of the current identifier when it names a live
with expression, or NULL.
Source: src/statements.x:492
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.