예제 #1
0
        public void CreateBooleanAnd()
        {
            Expression expression = factory.CreateExpression(
                factory.CreateComparationEqual(factory.CreateFieldNode("FIELD"),
                                               factory.CreateValueNode("VALUE", ValueNodeType.Text)));


            BooleanAnd and = factory.CreateBooleanAnd(expression, expression);

            Assert.IsNotNull(and);
            Assert.IsInstanceOfType(typeof(BooleanAnd), and);
            Assert.IsInstanceOfType(typeof(Expression), and.LeftNode);
            Assert.IsInstanceOfType(typeof(Expression), and.RightNode);
        }
예제 #2
0
        /// <summary>
        /// BOOLEAN expression Rule
        ///  | '(' BooleanRule ')'
        ///  | OperationRule
        /// <returns></returns>
        private Expression BooleanRule()
        {
            _token = _scanner.GetToken();

            switch (_token.Ttype)
            {
            case TokenType.LEFT_PARENTHESIS:
                _parenthesisDepth++;
                return(BooleanOperatorRule());

            case TokenType.FIELD:
                FieldNode fieldNode = _astFactory.CreateFieldNode(_token.Value);
                return(_astFactory.CreateExpression(ComparationRule(fieldNode)));

            default:
                throw new ParserException("Field expected.");
            }
        }