Skip to content
Snippets Groups Projects
Commit b7a6d95d authored by Sander Mathijs van Veen's avatar Sander Mathijs van Veen Committed by Taddeus Kroes
Browse files

Validation now iterates over best possibilities instead of best indices.

parent e4b29aa3
No related branches found
No related tags found
No related merge requests found
...@@ -122,6 +122,7 @@ def pick_best_possibility(parser, possibilities): ...@@ -122,6 +122,7 @@ def pick_best_possibility(parser, possibilities):
def traverse_breadth_first(node, result, depth=0): def traverse_breadth_first(node, result, depth=0):
if depth > MAX_TREE_DEPTH: if depth > MAX_TREE_DEPTH:
print 'warning: Aborting because MAX_TREE_DEPTH is reached.'
return return
node_expr = str(node) node_expr = str(node)
......
...@@ -18,16 +18,18 @@ def validate(exp, result): ...@@ -18,16 +18,18 @@ def validate(exp, result):
node_expr = str(node) node_expr = str(node)
possibilities = find_possibilities(node)
# If a best possibility chain of rewrite steps is discovered before,
# use the corresponding possibility index of that chain instead.
if node_expr in BEST_POSSIBILITY_CACHE: if node_expr in BEST_POSSIBILITY_CACHE:
possibility_index = BEST_POSSIBILITY_CACHE[node_expr] p = BEST_POSSIBILITY_CACHE[node_expr]
# If there is no possible rewrite step, bail out # If there is no possible rewrite step, bail out
if possibility_index is None: if p is None:
return False return False
possibilities = [possibility_index] possibilities = possibilities[p]
else:
possibilities = find_possibilities(node)
for p in possibilities: for p in possibilities:
# Clone the root node because it will be used in multiple # Clone the root node because it will be used in multiple
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment