コード例 #1
0
        private void HandleQuotedValues()
        {
            int startPosition = this.token.Position;

            do
            {
                do
                {
                    this.NextChar();
                }while (this.ch.HasValue && this.ch != '\'');

                if (this.ch == null)
                {
                    throw ParseError(ODataErrorStrings.ExpressionLexer_UnterminatedLiteral(this.textPos, this.Text));
                }

                this.NextChar();
            }while (this.ch.HasValue && this.ch == '\'');

            // Update token.Text to include the literal + the quoted value
            this.token.Text = this.Text.Substring(startPosition, this.textPos - startPosition);
        }
コード例 #2
0
        /// <summary>Handles lexemes that are formed by an identifier followed by a quoted string.</summary>
        /// <remarks>This method modified the token field as necessary.</remarks>
        private void HandleTypePrefixedLiterals()
        {
            ExpressionTokenKind id = this.token.Kind;

            if (id != ExpressionTokenKind.Identifier)
            {
                return;
            }

            bool quoteFollows = this.ch == '\'';

            if (!quoteFollows)
            {
                return;
            }

            string tokenText = this.token.Text;

            if (String.Equals(tokenText, ExpressionConstants.LiteralPrefixDuration, StringComparison.OrdinalIgnoreCase))
            {
                id = ExpressionTokenKind.DurationLiteral;
            }
            else if (String.Equals(tokenText, ExpressionConstants.LiteralPrefixBinary, StringComparison.OrdinalIgnoreCase))
            {
                id = ExpressionTokenKind.BinaryLiteral;
            }
            else if (String.Equals(tokenText, ExpressionConstants.LiteralPrefixGeography, StringComparison.OrdinalIgnoreCase))
            {
                id = ExpressionTokenKind.GeographyLiteral;
            }
            else if (String.Equals(tokenText, ExpressionConstants.LiteralPrefixGeometry, StringComparison.OrdinalIgnoreCase))
            {
                id = ExpressionTokenKind.GeometryLiteral;
            }
            else if (string.Equals(tokenText, ExpressionConstants.KeywordNull, StringComparison.OrdinalIgnoreCase))
            {
                // typed null literals are not supported.
                throw ParseError(ODataErrorStrings.ExpressionLexer_SyntaxError(this.textPos, this.Text));
            }
            else
            {
                // treat as quoted literal
                id = ExpressionTokenKind.QuotedLiteral;
            }

            int tokenPos = this.token.Position;

            do
            {
                this.NextChar();
            }while (this.ch.HasValue && this.ch != '\'');

            if (this.ch == null)
            {
                throw ParseError(ODataErrorStrings.ExpressionLexer_UnterminatedLiteral(this.textPos, this.Text));
            }

            this.NextChar();
            this.token.Kind = id;
            this.token.Text = this.Text.Substring(tokenPos, this.textPos - tokenPos);
        }