aboutsummaryrefslogtreecommitdiff
path: root/clojure/src/step0_repl.clj
blob: f6201ddc07c9c82227f0cde6496a8757161dc1ab (plain)
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
(ns step0-repl
  (:require [readline]))


;; read
(defn READ [& [strng]]
  (let [line (if strng strng (read-line))]
    strng))

;; eval
(defn EVAL [ast env]
  (eval (read-string ast)))

;; print
(defn PRINT [exp] exp)

;; repl
(defn rep [strng] (PRINT (EVAL (READ strng), {})))

(defn -main [& args]
  (loop []
    (let [line (readline/readline "user> ")]
      (when line
        (println (rep line))
        (recur)))))