sdk/dotnet/src/Microsoft.Datasync.Client/Query/OData/ODataExpressionLexer.cs
/// <summary>
/// Gets the next token in the expression.
/// </summary>
/// <returns>A <see cref="QueryToken"/>.</returns>
/// <exception cref="ODataException">If a syntax error is encountered.</exception>
Gets the next token in the expression.
Gets the next token in the expression .
public QueryToken NextToken()
        {
            SkipWhiteSpace();
            int tokenPosition = TextPosition;
            QueryTokenKind tokenKind;
            switch (CurrentChar)
            {
                case '(':
                    NextChar();
                    tokenKind = QueryTokenKind.OpenParen;
                    break;
                case ')':
                    NextChar();
                    tokenKind = QueryTokenKind.CloseParen;
                    break;
                case ',':
                    NextChar();
                    tokenKind = QueryTokenKind.Comma;
                    break;
                case '-':
                    NextChar();
                    tokenKind = QueryTokenKind.Minus;
                    break;
                case '/':
                    NextChar();
                    tokenKind = QueryTokenKind.Dot;
                    break;
                case '\'':
                    CompleteStringLiteral();
                    tokenKind = QueryTokenKind.StringLiteral;
                    break;
                default:
                    if (IsIdentifierStart(CurrentChar) || CurrentChar == '@' || CurrentChar == '_')
                    {
                        CompleteIdentifier();
                        tokenKind = QueryTokenKind.Identifier;
                        break;
                    }
                    if (char.IsDigit(CurrentChar))
                    {
                        tokenKind = CompleteNumberLiteral();
                        break;
                    }
                    if (TextPosition == Text.Length)
                    {
                        tokenKind = QueryTokenKind.End;
                        break;
                    }
                    throw new ODataException("The specified OData expression has syntax errors.", Text, TextPosition);
            }
            Token.Kind = tokenKind;
            Token.Text = Text.Substring(tokenPosition, TextPosition - tokenPosition);
            Token.Position = tokenPosition;
            if (Token.Kind == QueryTokenKind.Identifier && identifierClassification.ContainsKey(Token.Text))
            {
                Token.Kind = identifierClassification[Token.Text];
            }
            return Token;
        }
public QueryToken NextToken ( ) { SkipWhiteSpace ( ) ; int tokenPosition = TextPosition ; QueryTokenKind tokenKind ; switch ( CurrentChar ) { case ' ' : NextChar ( ) ; tokenKind = QueryTokenKind . OpenParen ; break ; case ' ' : NextChar ( ) ; tokenKind = QueryTokenKind . CloseParen ; break ; case ' ' : NextChar ( ) ; tokenKind = QueryTokenKind . Comma ; break ; case ' ' : NextChar ( ) ; tokenKind = QueryTokenKind . Minus ; break ; case ' ' : NextChar ( ) ; tokenKind = QueryTokenKind . Dot ; break ; case ' \' ' : CompleteStringLiteral ( ) ; tokenKind = QueryTokenKind . StringLiteral ; break ; default : if ( IsIdentifierStart ( CurrentChar ) || CurrentChar == ' ' || CurrentChar == ' ' ) { CompleteIdentifier ( ) ; tokenKind = QueryTokenKind . Identifier ; break ; } if ( char . IsDigit ( CurrentChar ) ) { tokenKind = CompleteNumberLiteral ( ) ; break ; } if ( TextPosition == Text . Length ) { tokenKind = QueryTokenKind . End ; break ; } throw new ODataException ( " " , Text , TextPosition ) ; } Token . Kind = tokenKind ; Token . Text = Text . Substring ( tokenPosition , TextPosition - tokenPosition ) ; Token . Position = tokenPosition ; if ( Token . Kind == QueryTokenKind . Identifier && identifierClassification . ContainsKey ( Token . Text ) ) { Token . Kind = identifierClassification [ Token . Text ] ; } return Token ; }
Gets the next token in the expression.
Gets the next token in the expression .
None
If a syntax error is encountered.
If a syntax error is encountered .