Source: src/parser/stmt.lx
Parses Luma statements into AST nodes.
Dispatches top-level and block statements by keyword: const/var/use/return
declarations, if/loop/switch/defer, @os, @link, @use, and
expression statements. Also handles doc comments, pub/priv visibility,
and the #returns_ownership / #takes_ownership / #dll_import /
#lib_import attributes.
#returns_ownership
_const -> fn(
p: *PARS::Parser,
is_public: i64,
returns_ownership: i64,
takes_ownership: i64,
doc_comment: *byte
) *AST::AstNode
#returns_ownership
_fn -> fn(
p: *PARS::Parser,
name: *byte,
is_public: i64,
returns_ownership: i64,
takes_ownership: i64,
doc_comment: *byte
) *AST::AstNode
#returns_ownership
break_continue_stmt -> fn(
p: *PARS::Parser,
is_continue: i64
) *AST::AstNode
#returns_ownership
_enum -> fn(
p: *PARS::Parser,
name: *byte,
is_public: i64,
doc_comment: *byte
) *AST::AstNode
#returns_ownership
_struct -> fn(
p: *PARS::Parser,
name: *byte,
is_public: i64,
doc_comment: *byte
) *AST::AstNode
#returns_ownership
parse_type_param_list -> fn(
p: *PARS::Parser
) VEC::Vector
#returns_ownership
var -> fn(
p: *PARS::Parser,
is_public: i64,
doc_comment: *byte
) *AST::AstNode
#returns_ownership
infinite_loop_stmt -> fn(
p: *PARS::Parser
) *AST::AstNode
#returns_ownership
for_loop_stmt -> fn(
p: *PARS::Parser
) *AST::AstNode
#returns_ownership
print_stmt -> fn(
p: *PARS::Parser,
ln: i64
) *AST::AstNode
#returns_ownership
expr -> fn(
p: *PARS::Parser
) *AST::AstNode
#returns_ownership
use -> fn(
p: *PARS::Parser
) *AST::AstNode
#returns_ownership
os_stmt -> fn(
p: *PARS::Parser
) *AST::AstNode
#returns_ownership
link_stmt -> fn(
p: *PARS::Parser
) *AST::AstNode
#returns_ownership
consume_doc_comments -> fn(
p: *PARS::Parser
) *byte
apply_dll_import -> fn(
node: *AST::AstNode,
dll_name: *byte,
dll_callconv: *byte
) void
apply_lib_import -> fn(
node: *AST::AstNode,
lib_name: *byte
) void
#returns_ownership
return_stmt -> fn(
p: *PARS::Parser
) *AST::AstNode
#returns_ownership
block -> fn(
p: *PARS::Parser
) *AST::AstNode
#returns_ownership
_if -> fn(
p: *PARS::Parser
) *AST::AstNode
#returns_ownership
_defer -> fn(
p: *PARS::Parser
) *AST::AstNode
#returns_ownership
_switch -> fn(
p: *PARS::Parser
) *AST::AstNode
#returns_ownership
parse_case_value -> fn(
p: *PARS::Parser,
using_path: *VEC::Vector
) *AST::AstNode
#returns_ownership
scoped_member -> fn(
using_path: *VEC::Vector,
member: *byte,
line: i64,
col: i64
) *AST::AstNode
free_using_path -> fn(
using_path: *VEC::Vector
) void
#returns_ownership
_impl -> fn(
p: *PARS::Parser
) *AST::AstNode
#returns_ownership
_loop -> fn(
p: *PARS::Parser
) *AST::AstNode
Parses a single statement, collecting the leading doc comment, ownership
and import attributes, and visibility, then dispatching on the keyword.
Applies #dll_import/#lib_import to the resulting function node.
pub #returns_ownership
parse_stmt -> fn(
p: *PARS::Parser
) *AST::AstNode
Returns: The statement node, or null after a lexical/parse error.
Consumes consecutive doc-comment tokens (/// and //!), returning their
newline-joined text, or null when the current token is not a doc comment.
pub #returns_ownership
consume_doc_comments -> fn(
p: *PARS::Parser
) *byte
Marks node (a function declaration) as a DLL import, storing the DLL name
and optional calling convention.
apply_dll_import -> fn(
node: *AST::AstNode,
dll_name: *byte,
dll_callconv: *byte
) void
Marks node (a function declaration) as a library import, storing the
library name.
apply_lib_import -> fn(
node: *AST::AstNode,
lib_name: *byte
) void
Parses @os { "platform" -> stmt, _ -> stmt, ... }, building an OS node
with per-platform bodies and an optional default arm.
#returns_ownership
os_stmt -> fn(
p: *PARS::Parser
) *AST::AstNode
Parses @link("name") into a link directive node.
#returns_ownership
link_stmt -> fn(
p: *PARS::Parser
) *AST::AstNode
Parses a const declaration: either a typed constant
(const name: Type = value;) or the start of a function, struct, or enum
declaration, delegated to _fn/_struct/_enum.
#returns_ownership
_const -> fn(
p: *PARS::Parser,
is_public: i64,
returns_ownership: i64,
takes_ownership: i64,
doc_comment: *byte
) *AST::AstNode
#returns_ownership
parse_type_param_list -> fn(
p: *PARS::Parser
) VEC::Vector
Parses a function declaration (optionally generic), producing a
function-declaration node. A trailing ; yields a forward declaration
without a body.
#returns_ownership
_fn -> fn(
p: *PARS::Parser,
name: *byte,
is_public: i64,
returns_ownership: i64,
takes_ownership: i64,
doc_comment: *byte
) *AST::AstNode
Parses an enum declaration (optionally generic; parameters act as phantom type tags), producing an enum-declaration node.
#returns_ownership
_enum -> fn(
p: *PARS::Parser,
name: *byte,
is_public: i64,
doc_comment: *byte
) *AST::AstNode
Parses a struct declaration (optionally generic), producing a
struct-declaration node. Handles pub:/priv: sections, ...Embedded
members, static and ownership markers, and method members.
#returns_ownership
_struct -> fn(
p: *PARS::Parser,
name: *byte,
is_public: i64,
doc_comment: *byte
) *AST::AstNode
Stub; always returns null.
#returns_ownership
print -> fn(
p: *PARS::Parser,
ln: i64
) *AST::AstNode
Parses var name: Type with an optional = value; initializer into a
variable-declaration node.
#returns_ownership
var -> fn(
p: *PARS::Parser,
is_public: i64,
doc_comment: *byte
) *AST::AstNode
Parses an expression statement followed by ;.
#returns_ownership
expr -> fn(
p: *PARS::Parser
) *AST::AstNode
Parses @use "module" as alias into a use-declaration node.
#returns_ownership
use -> fn(
p: *PARS::Parser
) *AST::AstNode
Parses a return; or return expr; statement.
#returns_ownership
return_stmt -> fn(
p: *PARS::Parser
) *AST::AstNode
Parses a { ... } block of statements into a block node.
#returns_ownership
block -> fn(
p: *PARS::Parser
) *AST::AstNode
Parses an if (cond) ... statement with optional elif chain and else
branch into an if node.
#returns_ownership
_if -> fn(
p: *PARS::Parser
) *AST::AstNode
Parses a break; or continue; statement.
#returns_ownership
break_continue_stmt -> fn(
p: *PARS::Parser,
is_continue: i64
) *AST::AstNode
Parses a defer <stmt> statement.
#returns_ownership
_defer -> fn(
p: *PARS::Parser
) *AST::AstNode
Parses a switch(cond) { ... } statement, supporting an optional
using Path::To::Enum label namespace, multi-value case labels, and a
default case.
#returns_ownership
_switch -> fn(
p: *PARS::Parser
) *AST::AstNode
Parses one switch case-label expression. A bare identifier under a using
path is desugared to <path>::<identifier>.
#returns_ownership
parse_case_value -> fn(
p: *PARS::Parser,
using_path: *VEC::Vector
) *AST::AstNode
Builds <path[0]>::<path[1]>::...::<member> as a chain of compiletime
member-access nodes, duplicating each segment string.
#returns_ownership
scoped_member -> fn(
using_path: *VEC::Vector,
member: *byte,
line: i64,
col: i64
) *AST::AstNode
Frees every segment string in using_path and the vector itself.
free_using_path -> fn(
using_path: *VEC::Vector
) void
Stub; always returns null.
#returns_ownership
_impl -> fn(
p: *PARS::Parser
) *AST::AstNode
Parses a loop initializer name: Type = expr inside a loop [ ... ]
header into a variable-declaration node.
#returns_ownership
loop_init -> fn(
p: *PARS::Parser
) *AST::AstNode
Parses loop [init, ...] (condition) : (post) { body } — a loop with a
header — into a loop node.
#returns_ownership
for_loop_stmt -> fn(
p: *PARS::Parser
) *AST::AstNode
Parses loop { body }, an infinite loop with no condition, into a loop
node.
#returns_ownership
infinite_loop_stmt -> fn(
p: *PARS::Parser
) *AST::AstNode
Parses a loop statement: dispatch to infinite_loop_stmt for loop { },
for_loop_stmt for loop [ ... ], otherwise loop (cond) : (post) { }.
#returns_ownership
_loop -> fn(
p: *PARS::Parser
) *AST::AstNode