/
README
39 lines (28 loc) · 920 Bytes
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
shave
This is the beginnings of a LISP interpreter. It's kind of full of garbage right now, because I got impatient and started copy-pasting. The lexer is handwritten, so yeah, it rules. The generated AST is a big linked list, which is evaluated in the eval step. The AST is made up of 'Token' structs, which have type and property enums used by the eval routines.
My end goal here is to make the cleanest, smallest, and simplest implementation of LISP that would handle the recursive computation of a factorial:
(defun factorial (n)
(if (<= n 1)
1
(* n (factorial (- n 1)))))
There's a ways to go; namely cleanup and implementing defun.
compile:
$ make
use:
$ ./shave
shave.
> (if (> 3 2) (/ 9 (+ 3 2)))
list:
if:
list:
>:
atom: 3
atom: 2
list:
/:
atom: 9
list:
+:
atom: 3
atom: 2
atom: 1.8