Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.
src/statements.x
X2c statement parsing.
Functions
| Function | Summary |
|---|---|
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 } in a new lexical scope. |
Compiler.parse_callable_body | Parses a callable’s outer block in its active parameter scope. |
Compiler.parse_case_body | Parses a source match arm’s guard and body, declaring its typed types captures, inside the arm scope that the binder opened. |
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 <block>. |
Compiler.parse_match_row_argument | Parses one MatchRow macro argument with the ordinary match-arm owner. |
Compiler.parse_source_clause | Parses the clause kind of a source if, while, do, for, match, or try, with the punctuation after it, when the binder reaches that clause. |
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.finish_return_statement
List Compiler.finish_return_statement(Compiler c, List expr)
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:303
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:702
Compiler.parse_block_items
List Compiler.parse_block_items(Compiler c, int anchor_items)
Parses block items after an already-consumed opening brace through } in
a new lexical scope. anchor_items records statement origins.
Source: src/statements.x:745
Compiler.parse_callable_body
List Compiler.parse_callable_body(Compiler c)
Parses a callable’s outer block in its active parameter scope.
Source: src/statements.x:752
Compiler.parse_case_body
List Compiler.parse_case_body(Compiler c, List types)
Parses a source match arm’s guard and body, declaring its typed
types captures, inside the arm scope that the binder opened.
Source: src/statements.x:475
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:740
Compiler.parse_governed
List Compiler.parse_governed(Compiler c, Symbol position)
Parses the statement a control keyword or statement macro governs, or a
block item at <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:620
Compiler.parse_match_row_argument
List Compiler.parse_match_row_argument(Compiler c)
Parses one MatchRow macro argument with the ordinary match-arm owner.
Source: src/statements.x:427
Compiler.parse_source_clause
List Compiler.parse_source_clause(Compiler c, Symbol kind)
Parses the clause kind of a source if, while, do, for,
match, or try, with the punctuation after it, when the binder
reaches that clause. An absent else, for header, catch, or
finally clause is NULL.
Source: src/statements.x:223
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:74
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:206
Design notes
Compiler.parse_statement dispatches each statement form to one
production, which consumes its tokens in grammar order and returns its
node. Preprocessor directives between statements stay in the tree, so
each one emits where C read it. Return checking uses the return type
that declaration parsing recorded.