code wiki / _hdl_build / nx_eoe_prog.nx
nx_eoe_prog.nx
buildroot/runtime/_hdl_build/nx_eoe_prog.nx
about
nx_eoe_prog.nx -- EMITTER-OF-EMITTERS, GENERALITY RUNG 5 (THE INFLECTION):
a UNIFIED STATEMENT-LIST MINI-LANGUAGE, not a 4th single-shape emitter.
Rungs 006g/h/i each emitted ONE fixed shape (a linear op-list / a 2-way branch /
a single-body while). This rung unifies them into a recursive GRAMMAR whose spec
is a LIST OF STATEMENTS, where a branch's or loop's body is ITSELF a statement
list (NESTING). That recursion is the qualitative jump: the team now specs an
organ in a real (if tiny) language -- sequence + conditional + iteration,
arbitrarily composed -- which is the shape of general control flow. A recursive
descent over the spec PRETTY-PRINTS the corresponding nested NishiLang; nx_cc
compiles it (codegen delegated to the compiler the team owns).
nx_eoe_prog <basename> <start> <stmt...>
stmt grammar (tokens):
a<n> | m<n> | s<n> acc = acc + / * / - n
if <pred> [ <stmt...> ] one-armed conditional (pred = g<t>|l<t>|e<t>)
while <pred> [ <stmt...> ] predicate-driven loop (per-loop runaway guard)
`[` and `]` are their own tokens; blocks NEST. Emits main() that runs the
program over acc=<start> and prints "RESULT=<acc>\n".
no-false-green plan (X-AUT-006d): nested specs that DIVERGE -- e.g. flipping an
inner threshold so the conditional inside a loop fires a different number of times
-> a DIFFERENT correct result; tamper any op/threshold -> result changes.
Sovereign, no gcc/.sh. HONEST SCOPE: single i64 accumulator, one-armed if, integer
ops; NOT yet multiple funcs/typed params/imports -- but the CONTROL-FLOW grammar is
now compositional, the real inflection toward general organ synthesis.
license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 29 | const K_MAGIC_262144: i64 = 262144 |
functions
| 31 | func eop_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[off+i] = s[i]; i = i + 1 } return off + i } |
| 32 | func eop_catn(dst: *u8, off: i64, v: i64) -> i64 |
| 44 | func eop_p(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 45 | func eop_atoi_from(s: *u8, from: i64) -> i64 |
| 50 | func eop_indent(buf: *u8, off: i64, depth: i64) -> i64 |
| 56 | func eop_cmp(buf: *u8, off: i64, pred: *u8) -> i64 |
| 70 | func eop_emit_stmts(buf: *u8, off: i64, argv: *i64, argc: i64, ti: i64, depth: i64, out_ti: *i64, gid: *i64) -> i64 |
| 107 | func main(argc: i64, argv: *i64) -> i64 |