Commits

Anonymous committed e759e45

fixed handling of parse errors in grammar definitions

  • Participants
  • Parent commits f6c48b1

Comments (0)

Files changed (2)

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

File 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):
         """