1
1
mirror of https://github.com/kanaka/mal.git synced 2024-11-11 00:52:44 +03:00
mal/hy/step1_read_print.hy
2017-09-21 23:32:15 -05:00

31 lines
679 B
Hy
Executable File

#!/usr/bin/env hy
(import sys traceback)
(import [reader [read-str Blank]])
(import [printer [pr-str]])
(defn READ [str]
(read-str str))
(defn EVAL [ast env]
ast)
(defn PRINT [exp]
(pr-str exp True))
(defn REP [str]
(PRINT (EVAL (READ str) {})))
(defmain [&rest args]
;; indented to match later steps
(while True
(try
(do (setv line (raw_input "user> "))
(if (= "" line) (continue))
(print (REP line)))
(except [EOFError] (break))
(except [Blank])
(except []
(print (.join "" (apply traceback.format_exception
(.exc_info sys))))))))