Source: src/parser/parser.lx
Core parser state and helpers: the Parser struct over the token stream, operator binding powers, and the token-to-operator lookup tables used by the expression and statement parsers.
Maps a literal-producing token kind to its AST LiteralType kind.
| Field | Type | Description |
|---|---|---|
tok |
i64 | |
literal |
i64 |
Maps an operator token kind to its AST BinaryOp kind.
| Field | Type | Description |
|---|---|---|
tok |
i64 | |
binop |
i64 |
Maps an operator token kind to its AST UnaryType kind.
| Field | Type | Description |
|---|---|---|
tok |
i64 | |
unop |
i64 |
Snapshot of parser position, sticky error flag and global error-list length, used to roll back a failed speculative parse.
| Field | Type | Description |
|---|---|---|
pos |
i64 | |
had_error |
i64 | |
err_count |
i64 |
The main parser state: owns the token table, current position, file path and a sticky error flag, and exposes token-stream navigation plus speculative-parse save/restore.
| Field | Type | Description |
|---|---|---|
file_path |
*byte | |
tks |
*TOK::Token | |
tok_count |
i64 | |
pos |
i64 | |
had_error |
i64 |
Methods:
Parser::has_tokens -> fn(
) bool
Parser::peek -> fn(
offset: i64
) TOK::Token
Parser::current -> fn(
) TOK::Token
Parser::advance -> fn(
) TOK::Token
Parser::consume -> fn(
kind: i64,
err_msg: *byte
) TOK::Token
Parser::error -> fn(
err_type: *byte,
err_msg: *byte
) void
Parser::save -> fn(
) Savepoint
Parser::restore -> fn(
sp: Savepoint
) void
#returns_ownership
Parser::get_name -> fn(
) *byte
static #returns_ownership
Parser::create_parser -> fn(
tks: *TOK::Token,
tok_count: i64,
file_path: *byte
) *Parser
static #takes_ownership
Parser::free_parser -> fn(
p: *Parser
) void
Precedence (binding power) levels assigned to operator tokens for the Pratt-style expression parser.
Values:
BP_NONEBP_LOWESTBP_ASSIGNBP_TERNARYBP_LOGICAL_ORBP_LOGICAL_ANDBP_BITWISE_ORBP_BITWISE_XORBP_BITWISE_ANDBP_EQUALITYBP_RELATIONALBP_RANGEBP_SHIFTBP_SUMBP_PRODUCTBP_EXPONENTBP_UNARYBP_POSTFIXBP_CALLBP_PRIMARY
Searches PRIMARY_LILERAL_MAP for a token kind, returning the matching
LiteralType kind or -1.
pub search_literal_map -> fn(
kind: i64
) i64
Searches BINOP_MAP for a token kind, returning the matching BinaryOp
kind or -1.
pub search_binop_map -> fn(
kind: i64
) i64
Searches UNOP_MAP for a token kind, returning the matching UnaryType
kind or -1.
pub search_unop_map -> fn(
kind: i64
) i64
Returns the binding-power level for an operator token kind, or BP_NONE.
pub get_bp -> fn(
kind: i64
) i64
Copies the contents of a Vector of *AST::AstNode into a new
heap-allocated array and returns it (the caller owns it).
pub #returns_ownership
vec_to_node_array -> fn(
v: *VEC::Vector
) **AST::AstNode
Copies the contents of a Vector of *byte into a new heap-allocated array
and returns it (the caller owns it).
pub #returns_ownership
vec_to_byte_array -> fn(
v: *VEC::Vector
) **byte
PRIMARY_LITERAL_TYPE_MAP: i64 (const) — Number of entries inPRIMARY_LILERAL_MAP.TOKEN_TO_BINOP_MAP: i64 (const) — Number of entries inBINOP_MAP.TOKEN_TO_UNOP_MAP: i64 (const) — Number of entries inUNOP_MAP.PRIMARY_LILERAL_MAP: [PRIMARY_LITERAL; 7] (const) — Lookup table from literal-producing token kinds to AST LiteralType kinds.BINOP_MAP: [TOKEN_TO_BINOP; 19] (const) — Lookup table from operator tokens to AST BinaryOp kinds.UNOP_MAP: [TOKEN_TO_UNOP; 6] (const) — Lookup table from prefix operator tokens to AST UnaryType kinds.EOF_TOK: TOK::Token (const) — The sentinel EOF token returned by navigation methods when the parser