1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-21 10:37:58 +03:00
mal/hy/step1_read_print.hy
2017-09-19 22:44:41 -05:00

28 lines
531 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) {})))
(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)))))))