MCPcopy
hub / github.com/psf/black / _iterative_matches

Method _iterative_matches

src/blib2to3/pytree.py:848–875  ·  view source on GitHub ↗

Helper to iteratively yield the matches.

(self, nodes)

Source from the content-addressed store, hash-verified

846 sys.stderr = save_stderr
847
848 def _iterative_matches(self, nodes) -> Iterator[tuple[int, _Results]]:
849 """Helper to iteratively yield the matches."""
850 nodelen = len(nodes)
851 if 0 >= self.min:
852 yield 0, {}
853
854 results = []
855 # generate matches that use just one alt from self.content
856 for alt in self.content:
857 for c, r in generate_matches(alt, nodes):
858 yield c, r
859 results.append((c, r))
860
861 # for each match, iterate down the nodes
862 while results:
863 new_results = []
864 for c0, r0 in results:
865 # stop if the entire set of nodes has been matched
866 if c0 < nodelen and c0 <= self.max:
867 for alt in self.content:
868 for c1, r1 in generate_matches(alt, nodes[c0:]):
869 if c1 > 0:
870 r = {}
871 r.update(r0)
872 r.update(r1)
873 yield c0 + c1, r
874 new_results.append((c0 + c1, r))
875 results = new_results
876
877 def _bare_name_matches(self, nodes) -> tuple[int, _Results]:
878 """Special optimized matcher for bare_name."""

Callers 1

generate_matchesMethod · 0.95

Calls 2

generate_matchesFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected