2014-03-25 01:32:24 +04:00
|
|
|
import sys, traceback
|
|
|
|
import mal_readline
|
2014-04-03 07:23:37 +04:00
|
|
|
import mal_types as types
|
|
|
|
import reader, printer
|
2014-03-25 01:32:24 +04:00
|
|
|
|
|
|
|
# read
|
|
|
|
def READ(str):
|
2014-04-03 07:23:37 +04:00
|
|
|
return reader.read_str(str)
|
2014-03-25 01:32:24 +04:00
|
|
|
|
|
|
|
# eval
|
|
|
|
def EVAL(ast, env):
|
2014-04-19 22:04:09 +04:00
|
|
|
#print("EVAL %s" % printer._pr_str(ast))
|
2014-04-03 07:23:37 +04:00
|
|
|
return ast
|
2014-03-25 01:32:24 +04:00
|
|
|
|
2015-03-07 18:04:07 +03:00
|
|
|
# print
|
2014-03-25 01:32:24 +04:00
|
|
|
def PRINT(exp):
|
2014-04-03 07:23:37 +04:00
|
|
|
return printer._pr_str(exp)
|
2014-03-25 01:32:24 +04:00
|
|
|
|
|
|
|
# repl
|
|
|
|
def REP(str):
|
|
|
|
return PRINT(EVAL(READ(str), {}))
|
|
|
|
|
2014-04-19 22:04:09 +04:00
|
|
|
# repl loop
|
2014-03-25 01:32:24 +04:00
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
line = mal_readline.readline("user> ")
|
|
|
|
if line == None: break
|
|
|
|
if line == "": continue
|
|
|
|
print(REP(line))
|
2014-04-03 07:23:37 +04:00
|
|
|
except reader.Blank: continue
|
2014-03-25 01:32:24 +04:00
|
|
|
except Exception as e:
|
2014-04-17 07:42:17 +04:00
|
|
|
print("".join(traceback.format_exception(*sys.exc_info())))
|