Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.
src/expressions.x
X2c expression parsing.
Functions
| Function | Summary |
|---|---|
Compiler.complete_iter_chain | Completes an eligible resolved Iter call chain for immediate consumption. |
Compiler.convert_expression | Adds operations to convert a resolved expression AST to target. |
Compiler.convert_segment_to_string | Converts a resolved interpolation segment to String when available. |
Compiler.parse_assignment | Parses one right-associative assignment expression. |
Compiler.parse_conditional | Parses a binary expression and its optional conditional tail. |
Compiler.parse_expression | Parses an assignment expression and any following comma expressions. |
Compiler.parse_macro_expression_target | Parses one macro target through the cast-expression grammar. |
Compiler.parse_parenthesized_statement | Parses a statement beginning with (. |
Compiler.parse_primary | Parses one primary expression or expression-valued macro slot. |
Compiler.parse_variable | Parses and resolves one complex identifier expression. |
Compiler.resolve_expression | Resolves and type-annotates one expression AST in current compiler state. |
Compiler.resolve_map_entry | Resolves the key and value of one (map-entry key value) AST row. |
Compiler.resolve_postfix_member | Resolves one field or method selection without consuming parser tokens. |
Compiler
Compiler.complete_iter_chain
List Compiler.complete_iter_chain(Compiler compiler, List expression)
Completes an eligible resolved Iter call chain for immediate consumption.
It accepts only a typed identifier call of the form
(expr R (call (expr ((func P) T) (ident B)) (args A))), where R and
the last formal in P canonicalize to Iter. Iter arguments are
completed recursively; a call missing only that last formal receives the
hidden destination. Variadic calls and Iter_unzip are returned unchanged.
Source: src/expressions.x:43
Compiler.convert_expression
List Compiler.convert_expression(Compiler c, List expr, Type target)
Adds operations to convert a resolved expression AST to target.
The result may contain converter, boxing, unboxing, Func, reference, or
composite-literal operations. Returns the original expression when C
performs the conversion implicitly; an unsupported x2c conversion reports
a type error through c. Synthesized operations may add generated
bindings or immutable literal entries to compiler state.
Source: src/expressions.x:2165
Compiler.convert_segment_to_string
List Compiler.convert_segment_to_string(Compiler compiler, List expr)
Converts a resolved interpolation segment to String when available.
A missing String conversion is expected: the transform boxes that segment
to Var and renders it at runtime.
A declared numeric converter keeps its formatting; other numeric segments
use Var.str. A segment statically spelled Var also uses Var.str for
every
runtime tag. The ordinary Var-to-String conversion is
not equivalent: it
extracts only a String payload and yields empty String for every other
tag.
Source: src/expressions.x:2422
Compiler.parse_assignment
List Compiler.parse_assignment(Compiler compiler)
Parses one right-associative assignment expression.
A parenthesized identifier list on the left becomes a destructuring
assignment only for =. compiler.token stops after the expression.
Source: src/expressions.x:1774
Compiler.parse_conditional
List Compiler.parse_conditional(Compiler compiler)
Parses a binary expression and its optional conditional tail.
The false arm recurses at conditional precedence, making ?:
right-associative, and compiler.token stops after the expression.
Source: src/expressions.x:1754
Compiler.parse_expression
List Compiler.parse_expression(Compiler compiler)
Parses an assignment expression and any following comma expressions.
A comma expression retains source order and takes the type of its final
value. compiler.token stops at the first token outside the expression.
Source: src/expressions.x:1834
Compiler.parse_macro_expression_target
List Compiler.parse_macro_expression_target(Compiler compiler)
Parses one macro target through the cast-expression grammar.
Parsing starts at compiler.token and leaves it at the first token after
the target.
Source: src/expressions.x:604
Compiler.parse_parenthesized_statement
List Compiler.parse_parenthesized_statement(Compiler c)
Parses a statement beginning with (.
The ordinary parameter parser consumes the contents once: one anonymous
parameter is a cast type, while named parameters are destructuring
declarations. Everything following an ordinary parenthesized expression
resumes at the postfix tail it had already reached. This entry consumes
the terminating ; and returns (stmnt expression) or an origin-anchored
(dstrdecl ...).
Source: src/expressions.x:1857
Compiler.parse_primary
List Compiler.parse_primary(Compiler compiler)
Parses one primary expression or expression-valued macro slot.
Dispatch starts at compiler.token to the selected literal, identifier,
grouping, or macro parser and leaves the token after that primary form.
Source: src/expressions.x:1781
Compiler.parse_variable
List Compiler.parse_variable(Compiler c)
Parses and resolves one complex identifier expression.
Parsing starts at compiler.token and leaves it after the identifier.
Source: src/expressions.x:1734
Compiler.resolve_expression
List Compiler.resolve_expression(Compiler compiler, List input, Token origin)
Resolves and type-annotates one expression AST in current compiler state.
Existing expr type annotations are resolved semantic types.
Already-resolved trees without unresolved descendants and non-expression
inputs are returned unchanged; abstract declarations use the declaration
binder. origin anchors diagnostics and generated operations that must
retain source position.
Source: src/expressions.x:1613
Compiler.resolve_map_entry
List Compiler.resolve_map_entry(Compiler compiler, List input, Token origin)
Resolves the key and value of one (map-entry key value) AST row.
Any other shape is reported at origin as a parse error.
Source: src/expressions.x:1597
Compiler.resolve_postfix_member
List Compiler.resolve_postfix_member( Compiler c, Type receiver_type, List field, Symbol access, int call_context)
Resolves one field or method selection without consuming parser tokens.
field is a single-name List and access is . or
->. The result is a
(field access type), (method binding signature), or (ambiguous ...)
row, or NULL when no member is visible. Method lookup is enabled only by
call_context and records the selected binding in compiler.sym.
Source: src/expressions.x:200
Design notes
Parses postfix operators and calls, unary operators and casts, binary operators with precedence/associativity, conditionals, assignment, primary/grouped forms, and comma folding. Precedence and associativity follow C; dotted method sugar and string-like addition use resolved type information from the compiler and type modules.