[pypy-svn] r51653 - pypy/dist/pypy/rlib/parsing

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Feb 19 21:24:45 CET 2008


Author: cfbolz
Date: Tue Feb 19 21:24:42 2008
New Revision: 51653

Modified:
   pypy/dist/pypy/rlib/parsing/ebnfparse.py
   pypy/dist/pypy/rlib/parsing/pypackrat.py
   pypy/dist/pypy/rlib/parsing/regexparse.py
Log:
regenerate all those files, to get the comments about auto-generated code


Modified: pypy/dist/pypy/rlib/parsing/ebnfparse.py
==============================================================================
--- pypy/dist/pypy/rlib/parsing/ebnfparse.py	(original)
+++ pypy/dist/pypy/rlib/parsing/ebnfparse.py	Tue Feb 19 21:24:42 2008
@@ -448,11 +448,13 @@
 # generated code between this line and its other occurence
 class EBNFToAST(object):
     def visit_file(self, node):
+        #auto-generated code, don't edit
         children = []
         children.extend(self.visit_list(node.children[0]))
         children.extend([node.children[1]])
         return [Nonterminal(node.symbol, children)]
     def visit__plus_symbol0(self, node):
+        #auto-generated code, don't edit
         length = len(node.children)
         if length == 1:
             children = []
@@ -465,17 +467,20 @@
         children.extend(expr[0].children)
         return [Nonterminal(node.symbol, children)]
     def visit_list(self, node):
+        #auto-generated code, don't edit
         children = []
         expr = self.visit__plus_symbol0(node.children[0])
         assert len(expr) == 1
         children.extend(expr[0].children)
         return [Nonterminal(node.symbol, children)]
     def visit_element(self, node):
+        #auto-generated code, don't edit
         length = len(node.children)
         if node.children[0].symbol == 'production':
             return self.visit_production(node.children[0])
         return self.visit_regex(node.children[0])
     def visit_regex(self, node):
+        #auto-generated code, don't edit
         children = []
         children.extend([node.children[0]])
         children.extend([node.children[1]])
@@ -483,10 +488,12 @@
         children.extend([node.children[3]])
         return [Nonterminal(node.symbol, children)]
     def visit__maybe_symbol0(self, node):
+        #auto-generated code, don't edit
         children = []
         children.extend(self.visit_body(node.children[0]))
         return [Nonterminal(node.symbol, children)]
     def visit_production(self, node):
+        #auto-generated code, don't edit
         length = len(node.children)
         if length == 3:
             children = []
@@ -503,6 +510,7 @@
         children.extend([node.children[3]])
         return [Nonterminal(node.symbol, children)]
     def visit__star_symbol1(self, node):
+        #auto-generated code, don't edit
         length = len(node.children)
         if length == 2:
             children = []
@@ -515,6 +523,7 @@
         children.extend(expr[0].children)
         return [Nonterminal(node.symbol, children)]
     def visit_body(self, node):
+        #auto-generated code, don't edit
         length = len(node.children)
         if length == 1:
             children = []
@@ -527,6 +536,7 @@
         children.extend(self.visit_expansion(node.children[1]))
         return [Nonterminal(node.symbol, children)]
     def visit__plus_symbol1(self, node):
+        #auto-generated code, don't edit
         length = len(node.children)
         if length == 1:
             children = []
@@ -539,12 +549,14 @@
         children.extend(expr[0].children)
         return [Nonterminal(node.symbol, children)]
     def visit_expansion(self, node):
+        #auto-generated code, don't edit
         children = []
         expr = self.visit__plus_symbol1(node.children[0])
         assert len(expr) == 1
         children.extend(expr[0].children)
         return [Nonterminal(node.symbol, children)]
     def visit_decorated(self, node):
+        #auto-generated code, don't edit
         length = len(node.children)
         if length == 1:
             return self.visit_enclosed(node.children[0])
@@ -563,6 +575,7 @@
         children.extend([node.children[1]])
         return [Nonterminal(node.symbol, children)]
     def visit_enclosed(self, node):
+        #auto-generated code, don't edit
         length = len(node.children)
         if length == 1:
             return self.visit_primary(node.children[0])
