summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--statemachine.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/statemachine.py b/statemachine.py
index ced6b60..9c943e1 100644
--- a/statemachine.py
+++ b/statemachine.py
@@ -2,6 +2,7 @@ __docformat__ = 'restructuredtext'
from category import Category
from pattern import Pattern
+import setcross
class StateMachine:
"""
@@ -22,20 +23,29 @@ class StateMachine:
"""
found = None
for (match, dependency) in self.get_applicable_deps(cat):
- res = self.get_satisfied_states(cat, dependency)
- print dependency, res
+ res = self.get_satisfied_states(match, dependency)
if len(res) == 0:
- res = cat.subtract(match)
+ return False
if found == None:
- found = res
+ found = [res]
else:
- found = self.intersect_list(found, res)
+ found.append(res)
if found == None:
self.add_hold(cat)
return True
- if len(found) == 0:
- return False
- for x in found:
+ to_add = set()
+ for tup in setcross.cross(*found):
+ orig = tup
+ while len(tup) > 1:
+ newtup = (tup[0].intersect(tup[1]),)
+ if newtup[0] == None:
+ tup = ()
+ break
+ tup = newtup + tup[2:len(tup)]
+ if len(tup) == 0 or tup[0] == None:
+ continue
+ to_add.add(tup[0])
+ for x in to_add:
self.add_hold(x)
return True