Sfoglia il codice sorgente

Validation now iterates over best possibilities instead of best indices.

Sander Mathijs van Veen 13 anni fa
parent
commit
b7a6d95d1c
2 ha cambiato i file con 8 aggiunte e 5 eliminazioni
  1. 1 0
      src/possibilities.py
  2. 7 5
      src/validation.py

+ 1 - 0
src/possibilities.py

@@ -122,6 +122,7 @@ def pick_best_possibility(parser, possibilities):
 
     def traverse_breadth_first(node, result, depth=0):
         if depth > MAX_TREE_DEPTH:
+            print 'warning: Aborting because MAX_TREE_DEPTH is reached.'
             return
 
         node_expr = str(node)

+ 7 - 5
src/validation.py

@@ -18,16 +18,18 @@ def validate(exp, result):
 
         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:
-            possibility_index = BEST_POSSIBILITY_CACHE[node_expr]
+            p = BEST_POSSIBILITY_CACHE[node_expr]
 
             # If there is no possible rewrite step, bail out
-            if possibility_index is None:
+            if p is None:
                 return False
 
-            possibilities = [possibility_index]
-        else:
-            possibilities = find_possibilities(node)
+            possibilities = possibilities[p]
 
         for p in possibilities:
             # Clone the root node because it will be used in multiple