nx_parse_field_candidate_t280.nx
buildroot/runtime/nx_parse_field_candidate_t280.nx
about
parse.nx -- NishiLang recursive-descent parser, in NishiLang.
2026-04-23: full monomorphization port landed; stdlib.nx's
Option<T> / Result<T, E> now instantiate to distinct cached
Types here the same way parse.c does.
Port of parse.c's core: precedence expression parsing, function
declarations, and the common statements (return, let, var, if,
while). Struct / enum / const / match / pattern-matching are
deferred to a second port turn so this file stays bounded.
Produces IR using the emitter functions defined in ir.nx: for
full compilation the driver (main.nx) passes the lex output
here, then onto opt -> regalloc -> riscv.
dependencies 7 imports · 1 importers
imports: nx_types.nxnx_quant.nxnx_f64.nxnx_f64_div.nxnx_lex_kinds.nxnx_ir.nxnx_linemap.nx
imported by: nx_compile_field_candidate_t280.nx
structs
| 495 | struct Local |
| 580 | struct Parser |
| 652 | struct EnumEntry |
| 663 | struct StaticEntry |
| 676 | struct StructEntry |
| 685 | struct MConst |
consts
| 98 | const NX_GENERIC_MAX_ARGS: i64 = 8 |
| 103 | const NX_PARSE_MAX_PARAMS: i64 = 24 |
| 154 | const NX_DIAG_MAX_ERRS: i64 = 20 |
| 540 | const LOCAL_BYTES: i64 = 128 |
| 551 | const NX_PARSE_LOCALS_CAP: i64 = 8192 |
| 559 | const NX_PARSE_STRUCTS_CAP: i64 = 1024 |
| 560 | const NX_PARSE_STATICS_CAP: i64 = 512 |
| 561 | const NX_PARSE_ENUMS_CAP: i64 = 256 |
| 562 | const NX_PARSE_MCONSTS_CAP: i64 = 8192 |
| 573 | const NX_PARSE_GLOBALS_SLACK: i64 = 256 |
| 578 | const NX_PARSE_FN_SLACK: i64 = 64 |
| 661 | const ENUM_ENTRY_BYTES: i64 = 96 |
| 671 | const STATIC_ENTRY_BYTES: i64 = 88 |
| 683 | const STRUCT_ENTRY_BYTES: i64 = 80 |
| 701 | const MCONST_BYTES: i64 = 96 |
| 1515 | const NX_BOUNDS_CHECK_LIVE: i64 = 1 |
| 1518 | const NX_TRAP_BOUNDS: i64 = 71 |
| 1522 | const NX_RV64_SYS_WRITE: i64 = 64 |
| 1523 | const NX_RV64_SYS_EXIT_GROUP: i64 = 94 |
| 1745 | const NX_TRAP_OVERFLOW: i64 = 72 |
| 1770 | const SEND_NAME_W: i64 = 64 |
| 1771 | const SEND_MAX: i64 = 256 |
| 1772 | const SEND_CALLEE_LEN: i64 = 14 // strlen("nx_pool_submit"), the one callee this check keys on |
| 2334 | const OWN_NONE: i64 = 0 |
| 2335 | const OWN_LIVE: i64 = 1 |
| 2336 | const OWN_MOVED: i64 = 2 |
| 2337 | const OWN_RELEASED: i64 = 3 |
| 2520 | const NX_FNPTR_MAX_ARGS: i64 = 23 |
functions
| 66 | func tok_at(toks: *Tok, i: i64) -> *Tok |
| 76 | func tr(c: i64) -> i64 |
| 112 | func parse_die(msg: *u8, msg_len: i64) -> i64 |
| 157 | func nx_diag_note_error() -> i64 called by 11: parse_typepp_idx_checksync_send_checkchk_const_overflow_refuseoe_refuseown_refuse+5 calls 1: nx_diag_puts |
| 171 | func nx_diag_puts(s: *u8) -> i64 |
| 180 | func nx_diag_why_undefined() -> i64 |
| 188 | func nx_diag_set_source(p: *u8, n: i64) -> i64 called by 1: main |
| 197 | func nx_diag_caret(line: i64, col: i64) -> i64 |
| 240 | func nx_diag_show_line(line: i64) -> i64 |
| 278 | func nx_dym_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: nx_dym_suggest_ident |
| 282 | func nx_dym_dist(a: *u8, la: i64, b: *u8, lb: i64, budget: i64) -> i64 |
| 326 | func nx_dym_suggest_fn(m: *Module, name: *u8, nlen: i64) -> i64 |
| 357 | func nx_put_dec_err(n: i64) -> i64 |
| 387 | func nx_diag_set_linemap(lm: *LineMap) -> i64 |
| 413 | func nx_diag_loc(line: i64) -> i64 called by 2: nx_diag_atnx_diag_organ_at calls 5: lm_lookuplm_file_pathnx_diag_putslm_basenamenx_put_dec_err |
| 439 | func nx_diag_at(line: i64) -> i64 called by 12: mainparse_typepp_idx_checksync_send_checkchk_const_overflow_refuseoe_refuse+6 calls 2: nx_diag_putsnx_diag_loc |
| 449 | func nx_diag_organ_at(line: i64) -> i64 called by 3: parse_dieparse_primary_callparse_primary_local_or_const calls 2: nx_diag_putsnx_diag_loc |
| 455 | func nx_put_tok_text_err(t: *Tok) -> i64 |
| 479 | func nx_diag_token_window(P: *Parser, tidx: i64) -> i64 |
| 719 | func sb_star_starts_store(P: *Parser) -> i64 |
| 744 | func peek_kind(P: *Parser) -> i64 called by 14: check_kindmatch_kindparse_typeparse_exprparse_field_chainparse_primary+8 calls 1: tok_at |
| 771 | func at_stmt_boundary(P: *Parser) -> i64 |
| 818 | func peek_at(P: *Parser, k: i64) -> *Tok calls 1: tok_at |
| 829 | func advance_tok(P: *Parser) -> *Tok |
| 836 | func check_kind(P: *Parser, k: i64) -> i64 calls 1: peek_kind |
| 840 | func match_kind(P: *Parser, k: i64) -> i64 |
| 864 | func ty_name_eq(a: *u8, a_len: i64, b: *u8, b_len: i64) -> i64 |
| 883 | func clone_type_substituting(t: *Type, param_name: *u8, called by 2: clone_type_substitutinginstantiate_generic_n calls 3: ty_name_eqclone_type_substitutingalloc_type |
| 913 | func ty_mangle_suffix(arg: *Type, out: *u8, off: i64, cap: i64) -> i64 |
| 982 | func lookup_struct(P: *Parser, name: *u8) -> *Type; |
| 983 | func register_struct(P: *Parser, name: *u8, name_len: i64, called by 1: instantiate_generic_n |
| 987 | func lookup_enum_type(P: *Parser, name: *u8) -> *Type; called by 1: parse_type |
| 998 | func instantiate_generic_n(P: *Parser, tmpl: *Type, |
| 1057 | func parse_type(P: *Parser) -> *Type called by 3: parse_typeparse_layout_query_valueparse_unary calls 18: match_kindpeek_kindadvance_tokparse_typealloc_typeir_type_void+12 |
| 1232 | func parser_loc_at(P: *Parser, i: i64) -> *Local |
| 1238 | func copy_name_into_local(L: *Local, src: *u8) -> i64 called by 1: add_local |
| 1252 | func local_name_eq(L: *Local, name: *u8) -> i64 |
| 1272 | func nx_dym_suggest_ident(P: *Parser, name: *u8, nlen: i64) -> i64 |
| 1326 | func find_local(P: *Parser, name: *u8) -> *Local |
| 1339 | func local_in_block(P: *Parser, name: *u8) -> i64 |
| 1349 | func add_local(P: *Parser, name: *u8, value_id: i64, is_alloca: i64, |
| 1406 | func parse_logical_or(P: *Parser) -> i64; called by 1: parse_expr |
| 1407 | func parse_unary_core(P: *Parser) -> i64; |
| 1408 | func parse_primary(P: *Parser) -> i64; called by 1: parse_unary_core |
| 1409 | func parse_primary_ident(P: *Parser, t: *Tok) -> i64; called by 1: parse_primary |
| 1410 | func parse_primary_qualified_variant(P: *Parser, name: *u8) -> i64; called by 1: parse_primary_ident |
| 1411 | func parse_primary_intrinsic(P: *Parser, name: *u8) -> i64; called by 1: parse_primary_ident |
| 1412 | func parse_primary_call(P: *Parser, name: *u8) -> i64; called by 1: parse_primary_ident |
| 1413 | func parse_primary_local_or_const(P: *Parser, name: *u8) -> i64; called by 1: parse_primary_ident |
| 1414 | func parse_stmt_list(P: *Parser) -> i64; |
| 1415 | func parse_stmt(P: *Parser) -> i64; |
| 1416 | func parse_stmt_return(P: *Parser) -> i64; |
| 1417 | func parse_stmt_let(P: *Parser) -> i64; |
| 1418 | func parse_stmt_var(P: *Parser) -> i64; |
| 1419 | func parse_stmt_if(P: *Parser) -> i64; |
| 1420 | func parse_stmt_while(P: *Parser) -> i64; |
| 1421 | func parse_stmt_for(P: *Parser) -> i64; |
| 1422 | func parse_stmt_break(P: *Parser) -> i64; |
| 1423 | func parse_stmt_continue(P: *Parser) -> i64; |
| 1424 | func parse_stmt_match(P: *Parser) -> i64; |
| 1425 | func parse_stmt_star(P: *Parser) -> i64; |
| 1426 | func parse_stmt_ident(P: *Parser) -> i64; |
| 1427 | func parse_stmt_ident_assign(P: *Parser) -> i64; |
| 1428 | func parse_stmt_ident_subscript(P: *Parser) -> i64; |
| 1429 | func parse_stmt_ident_dot(P: *Parser) -> i64; |
| 1430 | func parse_stmt_expr_fallback(P: *Parser) -> i64; |
| 1431 | func parse_module_const(P: *Parser) -> i64; |
| 1432 | func lookup_mconst(P: *Parser, name: *u8, out: *i64) -> i64; |
| 1433 | func lookup_mconst_f64(P: *Parser, name: *u8, out: *i64) -> i64; called by 1: parse_primary_local_or_const |
| 1434 | func const_eval_f64_addsub(P: *Parser, depth: i64) -> i64; |
| 1435 | func const_eval_f64_unary(P: *Parser, depth: i64) -> i64; |
| 1436 | func lookup_mconst_string(P: *Parser, name: *u8, called by 1: parse_primary_local_or_const |
| 1438 | func mconst_name_eq(mc: *MConst, name: *u8) -> i64; |
| 1439 | func mconst_at(P: *Parser, i: i64) -> *MConst; called by 1: nx_dym_suggest_ident |
| 1442 | func const_eval_expr(P: *Parser, depth: i64) -> i64; |
| 1443 | func const_eval_bor(P: *Parser, depth: i64) -> i64; |
| 1444 | func const_eval_bxor(P: *Parser, depth: i64) -> i64; |
| 1445 | func const_eval_band(P: *Parser, depth: i64) -> i64; |
| 1446 | func const_eval_shift(P: *Parser, depth: i64) -> i64; |
| 1447 | func const_eval_addsub(P: *Parser, depth: i64) -> i64; |
| 1448 | func const_eval_muldiv(P: *Parser, depth: i64) -> i64; |
| 1449 | func const_eval_unary(P: *Parser, depth: i64) -> i64; |
| 1450 | func const_eval_primary(P: *Parser, depth: i64) -> i64; |
| 1451 | func mconst_at(P: *Parser, i: i64) -> *MConst; |
| 1452 | func copy_name_into_mconst(mc: *MConst, src: *u8) -> i64; |
| 1453 | func parse_struct_decl(P: *Parser) -> i64; |
| 1454 | func parse_static_decl(P: *Parser) -> i64; |
| 1455 | func parse_module_enum(P: *Parser) -> i64; |
| 1456 | func inject_statics(P: *Parser) -> i64; |
| 1457 | func enum_entry_at(P: *Parser, i: i64) -> *EnumEntry; |
| 1458 | func lookup_enum(P: *Parser, name: *u8) -> *EnumEntry; called by 1: parse_primary_qualified_variant |
| 1460 | func struct_entry_at(P: *Parser, i: i64) -> *StructEntry; |
| 1462 | func parse_expr(P: *Parser) -> i64 |
| 1502 | func safe_const_i64(P: *Parser, val: i64, tag: *u8) -> i64 |
| 1538 | func emit_bounds_trap(P: *Parser) -> i64 called by 1: emit_bounds_check_v calls 4: ir_add_global_stringalloc_typeir_global_valueemit_trap_syscalls |
| 1568 | func emit_trap_syscalls(P: *Parser, msg_v: i64, mlen: i64, code: i64) -> i64 |
| 1603 | func emit_bounds_check_v(P: *Parser, idx: i64, len_v: i64) -> i64 |
| 1623 | func emit_bounds_check(P: *Parser, idx: i64, nelem: i64) -> i64 |
| 1664 | func nx_ptrprov_set(v: i64) -> i64 { g_ptrprov_live = v; return 0 } called by 1: main |
| 1667 | func nx_ptrprov_reset_fn() -> i64 |
| 1680 | func pp_idx_check(P: *Parser, idx: i64, nelem: i64, ln: i64) -> i64 |
| 1706 | func bck_ptr_provenance_live() -> i64 { return g_ptrprov_live } |
| 1748 | func nx_chkarith_set(v: i64) -> i64 { g_chkarith_live = v; return 0 } called by 1: main |
| 1773 | func nx_sendcheck_set(v: i64) -> i64 { g_sendcheck_live = v; return 0 } called by 1: main |
| 1774 | func sync_send_mark(name: *u8, len: i64) -> i64 |
| 1784 | func sync_send_is_marked(name: *u8, len: i64) -> i64 called by 1: sync_send_check |
| 1797 | func sync_send_check(P: *Parser, name: *u8, nlen: i64, args: *i64, n_args: i64, ln: i64, cl: i64) -> i64 |
| 1824 | func chk_add_overflow_live() -> i64 { return g_chkarith_live } |
| 1832 | func emit_overflow_trap(P: *Parser) -> i64 |
| 1855 | func chk_branch_on_overflow(P: *Parser, cond: i64) -> i64 called by 2: chk_add_overflowchk_sub_overflow calls 4: ir_block_newir_emit_br_condemit_overflow_trapir_emit_br |
| 1867 | func chk_add_overflow(P: *Parser, a: i64, b: i64, r: i64) -> i64 |
| 1877 | func chk_sub_overflow(P: *Parser, a: i64, b: i64, r: i64) -> i64 |
| 1888 | func chk_i64_min() -> i64 |
| 1901 | func chk_mul_overflow(P: *Parser, a: i64, b: i64, r: i64) -> i64 called by 1: chk_arith_inject calls 8: ir_block_newsafe_const_i64ir_emit_binopir_type_i64ir_emit_br_condchk_i64_min+2 |
| 1931 | func chk_arith_applies(P: *Parser, op: i64, left: i64, right: i64, rty: *Type) -> i64 calls 1: nx_value_type |
| 1948 | func chk_arith_inject(P: *Parser, op: i64, left: i64, right: i64, r: i64) -> i64 |
| 1957 | func chk_const_add_overflows(a: i64, b: i64) -> i64 called by 1: chk_const_overflow_refuse |
| 1962 | func chk_const_sub_overflows(a: i64, b: i64) -> i64 called by 1: chk_const_overflow_refuse |
| 1967 | func chk_const_mul_overflows(a: i64, b: i64) -> i64 |
| 1982 | func chk_const_overflow_refuse(P: *Parser, op: i64, left: i64, right: i64, op_tok: *Tok) -> i64 |
| 2041 | func nx_optenforce_set(v: i64) -> i64 { g_optenforce_live = v; return 0 } called by 1: main |
| 2044 | func opt_enforce_unwrap_live() -> i64 { return g_optenforce_live } |
| 2058 | func oe_reset_fn() -> i64 { g_oe_base_val = 0 - 1; g_oe_base_unchk = 0; g_oe_term = 0; return 0 } |
| 2067 | func oe_value_nonnull(P: *Parser, v: i64) -> i64 |
| 2127 | func oe_callee_is(fn: *Function, name: *u8, len: i64) -> i64 |
| 2143 | func oe_bind_local(P: *Parser, L: *Local, v: i64) -> i64 calls 1: oe_value_nonnull |
| 2152 | func oe_refuse(name: *u8, line: i64, col: i64) -> i64 called by 2: oe_check_local_derefoe_chain_check calls 4: nx_diag_atnx_diag_putsnx_diag_caretnx_diag_note_error |
| 2176 | func oe_local_is_static(P: *Parser, L: *Local) -> i64 |
| 2184 | func oe_check_local_deref(P: *Parser, L: *Local, tok: *Tok) -> i64 |
| 2195 | func oe_handshake_set(P: *Parser, L: *Local, v: i64, tok: *Tok) -> i64 |
| 2209 | func oe_chain_check(P: *Parser, v: i64) -> i64 |
| 2223 | func oe_probe_null_test(P: *Parser) -> i64 |
| 2340 | func nx_ownership_set(v: i64) -> i64 { g_ownership_live = v; return 0 } called by 1: main |
| 2349 | func own_check_live() -> i64 { return g_ownership_live } |
| 2355 | func own_value_is_alloc(P: *Parser, v: i64) -> i64 |
| 2382 | func own_bind_local(P: *Parser, L: *Local, v: i64) -> i64 calls 1: own_value_is_alloc |
| 2398 | func own_mark(P: *Parser, L: *Local, st: i64, ln: i64) -> i64 |
| 2421 | func own_refuse(name: *u8, line: i64, col: i64, st: i64, from_line: i64) -> i64 called by 1: own_check_use calls 5: nx_diag_atnx_diag_putsnx_put_dec_errnx_diag_caretnx_diag_note_error |
| 2460 | func own_check_use(P: *Parser, L: *Local, tok: *Tok) -> i64 |
| 2474 | func own_mark_named(P: *Parser, tok: *Tok, st: i64) -> i64 |
| 2487 | func own_move_arg(P: *Parser, tok: *Tok) -> i64 called by 1: parse_primary_intrinsic calls 8: own_check_livenx_diag_atnx_diag_putsnx_diag_caretnx_diag_note_errorfind_local+2 |
| 2529 | func parse_field_of_struct(P: *Parser, stty: *Type, ftok: *Tok, fname: *u8, flen: i64) -> *StructField |
| 2556 | func parse_field_chain(P: *Parser, base: i64, base_ty: *Type) -> i64 |
| 2778 | func parse_primary(P: *Parser) -> i64 |
| 3034 | func parse_primary_ident(P: *Parser, t: *Tok) -> i64 |
| 3052 | func parse_primary_qualified_variant(P: *Parser, name: *u8) -> i64 |
| 3135 | func parse_layout_query_kind(name: *u8) -> i64 |
| 3144 | func parse_layout_query_value(P: *Parser, layout_query: i64) -> i64 |
| 3175 | func parse_primary_intrinsic(P: *Parser, name: *u8) -> i64 |
| 4194 | func parse_primary_call(P: *Parser, name: *u8) -> i64 |
| 4504 | func mc_name_eq(a: *u8, b: *u8) -> i64 |
| 4514 | func mconst_declared_later(P: *Parser, name: *u8) -> i64 |
| 4538 | func parse_primary_local_or_const(P: *Parser, name: *u8) -> i64 |
| 4820 | func parse_unary(P: *Parser) -> i64 called by 1: parse_unary_core calls 7: parse_unary_coreval_atpeek_kindadvance_tokparse_typesafe_const_i64+1 |
| 4864 | func parse_unary_core(P: *Parser) -> i64 |
| 5035 | func fp_op_for_int(op: i64) -> i64 |
| 5043 | func has_fp_operand(P: *Parser, v: i64) -> i64 |
| 5054 | func nx_value_type(P: *Parser, v: i64) -> *Type |
| 5068 | func nx_value_is_const(P: *Parser, v: i64) -> i64 |