2020-02-13 14:34:05 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2020-03-17 09:35:50 +00:00
|
|
|
from typing import Dict, Iterable, Callable, Union
|
2020-02-13 14:34:05 +00:00
|
|
|
from .tree import Tree
|
2020-03-17 09:35:50 +00:00
|
|
|
from .lexer import Token
|
2020-02-13 14:34:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
class LarkError(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class GrammarError(LarkError):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class ParseError(LarkError):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class LexError(LarkError):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class UnexpectedInput(LarkError):
|
|
|
|
pos_in_stream: int
|
|
|
|
|
2020-02-16 06:09:53 +00:00
|
|
|
def get_context(self, text: str, span: int = ...):
|
2020-02-13 14:34:05 +00:00
|
|
|
...
|
|
|
|
|
|
|
|
def match_examples(
|
|
|
|
self,
|
|
|
|
parse_fn: Callable[[str], Tree],
|
|
|
|
examples: Dict[str, Iterable[str]]
|
|
|
|
):
|
|
|
|
...
|
|
|
|
|
|
|
|
|
|
|
|
class UnexpectedToken(ParseError, UnexpectedInput):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class UnexpectedCharacters(LexError, UnexpectedInput):
|
2020-02-16 06:09:53 +00:00
|
|
|
line: int
|
|
|
|
column: int
|
|
|
|
|
|
|
|
|
|
|
|
class VisitError(LarkError):
|
2020-03-17 09:35:50 +00:00
|
|
|
obj: Union[Tree, Token]
|
|
|
|
orig_exc: Exception
|