code wiki / (root) / nx_smoke_repro4.nx

nx_smoke_repro4.nx source

↩ module page · 82 lines · 1788 B

1// smoke_repro4.nx -- match Tok's 12-field layout + lex_ident_or_kw shape. 2 3// nx_safety_envelope: 4// intended_use: AUTO_APPLIED -- primitive-specific tuning queued 5// sil_target: SIL1 6// evidence: [bulk_applied_2026-05-16, see-file-comment-for-detail] 7// verdict: NOT_YET_EVALUATED 8 9import "nx_syscalls.nx" 10 11struct LX { 12 src: *u8, 13 pos: i64, 14 line: i64, 15 col: i64, 16 tokens: *u8, 17 n_tokens: i64, 18 cap: i64, 19} 20 21struct TK { 22 kind: i64, 23 line: i64, 24 col: i64, 25 int_val: i64, 26 text0: i64, text1: i64, text2: i64, text3: i64, 27 text4: i64, text5: i64, text6: i64, text7: i64, 28} 29 30func peek4(L: *LX) -> i64 { 31 let s: *u8 = L.src 32 return s[L.pos] 33} 34 35func is_alpha4(c: i64) -> i64 { 36 if c >= 0x41 { if c <= 0x5A { return 1 } } 37 if c >= 0x61 { if c <= 0x7A { return 1 } } 38 return 0 39} 40 41func advance4(L: *LX) -> i64 { 42 L.pos = L.pos + 1 43 return 0 44} 45 46func work(L: *LX) -> i64 { 47 let tr: *u8 = sys_mmap(96) 48 let t: *TK = tr as *TK 49 t.kind = 2 50 t.line = L.line 51 t.col = L.col 52 t.int_val = 0 53 t.text0 = 0; t.text1 = 0; t.text2 = 0; t.text3 = 0 54 t.text4 = 0; t.text5 = 0; t.text6 = 0; t.text7 = 0 55 let base: i64 = t as i64 56 let text: *u8 = (base + 32) as *u8 57 var i: i64 = 0 58 while i < 8 { 59 let c: i64 = peek4(L) 60 if is_alpha4(c) { 61 text[i] = c & 0xFF 62 advance4(L) 63 i = i + 1 64 } 65 if is_alpha4(c) == 0 { break } 66 } 67 return i 68} 69 70func main() -> i64 { 71 let raw: *u8 = sys_mmap(96) 72 let L: *LX = raw as *LX 73 L.src = "abcDEF" 74 L.pos = 0 75 L.line = 1 76 L.col = 1 77 L.tokens = 0 as *u8 78 L.n_tokens = 0 79 L.cap = 16 80 let r: i64 = work(L) 81 return __syscall(93, r, 0, 0, 0, 0, 0) 82}