summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-01-19 09:38:56 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2018-01-19 09:38:56 +0100
commitcd6a8247ab1c049c330318e086f19bea6f8d1050 (patch)
tree8cd5238d7b2fe47d7cd687876f9bf9eb4a962747
parent989c93ab0b9486aa3db579395a273a94e46ee2ca (diff)
regex: remove find_patterns (unused and broken)
-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)