code wiki / _hdl_build / nx_dom_tokenize.nx
nx_dom_tokenize.nx
buildroot/runtime/_hdl_build/nx_dom_tokenize.nx
about
nx_dom_tokenize.nx -- DOM TOKENIZER rung 1: the foundation for true layout-aware quality criteria
(contrast, focus order, overlap, responsive behavior all need STRUCTURE, not byte offsets). Parses
HTML into a flat ELEMENT TABLE, stride 5: {kind 0=open 1=close 2=self/void, name_off, pos, depth,
name_len}; names in a pool. Handles void elements (img/br/input/meta/link/hr), skips comments and
attribute text. Gates on the REAL artifact: (a) tag balance -- every open has a close, final
depth 0; (b) counts agree with the quality gate's independent byte-scan (nav/main/footer/h1);
(c) max depth sane (<32). The element table is what rung-2 criteria walk. 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
| 9 | const K_MAGIC_4194320: i64 = 4194320 |
| 10 | const K_MAGIC_2097152: i64 = 2097152 |
| 11 | const K_MAGIC_1048576: i64 = 1048576 |
| 12 | const K_MAGIC_262144: i64 = 262144 |
| 13 | const K_MAGIC_20000: i64 = 20000 |
functions
| 14 | func _p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 15 | func _pn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=48+(m%10);m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(1,bb,k); return 0 } |
| 16 | func dt_isalpha(c: i64) -> i64 { if c >= 97 { if c <= 122 { return 1 } } if c >= 65 { if c <= 90 { return 1 } } return 0 } called by 1: dt_tokenize |
| 17 | func dt_lower(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c } called by 1: dt_tokenize |
| 19 | func dt_isvoid(pool: *u8, off: i64, len: i64) -> i64 called by 1: dt_tokenize |
| 30 | func dt_tokenize(buf: *u8, n: i64, elems: *i64, maxel: i64, pool: *u8, state: *i64) -> i64 |
| 88 | func dt_count_named(elems: *i64, ne: i64, pool: *u8, name: *u8, kind: i64) -> i64 called by 1: main |
| 105 | func main() -> i64 |