_offc_lex_only.nx source
↩ module page · 20 lines · 616 B
1// Isolated test: just call lex_source on a tiny input.
2// If THIS crashes, the bug is in lex. If not, it's elsewhere
3// in the nxc.nx pipeline.
4
5import "syscalls.nx"
6import "types.nx"
7import "lex_kinds.nx"
8import "lex.nx"
9
10func main() -> i64 {
11 sys_write(2, "test: lex start\n" as *u8, 16)
12 let src: *u8 = "func main() -> i64 { return 0 }"
13 let toks: *Tok = lex_source(src, 256)
14 if toks == (0 as *Tok) {
15 sys_write(2, "test: lex returned NULL\n" as *u8, 24)
16 return 1
17 }
18 sys_write(2, "test: lex done\n" as *u8, 15)
19 return __syscall(93, 0, 0, 0, 0, 0, 0)
20}