def match_msequence(self, tokens, item):
        """Matches a middle sequence."""
        series_type, head_matches, middle, _, last_matches = tokens
        self.add_check("_coconut.isinstance(" + item + ", _coconut.abc.Sequence)")
        self.add_check("_coconut.len(" + item + ") >= " + str(len(head_matches) + len(last_matches)))
        if middle != wildcard:
            if len(head_matches) and len(last_matches):
                splice = "[" + str(len(head_matches)) + ":" + str(-len(last_matches)) + "]"
            elif len(head_matches):
                splice = "[" + str(len(head_matches)) + ":]"
            elif len(last_matches):
                splice = "[:" + str(-len(last_matches)) + "]"
            else:
                splice = ""
            self.assign_to_series(middle, series_type, item + splice)
        self.match_all_in(head_matches, item)
        for i, match in enumerate(last_matches):
            self.match(match, item + "[" + str(i - len(last_matches)) + "]")
def match_msequence ( self , tokens , item ) : series_type , head_matches , middle , _ , last_matches = tokens self . add_check ( "_coconut.isinstance(" + item + ", _coconut.abc.Sequence)" ) self . add_check ( "_coconut.len(" + item + ") >= " + str ( len ( head_matches ) + len ( last_matches ) ) ) if middle != wildcard : if len ( head_matches ) and len ( last_matches ) : splice = "[" + str ( len ( head_matches ) ) + ":" + str ( - len ( last_matches ) ) + "]" elif len ( head_matches ) : splice = "[" + str ( len ( head_matches ) ) + ":]" elif len ( last_matches ) : splice = "[:" + str ( - len ( last_matches ) ) + "]" else : splice = "" self . assign_to_series ( middle , series_type , item + splice ) self . match_all_in ( head_matches , item ) for i , match in enumerate ( last_matches ) : self . match ( match , item + "[" + str ( i - len ( last_matches ) ) + "]" )
Matches a middle sequence.