code wiki / _hdl_build / nx_ui_zss.nx
nx_ui_zss.nx
buildroot/runtime/_hdl_build/nx_ui_zss.nx
about
nx_ui_zss.nx -- ui-validation V1b (sovereign DETERMINISTIC engine). The EXACT-OPTIMAL structural
tree-edit-distance: real ZHANG-SHASHA (ZSS) over the DOM tree. Closes the honest gap nx_ui_tdist left
(postorder-Levenshtein = a tractable approximation; ZSS = the true tree-edit-distance that respects tree
structure in its edit operations). Reconstructs the tree from the postorder (tag,depth) DOM serialization:
leftmost-leaf-descendant l[] and keyroots derive directly from depth; then the ZSS forestdist DP. NO model.
KAT-GATED: `selftest` proves ZSS on known small-tree distances BEFORE any page is judged (anti-navel-gaze:
a hard algorithm must earn a green self-test first). HONEST ENVELOPE: exact ZSS over the SOURCE DOM tree,
node-capped for tractability; ZSS over the RENDERED AXTree = the browser-lane follow-on.
nx_ui_zss selftest | dist <urlA> <urlB> [connect]
exit: 0 (selftest GREEN / dist computed) | 1 selftest RED | 4 fetch-fail | 2 usage.
license_tier: ORIGINAL expect_exit: 0
dependencies 1 imports · 0 importers
imports: nx_tool_run.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
| 13 | const K_MAGIC_30000: i64 = 30000 |
| 14 | const K_MAGIC_2166136261: i64 = 2166136261 |
| 15 | const K_MAGIC_16777619: i64 = 16777619 |
| 16 | const K_MAGIC_2147483647: i64 = 2147483647 |
| 17 | const K_MAGIC_5000: i64 = 5000 |
| 18 | const K_MAGIC_4096: i64 = 4096 |
| 19 | const K_MAGIC_524288: i64 = 524288 |
| 20 | const K_MAGIC_2048: i64 = 2048 |
functions
| 22 | func z_w(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 } called by 1: main |
| 23 | func z_b(rep: *u8, pos: i64, s: *u8) -> i64 { var p: i64 = pos; var i: i64 = 0; while s[i] != (0 as u8) { if p < K_MAGIC_30000 { rep[p] = s[i]; p = p + 1 } i = i + 1 } return p } |
| 24 | func z_bn(rep: *u8, pos: i64, v: i64) -> i64 { var p: i64 = pos; var m: i64 = v; if m < 0 { if p < K_MAGIC_30000 { rep[p] = 45 as u8; p = p + 1 } m = 0 - m } let t: *u8 = sys_mmap(28); var k: i64 = 0; if m == 0 { t[0] = 48 as u8; k = 1 } while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } var i: i64 = 0; while i < k { if p < K_MAGIC_30000 { rep[p] = t[k - 1 - i]; p = p + 1 } i = i + 1 } return p } |
| 25 | func z_min3(a: i64, b: i64, c: i64) -> i64 { var m: i64 = a; if b < m { m = b } if c < m { m = c } return m } called by 1: z_zss |
| 26 | func z_hash(buf: *u8, s: i64, e: i64) -> i64 { var h: i64 = K_MAGIC_2166136261; var i: i64 = s; while i < e { let c: i64 = buf[i]; var lc: i64 = c; if c >= 65 { if c <= 90 { lc = c + 32 } } h = (h ^ lc) * K_MAGIC_16777619; h = h & K_MAGIC_2147483647; i = i + 1 } if h == 0 { h = 1 } return h } called by 1: z_parse |
| 27 | func z_void(buf: *u8, s: i64, e: i64) -> i64 { let ln: i64 = e - s; if ln == 3 { if buf[s]==(105 as u8) { if buf[s+1]==(109 as u8) { if buf[s+2]==(103 as u8) { return 1 } } } } if ln == 5 { if buf[s]==(105 as u8) { if buf[s+1]==(110 as u8) { return 1 } } } if ln == 2 { if buf[s]==(98 as u8) { if buf[s+1]==(114 as u8) { return 1 } } if buf[s]==(104 as u8) { if buf[s+1]==(114 as u8) { return 1 } } } if ln == 4 { if buf[s]==(109 as u8) { if buf[s+1]==(101 as u8) { return 1 } } if buf[s]==(108 as u8) { if buf[s+1]==(105 as u8) { return 1 } } } return 0 } called by 1: z_parse |
| 28 | func z_isletter(c: i64) -> i64 { if c >= 65 { if c <= 90 { return 1 } } if c >= 97 { if c <= 122 { return 1 } } return 0 } called by 1: z_parse |
| 30 | func z_parse(buf: *u8, n: i64, lab: *i64, dep: *i64, cap: i64) -> i64 |
| 64 | func z_lfd(dep: *i64, n: i64, l: *i64) -> i64 called by 1: z_zss |
| 76 | func z_keyroots(l: *i64, n: i64, kr: *i64) -> i64 called by 1: z_zss |
| 86 | func z_zss(lab1: *i64, dep1: *i64, n1: i64, lab2: *i64, dep2: *i64, n2: i64) -> i64 |
| 136 | func z_kat(rep: *u8, pos: i64, name: *u8, got: i64, want: i64, fails: *i64) -> i64 |
| 142 | func z_fetch(url: i64, connect: i64, buf: *u8, cap: i64, olen: *i64) -> i64 |
| 149 | func main(argc: i64, argv: *i64) -> i64 |