This repo contains code to mirror other repos. It also contains the code that is getting mirrored.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.1 KiB

  1. # -*- coding: utf-8 -*-
  2. from typing import Dict, Iterable, Callable, Union, TypeVar, Tuple, Any, List, Set
  3. from .tree import Tree
  4. from .lexer import Token
  5. class LarkError(Exception):
  6. pass
  7. class GrammarError(LarkError):
  8. pass
  9. class ParseError(LarkError):
  10. pass
  11. class LexError(LarkError):
  12. pass
  13. T = TypeVar('T')
  14. class UnexpectedInput(LarkError):
  15. line: int
  16. column: int
  17. pos_in_stream: int
  18. state: Any
  19. def get_context(self, text: str, span: int = ...):
  20. ...
  21. def match_examples(
  22. self,
  23. parse_fn: Callable[[str], Tree],
  24. examples: Union[Dict[T, Iterable[str]], Iterable[Tuple[T, Iterable[str]]]],
  25. token_type_match_fallback: bool = False,
  26. print_debug_info: bool = True
  27. ) -> T:
  28. ...
  29. class UnexpectedToken(ParseError, UnexpectedInput):
  30. expected: List[str]
  31. considered_rules: Set[str]
  32. puppet: Any
  33. accepts: List[str]
  34. class UnexpectedCharacters(LexError, UnexpectedInput):
  35. allowed: Set[str]
  36. considered_tokens: Set[Any]
  37. class VisitError(LarkError):
  38. obj: Union[Tree, Token]
  39. orig_exc: Exception