(self, nodes)
Generator yielding matches for a sequence of nodes.

        Args:
            nodes: sequence of nodes

        Yields:
            (count, results) tuples where:
            count: the match comprises nodes[:count];
            results: dict containing named submatches.
Generator yielding matches for a sequence of nodes.
Generator yielding matches for a sequence of nodes .
def generate_matches(self, nodes):
        """
        Generator yielding matches for a sequence of nodes.

        Args:
            nodes: sequence of nodes

        Yields:
            (count, results) tuples where:
            count: the match comprises nodes[:count];
            results: dict containing named submatches.
        """
        if self.content is None:
            # Shortcut for special case (see __init__.__doc__)
            for count in range(self.min, 1 + min(len(nodes), self.max)):
                r = {}
                if self.name:
                    r[self.name] = nodes[:count]
                yield count, r
        elif self.name == "bare_name":
            yield self._bare_name_matches(nodes)
        else:
            # The reason for this is that hitting the recursion limit usually
            # results in some ugly messages about how RuntimeErrors are being
            # ignored. We only have to do this on CPython, though, because other
            # implementations don't have this nasty bug in the first place.
            if hasattr(sys, "getrefcount"):
                save_stderr = sys.stderr
                sys.stderr = StringIO()
            try:
                for count, r in self._recursive_matches(nodes, 0):
                    if self.name:
                        r[self.name] = nodes[:count]
                    yield count, r
            except RuntimeError:
                # We fall back to the iterative pattern matching scheme if the recursive
                # scheme hits the recursion limit.
                for count, r in self._iterative_matches(nodes):
                    if self.name:
                        r[self.name] = nodes[:count]
                    yield count, r
            finally:
                if hasattr(sys, "getrefcount"):
                    sys.stderr = save_stderr
def generate_matches ( self , nodes ) : if self . content is None : # Shortcut for special case (see __init__.__doc__) for count in range ( self . min , 1 + min ( len ( nodes ) , self . max ) ) : r = { } if self . name : r [ self . name ] = nodes [ : count ] yield count , r elif self . name == "bare_name" : yield self . _bare_name_matches ( nodes ) else : # The reason for this is that hitting the recursion limit usually # results in some ugly messages about how RuntimeErrors are being # ignored. We only have to do this on CPython, though, because other # implementations don't have this nasty bug in the first place. if hasattr ( sys , "getrefcount" ) : save_stderr = sys . stderr sys . stderr = StringIO ( ) try : for count , r in self . _recursive_matches ( nodes , 0 ) : if self . name : r [ self . name ] = nodes [ : count ] yield count , r except RuntimeError : # We fall back to the iterative pattern matching scheme if the recursive # scheme hits the recursion limit. for count , r in self . _iterative_matches ( nodes ) : if self . name : r [ self . name ] = nodes [ : count ] yield count , r finally : if hasattr ( sys , "getrefcount" ) : sys . stderr = save_stderr