4 (import [reader [read-str Blank]])
5 (import [printer [pr-str]])
12 (defn eval-ast [ast env]
14 (symbol? ast) (if (.has_key env ast) (get env ast)
15 (raise (Exception (+ ast " not found"))))
16 (instance? dict ast) (dict (map (fn [k]
17 [(EVAL k env) (EVAL (get ast k) env)])
19 (instance? tuple ast) (tuple (map (fn [x] (EVAL x env)) ast))
20 (instance? list ast) (list (map (fn [x] (EVAL x env)) ast))
24 ;; indented to match later steps
25 (if (not (instance? tuple ast))
35 (setv el (eval-ast ast env)
37 args (list (rest el)))
48 '/ (fn [a b] (int (/ a b)))})
51 (PRINT (EVAL (READ str) repl-env)))
54 ;; indented to match later steps
57 (do (setv line (raw_input "user> "))
58 (if (= "" line) (continue))
60 (except [EOFError] (break))
63 (print (.join "" (apply traceback.format_exception
64 (.exc_info sys))))))))