summaryrefslogtreecommitdiff
path: root/regex
diff options
context:
space:
mode:
Diffstat (limited to 'regex')
-rw-r--r--regex/__init__.py42
1 files changed, 0 insertions, 42 deletions
diff --git a/regex/__init__.py b/regex/__init__.py
index bf96587..14de8a9 100644
--- a/regex/__init__.py
+++ b/regex/__init__.py
@@ -150,48 +150,6 @@ def get_patterns(code):
yield from patterns_with_literals(tree)
-def find_pattern(tree, pattern):
- def find_pattern_aux(node, pattern, varname=None):
- nodes = []
- if pattern.label == node.label:
- nodes = [node]
-
- if node.label in ('id', 'arg'):
- if not pattern:
- while node:
- node = node[0]
- if varname is None:
- varname = node.label
- return [node]
- elif node.label == varname:
- return [node]
- else:
- return []
-
- # subpatterns found so far among node’s children
- index = 0
- for subtree in node.subtrees():
- if index >= len(pattern):
- break
- new_nodes = find_pattern_aux(subtree, pattern[index], varname)
- if new_nodes:
- nodes += new_nodes
- index += 1
- if index < len(pattern):
- nodes = []
-
- else:
- for child in node:
- nodes = find_pattern_aux(child, pattern, varname)
- if nodes:
- break
- return nodes
-
- for variable in get_variables(tree):
- result = find_pattern_aux(tree, pattern, variable)
- if result:
- yield result
-
def get_attributes(programs):
# extract attributes from training data
patterns = collections.defaultdict(list)