| #======================================================================= |
| # Python Lexical Analyser |
| #======================================================================= |
| class PlexError(Exception): |
| class PlexTypeError(PlexError, TypeError): |
| class PlexValueError(PlexError, ValueError): |
| class InvalidRegex(PlexError): |
| class InvalidToken(PlexError): |
| def __init__(self, token_number, message): |
| PlexError.__init__(self, "Token number %d: %s" % (token_number, message)) |
| class InvalidScanner(PlexError): |
| class AmbiguousAction(PlexError): |
| message = "Two tokens with different actions can match the same string" |
| class UnrecognizedInput(PlexError): |
| def __init__(self, scanner, state_name): |
| self.position = scanner.get_position() |
| self.state_name = state_name |
| return ("'%s', line %d, char %d: Token not recognised in state %s" |
| % (self.position + (repr(self.state_name),))) |