@@ -586,6 +599,7 @@
         children.extend([node.children[2]])
         return [Nonterminal(node.symbol, children)]
     def visit_primary(self, node):
+        #auto-generated code, don't edit
         length = len(node.children)
         if node.children[0].symbol == 'NONTERMINALNAME':
             children = []
@@ -599,6 +613,7 @@
         children.extend([node.children[0]])
         return [Nonterminal(node.symbol, children)]
     def transform(self, tree):
+        #auto-generated code, don't edit
         assert isinstance(tree, Nonterminal)
         assert tree.symbol == 'file'
         r = self.visit_file(tree)

Modified: pypy/dist/pypy/rlib/parsing/pypackrat.py
==============================================================================
--- pypy/dist/pypy/rlib/parsing/pypackrat.py	(original)
+++ pypy/dist/pypy/rlib/parsing/pypackrat.py	Tue Feb 19 21:24:42 2008
@@ -2640,7 +2640,10 @@
             self._pos = _choice13
             raise BacktrackException
         _upto = _runner.last_matched_index + 1
-        _result = self._inputstream[self._pos: _upto]
+        _pos = self._pos
+        assert _pos >= 0
+        assert _upto >= 0
+        _result = self._inputstream[_pos: _upto]
         self._pos = _upto
         return _result
     def _regex1006631623(self):
@@ -2651,7 +2654,10 @@
             self._pos = _choice14
             raise BacktrackException
         _upto = _runner.last_matched_index + 1
-        _result = self._inputstream[self._pos: _upto]
+        _pos = self._pos
+        assert _pos >= 0
+        assert _upto >= 0
+        _result = self._inputstream[_pos: _upto]
         self._pos = _upto
         return _result
     def _regex528667127(self):
@@ -2662,7 +2668,10 @@
             self._pos = _choice15
             raise BacktrackException
         _upto = _runner.last_matched_index + 1
-        _result = self._inputstream[self._pos: _upto]
+        _pos = self._pos
+        assert _pos >= 0
+        assert _upto >= 0
+        _result = self._inputstream[_pos: _upto]
         self._pos = _upto
         return _result
     def _regex291086639(self):
@@ -2673,7 +2682,10 @@
             self._pos = _choice16
             raise BacktrackException
         _upto = _runner.last_matched_index + 1
-        _result = self._inputstream[self._pos: _upto]
+        _pos = self._pos
+        assert _pos >= 0
+        assert _upto >= 0
+        _result = self._inputstream[_pos: _upto]
         self._pos = _upto
         return _result
     def _regex1074651696(self):
@@ -2684,7 +2696,10 @@
             self._pos = _choice17
             raise BacktrackException
         _upto = _runner.last_matched_index + 1
-        _result = self._inputstream[self._pos: _upto]
+        _pos = self._pos
+        assert _pos >= 0
+        assert _upto >= 0
+        _result = self._inputstream[_pos: _upto]
         self._pos = _upto
         return _result
     def _regex1124192327(self):
@@ -2695,7 +2710,10 @@
             self._pos = _choice18
             raise BacktrackException
         _upto = _runner.last_matched_index + 1
-        _result = self._inputstream[self._pos: _upto]
+        _pos = self._pos
+        assert _pos >= 0
+        assert _upto >= 0
+        _result = self._inputstream[_pos: _upto]
         self._pos = _upto
         return _result
     def _regex1979538501(self):
@@ -2706,7 +2724,10 @@
             self._pos = _choice19
             raise BacktrackException
         _upto = _runner.last_matched_index + 1
-        _result = self._inputstream[self._pos: _upto]
+        _pos = self._pos
+        assert _pos >= 0
+        assert _upto >= 0
+        _result = self._inputstream[_pos: _upto]
         self._pos = _upto
         return _result
     class _Runner(object):
@@ -2717,6 +2738,7 @@
             self.last_matched_index = -1
             self.state = -1
         def recognize_299149370(runner, i):
+            #auto-generated code, don't edit
             assert i >= 0
             input = runner.text
             state = 0
@@ -2724,43 +2746,44 @@
                 if state == 0:
                     runner.last_matched_index = i - 1
                     runner.last_matched_state = state
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 0
                         return i
