protected internal virtual Expression VisitOperatorOr(OperatorOr node)
        {
            var left = Visit(node.Left);
            var right = Visit(node.Right);

            if (node.Left == left && node.Right == right)
            {
                return node;
            }
            else
            {
                return new OperatorOr(left, right);
            }
        }
        protected internal virtual Expression VisitOperatorOr(OperatorOr node)
        {
            var left  = Visit(node.Left);
            var right = Visit(node.Right);

            if (node.Left == left && node.Right == right)
            {
                return(node);
            }
            else
            {
                return(new OperatorOr(left, right));
            }
        }
        protected internal override Expression VisitOperatorAnd(OperatorAnd node)
        {
            // Both operands must be in DNF
            var left  = Visit(node.Left);
            var right = Visit(node.Right);

            // Form Cartesian product of terms
            Expression[] leftterms, rightterms;

            if (left is OperatorOr)
            {
                leftterms = ((OperatorOr)left).EnumerateTerms().ToArray();
            }
            else
            {
                leftterms = new Expression[] { left };
            }

            if (right is OperatorOr)
            {
                rightterms = ((OperatorOr)right).EnumerateTerms().ToArray();
            }
            else
            {
                rightterms = new Expression[] { right };
            }

            Expression res = null;

            for (int i = 0; i < leftterms.Length; i++)
            {
                for (int j = 0; j < rightterms.Length; j++)
                {
                    var t = new OperatorAnd(leftterms[i], rightterms[j]);

                    if (res == null)
                    {
                        res = t;
                    }
                    else
                    {
                        res = new OperatorOr(t, res);
                    }
                }
            }

            return(res);
        }
Exemple #4
0
        protected internal override Expression VisitOperatorOr(OperatorOr node)
        {
            // Both operands must be in CNF
            var left = Visit(node.Left);
            var right = Visit(node.Right);

            // Form Cartesian product of terms
            Expression[] leftterms, rightterms;

            if (left is OperatorAnd)
            {
                leftterms = ((OperatorAnd)left).EnumerateTerms().ToArray();
            }
            else
            {
                leftterms = new Expression[] { left };
            }

            if (right is OperatorAnd)
            {
                rightterms = ((OperatorAnd)right).EnumerateTerms().ToArray();
            }
            else
            {
                rightterms = new Expression[] { right };
            }

            Expression res = null;

            for (int i = 0; i < leftterms.Length; i++)
            {
                for (int j = 0; j < rightterms.Length; j++)
                {
                    var t = new OperatorOr(leftterms[i], rightterms[j]);

                    if (res == null)
                    {
                        res = t;
                    }
                    else
                    {
                        res = new OperatorAnd(t, res);
                    }
                }
            }

            return res;
        }
Exemple #5
0
        private void EnumerateTermsInternal(OperatorOr node, Stack<Expression> stack)
        {
            if (node.Left is OperatorOr)
            {
                EnumerateTermsInternal((OperatorOr)node.Left, stack);
            }
            else
            {
                stack.Push(node.Left);
            }

            if (node.Right is OperatorOr)
            {
                EnumerateTermsInternal((OperatorOr)node.Right, stack);
            }
            else
            {
                stack.Push(node.Right);
            }
        }
Exemple #6
0
        private void EnumerateTermsInternal(OperatorOr node, Stack <Expression> stack)
        {
            if (node.Left is OperatorOr)
            {
                EnumerateTermsInternal((OperatorOr)node.Left, stack);
            }
            else
            {
                stack.Push(node.Left);
            }

            if (node.Right is OperatorOr)
            {
                EnumerateTermsInternal((OperatorOr)node.Right, stack);
            }
            else
            {
                stack.Push(node.Right);
            }
        }