1 (de load-relative (Path)
2 (load (pack (car (file)) Path)) )
4 (load-relative "readline.l")
5 (load-relative "types.l")
6 (load-relative "reader.l")
7 (load-relative "printer.l")
8 (load-relative "env.l")
9 (load-relative "func.l")
10 (load-relative "core.l")
15 (def '*ReplEnv (MAL-env NIL))
16 (for Bind *Ns (set> *ReplEnv (car Bind) (cdr Bind)))
19 (if (= (MAL-type Ast) 'list)
20 (if (not (MAL-value Ast))
22 (let (Ast* (MAL-value Ast)
23 A0* (MAL-value (car Ast*))
30 (set> Env A1* (EVAL A2 Env)) )
32 (let Env* (MAL-env Env)
33 (for (Bindings A1* Bindings)
34 (let (Key (MAL-value (pop 'Bindings))
35 Value (EVAL (pop 'Bindings) Env*))
36 (set> Env* Key Value) ) )
42 (if (not (memq (MAL-type (EVAL A1 Env)) '(nil false)))
48 (let (Binds (mapcar MAL-value A1*)
51 (curry (Env Binds Body) @
52 (let Env* (MAL-env Env Binds (rest))
53 (EVAL Body Env*) ) ) ) ) )
55 (let (Ast* (MAL-value (eval-ast Ast Env))
56 Fn (MAL-value (car Ast*))
58 (apply Fn Args) ) ) ) ) )
59 (eval-ast Ast Env) ) )
61 (de eval-ast (Ast Env)
62 (let Value (MAL-value Ast)
64 (symbol (get> Env Value))
65 (list (MAL-list (mapcar '((Form) (EVAL Form Env)) Value)))
66 (vector (MAL-vector (mapcar '((Form) (EVAL Form Env)) Value)))
67 (map (MAL-map (mapcar '((Form) (EVAL Form Env)) Value)))
74 (PRINT (EVAL (READ String) *ReplEnv)) )
76 (rep "(def! not (fn* (a) (if a false true)))")
78 (load-history ".mal_history")
81 (until (=0 (setq Input (readline "user> ")))
82 (let Output (catch 'err (rep Input))
83 (if (isa '+MALError Output)
84 (let Message (MAL-value Output)
85 (unless (= (MAL-value Message) "end of token stream")
86 (prinl "[error] " (pr-str Message)) ) )
87 (prinl Output) ) ) ) )