-                    if char == ' ':
+                    if char == '\n':
                         state = 1
-                    elif char == '\n':
+                    elif char == ' ':
                         state = 2
                     else:
                         break
                 if state == 1:
-                    if i < len(input):
+                    runner.last_matched_index = i - 1
+                    runner.last_matched_state = state
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 1
-                        return ~i
-                    if char == ' ':
+                        return i
+                    if char == '\n':
+                        state = 1
+                        continue
+                    elif char == ' ':
                         state = 1
                         continue
-                    elif char == '\n':
-                        state = 2
                     else:
                         break
                 if state == 2:
-                    runner.last_matched_index = i - 1
-                    runner.last_matched_state = state
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 2
-                        return i
+                        return ~i
                     if char == '\n':
-                        state = 2
+                        state = 1
                         continue
                     elif char == ' ':
                         state = 2
@@ -2778,52 +2801,53 @@
             runner.state = state
             return ~i
         def recognize_1006631623(runner, i):
+            #auto-generated code, don't edit
             assert i >= 0
             input = runner.text
             state = 0
             while 1:
                 if state == 0:
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 0
                         return ~i
                     if char == '`':
-                        state = 1
+                        state = 3
                     else:
                         break
-                if state == 1:
-                    if i < len(input):
+                if state == 2:
+                    try:
                         char = input[i]
                         i += 1
-                    else:
-                        runner.state = 1
+                    except IndexError:
+                        runner.state = 2
                         return ~i
-                    if '\x00' <= char <= '[':
-                        state = 1
-                        continue
-                    elif ']' <= char <= '_':
-                        state = 1
-                        continue
-                    elif 'a' <= char <= '\xff':
-                        state = 1
-                        continue
-                    elif char == '\\':
-                        state = 2
-                    elif char == '`':
+                    if '\x00' <= char <= '\xff':
                         state = 3
                     else:
                         break
-                if state == 2:
-                    if i < len(input):
+                if state == 3:
+                    try:
                         char = input[i]
                         i += 1
-                    else:
-                        runner.state = 2
+                    except IndexError:
+                        runner.state = 3
                         return ~i
-                    if '\x00' <= char <= '\xff':
+                    if char == '`':
                         state = 1
+                    elif char == '\\':
+                        state = 2
+                        continue
+                    elif ']' <= char <= '_':
+                        state = 3
+                        continue
+                    elif '\x00' <= char <= '[':
+                        state = 3
+                        continue
+                    elif 'a' <= char <= '\xff':
+                        state = 3
                         continue
                     else:
                         break
@@ -2838,56 +2862,57 @@
             runner.state = state
             return ~i
         def recognize_528667127(runner, i):
+            #auto-generated code, don't edit
             assert i >= 0
             input = runner.text
             state = 0
             while 1:
                 if state == 0:
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 0
                         return ~i
                     if char == ' ':
                         state = 0
                         continue
                     elif char == '#':
-                        state = 1
+                        state = 2
                     else:
                         break
                 if state == 1:
-                    if i < len(input):
+                    runner.last_matched_index = i - 1
+                    runner.last_matched_state = state
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 1
-                        return ~i
-                    if '\x00' <= char <= '\t':
-                        state = 1
-                        continue
-                    elif '\x0b' <= char <= '\xff':
-                        state = 1
+                        return i
+                    if char == ' ':
+                        state = 0
                         continue
-                    elif char == '\n':
+                    elif char == '#':
                         state = 2
                     else:
                         break
                 if state == 2:
-                    runner.last_matched_index = i - 1
-                    runner.last_matched_state = state
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 2
-                        return i
-                    if char == ' ':
-                        state = 0
-                        continue
-                    elif char == '#':
+                        return ~i
+                    if char == '\n':
                         state = 1
                         continue
+                    elif '\x00' <= char <= '\t':
+                        state = 2
+                        continue
+                    elif '\x0b' <= char <= '\xff':
+                        state = 2
+                        continue
                     else:
                         break
                 runner.last_matched_state = state
@@ -2901,39 +2926,40 @@
             runner.state = state
             return ~i
         def recognize_291086639(runner, i):
