Provisional API: This reference documents current compiler behavior. Compatibility is not yet promised.
src/parse.x
X2c recursive-descent parser core.
Functions
| Function | Summary |
|---|---|
Compiler.bind_syntax | Binds parser-shaped syntax at context into current compiler state. |
Compiler.finish_foreign_alias | Constructs a foreign alias from one direct function declaration and target. |
Compiler.package_alias_spelling | Returns the folded package-member spelling at the current token, or NULL. |
Compiler.parse_basic_identifier | Consumes one ident token and returns its spelling as a one-item List. |
Compiler.parse_complex_identifier | Parses the current identifier or dotted owner/member as a one-item name. |
Compiler.parse_declaration_argument | Parses one non-function, non-typedef Decl macro argument. |
Compiler.parse_declaration_row | Parses one x2c declaration row and leaves its terminator current. |
Compiler.parse_enumerator | Parses one enumerator for enum type context and returns its AST. |
Compiler.parse_enumerators | Parses comma-separated enumerators up to the current closing brace. |
Compiler.parse_field | Parses one field for aggregate type context and returns its AST. |
Compiler.parse_fields | Parses aggregate fields in source order up to the current closing brace. |
Compiler.parse_function_definition | Parses one function declaration and its required compound body. |
Compiler.parse_function_target | Parses one function decorator target and returns its resulting AST. |
Compiler.parse_import_declaration | Parses and registers one import declaration, including its semicolon. |
Compiler.parse_optional_identifier | Consumes and returns the current identifier, or NULL without consuming. |
Compiler.parse_parameter | Parses one parameter and returns (param TYPE DECLARATOR) or (...). |
Compiler.parse_parameter_list | Parses a nonempty comma-separated parameter List in source order. |
Compiler.parse_simple_declaration | Parses one declaration group and leaves its terminating token current. |
Compiler.parse_top_level | Parses one top-level form and applies its source-ordered compiler effects. |
Compiler.parse_type_name | Parses a type specifier with qualifiers and pointer/reference modifiers. |
Compiler.test_declaration | Tests whether the current token can begin a declaration without consuming. |
Compiler
Compiler.bind_syntax
List Compiler.bind_syntax( Compiler compiler, Var syntax, AstPos context, Type return_type)
Binds parser-shaped syntax at context into current compiler state.
The input must evaluate to a nonempty AST List valid for the requested
AstPos. Bindings, types, scopes, and expressions are resolved in source
order; return_type applies only while descendants are bound. This method
mutates Sym and does not open a semantic transaction.
Source: src/parse.x:1622
Compiler.finish_foreign_alias
List Compiler.finish_foreign_alias( Compiler c, List declaration, List native_syntax)
Constructs a foreign alias from one direct function declaration and target.
native_syntax must resolve to a different direct identifier and, when
typed, a function. Storage is limited to static or inline, when
present, and variadic parameters are rejected.
Source: src/parse.x:1566
Compiler.package_alias_spelling
String Compiler.package_alias_spelling(Compiler c)
Returns the folded package-member spelling at the current token, or NULL.
The token must be an unshadowed imported alias followed by . and an
identifier. This lookahead does not consume tokens.
Source: src/parse.x:30
Compiler.parse_basic_identifier
List Compiler.parse_basic_identifier(Compiler compiler)
Consumes one ident token and returns its spelling as a one-item List.
Source: src/parse.x:108
Compiler.parse_complex_identifier
List Compiler.parse_complex_identifier(Compiler compiler)
Parses the current identifier or dotted owner/member as a one-item name.
Package aliases and imported method spellings are folded through the
current Sym, and all accepted tokens are consumed.
Source: src/parse.x:103
Compiler.parse_declaration_argument
List Compiler.parse_declaration_argument(Compiler c)
Parses one non-function, non-typedef Decl macro argument.
Returns a single declaration without consuming the invocation delimiter;
flat destructuring may omit an initializer in this position.
Source: src/parse.x:1194
Compiler.parse_declaration_row
List Compiler.parse_declaration_row(Compiler compiler)
Parses one x2c declaration row and leaves its terminator current.
A mixed-type comma row returns a seq of declarations in source order;
a single declaration returns directly.
Source: src/parse.x:1053
Compiler.parse_enumerator
List Compiler.parse_enumerator(Compiler c, Type context)
Parses one enumerator for enum type context and returns its AST.
Outside macro-template parsing, its binding is published immediately so
later initializers and enumerators can resolve it.
Source: src/parse.x:487
Compiler.parse_enumerators
List Compiler.parse_enumerators(Compiler c, List context)
Parses comma-separated enumerators up to the current closing brace.
Returns their flat source-order List and leaves the brace unconsumed.
Source: src/parse.x:538
Compiler.parse_field
List Compiler.parse_field(Compiler compiler, List context)
Parses one field for aggregate type context and returns its AST.
Ordinary fields publish their binding in the aggregate’s field scope and
consume their terminating semicolon; macro forms follow their own syntax.
Source: src/parse.x:392
Compiler.parse_fields
List Compiler.parse_fields(Compiler c, List context)
Parses aggregate fields in source order up to the current closing brace.
Returns a flat field List, publishes delegate-field metadata, and leaves
the closing brace unconsumed.
Source: src/parse.x:412
Compiler.parse_function_definition
List Compiler.parse_function_definition(Compiler compiler)
Parses one function declaration and its required compound body. The parameter bindings are active while the body is parsed, and the first token after the closing brace remains current.
Source: src/parse.x:1228
Compiler.parse_function_target
List Compiler.parse_function_target(Compiler compiler)
Parses one function decorator target and returns its resulting AST. A compatible unit macro at the current token is expanded first; otherwise an ordinary function definition is required.
Source: src/parse.x:1241
Compiler.parse_import_declaration
List Compiler.parse_import_declaration(Compiler c)
Parses and registers one import declaration, including its semicolon.
The alias defaults to the package name; with members add source-ordered
local spellings. These spellings affect source resolution only; the package
name in the returned AST drives the generated header include.
Source: src/parse.x:1286
Compiler.parse_optional_identifier
List Compiler.parse_optional_identifier(Compiler compiler)
Consumes and returns the current identifier, or NULL without consuming.
Source: src/parse.x:115
Compiler.parse_parameter
List Compiler.parse_parameter(Compiler compiler)
Parses one parameter and returns (param TYPE DECLARATOR) or (...).
Outside macro-template parsing, a named parameter is installed in the
current Sym scope. The following delimiter remains current.
Source: src/parse.x:671
Compiler.parse_parameter_list
List Compiler.parse_parameter_list(Compiler c)
Parses a nonempty comma-separated parameter List in source order.
The caller owns the parameter scope; the first non-comma delimiter remains
current.
Source: src/parse.x:684
Compiler.parse_simple_declaration
List Compiler.parse_simple_declaration(Compiler compiler)
Parses one declaration group and leaves its terminating token current.
Declared names are installed in Sym as their declarators are completed;
the result is one declare, typedef, or initialized dstrdecl AST.
Source: src/parse.x:1036
Compiler.parse_top_level
List Compiler.parse_top_level(Compiler c)
Parses one top-level form and applies its source-ordered compiler effects. Returns its AST, or NULL when a keyword definition or top-level Lisp form only updates compiler state, with the first following token current.
Source: src/parse.x:1320
Compiler.parse_type_name
Type Compiler.parse_type_name(Compiler compiler)
Parses a type specifier with qualifiers and pointer/reference modifiers.
Returns its flat Type AST and leaves the first following token current.
Source: src/parse.x:599
Compiler.test_declaration
int Compiler.test_declaration(Compiler compiler)
Tests whether the current token can begin a declaration without consuming. Typedefs, package aliases, and macro-hole kinds are resolved through the current compiler state.
Source: src/parse.x:1029
Design notes
Converts token streams into AST nodes for declarations and top-level constructs. Expression, statement, and literal parsing are in their own modules and are invoked via the Compiler.* entry points.
Declaration parsing recognizes initializers and finds the function body. Type resolution and lexical scopes use the Compiler’s current symbol environment; failures retain positioned diagnostic context.