1 from lib2to3.pgen2.grammar import Grammar
2 from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple, TypeVar, Union
5 _NL = Union[Node, Leaf]
6 _Context = Tuple[str, int, int]
7 _Results = Dict[str, _NL]
8 _RawNode = Tuple[int, str, _Context, Optional[List[_NL]]]
9 _Convert = Callable[[Grammar, _RawNode], Any]
13 def type_repr(type_num: int) -> str: ...
22 def __eq__(self, other: Any) -> bool: ...
23 def _eq(self: _P, other: _P) -> bool: ...
24 def clone(self: _P) -> _P: ...
25 def post_order(self) -> Iterator[_NL]: ...
26 def pre_order(self) -> Iterator[_NL]: ...
27 def replace(self, new: _NL | list[_NL]) -> None: ...
28 def get_lineno(self) -> int: ...
29 def changed(self) -> None: ...
30 def remove(self) -> int | None: ...
32 def next_sibling(self) -> _NL | None: ...
34 def prev_sibling(self) -> _NL | None: ...
35 def leaves(self) -> Iterator[Leaf]: ...
36 def depth(self) -> int: ...
37 def get_suffix(self) -> str: ...
40 fixers_applied: list[Any]
45 context: Any | None = ...,
46 prefix: str | None = ...,
47 fixers_applied: list[Any] | None = ...,
49 def set_child(self, i: int, child: _NL) -> None: ...
50 def insert_child(self, i: int, child: _NL) -> None: ...
51 def append_child(self, child: _NL) -> None: ...
57 fixers_applied: list[Any]
59 self, type: int, value: str, context: _Context | None = ..., prefix: str | None = ..., fixers_applied: list[Any] = ...
62 def convert(gr: Grammar, raw_node: _RawNode) -> _NL: ...
68 def optimize(self) -> BasePattern: ... # sic, subclasses are free to optimize themselves into different patterns
69 def match(self, node: _NL, results: _Results | None = ...) -> bool: ...
70 def match_seq(self, nodes: list[_NL], results: _Results | None = ...) -> bool: ...
71 def generate_matches(self, nodes: list[_NL]) -> Iterator[tuple[int, _Results]]: ...
73 class LeafPattern(BasePattern):
74 def __init__(self, type: int | None = ..., content: str | None = ..., name: str | None = ...) -> None: ...
76 class NodePattern(BasePattern):
78 def __init__(self, type: int | None = ..., content: str | None = ..., name: str | None = ...) -> None: ...
80 class WildcardPattern(BasePattern):
83 def __init__(self, content: str | None = ..., min: int = ..., max: int = ..., name: str | None = ...) -> None: ...
85 class NegatedPattern(BasePattern):
86 def __init__(self, content: str | None = ...) -> None: ...
88 def generate_matches(patterns: list[BasePattern], nodes: list[_NL]) -> Iterator[tuple[int, _Results]]: ...