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
25
repl.py
25
repl.py
|
|
@ -1,10 +1,27 @@
|
|||
import wasp.parser as parser
|
||||
|
||||
line = raw_input(">> ")
|
||||
while line != "":
|
||||
|
||||
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
|
||||
#tree.eval()
|
||||
line = raw_input(">> ")
|
||||
#ast.eval()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue