Lines Matching refs:pattern
38 """Reduces a fixer's pattern tree to a linear path and adds it
49 def add(self, pattern, start):
50 "Recursively adds a linear pattern to the AC automaton"
51 #print("adding pattern", pattern, "to", start)
52 if not pattern:
53 #print("empty pattern")
55 if isinstance(pattern[0], tuple):
59 for alternative in pattern[0]:
60 #add all alternatives, and add the rest of the pattern
64 match_nodes.extend(self.add(pattern[1:], end))
69 if pattern[0] not in start.transition_table:
72 start.transition_table[pattern[0]] = next_node
75 next_node = start.transition_table[pattern[0]]
77 if pattern[1:]:
78 end_nodes = self.add(pattern[1:], start=next_node)