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