code wiki / (root) / nx_nxc.nx

nx_nxc.nx

buildroot/runtime/nx_nxc.nx

13173 B303 linesdepth 6pulls 19 transitivereach 0 importersview sourcekind tooltopic nxc
docsdependenciesstructsconstsfunctions

about

nxc.nx -- the full NishiLang sovereign-compiler driver. Chains every piece of our stack in pure NishiLang: source (.nx) -> import-expand -> lex -> parse -> opt -> regalloc -> riscv -> nxasm (assemble) -> elf_writer (wrap) -> sys_write(stdout) Output is a self-contained RV64 Linux ELF executable. Zero third- party code on the program path: no gcc, no binutils `as`, no ld, no libc, no external crt0. The only external thing is the Linux kernel ABI, which NishiOS replaces 1:1. CLI: `nxc <path>.nx` reads the file, runs the import expander to inline `import \"...\"` directives into a single source blob, then drives the compile pipeline and writes the ELF to stdout. Pipe to a file + chmod +x to run: nxc hello.nx > hello && chmod +x hello && ./hello With no args it compiles a baked-in demo source so `./nxc` still exits successfully for smoke-testing the chain. Status (2026-04-22): parse.nx has full monomorphization for generic struct + enum; the earlier \"syntax accepted but no substitution\" gap is closed. Outstanding work to fully retire gcc from the compiler bootstrap is QEMU/real-RV64 verification of the produced ELF (Phase 5 roadmap).

dependencies 15 imports · 0 importers

nx_syscalls.nx nx_types.nx nx_lex_kinds.nx nx_outbuf.nx nx_ir.nx nx_ir_validate.nx nx_tokenizer.nx nx_parse.nx nx_opt.nx nx_regalloc.nx nx_nxc.nx

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

imports: nx_syscalls.nxnx_types.nxnx_lex_kinds.nxnx_outbuf.nxnx_ir.nxnx_ir_validate.nxnx_tokenizer.nxnx_parse.nxnx_opt.nxnx_regalloc.nxnx_riscv.nxcrt0.nxnx_import.nxnxasm_v2.nxelf_writer.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_write nxc_compile sys_write ↻ lex_source sys_mmap lexm_expand lexm_prescan lexm_isid is_alnum lexm_body_end lexm_define lexm_init lexm_warn_body_too_long lexm_name_at lexm_body_at sys_mmap ↻ lexm_isid ↻ lexm_body_end ↻ lexm_for_expand lexm_isid ↻ lexm_body_end ↻ lexm_for_emit lexm_isid ↻ sys_mmap ↻ lexm_for_bound lexm_lookup lexm_body_int lexm_emit_dec sys_mmap ↻ lexm_kw_is lexm_paste_expand sys_mmap ↻ lexm_trim lexm_is_ident_text is_alpha lexm_isid ↻ lexm_warn_bad_paste lexm_diag_cell lexm_emit_str

structs

none

consts

254const EXPAND_OUT_CAP: i64 = 4194304

functions

65func nxc_compile(src: *u8, fd: i64) -> i64
256func main(argc: i64, argv: *i64) -> i64