Module scrolls.ast.ast_errors
Errors related to language parsing.
Expand source code
"""
Errors related to language parsing.
"""
from .. import errors as base_errors
__all__ = (
"StreamError",
"StreamEofError",
"TokenizeError",
"TokenizeEofError",
"ParseError",
"ParseEofError",
"ParseExpectError"
)
class StreamError(base_errors.ScrollError):
pass
class StreamEofError(StreamError):
pass
class TokenizeError(base_errors.PositionalError):
"""Generic error raised while lexing/tokenizing a script."""
pass
class TokenizeEofError(TokenizeError):
"""Raised when the lexer/tokenizer hits an unexpected EOF (end of script)."""
pass
class ParseError(base_errors.PositionalError):
"""Generic error raised during the parsing stage."""
def __init__(
self,
line: int,
pos: int,
string: str,
message: str
):
super().__init__(
line,
pos,
string,
message
)
# IMPLEMENTATION DETAIL
# Sets whether this parse error is fatal or not. Defaults to `False`.
# If `True`, a `ParseError` will cause all parsing to stop immediately and
# raise the error. If `fatal` is `False`, a parse function may try alternative
# parsing. Internally, `fatal = False` is used by `parse_choice` to determine
# which parsing function to choose. See `scrolls.ast` for more details.
self.fatal = False
class ParseEofError(ParseError):
"""Raised when an EOF is encountered too early while parsing a script."""
pass
class ParseExpectError(ParseError):
"""Raised when an unexpected token is encountered during parsing."""
pass
Classes
class ParseEofError (line: int, pos: int, string: str, message: str)
-
Raised when an EOF is encountered too early while parsing a script.
Expand source code
class ParseEofError(ParseError): """Raised when an EOF is encountered too early while parsing a script.""" pass
Ancestors
- ParseError
- PositionalError
- ScrollError
- builtins.Exception
- builtins.BaseException
Inherited members
class ParseError (line: int, pos: int, string: str, message: str)
-
Generic error raised during the parsing stage.
Expand source code
class ParseError(base_errors.PositionalError): """Generic error raised during the parsing stage.""" def __init__( self, line: int, pos: int, string: str, message: str ): super().__init__( line, pos, string, message ) # IMPLEMENTATION DETAIL # Sets whether this parse error is fatal or not. Defaults to `False`. # If `True`, a `ParseError` will cause all parsing to stop immediately and # raise the error. If `fatal` is `False`, a parse function may try alternative # parsing. Internally, `fatal = False` is used by `parse_choice` to determine # which parsing function to choose. See `scrolls.ast` for more details. self.fatal = False
Ancestors
- PositionalError
- ScrollError
- builtins.Exception
- builtins.BaseException
Subclasses
Inherited members
class ParseExpectError (line: int, pos: int, string: str, message: str)
-
Raised when an unexpected token is encountered during parsing.
Expand source code
class ParseExpectError(ParseError): """Raised when an unexpected token is encountered during parsing.""" pass
Ancestors
- ParseError
- PositionalError
- ScrollError
- builtins.Exception
- builtins.BaseException
Inherited members
class StreamEofError (*args, **kwargs)
-
Base class for all Scrolls-related errors.
Expand source code
class StreamEofError(StreamError): pass
Ancestors
- StreamError
- ScrollError
- builtins.Exception
- builtins.BaseException
class StreamError (*args, **kwargs)
-
Base class for all Scrolls-related errors.
Expand source code
class StreamError(base_errors.ScrollError): pass
Ancestors
- ScrollError
- builtins.Exception
- builtins.BaseException
Subclasses
class TokenizeEofError (line: int, pos: int, string: str, message: str)
-
Raised when the lexer/tokenizer hits an unexpected EOF (end of script).
Expand source code
class TokenizeEofError(TokenizeError): """Raised when the lexer/tokenizer hits an unexpected EOF (end of script).""" pass
Ancestors
- TokenizeError
- PositionalError
- ScrollError
- builtins.Exception
- builtins.BaseException
Inherited members
class TokenizeError (line: int, pos: int, string: str, message: str)
-
Generic error raised while lexing/tokenizing a script.
Expand source code
class TokenizeError(base_errors.PositionalError): """Generic error raised while lexing/tokenizing a script.""" pass
Ancestors
- PositionalError
- ScrollError
- builtins.Exception
- builtins.BaseException
Subclasses
Inherited members