+            #auto-generated code, don't edit
             assert i >= 0
             input = runner.text
             state = 0
             while 1:
                 if state == 0:
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 0
                         return ~i
                     if char == '{':
-                        state = 1
+                        state = 2
                     else:
                         break
-                if state == 1:
-                    if i < len(input):
+                if state == 2:
+                    try:
                         char = input[i]
                         i += 1
-                    else:
-                        runner.state = 1
+                    except IndexError:
+                        runner.state = 2
                         return ~i
-                    if '\x00' <= char <= '\t':
+                    if char == '}':
                         state = 1
+                    elif '\x00' <= char <= '\t':
+                        state = 2
                         continue
                     elif '\x0b' <= char <= '|':
-                        state = 1
+                        state = 2
                         continue
                     elif '~' <= char <= '\xff':
-                        state = 1
-                        continue
-                    elif char == '}':
                         state = 2
+                        continue
                     else:
                         break
                 runner.last_matched_state = state
@@ -2947,20 +2973,21 @@
             runner.state = state
             return ~i
         def recognize_1074651696(runner, i):
+            #auto-generated code, don't edit
             assert i >= 0
             input = runner.text
             state = 0
             while 1:
                 if state == 0:
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 0
                         return ~i
-                    if 'A' <= char <= 'Z':
+                    if char == '_':
                         state = 1
-                    elif char == '_':
+                    elif 'A' <= char <= 'Z':
                         state = 1
                     elif 'a' <= char <= 'z':
                         state = 1
@@ -2969,19 +2996,19 @@
                 if state == 1:
                     runner.last_matched_index = i - 1
                     runner.last_matched_state = state
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 1
                         return i
-                    if '0' <= char <= '9':
+                    if char == '_':
                         state = 1
                         continue
-                    elif 'A' <= char <= 'Z':
+                    elif '0' <= char <= '9':
                         state = 1
                         continue
-                    elif char == '_':
+                    elif 'A' <= char <= 'Z':
                         state = 1
                         continue
                     elif 'a' <= char <= 'z':
@@ -3000,15 +3027,16 @@
             runner.state = state
             return ~i
         def recognize_1124192327(runner, i):
+            #auto-generated code, don't edit
             assert i >= 0
             input = runner.text
             state = 0
             while 1:
                 if state == 0:
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 0
                         return ~i
                     if char == "'":
@@ -3016,10 +3044,10 @@
                     else:
                         break
                 if state == 1:
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 1
                         return ~i
                     if '\x00' <= char <= '&':
@@ -3043,32 +3071,33 @@
             runner.state = state
             return ~i
         def recognize_1979538501(runner, i):
+            #auto-generated code, don't edit
             assert i >= 0
             input = runner.text
             state = 0
             while 1:
                 if state == 0:
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 0
                         return ~i
                     if char == '#':
                         state = 1
+                    elif char == ' ':
+                        state = 2
                     elif char == '\t':
                         state = 2
                     elif char == '\n':
                         state = 2
-                    elif char == ' ':
-                        state = 2
                     else:
                         break
                 if state == 1:
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 1
                         return ~i
                     if '\x00' <= char <= '\t':

Modified: pypy/dist/pypy/rlib/parsing/regexparse.py
==============================================================================
--- pypy/dist/pypy/rlib/parsing/regexparse.py	(original)
+++ pypy/dist/pypy/rlib/parsing/regexparse.py	Tue Feb 19 21:24:42 2008
@@ -1277,7 +1277,10 @@
             self._pos = _choice0
             raise BacktrackException
         _upto = _runner.last_matched_index + 1
-        _result = self._inputstream[self._pos: _upto]
+        _pos = self._pos
+        assert _pos >= 0
+        assert _upto >= 0
+        _result = self._inputstream[_pos: _upto]
         self._pos = _upto
         return _result
     def _regex1323868075(self):
@@ -1288,7 +1291,10 @@
             self._pos = _choice1
             raise BacktrackException
         _upto = _runner.last_matched_index + 1
-        _result = self._inputstream[self._pos: _upto]
+        _pos = self._pos
+        assert _pos >= 0
+        assert _upto >= 0
+        _result = self._inputstream[_pos: _upto]
         self._pos = _upto
         return _result
     def _regex1380912319(self):
