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.

54 lines
1.6 KiB

  1. # -*- coding: utf-8 -*-
  2. from typing import (
  3. Type, List, Dict, IO, Iterator, Callable, Union, Optional,
  4. Literal, Protocol, Tuple, Iterable,
  5. )
  6. from .visitors import Transformer
  7. from .lexer import Token, Lexer, TerminalDef
  8. from .load_grammar import Grammar, PackageResource
  9. class PostLex(Protocol):
  10. def process(self, stream: Iterator[Token]) -> Iterator[Token]:
  11. ...
  12. always_accept: Iterable[str]
  13. class LarkOptions:
  14. ...
  15. class Lark:
  16. source_path: str
  17. source_grammar: str
  18. grammar: Grammar
  19. options: LarkOptions
  20. lexer: Lexer
  21. terminals: List[TerminalDef]
  22. def __init__(
  23. self,
  24. grammar: Union[Grammar, str, IO[str]],
  25. *,
  26. start: Union[None, str, List[str]] = "start",
  27. parser: Literal["earley", "lalr", "cyk", "auto"] = "auto",
  28. lexer: Union[Literal["auto", "standard", "contextual", "dynamic", "dynamic_complete"], Type[Lexer]] = "auto",
  29. transformer: Optional[Transformer] = None,
  30. postlex: Optional[PostLex] = None,
  31. ambiguity: Literal["explicit", "resolve"] = "resolve",
  32. regex: bool = False,
  33. debug: bool = False,
  34. keep_all_tokens: bool = False,
  35. propagate_positions: Union[bool, str] = False,
  36. maybe_placeholders: bool = False,
  37. lexer_callbacks: Optional[Dict[str, Callable[[Token], Token]]] = None,
  38. cache: Union[bool, str] = False,
  39. g_regex_flags: int = ...,
  40. use_bytes: bool = False,
  41. import_paths: List[Union[str, Callable[[Union[None, str, PackageResource], str], Tuple[str, str]]]] = ...,
  42. source_path: Optional[str]=None,
  43. ):
  44. ...