better repl reader

This commit is contained in:
Loic Nageleisen 2014-01-24 23:16:25 +01:00
parent daa57a1f47
commit bc2556da4d

33
repl.py
View file

@ -1,10 +1,27 @@
import wasp.parser as parser
line = raw_input(">> ")
while line != "":
ptree = parser.parse(line)
print " ^ %s" % ptree
ast = ptree.ast()
print "%r" % ast
#tree.eval()
line = raw_input(">> ")
class Reader(object):
def __init__(self):
pass
def __iter__(self):
return self
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()