code wiki / (root) / nx_nparse.nx

nx_nparse.nx

buildroot/runtime/nx_nparse.nx

15010 B450 linesdepth 5pulls 6 transitivereach 12 importersview sourcekind library
docsdependenciesstructsconstsfunctions

about

nx_nparse.nx -- NishiLang parser in pure NishiLang. SECOND CONCRETE STEP of the nxc2 self-hosting trajectory. Consumes the NxToken stream emitted by nx_nlex.nx and produces an AST. Minimum viable subset: - Function declarations: `func name(...) -> type { body }` (empty parameter list for now) - Block: { stmts ... } - Statements: return <expr> ;? | <expr> ;? - Expressions: integer literal, identifier, binary +/-/*//, parenthesized Future: parameter lists, let/var bindings, if/while, struct, etc.

dependencies 3 imports · 11 importers

syscalls.nx nx_nlex.nx nx_loop.nx nx_nparse.nx _a2a_selfhost_binop.nx _a2a_selfhost_let.nx _selfhost_compile_42.nx _selfhost_compile_binop.nx _selfhost_compile_if.nx _selfhost_compile_if_false.nx _selfhost_compile_let.nx nx_nir.nx nx_nir_test.nx nx_nparse_test.nx

diagram shows first 10 each side; +0 more imports, +1 more importers in the complete lists below.

imports: syscalls.nxnx_nlex.nxnx_loop.nx

imported by: _a2a_selfhost_binop.nx_a2a_selfhost_let.nx_selfhost_compile_42.nx_selfhost_compile_binop.nx_selfhost_compile_if.nx_selfhost_compile_if_false.nx_selfhost_compile_let.nxnx_nir.nxnx_nir_test.nxnx_nparse_test.nxnx_nx86_test.nx

structs

46struct NxAst
57struct NxNParser

consts

22const NX_AST_FUNC: i64 = 1
23const NX_AST_BLOCK: i64 = 2
24const NX_AST_RETURN: i64 = 3
25const NX_AST_INT: i64 = 4
26const NX_AST_IDENT: i64 = 5
27const NX_AST_BINOP: i64 = 6
28const NX_AST_TYPE_REF: i64 = 7 // simple type identifier (e.g., i64)
29const NX_AST_LET: i64 = 8 // a=value expr idx; c=slot index
30const NX_AST_IF: i64 = 9 // a=cond expr idx; b=then-block idx
33const NX_BIN_ADD: i64 = 1
34const NX_BIN_SUB: i64 = 2
35const NX_BIN_MUL: i64 = 3
36const NX_BIN_DIV: i64 = 4
39const NX_NPARSE_MAX_LOCALS: i64 = 8

functions

72func nx_nparse_new(lex: *NxNLexer, cap: i64) -> *NxNParser
called by 10: mainmainmainmainmainmain+4
87func nx_nparse_sym_lookup(p: *NxNParser, start: i64, len: i64) -> i64
called by 1: nx_nparse_primary
108func nx_nparse_sym_bind(p: *NxNParser, start: i64, len: i64) -> i64
called by 1: nx_nparse_stmt
117func nx_nparse_node_at(p: *NxNParser, i: i64) -> *NxAst
121func nx_nparse_alloc(p: *NxNParser, kind: i64) -> i64
139func nx_nparse_peek(p: *NxNParser) -> *NxToken
143func nx_nparse_peek_kind(p: *NxNParser) -> i64
148func nx_nparse_advance(p: *NxNParser) -> *NxToken
155func nx_nparse_match(p: *NxNParser, kind: i64) -> i64
171func nx_nparse_primary(p: *NxNParser) -> i64
197func nx_nparse_mul(p: *NxNParser) -> i64
222func nx_nparse_expr(p: *NxNParser) -> i64
278func nx_nparse_stmt(p: *NxNParser) -> i64
373func nx_nparse_block(p: *NxNParser) -> i64
410func nx_nparse_func(p: *NxNParser) -> i64
447func nx_nparse_run(p: *NxNParser) -> i64
called by 10: mainmainmainmainmainmain+4 calls 1: nx_nparse_func