@@ -1299,7 +1305,10 @@
             self._pos = _choice2
             raise BacktrackException
         _upto = _runner.last_matched_index + 1
-        _result = self._inputstream[self._pos: _upto]
+        _pos = self._pos
+        assert _pos >= 0
+        assert _upto >= 0
+        _result = self._inputstream[_pos: _upto]
         self._pos = _upto
         return _result
     class _Runner(object):
@@ -1310,34 +1319,35 @@
             self.last_matched_index = -1
             self.state = -1
         def recognize_1166214427(runner, i):
+            #auto-generated code, don't edit
             assert i >= 0
             input = runner.text
             state = 0
             while 1:
                 if state == 0:
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 0
                         return ~i
-                    if '1' <= char <= '9':
+                    if char == '0':
                         state = 1
-                    elif char == '0':
+                    elif '1' <= char <= '9':
                         state = 2
                     else:
                         break
-                if state == 1:
+                if state == 2:
                     runner.last_matched_index = i - 1
                     runner.last_matched_state = state
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
-                        runner.state = 1
+                    except IndexError:
+                        runner.state = 2
                         return i
                     if '0' <= char <= '9':
-                        state = 1
+                        state = 2
                         continue
                     else:
                         break
@@ -1352,27 +1362,28 @@
             runner.state = state
             return ~i
         def recognize_1323868075(runner, i):
+            #auto-generated code, don't edit
             assert i >= 0
             input = runner.text
             state = 0
             while 1:
                 if state == 0:
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 0
                         return ~i
-                    if '\x00' <= char <= "'":
+                    if char == '\\':
                         state = 1
                     elif '/' <= char <= '>':
                         state = 1
                     elif '@' <= char <= 'Z':
                         state = 1
-                    elif char == '\\':
-                        state = 1
                     elif '_' <= char <= 'z':
                         state = 1
+                    elif '\x00' <= char <= "'":
+                        state = 1
                     elif '~' <= char <= '\xff':
                         state = 1
                     else:
@@ -1388,65 +1399,70 @@
             runner.state = state
             return ~i
         def recognize_1380912319(runner, i):
+            #auto-generated code, don't edit
             assert i >= 0
             input = runner.text
             state = 0
             while 1:
                 if state == 0:
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 0
                         return ~i
                     if char == '\\':
-                        state = 1
+                        state = 4
                     else:
                         break
                 if state == 1:
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 1
                         return ~i
-                    if char == 'x':
-                        state = 2
-                    elif '\x00' <= char <= 'w':
+                    if 'A' <= char <= 'F':
                         state = 3
-                    elif 'y' <= char <= '\xff':
+                    elif 'a' <= char <= 'f':
+                        state = 3
+                    elif '0' <= char <= '9':
                         state = 3
                     else:
                         break
                 if state == 2:
                     runner.last_matched_index = i - 1
                     runner.last_matched_state = state
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 2
                         return i
-                    if '0' <= char <= '9':
-                        state = 4
-                    elif 'A' <= char <= 'F':
-                        state = 4
+                    if 'A' <= char <= 'F':
+                        state = 1
+                        continue
                     elif 'a' <= char <= 'f':
-                        state = 4
+                        state = 1
+                        continue
+                    elif '0' <= char <= '9':
+                        state = 1
+                        continue
                     else:
                         break
                 if state == 4:
-                    if i < len(input):
+                    try:
                         char = input[i]
                         i += 1
-                    else:
+                    except IndexError:
                         runner.state = 4
                         return ~i
-                    if '0' <= char <= '9':
-                        state = 3
-                    elif 'A' <= char <= 'F':
+                    if char == 'x':
+                        state = 2
+                        continue
+                    elif '\x00' <= char <= 'w':
                         state = 3
-                    elif 'a' <= char <= 'f':
+                    elif 'y' <= char <= '\xff':
                         state = 3
                     else:
                         break
@@ -1490,6 +1506,7 @@
 
 
 
+
 def test_generate():
     f = py.magic.autopath()
     oldcontent = f.read()



More information about the Pypy-commit mailing list