Ejemplo n.º 1
0
        private ExpressionTreeNode ParseNot()
        {
            if (_tokenReader.Token != Token.Not)
            {
                return(ParseTerm());
            }

            _tokenReader.NextToken();

            var term = ParseNot();

            return(ExpressionTreeNode.CreateNot(term));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// AND(NOT,NOT) -> NOT(OR)
        /// </summary>
        /// <param name="node"></param>
        private static ExpressionTreeNode TwoNotInAndRule(ExpressionTreeNode node, ref int count)
        {
            if (node == null)
            {
                return(null);
            }

            if (node.Operation == "AND" && node.Child1.Operation == "NOT" && node.Child2.Operation == "NOT")
            {
                var andChild = ExpressionTreeNode.CreateOr(node.Child1.Child1, node.Child2.Child1);

                node = ExpressionTreeNode.CreateNot(andChild);

                count++;
            }

            return(node);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// OR(NOT, NOT) -> ALL - if terms are not equal
        /// OR(NOT, NOT) -> NOT(term) - if terms are equal
        /// </summary>
        /// <param name="node"></param>
        private static ExpressionTreeNode TwoNotInOrRule(ExpressionTreeNode node, ref int count)
        {
            if (node == null)
            {
                return(null);
            }

            if (node.Operation == "OR" && node.Child1.Operation == "NOT" && node.Child2.Operation == "NOT")
            {
                if (node.Child1.Child1.Term == node.Child2.Child1.Term)
                {
                    node = ExpressionTreeNode.CreateNot(node.Child1.Child1);
                }
                else
                {
                    node = ExpressionTreeNode.CreateAllNode();
                }

                count++;
            }

            return(node);
        }