[pypy-svn] r44520 - in pypy/dist/pypy/rlib/parsing: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Mon Jun 25 19:43:44 CEST 2007


Author: cfbolz
Date: Mon Jun 25 19:43:44 2007
New Revision: 44520

Modified:
   pypy/dist/pypy/rlib/parsing/makepackrat.py
   pypy/dist/pypy/rlib/parsing/pypackrat.py
   pypy/dist/pypy/rlib/parsing/regexparse.py
   pypy/dist/pypy/rlib/parsing/test/test_pypackrat.py
   pypy/dist/pypy/rlib/parsing/test/test_translate.py
Log:
get the first translation test to run

Modified: pypy/dist/pypy/rlib/parsing/makepackrat.py
==============================================================================
--- pypy/dist/pypy/rlib/parsing/makepackrat.py	(original)
+++ pypy/dist/pypy/rlib/parsing/makepackrat.py	Mon Jun 25 19:43:44 2007
@@ -1,11 +1,13 @@
 import py
 import sys
 from pypy.rlib.parsing.tree import Nonterminal, Symbol, RPythonVisitor
+from pypy.rlib.objectmodel import we_are_translated
 
 class BacktrackException(Exception):
     def __init__(self, error=None):
         self.error = error
-        Exception.__init__(self, error)
+        if not we_are_translated():
+            Exception.__init__(self, error)
 
 
 class TreeOptimizer(RPythonVisitor):
@@ -255,10 +257,17 @@
     INPROGRESS = 2
     LEFTRECURSION = 3
     SOMESOLUTIONS = 4
+    
+    _annspecialcase_ = 'specialize:ctr_location' # polymorphic
     def __repr__(self):
         return "Status(%s, %s, %s, %s)" % (self.pos, self.result, self.error,
                                            self.status)
 
+    def __init__(self):
+        self.pos = 0
+        self.error = None
+        self.status = self.INPROGRESS
+        self.result = None
 
 class ParserBuilder(RPythonVisitor):
     def __init__(self):
@@ -274,7 +283,7 @@
         return "\n".join(self.code)
 
     def make_parser(self):
-        m = {'_Status': Status,
+        m = {'Status': Status,
              'Nonterminal': Nonterminal,
              'Symbol': Symbol,}
         exec py.code.Source(self.get_code()).compile() in m
@@ -303,7 +312,6 @@
             block, starterpart)
 
     def memoize_header(self, name, args):
-        statusclassname = "self._Status_%s" % (name, )
         dictname = "_dict_%s" % (name, )
         self.emit_initcode("self.%s = {}" % (dictname, ))
         if args:
@@ -312,32 +320,33 @@
             self.emit("_key = self._pos")
         self.emit("_status = self.%s.get(_key, None)" % (dictname, ))
         for _ in self.start_block("if _status is None:"):
-            self.emit("_status = self.%s[_key] = %s()" % (
-                dictname, statusclassname))
-        for _ in self.start_block("elif _status.status == _status.NORMAL:"):
-            self.emit("self._pos = _status.pos")
-            self.emit("return _status")
-        for _ in self.start_block("elif _status.status == _status.ERROR:"):
-            self.emit("raise self._BacktrackException(_status.error)")
-        for _ in self.start_block(
-            "elif (_status.status == _status.INPROGRESS or\n"
-            "      _status.status == _status.LEFTRECURSION):"):
-            self.emit("_status.status = _status.LEFTRECURSION")
-            for _ in self.start_block("if _status.result is not None:"):
+            self.emit("_status = self.%s[_key] = Status()" % (
+                dictname, ))
+        for _ in self.start_block("else:"):
+            self.emit("_statusstatus = _status.status")
+            for _ in self.start_block("if _statusstatus == _status.NORMAL:"):
                 self.emit("self._pos = _status.pos")
                 self.emit("return _status")
-            for _ in self.start_block("else:"):
-                self.emit("raise self._BacktrackException(None)")
-        for _ in self.start_block(
-            "elif _status.status == _status.SOMESOLUTIONS:"):
-            self.emit("_status.status = _status.INPROGRESS")
+            for _ in self.start_block("elif _statusstatus == _status.ERROR:"):
+                self.emit("raise BacktrackException(_status.error)")
+            for _ in self.start_block(
+                "elif (_statusstatus == _status.INPROGRESS or\n"
+                "      _statusstatus == _status.LEFTRECURSION):"):
+                self.emit("_status.status = _status.LEFTRECURSION")
+                for _ in self.start_block("if _status.result is not None:"):
+                    self.emit("self._pos = _status.pos")
+                    self.emit("return _status")
+                for _ in self.start_block("else:"):
+                    self.emit("raise BacktrackException(None)")
+            for _ in self.start_block(
+                "elif _statusstatus == _status.SOMESOLUTIONS:"):
+                self.emit("_status.status = _status.INPROGRESS")
         self.emit("_startingpos = self._pos")
         self.start_block("try:")
         self.emit("_result = None")
         self.emit("_error = None")
 
     def memoize_footer(self, name):
-        statusclassname = "self._Status_%s" % (name, )
         dictname = "_dict_%s" % (name, )
         for _ in self.start_block("if _status.status == _status.LEFTRECURSION:"):
             for _ in self.start_block("if _status.result is not None:"):
@@ -357,13 +366,13 @@
         self.emit("_status.error = _error")
         self.emit("return _status")
         self.end_block("try")
-        for _ in self.start_block("except self._BacktrackException, _exc:"):
+        for _ in self.start_block("except BacktrackException, _exc:"):
             self.emit("_status.pos = -1")
             self.emit("_status.result = None")
             self.emit("_error = self._combine_errors(_error, _exc.error)")
             self.emit("_status.error = _error")
             self.emit("_status.status = _status.ERROR")
-            self.emit("raise self._BacktrackException(_error)")
+            self.emit("raise BacktrackException(_error)")
 
     def choice_point(self, name=None):
         var = "_choice%s" % (self.namecount, )
@@ -374,16 +383,6 @@
     def revert(self, var):
         self.emit("self._pos = %s" % (var, ))
 
-    def make_status_class(self, name):
-        classname = "_Status_%s" % (name, )
-        for _ in self.start_block("class %s(_Status):" % (classname, )):
-            for _ in self.start_block("def __init__(self):"):
-                self.emit("self.pos = 0")
-                self.emit("self.error = None")
-                self.emit("self.status = self.INPROGRESS")
-                self.emit("self.result = None")
-        return classname
-
     def visit_list(self, t):
         self.start_block("class Parser(object):")
         for elt in t.children:
@@ -407,7 +406,7 @@
                     abs(hash(regex)), ))
                 self.start_block("if _runner.last_matched_state == -1:")
                 self.revert(c)
-                self.emit("raise self._BacktrackException")
+                self.emit("raise BacktrackException")
                 self.end_block("if")
                 self.emit("_upto = _runner.last_matched_index + 1")
                 self.emit("_result = self._inputstream[self._pos: _upto]")
@@ -432,7 +431,6 @@
         if name in self.names:
             raise Exception("name %s appears twice" % (name, ))
         self.names[name] = True
-        self.make_status_class(name)
         otherargs = t.children[1].children
         argswithself = ", ".join(["self"] + otherargs)
         argswithoutself = ", ".join(otherargs)
@@ -457,11 +455,11 @@
             for _ in self.start_block("try:"):
                 self.dispatch(p)
                 self.emit("break")
-            for _ in self.start_block("except self._BacktrackException, _exc:"):
+            for _ in self.start_block("except BacktrackException, _exc:"):
                 self.emit("_error = self._combine_errors(_error, _exc.error)")
                 self.revert(c)
                 if i == len(possibilities) - 1:
-                    self.emit("raise self._BacktrackException(_error)")
+                    self.emit("raise BacktrackException(_error)")
         self.dispatch(possibilities[-1])
         if len(possibilities) > 1:
             self.emit("break")
