Heh, now I can run a REPL

This commit is contained in:
Paul Tagliamonte 2012-12-18 22:36:25 -05:00
parent deb0f5820b
commit c88ab1f787
2 changed files with 15 additions and 1 deletions

View File

@ -15,6 +15,10 @@ def _add_native_methods(mod):
sys.stdout.flush()
def _read(*args):
return sys.stdin.readline()
def _lex(*args):
ret = []
for thing in args:
@ -124,7 +128,8 @@ def _add_native_methods(mod):
"<=": _le,
"!=": _ne,
"eval": _eval,
"lex": _lex
"lex": _lex,
"read": _read,
}
for native in natives:

View File

@ -9,6 +9,14 @@ def _define(obj, lns):
obj.namespace[args[0]] = args[1]()
def _loop(obj, lns):
fd = obj.get_invocation()
args = fd['args']
while True:
for arg in args:
arg.eval(lns.clone())
def _fn(obj, lns):
fd = obj.get_invocation()
args = fd['args']
@ -62,4 +70,5 @@ builtins = {
"import": _import,
"kwapply": _kwapply,
"if": _if,
"loop": _loop
}