diff --git a/analyze.py b/analyze.py index 5582718a40eafd24642515ce8229246ef367ba75_YW5hbHl6ZS5weQ==..d7877cf6281eb7b6175c62fdd767511559153f43_YW5hbHl6ZS5weQ== 100644 --- a/analyze.py +++ b/analyze.py @@ -198,4 +198,11 @@ class DistributeVisitor(object): + """The purpose of this visitor is to distribute and's over + or's in the expression tree. For example if A and B is + represented as A*B and A or B as A+B we want to transform : + A*(B+C*(D+E)+A*B) into A*B+A*C*D+A*C*E+A*A*B + """ + def __init__(self): + self.stack = [] def visit_and(self, node): @@ -201,5 +208,12 @@ def visit_and(self, node): - pass + first = self.cond.pop(0) + if isinstance(first, _or): + distrib = _or.cond[:] + else: + distrib = [first] + while self.cond: + next = self.cond.pop(0) + def visit_or(self, node): pass def visit_true(self, node):