/// <summary> /// Parses the primary expressions. /// </summary> /// <returns>The lexical token representing the expression.</returns> private QueryToken ParsePrimary() { this.RecurseEnter(); QueryToken expr; if (this.lexer.PeekNextToken().Kind == ExpressionTokenKind.Slash) { expr = this.ParseSegment(null); } else { expr = this.ParsePrimaryStart(); } while (true) { if (this.lexer.CurrentToken.Kind == ExpressionTokenKind.Slash) { this.lexer.NextToken(); if (this.TokenIdentifierIs(ExpressionConstants.KeywordAny)) { expr = this.ParseAny(expr); } else if (this.TokenIdentifierIs(ExpressionConstants.KeywordAll)) { expr = this.ParseAll(expr); } else if (this.lexer.PeekNextToken().Kind == ExpressionTokenKind.Slash) { expr = this.ParseSegment(expr); } else { IdentifierTokenizer identifierTokenizer = new IdentifierTokenizer(this.parameters, new FunctionCallParser(this.lexer, this)); expr = identifierTokenizer.ParseIdentifier(expr); } } else { break; } } this.RecurseLeave(); return(expr); }
/// <summary> /// Handles the start of primary expressions. /// </summary> /// <returns>The lexical token representing the expression.</returns> private QueryToken ParsePrimaryStart() { switch (this.lexer.CurrentToken.Kind) { case ExpressionTokenKind.ParameterAlias: { return(ParseParameterAlias(this.lexer)); } case ExpressionTokenKind.Identifier: { IdentifierTokenizer identifierTokenizer = new IdentifierTokenizer(this.parameters, new FunctionCallParser(this.lexer, this, this.IsInAggregateExpression)); QueryToken parent = this.aggregateExpressionParents.Count > 0 ? this.aggregateExpressionParents.Peek() : null; return(identifierTokenizer.ParseIdentifier(parent)); } case ExpressionTokenKind.OpenParen: { return(this.ParseParenExpression()); } case ExpressionTokenKind.Star: { IdentifierTokenizer identifierTokenizer = new IdentifierTokenizer(this.parameters, new FunctionCallParser(this.lexer, this, this.IsInAggregateExpression)); return(identifierTokenizer.ParseStarMemberAccess(null)); } default: { QueryToken primitiveLiteralToken = TryParseLiteral(this.lexer); if (primitiveLiteralToken == null) { throw ParseError(ODataErrorStrings.UriQueryExpressionParser_ExpressionExpected(this.lexer.CurrentToken.Position, this.lexer.ExpressionText)); } return(primitiveLiteralToken); } } }