1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/pyparser/error.py Sun Jan 08 20:20:39 2017 +0100
1.3 @@ -0,0 +1,40 @@
1.4 +
1.5 +class SyntaxError(Exception):
1.6 + """Base class for exceptions raised by the parser."""
1.7 +
1.8 + def __init__(self, msg, lineno=0, offset=0, text=None, filename=None,
1.9 + lastlineno=0):
1.10 + self.msg = msg
1.11 + self.lineno = lineno
1.12 + self.offset = offset
1.13 + self.text = text
1.14 + self.filename = filename
1.15 + self.lastlineno = lastlineno
1.16 +
1.17 + def __str__(self):
1.18 + return "%s at pos (%d, %d) in %r" % (self.__class__.__name__,
1.19 + self.lineno,
1.20 + self.offset,
1.21 + self.text)
1.22 +
1.23 +class IndentationError(SyntaxError):
1.24 + pass
1.25 +
1.26 +class ASTError(Exception):
1.27 + def __init__(self, msg, ast_node ):
1.28 + self.msg = msg
1.29 + self.ast_node = ast_node
1.30 +
1.31 +
1.32 +class TokenError(SyntaxError):
1.33 +
1.34 + def __init__(self, msg, line, lineno, column, tokens, lastlineno=0):
1.35 + SyntaxError.__init__(self, msg, lineno, column, line,
1.36 + lastlineno=lastlineno)
1.37 + self.tokens = tokens
1.38 +
1.39 +class TokenIndentationError(IndentationError):
1.40 +
1.41 + def __init__(self, msg, line, lineno, column, tokens):
1.42 + SyntaxError.__init__(self, msg, lineno, column, line)
1.43 + self.tokens = tokens