private ExpressionTreeNode ParseNot() { if (_tokenReader.Token != Token.Not) { return(ParseTerm()); } _tokenReader.NextToken(); var term = ParseNot(); return(ExpressionTreeNode.CreateNot(term)); }
/// <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); }
/// <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); }