smoke_repro2.nx source
↩ module page · 45 lines · 916 B
1// smoke_repro2.nx -- closer to the lex_ident_or_kw shape.
2// Adds a function call inside the loop body.
3
4import "syscalls.nx"
5
6struct S {
7 src: *u8,
8 pos: i64,
9}
10
11func peek2(L: *S) -> i64 {
12 let s: *u8 = L.src
13 return s[L.pos]
14}
15
16func is_alpha2(c: i64) -> i64 {
17 if c >= 0x41 { if c <= 0x5A { return 1 } }
18 if c >= 0x61 { if c <= 0x7A { return 1 } }
19 return 0
20}
21
22func work(L: *S) -> i64 {
23 let raw: *u8 = sys_mmap(96)
24 let t: *S = raw as *S
25 t.src = 0 as *u8
26 t.pos = 0
27 var i: i64 = 0
28 while i < 3 {
29 let c: i64 = peek2(L)
30 if is_alpha2(c) {
31 i = i + 1
32 }
33 if is_alpha2(c) == 0 { break }
34 }
35 return i
36}
37
38func main() -> i64 {
39 let raw: *u8 = sys_mmap(64)
40 let L: *S = raw as *S
41 L.src = "abc"
42 L.pos = 0
43 let r: i64 = work(L)
44 return __syscall(93, r, 0, 0, 0, 0, 0)
45}