/// <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)); return(identifierTokenizer.ParseIdentifier(null)); } case ExpressionTokenKind.OpenParen: { return(this.ParseParenExpression()); } case ExpressionTokenKind.Star: { IdentifierTokenizer identifierTokenizer = new IdentifierTokenizer(this.parameters, new FunctionCallParser(this.lexer, this)); 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); } } }
/// <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)); return identifierTokenizer.ParseIdentifier(null); } case ExpressionTokenKind.OpenParen: { return this.ParseParenExpression(); } case ExpressionTokenKind.Star: { IdentifierTokenizer identifierTokenizer = new IdentifierTokenizer(this.parameters, new FunctionCallParser(this.lexer, this)); 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; } } }
// Helpers private IdentifierTokenizer GetIdentifierTokenizerWithRealFunctionParser(string expression) { IdentifierTokenizer tokenizer = new IdentifierTokenizer(this.parameters, GetRealFunctionCallParser(expression)); return tokenizer; }
/// <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; }