# HG changeset patch # User ludal@logilab.fr # Date 1234984141 -3600 # Wed Feb 18 20:09:01 2009 +0100 # Node ID d7877cf6281eb7b6175c62fdd767511559153f43 # Parent 5582718a40eafd24642515ce8229246ef367ba75 WIP solver rql diff --git a/analyze.py b/analyze.py --- a/analyze.py +++ b/analyze.py @@ -198,8 +198,22 @@ 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): - 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):