-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror.py
More file actions
45 lines (34 loc) · 1.37 KB
/
Copy patherror.py
File metadata and controls
45 lines (34 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class SyntaxError(Exception):
"""Base class for exceptions raised by the parser."""
def __init__(self, msg, lineno=0, offset=0, text=None, filename=None,
lastlineno=0):
self.msg = msg
self.lineno = lineno
# NB: offset is a 1-based index!
self.offset = offset
self.text = text
self.filename = filename
self.lastlineno = lastlineno
def __str__(self):
return "%s at pos (%d, %d) in %r" % (self.__class__.__name__,
self.lineno,
self.offset,
self.text)
class IndentationError(SyntaxError):
pass
class ASTError(Exception):
def __init__(self, msg, ast_node ):
self.msg = msg
self.ast_node = ast_node
class TokenError(SyntaxError):
def __init__(self, msg, line, lineno, column, tokens, lastlineno=0):
SyntaxError.__init__(self, msg, lineno, column, line,
lastlineno=lastlineno)
self.tokens = tokens
class TokenIndentationError(IndentationError):
def __init__(self, msg, line, lineno, column, tokens):
SyntaxError.__init__(self, msg, lineno, column, line)
self.tokens = tokens
class MultipleSyntaxErrors(Exception):
def __init__(self, errors):
self.errors = errors