code wiki / (root) / nx_diagram_test.nx

nx_diagram_test.nx source

↩ module page · 44 lines · 1955 B

1// nx_diagram_test.nx -- exercise all 4 emitters on a small substrate diagram. 2 3import "nx_syscalls.nx" 4import "nx_runtime.nx" 5import "nx_diagram.nx" 6 7func main() -> i64 { 8 let d: *Diagram = nx_diagram_new(8, 16) 9 10 // Build a 4-generation substrate fragment. 11 let axioms: i64 = nx_diagram_add_node(d, "axioms" as *u8, "formal foundations" as *u8) 12 let syscalls: i64 = nx_diagram_add_node(d, "syscalls" as *u8, "kernel bridge" as *u8) 13 let runtime: i64 = nx_diagram_add_node(d, "runtime" as *u8, "strlen / memcpy / itoa" as *u8) 14 let math: i64 = nx_diagram_add_node(d, "nx_math" as *u8, "integer sqrt" as *u8) 15 let lex: i64 = nx_diagram_add_node(d, "nx_lex" as *u8, "char classes" as *u8) 16 let image: i64 = nx_diagram_add_node(d, "nx_image" as *u8, "image primitives" as *u8) 17 let features: i64 = nx_diagram_add_node(d, "nx_features" as *u8, "Harris / BRIEF" as *u8) 18 let pipeline: i64 = nx_diagram_add_node(d, "nx_pipeline" as *u8, "vision integration" as *u8) 19 20 nx_diagram_add_edge(d, math, runtime, "" as *u8) 21 nx_diagram_add_edge(d, math, axioms, "" as *u8) 22 nx_diagram_add_edge(d, lex, axioms, "" as *u8) 23 nx_diagram_add_edge(d, image, math, "" as *u8) 24 nx_diagram_add_edge(d, image, syscalls, "" as *u8) 25 nx_diagram_add_edge(d, features, image, "" as *u8) 26 nx_diagram_add_edge(d, pipeline, features, "" as *u8) 27 nx_diagram_add_edge(d, pipeline, lex, "" as *u8) 28 29 // Verify counts. 30 if d.n_nodes != 8 { return 1 } 31 if d.n_edges != 8 { return 2 } 32 33 // Emit all 4 formats (sequentially; they all go to stdout but that's 34 // fine for the smoke -- we just want them to not crash). 35 nx_diagram_emit_ascii(d) 36 println("=== MERMAID ===" as *u8) 37 nx_diagram_emit_mermaid(d) 38 println("=== DOT ===" as *u8) 39 nx_diagram_emit_dot(d) 40 println("=== JSON ===" as *u8) 41 nx_diagram_emit_json(d) 42 43 return 0 44}