aboutsummaryrefslogtreecommitdiff
path: root/python/step7_quote.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/step7_quote.py')
-rw-r--r--python/step7_quote.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/python/step7_quote.py b/python/step7_quote.py
index aefa421..1002613 100644
--- a/python/step7_quote.py
+++ b/python/step7_quote.py
@@ -46,7 +46,7 @@ def eval_ast(ast, env):
def EVAL(ast, env):
while True:
- #print("EVAL %s" % ast)
+ #print("EVAL %s" % printer._pr_str(ast))
if not types._list_Q(ast):
return eval_ast(ast, env)
@@ -105,6 +105,7 @@ def REP(str):
# core.py: defined using python
for k, v in core.ns.items(): repl_env.set(k, v)
repl_env.set('eval', lambda ast: EVAL(ast, repl_env))
+repl_env.set('*ARGV*', types._list(*sys.argv[2:]))
# core.mal: defined using the language itself
REP("(def! not (fn* (a) (if a false true)))")
@@ -112,13 +113,15 @@ REP("(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \")\"))
if len(sys.argv) >= 2:
REP('(load-file "' + sys.argv[1] + '")')
-else:
- while True:
- try:
- line = mal_readline.readline("user> ")
- if line == None: break
- if line == "": continue
- print(REP(line))
- except reader.Blank: continue
- except Exception as e:
- print("".join(traceback.format_exception(*sys.exc_info())))
+ sys.exit(0)
+
+# repl loop
+while True:
+ try:
+ line = mal_readline.readline("user> ")
+ if line == None: break
+ if line == "": continue
+ print(REP(line))
+ except reader.Blank: continue
+ except Exception as e:
+ print("".join(traceback.format_exception(*sys.exc_info())))