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.

109 regels
1.9 KiB

  1. # -*- coding: utf-8 -*-
  2. from typing import TypeVar, Tuple, List, Callable, Generic, Type, Union
  3. from abc import ABC
  4. from .tree import Tree
  5. _T = TypeVar('_T')
  6. _R = TypeVar('_R')
  7. _FUNC = Callable[..., _T]
  8. _DECORATED = Union[_FUNC, type]
  9. class Transformer(ABC, Generic[_T]):
  10. def __init__(self, visit_tokens: bool = True) -> None:
  11. ...
  12. def transform(self, tree: Tree) -> _T:
  13. ...
  14. def __mul__(self, other: Transformer[_T]) -> TransformerChain[_T]:
  15. ...
  16. class TransformerChain(Generic[_T]):
  17. transformers: Tuple[Transformer[_T], ...]
  18. def __init__(self, *transformers: Transformer[_T]) -> None:
  19. ...
  20. def transform(self, tree: Tree) -> _T:
  21. ...
  22. def __mul__(self, other: Transformer[_T]) -> TransformerChain[_T]:
  23. ...
  24. class Transformer_InPlace(Transformer):
  25. pass
  26. class Transformer_NonRecursive(Transformer):
  27. pass
  28. class Transformer_InPlaceRecursive(Transformer):
  29. pass
  30. class VisitorBase:
  31. pass
  32. class Visitor(VisitorBase, ABC, Generic[_T]):
  33. def visit(self, tree: Tree) -> Tree:
  34. ...
  35. def visit_topdown(self, tree: Tree) -> Tree:
  36. ...
  37. class Visitor_Recursive(VisitorBase):
  38. def visit(self, tree: Tree) -> Tree:
  39. ...
  40. def visit_topdown(self, tree: Tree) -> Tree:
  41. ...
  42. class Interpreter(ABC, Generic[_T]):
  43. def visit(self, tree: Tree) -> _T:
  44. ...
  45. def visit_children(self, tree: Tree) -> List[_T]:
  46. ...
  47. _InterMethod = Callable[[Type[Interpreter], _T], _R]
  48. def v_args(
  49. inline: bool = False,
  50. meta: bool = False,
  51. tree: bool = False,
  52. wrapper: Callable = None
  53. ) -> Callable[[_DECORATED], _DECORATED]:
  54. ...
  55. def visit_children_decor(func: _InterMethod) -> _InterMethod:
  56. ...
  57. class Discard(Exception):
  58. pass
  59. # Deprecated
  60. class InlineTransformer:
  61. pass
  62. # Deprecated
  63. def inline_args(obj: _FUNC) -> _FUNC:
  64. ...