DISABLE FDs (REMOVE ME).
[jackhill/mal.git] / python / step1_read_print.py
1 import sys, traceback
2 import mal_readline
3 import mal_types as types
4 import reader, printer
5
6 # read
7 def READ(str):
8 return reader.read_str(str)
9
10 # eval
11 def EVAL(ast, env):
12 #print("EVAL %s" % printer._pr_str(ast))
13 return ast
14
15 # print
16 def PRINT(exp):
17 return printer._pr_str(exp)
18
19 # repl
20 def REP(str):
21 return PRINT(EVAL(READ(str), {}))
22
23 # repl loop
24 while True:
25 try:
26 line = mal_readline.readline("user> ")
27 if line == None: break
28 if line == "": continue
29 print(REP(line))
30 except reader.Blank: continue
31 except Exception as e:
32 print("".join(traceback.format_exception(*sys.exc_info())))