/// <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); }
/// <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)); }
/// <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)); }
/// <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)); }