Sfoglia il codice sorgente

Implemented hook_read_{after,before} handlers.

Sander Mathijs van Veen 14 anni fa
parent
commit
d6682c57d7
2 ha cambiato i file con 8 aggiunte e 10 eliminazioni
  1. 1 1
      external/pybison
  2. 7 9
      src/parser.py

+ 1 - 1
external/pybison

@@ -1 +1 @@
-Subproject commit 282beeb275a9dde703523670a77c4449ce1decf8
+Subproject commit 8ec21981dc8afac97b06f737b50209e2b318037d

+ 7 - 9
src/parser.py

@@ -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):
                 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):