Commit | Line | Data |
---|---|---|
31690700 JM |
1 | import sys, traceback |
2 | import mal_readline | |
ea81a808 JM |
3 | import mal_types as types |
4 | import reader, printer | |
31690700 JM |
5 | |
6 | # read | |
7 | def READ(str): | |
ea81a808 | 8 | return reader.read_str(str) |
31690700 JM |
9 | |
10 | # eval | |
11 | def EVAL(ast, env): | |
86b689f3 | 12 | #print("EVAL %s" % printer._pr_str(ast)) |
ea81a808 | 13 | return ast |
31690700 | 14 | |
10b07148 | 15 | |
31690700 | 16 | def PRINT(exp): |
ea81a808 | 17 | return printer._pr_str(exp) |
31690700 JM |
18 | |
19 | # repl | |
20 | def REP(str): | |
21 | return PRINT(EVAL(READ(str), {})) | |
22 | ||
86b689f3 | 23 | # repl loop |
31690700 JM |
24 | while 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()))) |