Ruby,Python,C#: readline history fixes. Ruby include path.
[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" % ast)
13 return ast
14
15 def PRINT(exp):
16 return printer._pr_str(exp)
17
18 # repl
19 def REP(str):
20 return PRINT(EVAL(READ(str), {}))
21
22 while True:
23 try:
24 line = mal_readline.readline("user> ")
25 if line == None: break
26 if line == "": continue
27 print(REP(line))
28 except reader.Blank: continue
29 except Exception as e:
30 print("".join(traceback.format_exception(*sys.exc_info())))