From 86b689f3d7111a9fa13da389a30f3dfdf877d1a4 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Sat, 19 Apr 2014 13:04:09 -0500 Subject: All: *ARGV* and *host-language*. Misc syncing/fixes. --- python/stepA_more.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'python/stepA_more.py') diff --git a/python/stepA_more.py b/python/stepA_more.py index e4bc768..b9d8152 100644 --- a/python/stepA_more.py +++ b/python/stepA_more.py @@ -148,6 +148,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! *host-language* \"python\")") @@ -158,13 +159,16 @@ REP("(defmacro! or (fn* (& xs) (if (empty? xs) nil (if (= 1 (count xs)) (first x 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 +REP("(println (str \"Mal [\" *host-language* \"]\"))") +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()))) -- cgit v1.2.3