@@ -476,7 +474,7 @@
         c = self.choice_point()
         for _ in self.start_block("try:"):
             self.dispatch(t.children[0])
-        for _ in self.start_block("except self._BacktrackException:"):
+        for _ in self.start_block("except BacktrackException:"):
             self.revert(c)
 
     def visit_repetition(self, t):
@@ -491,7 +489,7 @@
             for _ in self.start_block("try:"):
                 self.dispatch(t.children[1])
                 self.emit("%s.append(_result)" % (name, ))
-            for _ in self.start_block("except self._BacktrackException, _exc:"):
+            for _ in self.start_block("except BacktrackException, _exc:"):
                 self.emit("_error = self._combine_errors(_error, _exc.error)")
                 self.revert(c)
                 self.emit("break")
@@ -517,7 +515,7 @@
         self.emit("%s = _result" % (resultname, ))
         for _ in self.start_block("try:"):
             self.dispatch(child)
-        for _ in self.start_block("except self._BacktrackException:"):
+        for _ in self.start_block("except BacktrackException:"):
             self.revert(c)
             self.emit("_result = %s" % (resultname, ))
         for _ in self.start_block("else:"):
@@ -528,7 +526,7 @@
                         c, child.additional_info[1:-1], )
             else:
                 error = "None"
-            self.emit("raise self._BacktrackException(%s)" % (error, ))
+            self.emit("raise BacktrackException(%s)" % (error, ))
 
     def visit_lookahead(self, t):
         resultname = "_stored_result%i" % (self.namecount, )
@@ -551,7 +549,7 @@
             self.dispatch(t.children[0])
         for _ in self.start_block("if not (%s):" % (
             t.children[-1].additional_info[1:-1], )):
-            self.emit("raise self._BacktrackException(")
+            self.emit("raise BacktrackException(")
             self.emit("    self._ErrorInformation(")
             self.emit("         _startingpos, ['condition not met']))")
     
@@ -619,6 +617,9 @@
                                    "__dict__ __module__").split())
         initthere = "__init__" in dct
 
+        #XXX XXX XXX
+        if 'BacktrackException' not in frame.f_globals:
+            raise Exception("must import BacktrackException")
         for key, value in pcls.__dict__.iteritems():
             if isinstance(value, type(lambda: None)):
                 value = new.function(value.func_code, frame.f_globals)
@@ -631,7 +632,6 @@
 class PackratParser(object):
     __metaclass__ = MetaPackratParser
 
-    _Status = Status
     _ErrorInformation = ErrorInformation
     _BacktrackException = BacktrackException
 
@@ -640,12 +640,12 @@
         try:
             for i in range(len(chars)):
                 if self._inputstream[self._pos + i] != chars[i]:
