Anonymous avatar Anonymous committed e759e45

fixed handling of parse errors in grammar definitions

Comments (0)

Files changed (2)

pymeta/bootbase.py

-from .runtime import OMetaBase, _MaybeParseError, EOFError
+from .runtime import OMetaBase, _MaybeParseError, ParseError, EOFError
 
 class BootBaseTraits(object):
     def parseGrammar(self, name, builder, *args):
         except EOFError:
             pass
         else:
-            raise _MaybeParseError(self.input.position, err, "Grammar parse failed.\n%s" % self.currentError.formatError(''.join(self.input.data)))
+            raise ParseError("Grammar parse failed.\n%s" % self.currentError.formatError(''.join(self.input.data)))
         return res
 
     def applicationArgs(self):

pymeta/runtime.py

         if self.error is None:
             return ''
         if len(self.error) == 1:
-            if self.error[0][2] == None:
+            if self.error[0][0] == 'message':
+                return self.error[0][1]
+            elif self.error[0][2] == None:
                 return 'expected a ' + self.error[0][1]
             else:
                 return 'expected the %s %s' % (self.error[0][1], self.error[0][2])
             raise ParseError(parser.currentError.formatError(source))
 
     def considerError(self, error):
+        if isinstance(error, _MaybeParseError):
+            error = error.args
         if error and error[1] and error[0] > self.currentError[0]:
-            self.currentError = error
+            self.currentError = _MaybeParseError(*error)
 
     def superApply(self, ruleName, *args):
         """
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.