1
#=======================================================================
3
# Python Lexical Analyser
7
#=======================================================================
11
class PlexError(exceptions.Exception):
14
class PlexTypeError(PlexError, TypeError):
17
class PlexValueError(PlexError, ValueError):
20
class InvalidRegex(PlexError):
23
class InvalidToken(PlexError):
25
def __init__(self, token_number, message):
26
PlexError.__init__(self, "Token number %d: %s" % (token_number, message))
28
class InvalidScanner(PlexError):
31
class AmbiguousAction(PlexError):
32
message = "Two tokens with different actions can match the same string"
37
class UnrecognizedInput(PlexError):
42
def __init__(self, scanner, state_name):
43
self.scanner = scanner
44
self.position = scanner.position()
45
self.state_name = state_name
48
return ("'%s', line %d, char %d: Token not recognised in state %s"
49
% (self.position + (repr(self.state_name),)))