-                    raise self._BacktrackException(
+                    raise BacktrackException(
                         self._ErrorInformation(self._pos, [chars]))
             self._pos += len(chars)
             return chars
         except IndexError:
-            raise self._BacktrackException(
+            raise BacktrackException(
                 self._ErrorInformation(self._pos, [chars]))
 
     def  __any__(self):
@@ -654,7 +654,7 @@
             self._pos += 1
             return result
         except IndexError:
-            raise self._BacktrackException(
+            raise BacktrackException(
                 self._ErrorInformation(self._pos, ['anything']))
 
     def _combine_errors(self, error1, error2):
@@ -686,7 +686,7 @@
     code = visitor.get_code()
     content = """
 from pypy.rlib.parsing.tree import Nonterminal, Symbol
-from makepackrat import PackratParser, BacktrackException, Status as _Status
+from makepackrat import PackratParser, BacktrackException, Status
 %s
 class PyPackratSyntaxParser(PackratParser):
     def __init__(self, stream):

Modified: pypy/dist/pypy/rlib/parsing/pypackrat.py
==============================================================================
--- pypy/dist/pypy/rlib/parsing/pypackrat.py	(original)
+++ pypy/dist/pypy/rlib/parsing/pypackrat.py	Mon Jun 25 19:43:44 2007
@@ -1,25 +1,19 @@
 
 from pypy.rlib.parsing.tree import Nonterminal, Symbol
-from makepackrat import PackratParser, BacktrackException, Status as _Status
+from makepackrat import PackratParser, BacktrackException, Status
 class Parser(object):
-    class _Status_NAME(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
     def NAME(self):
         return self._NAME().result
     def _NAME(self):
         _key = self._pos
         _status = self._dict_NAME.get(_key, None)
         if _status is None:
-            _status = self._dict_NAME[_key] = self._Status_NAME()
+            _status = self._dict_NAME[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -27,7 +21,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -52,31 +46,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_SPACE(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def SPACE(self):
         return self._SPACE().result
     def _SPACE(self):
         _key = self._pos
         _status = self._dict_SPACE.get(_key, None)
         if _status is None:
-            _status = self._dict_SPACE[_key] = self._Status_SPACE()
+            _status = self._dict_SPACE[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -84,7 +72,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -109,31 +97,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_COMMENT(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def COMMENT(self):
         return self._COMMENT().result
     def _COMMENT(self):
         _key = self._pos
         _status = self._dict_COMMENT.get(_key, None)
         if _status is None:
-            _status = self._dict_COMMENT[_key] = self._Status_COMMENT()
+            _status = self._dict_COMMENT[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -141,7 +123,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -166,31 +148,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_IGNORE(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def IGNORE(self):
         return self._IGNORE().result
     def _IGNORE(self):
         _key = self._pos
         _status = self._dict_IGNORE.get(_key, None)
         if _status is None:
-            _status = self._dict_IGNORE[_key] = self._Status_IGNORE()
+            _status = self._dict_IGNORE[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -198,7 +174,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -223,31 +199,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_newline(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def newline(self):
         return self._newline().result
     def _newline(self):
         _key = self._pos
         _status = self._dict_newline.get(_key, None)
         if _status is None:
-            _status = self._dict_newline[_key] = self._Status_newline()
+            _status = self._dict_newline[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -255,7 +225,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -270,17 +240,17 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice0
                 _choice1 = self._pos
                 try:
                     _result = self._regex299149370()
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice1
-                    raise self._BacktrackException(_error)
+                    raise BacktrackException(_error)
                 _result = self._regex299149370()
                 break
             if _status.status == _status.LEFTRECURSION:
@@ -300,31 +270,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_REGEX(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def REGEX(self):
         return self._REGEX().result
     def _REGEX(self):
         _key = self._pos
         _status = self._dict_REGEX.get(_key, None)
         if _status is None:
-            _status = self._dict_REGEX[_key] = self._Status_REGEX()
+            _status = self._dict_REGEX[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -332,7 +296,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -359,31 +323,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_QUOTE(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def QUOTE(self):
         return self._QUOTE().result
     def _QUOTE(self):
         _key = self._pos
         _status = self._dict_QUOTE.get(_key, None)
         if _status is None:
-            _status = self._dict_QUOTE[_key] = self._Status_QUOTE()
+            _status = self._dict_QUOTE[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -391,7 +349,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -418,31 +376,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_PYTHONCODE(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def PYTHONCODE(self):
         return self._PYTHONCODE().result
     def _PYTHONCODE(self):
         _key = self._pos
         _status = self._dict_PYTHONCODE.get(_key, None)
         if _status is None:
-            _status = self._dict_PYTHONCODE[_key] = self._Status_PYTHONCODE()
+            _status = self._dict_PYTHONCODE[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -450,7 +402,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -477,31 +429,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_EOF(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def EOF(self):
         return self._EOF().result
     def _EOF(self):
         _key = self._pos
         _status = self._dict_EOF.get(_key, None)
         if _status is None:
-            _status = self._dict_EOF[_key] = self._Status_EOF()
+            _status = self._dict_EOF[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -509,7 +455,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -520,11 +466,11 @@
             _stored_result3 = _result
             try:
                 _result = self.__any__()
-            except self._BacktrackException:
+            except BacktrackException:
                 self._pos = _choice2
                 _result = _stored_result3
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
             if _status.status == _status.LEFTRECURSION:
                 if _status.result is not None:
                     if _status.pos >= self._pos:
@@ -542,31 +488,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_file(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def file(self):
         return self._file().result
     def _file(self):
         _key = self._pos
         _status = self._dict_file.get(_key, None)
         if _status is None:
-            _status = self._dict_file[_key] = self._Status_file()
+            _status = self._dict_file[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -574,7 +514,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -589,7 +529,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     _all4.append(_result)
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice5
                     break
@@ -619,31 +559,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_list(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def list(self):
         return self._list().result
     def _list(self):
         _key = self._pos
         _status = self._dict_list.get(_key, None)
         if _status is None:
-            _status = self._dict_list[_key] = self._Status_list()
+            _status = self._dict_list[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -651,7 +585,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -670,7 +604,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     _all7.append(_result)
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice8
                     break
@@ -694,31 +628,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_production(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def production(self):
         return self._production().result
     def _production(self):
         _key = self._pos
         _status = self._dict_production.get(_key, None)
         if _status is None:
-            _status = self._dict_production[_key] = self._Status_production()
+            _status = self._dict_production[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -726,7 +654,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -745,7 +673,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     _all9.append(_result)
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice10
                     break
@@ -763,7 +691,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     _all11.append(_result)
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice12
                     break
@@ -780,7 +708,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     _all13.append(_result)
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice14
                     break
@@ -794,7 +722,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     _all15.append(_result)
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice16
                     break
@@ -817,31 +745,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_productionargs(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def productionargs(self):
         return self._productionargs().result
     def _productionargs(self):
         _key = self._pos
         _status = self._dict_productionargs.get(_key, None)
         if _status is None:
-            _status = self._dict_productionargs[_key] = self._Status_productionargs()
+            _status = self._dict_productionargs[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -849,7 +771,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -869,7 +791,7 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all18.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice19
                             break
@@ -890,7 +812,7 @@
                                     _result = _call_status.result
                                     _error = self._combine_errors(_call_status.error, _error)
                                     _all23.append(_result)
-                                except self._BacktrackException, _exc:
+                                except BacktrackException, _exc:
                                     _error = self._combine_errors(_error, _exc.error)
                                     self._pos = _choice24
                                     break
@@ -904,14 +826,14 @@
                                     _result = _call_status.result
                                     _error = self._combine_errors(_call_status.error, _error)
                                     _all25.append(_result)
-                                except self._BacktrackException, _exc:
+                                except BacktrackException, _exc:
                                     _error = self._combine_errors(_error, _exc.error)
                                     self._pos = _choice26
                                     break
                             _result = _all25
                             _result = _before_discard22
                             _all20.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice21
                             break
@@ -929,7 +851,7 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all27.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice28
                             break
@@ -943,24 +865,24 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all29.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice30
                             break
                     _result = _all29
                     _result = (Nonterminal('productionargs', args + [arg]))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice17
                 _choice31 = self._pos
                 try:
                     _result = (Nonterminal('productionargs', []))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice31
-                    raise self._BacktrackException(_error)
+                    raise BacktrackException(_error)
                 _result = (Nonterminal('productionargs', []))
                 break
             if _status.status == _status.LEFTRECURSION:
@@ -980,31 +902,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_or_(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def or_(self):
         return self._or_().result
     def _or_(self):
         _key = self._pos
         _status = self._dict_or_.get(_key, None)
         if _status is None:
-            _status = self._dict_or_[_key] = self._Status_or_()
+            _status = self._dict_or_[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -1012,7 +928,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -1037,7 +953,7 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all35.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice36
                             break
@@ -1060,14 +976,14 @@
                                     _result = _call_status.result
                                     _error = self._combine_errors(_call_status.error, _error)
                                     _all39.append(_result)
-                                except self._BacktrackException, _exc:
+                                except BacktrackException, _exc:
                                     _error = self._combine_errors(_error, _exc.error)
                                     self._pos = _choice40
                                     break
                             _result = _all39
                             _result = _before_discard38
                             _all33.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice37
                             break
@@ -1079,7 +995,7 @@
                     last = _result
                     _result = (Nonterminal('or', l + [last]))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice32
                 _choice41 = self._pos
@@ -1088,10 +1004,10 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice41
-                    raise self._BacktrackException(_error)
+                    raise BacktrackException(_error)
                 _call_status = self._commands()
                 _result = _call_status.result
                 _error = self._combine_errors(_call_status.error, _error)
@@ -1113,31 +1029,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_commands(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def commands(self):
         return self._commands().result
     def _commands(self):
         _key = self._pos
         _status = self._dict_commands.get(_key, None)
         if _status is None:
-            _status = self._dict_commands[_key] = self._Status_commands()
+            _status = self._dict_commands[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -1145,7 +1055,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -1185,7 +1095,7 @@
                             _error = self._combine_errors(_call_status.error, _error)
                             _result = _before_discard46
                             _all43.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice45
                             break
@@ -1193,7 +1103,7 @@
                     cmds = _result
                     _result = (Nonterminal('commands', [cmd] + cmds))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice42
                 _choice47 = self._pos
@@ -1202,10 +1112,10 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice47
-                    raise self._BacktrackException(_error)
+                    raise BacktrackException(_error)
                 _call_status = self._command()
                 _result = _call_status.result
                 _error = self._combine_errors(_call_status.error, _error)
@@ -1227,31 +1137,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_command(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def command(self):
         return self._command().result
     def _command(self):
         _key = self._pos
         _status = self._dict_command.get(_key, None)
         if _status is None:
-            _status = self._dict_command[_key] = self._Status_command()
+            _status = self._dict_command[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -1259,7 +1163,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -1286,31 +1190,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_simplecommand(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def simplecommand(self):
         return self._simplecommand().result
     def _simplecommand(self):
         _key = self._pos
         _status = self._dict_simplecommand.get(_key, None)
         if _status is None:
-            _status = self._dict_simplecommand[_key] = self._Status_simplecommand()
+            _status = self._dict_simplecommand[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -1318,7 +1216,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -1333,7 +1231,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice48
                 _choice49 = self._pos
@@ -1342,7 +1240,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice49
                 _choice50 = self._pos
@@ -1351,7 +1249,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice50
                 _choice51 = self._pos
@@ -1360,7 +1258,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice51
                 _choice52 = self._pos
@@ -1369,7 +1267,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice52
                 _choice53 = self._pos
@@ -1378,10 +1276,10 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice53
-                    raise self._BacktrackException(_error)
+                    raise BacktrackException(_error)
                 _call_status = self._negation()
                 _result = _call_status.result
                 _error = self._combine_errors(_call_status.error, _error)
@@ -1403,31 +1301,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_return_(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def return_(self):
         return self._return_().result
     def _return_(self):
         _key = self._pos
         _status = self._dict_return_.get(_key, None)
         if _status is None:
-            _status = self._dict_return_[_key] = self._Status_return_()
+            _status = self._dict_return_[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -1435,7 +1327,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -1451,7 +1343,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     _all54.append(_result)
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice55
                     break
@@ -1468,7 +1360,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     _all56.append(_result)
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice57
                     break
@@ -1491,31 +1383,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_if_(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def if_(self):
         return self._if_().result
     def _if_(self):
         _key = self._pos
         _status = self._dict_if_.get(_key, None)
         if _status is None:
-            _status = self._dict_if_[_key] = self._Status_if_()
+            _status = self._dict_if_[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -1523,7 +1409,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -1550,7 +1436,7 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all59.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice60
                             break
@@ -1564,7 +1450,7 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all61.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice62
                             break
@@ -1581,14 +1467,14 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all63.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice64
                             break
                     _result = _all63
                     _result = (Nonterminal('if', [cmd, condition]))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice58
                 _choice65 = self._pos
@@ -1602,7 +1488,7 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all66.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice67
                             break
@@ -1619,17 +1505,17 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all68.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice69
                             break
                     _result = _all68
                     _result = (Nonterminal('if', [condition]))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice65
-                    raise self._BacktrackException(_error)
+                    raise BacktrackException(_error)
                 _result = self.__chars__('if')
                 _all70 = []
                 while 1:
@@ -1639,7 +1525,7 @@
                         _result = _call_status.result
                         _error = self._combine_errors(_call_status.error, _error)
                         _all70.append(_result)
-                    except self._BacktrackException, _exc:
+                    except BacktrackException, _exc:
                         _error = self._combine_errors(_error, _exc.error)
                         self._pos = _choice71
                         break
@@ -1656,7 +1542,7 @@
                         _result = _call_status.result
                         _error = self._combine_errors(_call_status.error, _error)
                         _all72.append(_result)
-                    except self._BacktrackException, _exc:
+                    except BacktrackException, _exc:
                         _error = self._combine_errors(_error, _exc.error)
                         self._pos = _choice73
                         break
@@ -1680,31 +1566,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_choose(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def choose(self):
         return self._choose().result
     def _choose(self):
         _key = self._pos
         _status = self._dict_choose.get(_key, None)
         if _status is None:
-            _status = self._dict_choose[_key] = self._Status_choose()
+            _status = self._dict_choose[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -1712,7 +1592,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -1728,7 +1608,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     _all74.append(_result)
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice75
                     break
@@ -1745,7 +1625,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     _all76.append(_result)
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice77
                     break
@@ -1759,7 +1639,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     _all78.append(_result)
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice79
                     break
@@ -1776,7 +1656,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     _all80.append(_result)
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice81
                     break
@@ -1803,31 +1683,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_commandchain(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def commandchain(self):
         return self._commandchain().result
     def _commandchain(self):
         _key = self._pos
         _status = self._dict_commandchain.get(_key, None)
         if _status is None:
-            _status = self._dict_commandchain[_key] = self._Status_commandchain()
+            _status = self._dict_commandchain[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -1835,7 +1709,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -1854,7 +1728,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     _all82.append(_result)
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice83
                     break
@@ -1878,31 +1752,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_named_command(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def named_command(self):
         return self._named_command().result
     def _named_command(self):
         _key = self._pos
         _status = self._dict_named_command.get(_key, None)
         if _status is None:
-            _status = self._dict_named_command[_key] = self._Status_named_command()
+            _status = self._dict_named_command[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -1910,7 +1778,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -1929,7 +1797,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     _all84.append(_result)
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice85
                     break
@@ -1943,7 +1811,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     _all86.append(_result)
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice87
                     break
@@ -1970,31 +1838,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_repetition(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def repetition(self):
         return self._repetition().result
     def _repetition(self):
         _key = self._pos
         _status = self._dict_repetition.get(_key, None)
         if _status is None:
-            _status = self._dict_repetition[_key] = self._Status_repetition()
+            _status = self._dict_repetition[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -2002,7 +1864,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -2025,7 +1887,7 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all89.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice90
                             break
@@ -2039,14 +1901,14 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all91.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice92
                             break
                     _result = _all91
                     _result = (Nonterminal('maybe', [what]))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice88
                 _choice93 = self._pos
@@ -2063,7 +1925,7 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all94.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice95
                             break
@@ -2074,17 +1936,17 @@
                         try:
                             _result = self.__chars__('*')
                             break
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice96
                         _choice97 = self._pos
                         try:
                             _result = self.__chars__('+')
                             break
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice97
-                            raise self._BacktrackException(_error)
+                            raise BacktrackException(_error)
                         _result = self.__chars__('+')
                         break
                     repetition = _result
@@ -2096,17 +1958,17 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all98.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice99
                             break
                     _result = _all98
                     _result = (Nonterminal('repetition', [repetition, what]))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice93
-                    raise self._BacktrackException(_error)
+                    raise BacktrackException(_error)
                 _call_status = self._enclosed()
                 _result = _call_status.result
                 _error = self._combine_errors(_call_status.error, _error)
@@ -2119,7 +1981,7 @@
                         _result = _call_status.result
                         _error = self._combine_errors(_call_status.error, _error)
                         _all100.append(_result)
-                    except self._BacktrackException, _exc:
+                    except BacktrackException, _exc:
                         _error = self._combine_errors(_error, _exc.error)
                         self._pos = _choice101
                         break
@@ -2130,17 +1992,17 @@
                     try:
                         _result = self.__chars__('*')
                         break
-                    except self._BacktrackException, _exc:
+                    except BacktrackException, _exc:
                         _error = self._combine_errors(_error, _exc.error)
                         self._pos = _choice102
                     _choice103 = self._pos
                     try:
                         _result = self.__chars__('+')
                         break
-                    except self._BacktrackException, _exc:
+                    except BacktrackException, _exc:
                         _error = self._combine_errors(_error, _exc.error)
                         self._pos = _choice103
-                        raise self._BacktrackException(_error)
+                        raise BacktrackException(_error)
                     _result = self.__chars__('+')
                     break
                 repetition = _result
@@ -2152,7 +2014,7 @@
                         _result = _call_status.result
                         _error = self._combine_errors(_call_status.error, _error)
                         _all104.append(_result)
-                    except self._BacktrackException, _exc:
+                    except BacktrackException, _exc:
                         _error = self._combine_errors(_error, _exc.error)
                         self._pos = _choice105
                         break
@@ -2176,31 +2038,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_negation(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def negation(self):
         return self._negation().result
     def _negation(self):
         _key = self._pos
         _status = self._dict_negation.get(_key, None)
         if _status is None:
-            _status = self._dict_negation[_key] = self._Status_negation()
+            _status = self._dict_negation[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -2208,7 +2064,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -2228,7 +2084,7 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all107.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice108
                             break
@@ -2245,14 +2101,14 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all109.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice110
                             break
                     _result = _all109
                     _result = (Nonterminal('negation', [what]))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice106
                 _choice111 = self._pos
@@ -2261,10 +2117,10 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice111
-                    raise self._BacktrackException(_error)
+                    raise BacktrackException(_error)
                 _call_status = self._enclosed()
                 _result = _call_status.result
                 _error = self._combine_errors(_call_status.error, _error)
@@ -2286,31 +2142,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_enclosed(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def enclosed(self):
         return self._enclosed().result
     def _enclosed(self):
         _key = self._pos
         _status = self._dict_enclosed.get(_key, None)
         if _status is None:
-            _status = self._dict_enclosed[_key] = self._Status_enclosed()
+            _status = self._dict_enclosed[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -2318,7 +2168,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -2338,7 +2188,7 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all113.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice114
                             break
@@ -2355,7 +2205,7 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all115.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice116
                             break
@@ -2369,14 +2219,14 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all117.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice118
                             break
                     _result = _all117
                     _result = (Nonterminal('exclusive', [what]))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice112
                 _choice119 = self._pos
@@ -2390,7 +2240,7 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all120.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice121
                             break
@@ -2407,7 +2257,7 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all122.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice123
                             break
@@ -2421,14 +2271,14 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all124.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice125
                             break
                     _result = _all124
                     _result = (Nonterminal('ignore', [what]))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice119
                 _choice126 = self._pos
@@ -2443,7 +2293,7 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all128.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice129
                             break
@@ -2462,14 +2312,14 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all131.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice132
                             break
                     _result = _all131
                     _result = _before_discard130
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice126
                 _choice133 = self._pos
@@ -2478,10 +2328,10 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice133
-                    raise self._BacktrackException(_error)
+                    raise BacktrackException(_error)
                 _call_status = self._primary()
                 _result = _call_status.result
                 _error = self._combine_errors(_call_status.error, _error)
@@ -2503,31 +2353,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_primary(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def primary(self):
         return self._primary().result
     def _primary(self):
         _key = self._pos
         _status = self._dict_primary.get(_key, None)
         if _status is None:
-            _status = self._dict_primary[_key] = self._Status_primary()
+            _status = self._dict_primary[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -2535,7 +2379,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -2550,7 +2394,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice134
                 _choice135 = self._pos
@@ -2567,14 +2411,14 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all137.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice138
                             break
                     _result = _all137
                     _result = _before_discard136
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice135
                 _choice139 = self._pos
@@ -2591,17 +2435,17 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all141.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice142
                             break
                     _result = _all141
                     _result = _before_discard140
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice139
-                    raise self._BacktrackException(_error)
+                    raise BacktrackException(_error)
                 _call_status = self._QUOTE()
                 _result = _call_status.result
                 _error = self._combine_errors(_call_status.error, _error)
@@ -2614,7 +2458,7 @@
                         _result = _call_status.result
                         _error = self._combine_errors(_call_status.error, _error)
                         _all144.append(_result)
-                    except self._BacktrackException, _exc:
+                    except BacktrackException, _exc:
                         _error = self._combine_errors(_error, _exc.error)
                         self._pos = _choice145
                         break
@@ -2638,31 +2482,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_call(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def call(self):
         return self._call().result
     def _call(self):
         _key = self._pos
         _status = self._dict_call.get(_key, None)
         if _status is None:
-            _status = self._dict_call[_key] = self._Status_call()
+            _status = self._dict_call[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -2670,7 +2508,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -2693,7 +2531,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     _all146.append(_result)
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice147
                     break
@@ -2716,31 +2554,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_arguments(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def arguments(self):
         return self._arguments().result
     def _arguments(self):
         _key = self._pos
         _status = self._dict_arguments.get(_key, None)
         if _status is None:
-            _status = self._dict_arguments[_key] = self._Status_arguments()
+            _status = self._dict_arguments[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -2748,7 +2580,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -2768,7 +2600,7 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all149.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice150
                             break
@@ -2789,7 +2621,7 @@
                                     _result = _call_status.result
                                     _error = self._combine_errors(_call_status.error, _error)
                                     _all154.append(_result)
-                                except self._BacktrackException, _exc:
+                                except BacktrackException, _exc:
                                     _error = self._combine_errors(_error, _exc.error)
                                     self._pos = _choice155
                                     break
@@ -2803,14 +2635,14 @@
                                     _result = _call_status.result
                                     _error = self._combine_errors(_call_status.error, _error)
                                     _all156.append(_result)
-                                except self._BacktrackException, _exc:
+                                except BacktrackException, _exc:
                                     _error = self._combine_errors(_error, _exc.error)
                                     self._pos = _choice157
                                     break
                             _result = _all156
                             _result = _before_discard153
                             _all151.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice152
                             break
@@ -2829,24 +2661,24 @@
                             _result = _call_status.result
                             _error = self._combine_errors(_call_status.error, _error)
                             _all158.append(_result)
-                        except self._BacktrackException, _exc:
+                        except BacktrackException, _exc:
                             _error = self._combine_errors(_error, _exc.error)
                             self._pos = _choice159
                             break
                     _result = _all158
                     _result = (Nonterminal("args", args + [last]))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice148
                 _choice160 = self._pos
                 try:
                     _result = (Nonterminal("args", []))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice160
-                    raise self._BacktrackException(_error)
+                    raise BacktrackException(_error)
                 _result = (Nonterminal("args", []))
                 break
             if _status.status == _status.LEFTRECURSION:
@@ -2866,13 +2698,13 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
+            raise BacktrackException(_error)
     def __init__(self, inputstream):
         self._dict_NAME = {}
         self._dict_SPACE = {}
@@ -2910,7 +2742,7 @@
         _i = _runner.recognize_299149370(self._pos)
         if _runner.last_matched_state == -1:
             self._pos = _choice161
-            raise self._BacktrackException
+            raise BacktrackException
         _upto = _runner.last_matched_index + 1
         _result = self._inputstream[self._pos: _upto]
         self._pos = _upto
@@ -2921,7 +2753,7 @@
         _i = _runner.recognize_1006631623(self._pos)
         if _runner.last_matched_state == -1:
             self._pos = _choice162
-            raise self._BacktrackException
+            raise BacktrackException
         _upto = _runner.last_matched_index + 1
         _result = self._inputstream[self._pos: _upto]
         self._pos = _upto
@@ -2932,7 +2764,7 @@
         _i = _runner.recognize_528667127(self._pos)
         if _runner.last_matched_state == -1:
             self._pos = _choice163
-            raise self._BacktrackException
+            raise BacktrackException
         _upto = _runner.last_matched_index + 1
         _result = self._inputstream[self._pos: _upto]
         self._pos = _upto
@@ -2943,7 +2775,7 @@
         _i = _runner.recognize_291086639(self._pos)
         if _runner.last_matched_state == -1:
             self._pos = _choice164
-            raise self._BacktrackException
+            raise BacktrackException
         _upto = _runner.last_matched_index + 1
         _result = self._inputstream[self._pos: _upto]
         self._pos = _upto
@@ -2954,7 +2786,7 @@
         _i = _runner.recognize_1074651696(self._pos)
         if _runner.last_matched_state == -1:
             self._pos = _choice165
-            raise self._BacktrackException
+            raise BacktrackException
         _upto = _runner.last_matched_index + 1
         _result = self._inputstream[self._pos: _upto]
         self._pos = _upto
@@ -2965,7 +2797,7 @@
         _i = _runner.recognize_1124192327(self._pos)
         if _runner.last_matched_state == -1:
             self._pos = _choice166
-            raise self._BacktrackException
+            raise BacktrackException
         _upto = _runner.last_matched_index + 1
         _result = self._inputstream[self._pos: _upto]
         self._pos = _upto
@@ -2976,7 +2808,7 @@
         _i = _runner.recognize_1979538501(self._pos)
         if _runner.last_matched_state == -1:
             self._pos = _choice167
-            raise self._BacktrackException
+            raise BacktrackException
         _upto = _runner.last_matched_index + 1
         _result = self._inputstream[self._pos: _upto]
         self._pos = _upto

Modified: pypy/dist/pypy/rlib/parsing/regexparse.py
==============================================================================
--- pypy/dist/pypy/rlib/parsing/regexparse.py	(original)
+++ pypy/dist/pypy/rlib/parsing/regexparse.py	Mon Jun 25 19:43:44 2007
@@ -1,3 +1,8 @@
+
+
+
+
+
 import py
 from pypy.rlib.parsing.parsing import PackratParser, Rule
 from pypy.rlib.parsing.tree import Nonterminal
@@ -188,30 +193,31 @@
 
 
 
+
+
+
+
+
 # generated code between this line and its other occurence
 
 
-from pypy.rlib.parsing.pypackrat import PackratParser, _Status
+from pypy.rlib.parsing.pypackrat import PackratParser, Status
+from pypy.rlib.parsing.pypackrat import BacktrackException
 from pypy.rlib.parsing import regex
 import operator
 class Parser(object):
-    class _Status_EOF(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
     def EOF(self):
         return self._EOF().result
     def _EOF(self):
-        _status = self._dict_EOF.get(self._pos, None)
+        _key = self._pos
+        _status = self._dict_EOF.get(_key, None)
         if _status is None:
-            _status = self._dict_EOF[self._pos] = self._Status_EOF()
+            _status = self._dict_EOF[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -219,7 +225,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -230,11 +236,11 @@
             _stored_result1 = _result
             try:
                 _result = self.__any__()
-            except self._BacktrackException:
+            except BacktrackException:
                 self._pos = _choice0
                 _result = _stored_result1
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
             if _status.status == _status.LEFTRECURSION:
                 if _status.result is not None:
                     if _status.pos >= self._pos:
@@ -252,30 +258,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_parse(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def parse(self):
         return self._parse().result
     def _parse(self):
-        _status = self._dict_parse.get(self._pos, None)
+        _key = self._pos
+        _status = self._dict_parse.get(_key, None)
         if _status is None:
-            _status = self._dict_parse[self._pos] = self._Status_parse()
+            _status = self._dict_parse[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -283,7 +284,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -315,30 +316,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_regex(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def regex(self):
         return self._regex().result
     def _regex(self):
-        _status = self._dict_regex.get(self._pos, None)
+        _key = self._pos
+        _status = self._dict_regex.get(_key, None)
         if _status is None:
-            _status = self._dict_regex[self._pos] = self._Status_regex()
+            _status = self._dict_regex[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -346,7 +342,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -368,7 +364,7 @@
                     r2 = _result
                     _result = (r1 | r2)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice3
                 _choice4 = self._pos
@@ -377,10 +373,10 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice4
-                    raise self._BacktrackException(_error)
+                    raise BacktrackException(_error)
                 _call_status = self._concatenation()
                 _result = _call_status.result
                 _error = self._combine_errors(_call_status.error, _error)
@@ -402,30 +398,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_concatenation(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def concatenation(self):
         return self._concatenation().result
     def _concatenation(self):
-        _status = self._dict_concatenation.get(self._pos, None)
+        _key = self._pos
+        _status = self._dict_concatenation.get(_key, None)
         if _status is None:
-            _status = self._dict_concatenation[self._pos] = self._Status_concatenation()
+            _status = self._dict_concatenation[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -433,7 +424,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -452,7 +443,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     _all5.append(_result)
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice6
                     break
@@ -476,30 +467,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_repetition(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def repetition(self):
         return self._repetition().result
     def _repetition(self):
-        _status = self._dict_repetition.get(self._pos, None)
+        _key = self._pos
+        _status = self._dict_repetition.get(_key, None)
         if _status is None:
-            _status = self._dict_repetition[self._pos] = self._Status_repetition()
+            _status = self._dict_repetition[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -507,7 +493,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -525,7 +511,7 @@
                     _result = self.__chars__('*')
                     _result = (r1.kleene())
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice7
                 _choice8 = self._pos
@@ -537,7 +523,7 @@
                     _result = self.__chars__('+')
                     _result = (r1 + r1.kleene())
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice8
                 _choice9 = self._pos
@@ -549,7 +535,7 @@
                     _result = self.__chars__('?')
                     _result = (regex.StringExpression("") | r1)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice9
                 _choice10 = self._pos
@@ -566,7 +552,7 @@
                     _result = self.__chars__('}')
                     _result = (r * n[0] + reduce(operator.or_, [r * i for i in range(n[1] - n[0] + 1)], regex.StringExpression("")))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice10
                 _choice11 = self._pos
@@ -575,10 +561,10 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice11
-                    raise self._BacktrackException(_error)
+                    raise BacktrackException(_error)
                 _call_status = self._primary()
                 _result = _call_status.result
                 _error = self._combine_errors(_call_status.error, _error)
@@ -600,30 +586,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_primary(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def primary(self):
         return self._primary().result
     def _primary(self):
-        _status = self._dict_primary.get(self._pos, None)
+        _key = self._pos
+        _status = self._dict_primary.get(_key, None)
         if _status is None:
-            _status = self._dict_primary[self._pos] = self._Status_primary()
+            _status = self._dict_primary[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -631,7 +612,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -652,7 +633,7 @@
                     _result = self.__chars__(')')
                     _result = _before_discard14
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice12
                 _choice15 = self._pos
@@ -661,7 +642,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice15
                 _choice16 = self._pos
@@ -672,7 +653,7 @@
                     c = _result
                     _result = (regex.StringExpression(c))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice16
                 _choice17 = self._pos
@@ -680,10 +661,10 @@
                     _result = self.__chars__('.')
                     _result = (regex.RangeExpression(chr(0), chr(255)))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice17
-                    raise self._BacktrackException(_error)
+                    raise BacktrackException(_error)
                 _result = self.__chars__('.')
                 _result = (regex.RangeExpression(chr(0), chr(255)))
                 break
@@ -704,30 +685,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_char(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def char(self):
         return self._char().result
     def _char(self):
-        _status = self._dict_char.get(self._pos, None)
+        _key = self._pos
+        _status = self._dict_char.get(_key, None)
         if _status is None:
-            _status = self._dict_char[self._pos] = self._Status_char()
+            _status = self._dict_char[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -735,7 +711,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -752,7 +728,7 @@
                     c = _result
                     _result = (unescape(c))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice18
                 _choice19 = self._pos
@@ -763,10 +739,10 @@
                     c = _result
                     _result = (c)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice19
-                    raise self._BacktrackException(_error)
+                    raise BacktrackException(_error)
                 _call_status = self._CHAR()
                 _result = _call_status.result
                 _error = self._combine_errors(_call_status.error, _error)
@@ -790,30 +766,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_QUOTEDCHAR(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def QUOTEDCHAR(self):
         return self._QUOTEDCHAR().result
     def _QUOTEDCHAR(self):
-        _status = self._dict_QUOTEDCHAR.get(self._pos, None)
+        _key = self._pos
+        _status = self._dict_QUOTEDCHAR.get(_key, None)
         if _status is None:
-            _status = self._dict_QUOTEDCHAR[self._pos] = self._Status_QUOTEDCHAR()
+            _status = self._dict_QUOTEDCHAR[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -821,7 +792,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -846,30 +817,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_CHAR(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def CHAR(self):
         return self._CHAR().result
     def _CHAR(self):
-        _status = self._dict_CHAR.get(self._pos, None)
+        _key = self._pos
+        _status = self._dict_CHAR.get(_key, None)
         if _status is None:
-            _status = self._dict_CHAR[self._pos] = self._Status_CHAR()
+            _status = self._dict_CHAR[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -877,7 +843,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -902,30 +868,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_range(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def range(self):
         return self._range().result
     def _range(self):
-        _status = self._dict_range.get(self._pos, None)
+        _key = self._pos
+        _status = self._dict_range.get(_key, None)
         if _status is None:
-            _status = self._dict_range[self._pos] = self._Status_range()
+            _status = self._dict_range[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -933,7 +894,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -964,30 +925,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_rangeinner(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def rangeinner(self):
         return self._rangeinner().result
     def _rangeinner(self):
-        _status = self._dict_rangeinner.get(self._pos, None)
+        _key = self._pos
+        _status = self._dict_rangeinner.get(_key, None)
         if _status is None:
-            _status = self._dict_rangeinner[self._pos] = self._Status_rangeinner()
+            _status = self._dict_rangeinner[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -995,7 +951,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -1013,7 +969,7 @@
                     s = _result
                     _result = (set([chr(c) for c in range(256)]) - s)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice20
                 _choice21 = self._pos
@@ -1022,10 +978,10 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice21
-                    raise self._BacktrackException(_error)
+                    raise BacktrackException(_error)
                 _call_status = self._subrange()
                 _result = _call_status.result
                 _error = self._combine_errors(_call_status.error, _error)
@@ -1047,30 +1003,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_subrange(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def subrange(self):
         return self._subrange().result
     def _subrange(self):
-        _status = self._dict_subrange.get(self._pos, None)
+        _key = self._pos
+        _status = self._dict_subrange.get(_key, None)
         if _status is None:
-            _status = self._dict_subrange[self._pos] = self._Status_subrange()
+            _status = self._dict_subrange[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -1078,7 +1029,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -1097,7 +1048,7 @@
                     _result = _call_status.result
                     _error = self._combine_errors(_call_status.error, _error)
                     _all22.append(_result)
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice23
                     break
@@ -1121,30 +1072,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_rangeelement(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def rangeelement(self):
         return self._rangeelement().result
     def _rangeelement(self):
-        _status = self._dict_rangeelement.get(self._pos, None)
+        _key = self._pos
+        _status = self._dict_rangeelement.get(_key, None)
         if _status is None:
-            _status = self._dict_rangeelement[self._pos] = self._Status_rangeelement()
+            _status = self._dict_rangeelement[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -1152,7 +1098,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -1174,7 +1120,7 @@
                     c2 = _result
                     _result = (set([chr(i) for i in range(ord(c1), ord(c2) + 1)]))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice24
                 _choice25 = self._pos
@@ -1185,10 +1131,10 @@
                     c = _result
                     _result = (set([c]))
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice25
-                    raise self._BacktrackException(_error)
+                    raise BacktrackException(_error)
                 _call_status = self._char()
                 _result = _call_status.result
                 _error = self._combine_errors(_call_status.error, _error)
@@ -1212,30 +1158,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_numrange(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def numrange(self):
         return self._numrange().result
     def _numrange(self):
-        _status = self._dict_numrange.get(self._pos, None)
+        _key = self._pos
+        _status = self._dict_numrange.get(_key, None)
         if _status is None:
-            _status = self._dict_numrange[self._pos] = self._Status_numrange()
+            _status = self._dict_numrange[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -1243,7 +1184,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -1265,7 +1206,7 @@
                     n2 = _result
                     _result = (n1, n2)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice26
                 _choice27 = self._pos
@@ -1276,10 +1217,10 @@
                     n1 = _result
                     _result = (n1, n1)
                     break
-                except self._BacktrackException, _exc:
+                except BacktrackException, _exc:
                     _error = self._combine_errors(_error, _exc.error)
                     self._pos = _choice27
-                    raise self._BacktrackException(_error)
+                    raise BacktrackException(_error)
                 _call_status = self._NUM()
                 _result = _call_status.result
                 _error = self._combine_errors(_call_status.error, _error)
@@ -1303,30 +1244,25 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
-    class _Status_NUM(_Status):
-        def __init__(self):
-            self.pos = 0
-            self.error = None
-            self.status = self.INPROGRESS
-            self.result = None
+            raise BacktrackException(_error)
     def NUM(self):
         return self._NUM().result
     def _NUM(self):
-        _status = self._dict_NUM.get(self._pos, None)
+        _key = self._pos
+        _status = self._dict_NUM.get(_key, None)
         if _status is None:
-            _status = self._dict_NUM[self._pos] = self._Status_NUM()
+            _status = self._dict_NUM[_key] = Status()
         elif _status.status == _status.NORMAL:
             self._pos = _status.pos
             return _status
         elif _status.status == _status.ERROR:
-            raise self._BacktrackException(_status.error)
+            raise BacktrackException(_status.error)
         elif (_status.status == _status.INPROGRESS or
               _status.status == _status.LEFTRECURSION):
             _status.status = _status.LEFTRECURSION
@@ -1334,7 +1270,7 @@
                 self._pos = _status.pos
                 return _status
             else:
-                raise self._BacktrackException(None)
+                raise BacktrackException(None)
         elif _status.status == _status.SOMESOLUTIONS:
             _status.status = _status.INPROGRESS
         _startingpos = self._pos
@@ -1361,13 +1297,13 @@
             _status.result = _result
             _status.error = _error
             return _status
-        except self._BacktrackException, _exc:
+        except BacktrackException, _exc:
             _status.pos = -1
             _status.result = None
             _error = self._combine_errors(_error, _exc.error)
             _status.error = _error
             _status.status = _status.ERROR
-            raise self._BacktrackException(_error)
+            raise BacktrackException(_error)
     def __init__(self, inputstream):
         self._dict_EOF = {}
         self._dict_parse = {}
@@ -1392,7 +1328,7 @@
         _i = _runner.recognize_1166214427(self._pos)
         if _runner.last_matched_state == -1:
             self._pos = _choice28
-            raise self._BacktrackException
+            raise BacktrackException
         _upto = _runner.last_matched_index + 1
         _result = self._inputstream[self._pos: _upto]
         self._pos = _upto
@@ -1403,7 +1339,7 @@
         _i = _runner.recognize_1323868075(self._pos)
         if _runner.last_matched_state == -1:
             self._pos = _choice29
-            raise self._BacktrackException
+            raise BacktrackException
         _upto = _runner.last_matched_index + 1
         _result = self._inputstream[self._pos: _upto]
         self._pos = _upto
@@ -1414,7 +1350,7 @@
         _i = _runner.recognize_1380912319(self._pos)
         if _runner.last_matched_state == -1:
             self._pos = _choice30
-            raise self._BacktrackException
+            raise BacktrackException
         _upto = _runner.last_matched_index + 1
         _result = self._inputstream[self._pos: _upto]
         self._pos = _upto
@@ -1438,23 +1374,23 @@
                     else:
                         runner.state = 0
                         return ~i
-                    if char == '0':
+                    if '1' <= char <= '9':
                         state = 1
-                    elif '1' <= char <= '9':
+                    elif char == '0':
                         state = 2
                     else:
                         break
-                if state == 2:
+                if state == 1:
                     runner.last_matched_index = i - 1
                     runner.last_matched_state = state
                     if i < len(input):
                         char = input[i]
                         i += 1
                     else:
-                        runner.state = 2
+                        runner.state = 1
                         return i
                     if '0' <= char <= '9':
-                        state = 2
+                        state = 1
                         continue
                     else:
                         break
@@ -1517,7 +1453,7 @@
                         runner.state = 0
                         return ~i
                     if char == '\\':
-                        state = 4
+                        state = 1
                     else:
                         break
                 if state == 1:
@@ -1527,11 +1463,11 @@
                     else:
                         runner.state = 1
                         return ~i
-                    if '0' <= char <= '9':
-                        state = 3
-                    elif 'A' <= char <= 'F':
+                    if char == 'x':
+                        state = 2
+                    elif '\x00' <= char <= 'w':
                         state = 3
-                    elif 'a' <= char <= 'f':
+                    elif 'y' <= char <= '\xff':
                         state = 3
                     else:
                         break
@@ -1545,14 +1481,11 @@
                         runner.state = 2
                         return i
                     if '0' <= char <= '9':
-                        state = 1
-                        continue
+                        state = 4
                     elif 'A' <= char <= 'F':
-                        state = 1
-                        continue
+                        state = 4
                     elif 'a' <= char <= 'f':
-                        state = 1
-                        continue
+                        state = 4
                     else:
                         break
                 if state == 4:
@@ -1562,12 +1495,11 @@
                     else:
                         runner.state = 4
                         return ~i
-                    if char == 'x':
-                        state = 2
-                        continue
-                    elif '\x00' <= char <= 'w':
+                    if '0' <= char <= '9':
                         state = 3
-                    elif 'y' <= char <= '\xff':
+                    elif 'A' <= char <= 'F':
+                        state = 3
+                    elif 'a' <= char <= 'f':
                         state = 3
                     else:
                         break
@@ -1600,7 +1532,12 @@
 
 
 
-if __name__ == '__main__':
+
+
+
+
+
+def test_generate():
     f = py.magic.autopath()
     oldcontent = f.read()
     s = "# GENERATED CODE BETWEEN THIS LINE AND ITS OTHER OCCURENCE\n".lower()
@@ -1618,7 +1555,8 @@
 %s
 %s
 
-from pypy.rlib.parsing.pypackrat import PackratParser, _Status
+from pypy.rlib.parsing.pypackrat import PackratParser, Status
+from pypy.rlib.parsing.pypackrat import BacktrackException
 from pypy.rlib.parsing import regex
 import operator
 %s
@@ -1641,4 +1579,3 @@
 
 
 
-

Modified: pypy/dist/pypy/rlib/parsing/test/test_pypackrat.py
==============================================================================
--- pypy/dist/pypy/rlib/parsing/test/test_pypackrat.py	(original)
+++ pypy/dist/pypy/rlib/parsing/test/test_pypackrat.py	Mon Jun 25 19:43:44 2007
@@ -432,3 +432,168 @@
         expected.sort()
         assert expected == ['a', 'x', 'y']
 
+    def test_prolog(self):
+        py.test.skip()
+        class PrologParser(PackratParser):
+            r"""
+            VAR:
+                `[A-Z_]([a-zA-Z0-9]|_)*|_`;
+
+            NUMBER:
+                `(0|[1-9][0-9]*)(\.[0-9]+)?`;
+
+            IGNORE:
+                `[ \\n\\t]|(/\\*[^\\*]*(\\*[^/][^\\*]*)*\\*/)|(%[^\\n]*)`;
+
+            ATOM:
+                `([a-z]([a-zA-Z0-9]|_)*)|('[^']*')|\[\]|!|\+|\-`;
+
+            EOF:
+                !__any__;
+
+            fact:
+                toplevel_op_expr ['.'];
+
+            simple:
+                VAR
+                [IGNORE*]
+              | sign = ('+' | '-')
+                IGNORE*
+                num = NUMBER
+                IGNORE*
+                return {XXX}
+              | ATOM
+                [IGNORE*]
+              | '('
+                IGNORE*
+                expr = toplevel_op_expr
+                ')'
+                IGNORE*
+                return {expr};
+              | listexpr;
+
+            listexpr:
+                '['
+                IGNORE*
+                body = listbody
+                ']'
+                return {body};
+            
+            listbody:
+                head = toplevel_op_expr            
+                '|'
+                tail = toplevel_op_expr
+                return {XXX}
+              | list = toplevel_op_expr
+                return {XXX};
+
+            toplevel_op_expr:
+                choose priority in {range(len(self.ops))}
+                expr(priority);
+
+            expr(priority):
+                if {priority < len(self.ops)}
+                choose patternindex in {range(len(self.ops[priority]))}
+                expr_pattern({priority}, {patternindex})
+              | simple;
+
+            expr_pattern(priority, patternindex):
+                choose operator in {self.ops[priority][patternindex]}
+                args = pattern({priority}, {self.pattern[patternindex]},
+                               {operator})
+                return {Term(operator, args)};
+
+            pattern(priority, pattern, operator):
+                loop({priority}, {pattern}, {operator}, {0});
+                
+            loop(priority, pattern, operator, index):
+                (
+                    if {pattern[index] == 'f'}
+                    args1 = op({operator})
+                  | if {pattern[index] == 'x'}
+                    args1 = lower({priority})
+                  | if {pattern[index] == 'y'}
+                    args1 = same({priority})
+                )
+                args2 = loop(
+            
+            op(operator):
+                __chars__({self.ops[priority].xfx[pos]})
+                return {[]}
+                
+            xfx(priority, pos):
+                expr1 = expr({priority + 1})
+                IGNORE*
+                op = __chars__({self.ops[priority].xfx[pos]})
+                IGNORE*
+                expr2 = expr({priority + 1})
+                return {Term(op, [expr1, expr2])}
+              | do !!__any__ if {len(self.ops[priority].xfx) < pos - 1}
+                xfx({priority}, {pos + 1});
+
+            xfy(priority, pos):
+                expr1 = expr({priority + 1})
+                IGNORE*
+                op = __chars__({self.ops[priority].xfx[pos]})
+                IGNORE*
+                expr2 = expr({priority})
+                return {Term(op, [expr1, expr2])}
+              | do !!__any__ if {len(self.ops[priority].xfx) < pos - 1}
+                xfx({priority}, {pos + 1});
+
+            yfx(priority, pos):
+                expr1 = expr({priority + 1})
+                IGNORE*
+                op = __chars__({self.ops[priority].xfx[pos]})
+                IGNORE*
+                expr2 = expr({priority})
+                return {Term(op, [expr1, expr2])}
+              | do !!__any__ if {len(self.ops[priority].xfx) < pos - 1}
+                xfx({priority}, {pos + 1});
+
+            yfy(priority, pos):
+                expr1 = expr({priority})
+                IGNORE*
+                op = __chars__({self.ops[priority].xfx[pos]})
+                IGNORE*
+                expr2 = expr({priority})
+                return {Term(op, [expr1, expr2])}
+              | do !!__any__ if {len(self.ops[priority].xfx) < pos - 1}
+                xfx({priority}, {pos + 1});
+
+            fx(priority, pos):
+                op = __chars__({self.ops[priority].fx[pos]})
+                IGNORE*
+                ex = expr({priority + 1})
+                return {Term(op, [ex])}
+              | do !!__any__ if {len(self.ops[priority].xfx) < pos - 1}
+                xfx({priority}, {pos + 1});
+
+            fy(priority, pos):
+                op = __chars__({self.ops[priority].xfx[pos]})
+                IGNORE*
+                ex = expr({priority})
+                return {Term(op, [ex])}
+              | do !!__any__ if {len(self.ops[priority].xfx) < pos - 1}
+                xfx({priority}, {pos + 1});
+
+            xf(priority, pos):
+                op = __chars__({self.ops[priority].xfx[pos]})
+                IGNORE*
+                expr2 = expr({priority + 1})
+                return {Term(op, [expr1, expr2])}
+              | do !!__any__ if {len(self.ops[priority].xfx) < pos - 1}
+                xfx({priority}, {pos + 1});
+
+            yf(priority, pos):
+                ex = expr({priority + 1})
+                IGNORE*
+                op = __chars__({self.ops[priority].xfx[pos]})
+                IGNORE*
+                expr2 = expr({priority + 1})
+                return {Term(op, [expr1, expr2])}
+              | do !!__any__ if {len(self.ops[priority].xfx) < pos - 1}
+                xfx({priority}, {pos + 1});
+
+
+     """

Modified: pypy/dist/pypy/rlib/parsing/test/test_translate.py
==============================================================================
--- pypy/dist/pypy/rlib/parsing/test/test_translate.py	(original)
+++ pypy/dist/pypy/rlib/parsing/test/test_translate.py	Mon Jun 25 19:43:44 2007
@@ -4,6 +4,7 @@
 from pypy.rlib.parsing.regex import *
 from pypy.rlib.parsing.parsing import *
 from pypy.rlib.parsing import deterministic
+from pypy.rlib.parsing.pypackrat import BacktrackException, Status
 
 
 class TestTranslateLexer(object):
@@ -120,3 +121,39 @@
     func = t.compile_c()
     res2 = func()
     assert res1 == res2
+
+def test_translate_pypackrat():
+    from pypy.rlib.parsing.pypackrat import PackratParser
+    class parser(PackratParser):
+        """
+        expr:
+            additive;
+        additive:
+            a = additive
+            '-'
+            b = multitive
+            return {'(%s - %s)' % (a, b)}
+          | multitive;
+        multitive:
+            a = multitive
+            '*'
+            b = simple
+            return {'(%s * %s)' % (a, b)}
+          | simple;
+        simple:
+            ('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9');
+        """
+    print parser._code
+    def parse(s):
+        p = parser(s)
+        return p.expr()
+    res = parse("5-5-5")
+    assert res == '((5 - 5) - 5)'
+    t = Translation(parse)
+    t.annotate([str])
+    t.rtype()
+    t.backendopt()
+    func = t.compile_c()
+    res = func("5-5-5")
+    assert res == '((5 - 5) - 5)'
+



More information about the Pypy-commit mailing list