https://github.com/akkartik/mu/blob/main/shell/read.mu
1 fn read-cell in: (addr gap-buffer), out: (addr handle cell), trace: (addr trace) {
2
3 var tokens-storage: (stream token 0x400)
4 var tokens/edx: (addr stream token) <- address tokens-storage
5 tokenize in, tokens, trace
6 var error?/eax: boolean <- has-errors? trace
7 compare error?, 0/false
8 {
9 break-if-=
10 return
11 }
12
13 var parenthesized-tokens-storage: (stream token 0x400)
14 var parenthesized-tokens/ecx: (addr stream token) <- address parenthesized-tokens-storage
15 parenthesize tokens, parenthesized-tokens, trace
16 var error?/eax: boolean <- has-errors? trace
17 compare error?, 0/false
18 {
19 break-if-=
20 return
21 }
22 parse-input parenthesized-tokens, out, trace
23 transform-infix out, trace
24 }