Implemented hook_read_{after,before} handlers.

parent 1c6c77ed
pybison @ 8ec21981
Subproject commit 282beeb275a9dde703523670a77c4449ce1decf8 Subproject commit 8ec21981dc8afac97b06f737b50209e2b318037d
...@@ -87,7 +87,12 @@ class Parser(BisonParser): ...@@ -87,7 +87,12 @@ class Parser(BisonParser):
except EOFError: except EOFError:
return '' return ''
def hook_read(self, data): def hook_read_before(self):
if self.interactive and self.possibilities:
print 'possibilities:'
print self.possibilities
def hook_read_after(self, data):
""" """
This hook will be called when the read() method returned. The data This hook will be called when the read() method returned. The data
argument points to the data read by the read() method. This hook argument points to the data read by the read() method. This hook
...@@ -138,19 +143,12 @@ class Parser(BisonParser): ...@@ -138,19 +143,12 @@ class Parser(BisonParser):
break break
if self.verbose: if self.verbose:
print 'hook_read() modified the input data:' print 'hook_read_after() modified the input data:'
print 'before:', data.replace('\n', '\\n') print 'before:', data.replace('\n', '\\n')
print 'after :', data_after.replace('\n', '\\n') print 'after :', data_after.replace('\n', '\\n')
data = data_after data = data_after
if self.interactive:
if not self.possibilities:
print 'possibilities: None'
else:
print 'possibilities:'
print self.possibilities
return data return data
def hook_handler(self, target, option, names, values, retval): def hook_handler(self, target, option, names, values, retval):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment