This repo contains code to mirror other repos. It also contains the code that is getting mirrored.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

80 řádky
2.2 KiB

  1. # -*- coding: utf-8 -*-
  2. from typing import (
  3. TypeVar, Type, List, Dict, IO, Iterator, Callable, Union, Optional,
  4. Literal, Protocol, Tuple,
  5. )
  6. from .visitors import Transformer
  7. from .lexer import Token, Lexer, TerminalDef
  8. from .tree import Tree
  9. _T = TypeVar('_T')
  10. class PostLex(Protocol):
  11. def process(self, stream: Iterator[Token]) -> Iterator[Token]:
  12. ...
  13. class LarkOptions:
  14. start: List[str]
  15. parser: str
  16. lexer: str
  17. transformer: Optional[Transformer]
  18. postlex: Optional[PostLex]
  19. ambiguity: str
  20. regex: bool
  21. debug: bool
  22. keep_all_tokens: bool
  23. propagate_positions: bool
  24. maybe_placeholders: bool
  25. lexer_callbacks: Dict[str, Callable[[Token], Token]]
  26. cache: Union[bool, str]
  27. g_regex_flags: int
  28. use_bytes: bool
  29. import_sources: List[Union[str, Callable[[str, str], str]]]
  30. class Lark:
  31. source: str
  32. grammar_source: str
  33. options: LarkOptions
  34. lexer: Lexer
  35. terminals: List[TerminalDef]
  36. def __init__(
  37. self,
  38. grammar: Union[str, IO[str]],
  39. *,
  40. start: Union[None, str, List[str]] = "start",
  41. parser: Literal["earley", "lalr", "cyk"] = "auto",
  42. lexer: Union[Literal["auto", "standard", "contextual", "dynamic", "dynamic_complete"], Lexer] = "auto",
  43. transformer: Optional[Transformer] = None,
  44. postlex: Optional[PostLex] = None,
  45. ambiguity: Literal["explicit", "resolve"] = "resolve",
  46. regex: bool = False,
  47. debug: bool = False,
  48. keep_all_tokens: bool = False,
  49. propagate_positions: bool = False,
  50. maybe_placeholders: bool = False,
  51. lexer_callbacks: Optional[Dict[str, Callable[[Token], Token]]] = None,
  52. cache: Union[bool, str] = False,
  53. g_regex_flags: int = ...,
  54. use_bytes: bool = False,
  55. import_sources: List[Union[str, Callable[[List[str], str], Tuple[str, str]]]] = ...,
  56. ):
  57. ...
  58. def parse(self, text: str, start: Optional[str] = None) -> Tree:
  59. ...
  60. @classmethod
  61. def open(cls: Type[_T], grammar_filename: str, rel_to: Optional[str] = None, **options) -> _T:
  62. ...
  63. def lex(self, text: str) -> Iterator[Token]:
  64. ...
  65. def get_terminal(self, name: str) -> TerminalDef:
  66. ...