https://github.com/akkartik/mu/blob/master/apps/mulisp.mu
 1 # To run unit tests:
 2 #   $ ./a.elf test
 3 fn main args-on-stack: (addr array addr array byte) -> exit-status/ebx: int {
 4   var args/eax: (addr array addr array byte) <- copy args-on-stack
 5   var tmp/ecx: int <- length args
 6   $main-body: {
 7     # if (len(args) > 1 && args[1] == "test") run-tests()
 8     compare tmp, 1
 9     {
10       break-if-<=
11       # if (args[1] == "test") run-tests()
12       var tmp2/ecx: (addr addr array byte) <- index args, 1
13       var tmp3/eax: boolean <- string-equal? *tmp2, "test"
14       compare tmp3, 0
15       {
16         break-if-=
17         run-tests
18         exit-status <- copy 0  # TODO: get at Num-test-failures somehow
19       }
20       break $main-body
21     }
22     # otherwise operate interactively
23     enable-keyboard-immediate-mode
24     repl
25     enable-keyboard-type-mode
26     exit-status <- copy 0
27   }
28 }
29 
30 type cell {
31   tag: int
32     # 0: nil
33     # 1: num
34     # 2: char
35     value: int
36     # 3: sym
37     # 4: string
38     name: (handle array byte)
39     # 4: array
40     # 5: tree
41     left: (handle cell)
42     right: (handle cell)
43     # 6: stream
44     stream: (handle stream byte)
45 }
46 
47 fn repl {
48   var c: (handle cell)
49   var c-ah/ecx: (addr handle cell) <- address c
50   lisp-read c-ah
51   var c-a/eax: (addr cell) <- lookup c
52   compare c-a, 0
53   break-if-=
54   lisp-eval c-a c-ah
55   lisp-print c-a
56   loop
57 }
58 
59 fn lisp-read out: (addr handle cell) {
60 }
61 
62 fn lisp-eval in: (addr cell), out: (addr handle cell) {
63 }
64 
65 fn lisp-print in: (addr cell) {
66 }