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.2 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. from .parsers.lalr_puppet import ParserPuppet
  6. class LarkError(Exception):
  7. pass
  8. class GrammarError(LarkError):
  9. pass
  10. class ParseError(LarkError):
  11. pass
  12. class LexError(LarkError):
  13. pass
  14. T = TypeVar('T')
  15. class UnexpectedInput(LarkError):
  16. line: int
  17. column: int
  18. pos_in_stream: int
  19. state: Any
  20. def get_context(self, text: str, span: int = ...):
  21. ...
  22. def match_examples(
  23. self,
  24. parse_fn: Callable[[str], Tree],
  25. examples: Union[Dict[T, Iterable[str]], Iterable[Tuple[T, Iterable[str]]]],
  26. token_type_match_fallback: bool = False,
  27. use_accepts: bool = False,
  28. ) -> T:
  29. ...
  30. class UnexpectedToken(ParseError, UnexpectedInput):
  31. expected: Set[str]
  32. considered_rules: Set[str]
  33. puppet: ParserPuppet
  34. accepts: Set[str]
  35. class UnexpectedCharacters(LexError, UnexpectedInput):
  36. allowed: Set[str]
  37. considered_tokens: Set[Any]
  38. class VisitError(LarkError):
  39. obj: Union[Tree, Token]
  40. orig_exc: Exception