Exemplo n.º 1
0
        /// <summary>
        /// Parses the eq, ne, lt, gt, le, ge, has, and in operators.
        /// </summary>
        /// <returns>The lexical token representing the expression.</returns>
        private QueryToken ParseComparison()
        {
            this.RecurseEnter();
            QueryToken left = this.ParseAdditive();

            while (true)
            {
                if (this.TokenIdentifierIs(ExpressionConstants.KeywordIn))
                {
                    this.lexer.NextToken();
                    QueryToken right = this.ParseAdditive();
                    left = new InToken(left, right);
                }
                else
                {
                    BinaryOperatorKind binaryOperatorKind;
                    if (this.TokenIdentifierIs(ExpressionConstants.KeywordEqual))
                    {
                        binaryOperatorKind = BinaryOperatorKind.Equal;
                    }
                    else if (this.TokenIdentifierIs(ExpressionConstants.KeywordNotEqual))
                    {
                        binaryOperatorKind = BinaryOperatorKind.NotEqual;
                    }
                    else if (this.TokenIdentifierIs(ExpressionConstants.KeywordGreaterThan))
                    {
                        binaryOperatorKind = BinaryOperatorKind.GreaterThan;
                    }
                    else if (this.TokenIdentifierIs(ExpressionConstants.KeywordGreaterThanOrEqual))
                    {
                        binaryOperatorKind = BinaryOperatorKind.GreaterThanOrEqual;
                    }
                    else if (this.TokenIdentifierIs(ExpressionConstants.KeywordLessThan))
                    {
                        binaryOperatorKind = BinaryOperatorKind.LessThan;
                    }
                    else if (this.TokenIdentifierIs(ExpressionConstants.KeywordLessThanOrEqual))
                    {
                        binaryOperatorKind = BinaryOperatorKind.LessThanOrEqual;
                    }
                    else if (this.TokenIdentifierIs(ExpressionConstants.KeywordHas))
                    {
                        binaryOperatorKind = BinaryOperatorKind.Has;
                    }
                    else
                    {
                        break;
                    }

                    this.lexer.NextToken();
                    QueryToken right = this.ParseAdditive();
                    left = new BinaryOperatorToken(binaryOperatorKind, left, right);
                }
            }

            this.RecurseLeave();
            return(left);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Binds an In operator token.
        /// </summary>
        /// <param name="inToken">The In operator token to bind.</param>
        /// <param name="state">State of the metadata binding.</param>
        /// <returns>The bound In operator token.</returns>
        internal QueryNode BindInOperator(InToken inToken, BindingState state)
        {
            ExceptionUtils.CheckArgumentNotNull(inToken, "inToken");

            SingleValueNode left  = this.GetSingleValueOperandFromToken(inToken.Left);
            CollectionNode  right = this.GetCollectionOperandFromToken(
                inToken.Right, new EdmCollectionTypeReference(new EdmCollectionType(left.TypeReference)), state.Model);

            return(new InNode(left, right));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Binds an In token.
        /// </summary>
        /// <param name="inToken">The In token to bind.</param>
        /// <returns>The bound In token.</returns>
        protected virtual QueryNode BindIn(InToken inToken)
        {
            Func <QueryToken, QueryNode> InBinderMethod = (queryToken) =>
            {
                ExceptionUtils.CheckArgumentNotNull(queryToken, "queryToken");

                if (queryToken.Kind == QueryTokenKind.Literal)
                {
                    return(LiteralBinder.BindInLiteral((LiteralToken)queryToken));
                }

                return(this.Bind(queryToken));
            };

            InBinder inBinder = new InBinder(InBinderMethod);

            return(inBinder.BindInOperator(inToken, this.BindingState));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Binds an In token.
        /// </summary>
        /// <param name="inToken">The In token to bind.</param>
        /// <returns>The bound In token.</returns>
        protected virtual QueryNode BindIn(InToken inToken)
        {
            InBinder inBinder = new InBinder(this.Bind);

            return(inBinder.BindInOperator(inToken, this.BindingState));
        }