nx_nparse.nx
buildroot/runtime/nx_nparse.nx
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
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
| 46 | struct NxAst |
| 57 | struct NxNParser |
consts
| 22 | const NX_AST_FUNC: i64 = 1 |
| 23 | const NX_AST_BLOCK: i64 = 2 |
| 24 | const NX_AST_RETURN: i64 = 3 |
| 25 | const NX_AST_INT: i64 = 4 |
| 26 | const NX_AST_IDENT: i64 = 5 |
| 27 | const NX_AST_BINOP: i64 = 6 |
| 28 | const NX_AST_TYPE_REF: i64 = 7 // simple type identifier (e.g., i64) |
| 29 | const NX_AST_LET: i64 = 8 // a=value expr idx; c=slot index |
| 30 | const NX_AST_IF: i64 = 9 // a=cond expr idx; b=then-block idx |
| 33 | const NX_BIN_ADD: i64 = 1 |
| 34 | const NX_BIN_SUB: i64 = 2 |
| 35 | const NX_BIN_MUL: i64 = 3 |
| 36 | const NX_BIN_DIV: i64 = 4 |
| 39 | const NX_NPARSE_MAX_LOCALS: i64 = 8 |
functions
| 72 | func nx_nparse_new(lex: *NxNLexer, cap: i64) -> *NxNParser |
| 87 | func nx_nparse_sym_lookup(p: *NxNParser, start: i64, len: i64) -> i64 called by 1: nx_nparse_primary |
| 108 | func nx_nparse_sym_bind(p: *NxNParser, start: i64, len: i64) -> i64 called by 1: nx_nparse_stmt |
| 117 | func nx_nparse_node_at(p: *NxNParser, i: i64) -> *NxAst |
| 121 | func nx_nparse_alloc(p: *NxNParser, kind: i64) -> i64 |
| 139 | func nx_nparse_peek(p: *NxNParser) -> *NxToken |
| 143 | func nx_nparse_peek_kind(p: *NxNParser) -> i64 called by 5: nx_nparse_matchnx_nparse_mulnx_nparse_exprnx_nparse_stmtnx_nparse_block calls 1: nx_nparse_peek |
| 148 | func nx_nparse_advance(p: *NxNParser) -> *NxToken |
| 155 | func nx_nparse_match(p: *NxNParser, kind: i64) -> i64 |
| 171 | func nx_nparse_primary(p: *NxNParser) -> i64 |
| 197 | func nx_nparse_mul(p: *NxNParser) -> i64 |
| 222 | func nx_nparse_expr(p: *NxNParser) -> i64 |
| 278 | func nx_nparse_stmt(p: *NxNParser) -> i64 |
| 373 | func nx_nparse_block(p: *NxNParser) -> i64 |
| 410 | func nx_nparse_func(p: *NxNParser) -> i64 |
| 447 | func nx_nparse_run(p: *NxNParser) -> i64 |