[pypy-svn] r16446 - pypy/dist/pypy/interpreter/pyparser
ludal at codespeak.net
ludal at codespeak.net
Thu Aug 25 11:06:34 CEST 2005
Author: ludal
Date: Thu Aug 25 11:06:33 2005
New Revision: 16446
Modified:
pypy/dist/pypy/interpreter/pyparser/error.py
Log:
added SyntaxError class because we raise it and it needs to be annotatable
Modified: pypy/dist/pypy/interpreter/pyparser/error.py
==============================================================================
--- pypy/dist/pypy/interpreter/pyparser/error.py (original)
+++ pypy/dist/pypy/interpreter/pyparser/error.py Thu Aug 25 11:06:33 2005
@@ -22,3 +22,28 @@
self.lineno,
self.offset,
self.text)
+
+
+class SyntaxError(Exception):
+ """Base class for exceptions raised by the parser."""
+
+ def __init__(self, msg, lineno=0, offset=0, text=0):
+ self.msg = msg
+ self.lineno = lineno
+ self.offset = offset
+ self.text = text
+ self.filename = ""
+ self.print_file_and_line = False
+
+ def wrap_info(self, space, filename):
+ return space.newtuple([space.wrap(self.msg),
+ space.newtuple([space.wrap(filename),
+ space.wrap(self.lineno),
+ space.wrap(self.offset),
+ space.wrap(self.text)])])
+
+ def __str__(self):
+ return "%s at pos (%d, %d) in %r" % (self.__class__.__name__,
+ self.lineno,
+ self.offset,
+ self.text)
More information about the Pypy-commit
mailing list