Helper to iteratively yield the matches.
(self, nodes)
| 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.""" |
no test coverage detected