diff options
| author | Devtools Arcadia <[email protected]> | 2022-02-07 18:08:42 +0300 |
|---|---|---|
| committer | Devtools Arcadia <[email protected]> | 2022-02-07 18:08:42 +0300 |
| commit | 1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch) | |
| tree | e26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/tools/cython/Cython/Plex/Errors.py | |
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/tools/cython/Cython/Plex/Errors.py')
| -rw-r--r-- | contrib/tools/cython/Cython/Plex/Errors.py | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/contrib/tools/cython/Cython/Plex/Errors.py b/contrib/tools/cython/Cython/Plex/Errors.py new file mode 100644 index 00000000000..f460100d77e --- /dev/null +++ b/contrib/tools/cython/Cython/Plex/Errors.py @@ -0,0 +1,54 @@ +#======================================================================= +# +# Python Lexical Analyser +# +# Exception classes +# +#======================================================================= + + +class PlexError(Exception): + message = "" + + +class PlexTypeError(PlexError, TypeError): + pass + + +class PlexValueError(PlexError, ValueError): + pass + + +class InvalidRegex(PlexError): + pass + + +class InvalidToken(PlexError): + def __init__(self, token_number, message): + PlexError.__init__(self, "Token number %d: %s" % (token_number, message)) + + +class InvalidScanner(PlexError): + pass + + +class AmbiguousAction(PlexError): + message = "Two tokens with different actions can match the same string" + + def __init__(self): + pass + + +class UnrecognizedInput(PlexError): + scanner = None + position = None + state_name = None + + def __init__(self, scanner, state_name): + self.scanner = scanner + self.position = scanner.get_position() + self.state_name = state_name + + def __str__(self): + return ("'%s', line %d, char %d: Token not recognised in state %r" % ( + self.position + (self.state_name,))) |
