Heh, now I can run a REPL
This commit is contained in:
parent
deb0f5820b
commit
c88ab1f787
@ -15,6 +15,10 @@ def _add_native_methods(mod):
|
|||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
|
||||||
|
def _read(*args):
|
||||||
|
return sys.stdin.readline()
|
||||||
|
|
||||||
|
|
||||||
def _lex(*args):
|
def _lex(*args):
|
||||||
ret = []
|
ret = []
|
||||||
for thing in args:
|
for thing in args:
|
||||||
@ -124,7 +128,8 @@ def _add_native_methods(mod):
|
|||||||
"<=": _le,
|
"<=": _le,
|
||||||
"!=": _ne,
|
"!=": _ne,
|
||||||
"eval": _eval,
|
"eval": _eval,
|
||||||
"lex": _lex
|
"lex": _lex,
|
||||||
|
"read": _read,
|
||||||
}
|
}
|
||||||
|
|
||||||
for native in natives:
|
for native in natives:
|
||||||
|
@ -9,6 +9,14 @@ def _define(obj, lns):
|
|||||||
obj.namespace[args[0]] = args[1]()
|
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):
|
def _fn(obj, lns):
|
||||||
fd = obj.get_invocation()
|
fd = obj.get_invocation()
|
||||||
args = fd['args']
|
args = fd['args']
|
||||||
@ -62,4 +70,5 @@ builtins = {
|
|||||||
"import": _import,
|
"import": _import,
|
||||||
"kwapply": _kwapply,
|
"kwapply": _kwapply,
|
||||||
"if": _if,
|
"if": _if,
|
||||||
|
"loop": _loop
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user