mirror of
https://github.com/lloeki/wasp.git
synced 2025-12-06 10:44:39 +01:00
better repl reader
This commit is contained in:
parent
daa57a1f47
commit
bc2556da4d
1 changed files with 25 additions and 8 deletions
33
repl.py
33
repl.py
|
|
@ -1,10 +1,27 @@
|
||||||
import wasp.parser as parser
|
import wasp.parser as parser
|
||||||
|
|
||||||
line = raw_input(">> ")
|
|
||||||
while line != "":
|
class Reader(object):
|
||||||
ptree = parser.parse(line)
|
def __init__(self):
|
||||||
print " ^ %s" % ptree
|
pass
|
||||||
ast = ptree.ast()
|
|
||||||
print " ‡ %r" % ast
|
def __iter__(self):
|
||||||
#tree.eval()
|
return self
|
||||||
line = raw_input(">> ")
|
|
||||||
|
def __next__(self):
|
||||||
|
return self.next()
|
||||||
|
|
||||||
|
def next(self):
|
||||||
|
try:
|
||||||
|
return raw_input(">> ")
|
||||||
|
except EOFError:
|
||||||
|
raise StopIteration()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
for line in Reader():
|
||||||
|
ptree = parser.parse(line)
|
||||||
|
print " ^ %s" % ptree
|
||||||
|
ast = ptree.ast()
|
||||||
|
print " ‡ %r" % ast
|
||||||
|
#ast.eval()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue