public override bool Handle(char c, Token tokenSeparator, TokenizerContext context, ITokenIndexProvider tokenIndexProvider)
        {
            if (context.IsInSheetName)
            {
                if (IsDoubleQuote(tokenSeparator, tokenIndexProvider.Index, context))
                {
                    tokenIndexProvider.MoveIndexPointerForward();
                    context.AppendToCurrentToken(c);
                    return(true);
                }
                if (tokenSeparator.TokenType != TokenType.WorksheetQuote)
                {
                    context.AppendToCurrentToken(c);
                    return(true);
                }
            }

            if (tokenSeparator.TokenType == TokenType.WorksheetQuote)
            {
                if (context.LastToken != null && context.LastToken.TokenType == TokenType.WorksheetQuote)
                {
                    context.AddToken(!context.CurrentTokenHasValue
                        ? new Token(string.Empty, TokenType.WorksheetName)
                        : new Token(context.CurrentToken, TokenType.WorksheetName));
                }
                context.AddToken(new Token("'", TokenType.WorksheetQuote));
                context.ToggleIsInSheetName();
                context.NewToken();
                return(true);
            }
            return(false);
        }
예제 #2
0
        public override bool Handle(char c, Token tokenSeparator, TokenizerContext context, ITokenIndexProvider tokenIndexProvider)
        {
            if (context.IsInSheetName)
            {
                if (IsDoubleQuote(tokenSeparator, tokenIndexProvider.Index, context))
                {
                    tokenIndexProvider.MoveIndexPointerForward();
                    context.AppendToCurrentToken(c);
                    return true;
                }
                if (tokenSeparator.TokenType != TokenType.WorksheetName)
                {
                    context.AppendToCurrentToken(c);
                    return true;
                }
            }

            if (tokenSeparator.TokenType == TokenType.WorksheetName)
            {
                if (context.LastToken != null && context.LastToken.TokenType == TokenType.WorksheetName)
                {
                    context.AddToken(!context.CurrentTokenHasValue
                        ? new Token(string.Empty, TokenType.WorksheetNameContent)
                        : new Token(context.CurrentToken, TokenType.WorksheetNameContent));
                }
                context.AddToken(new Token("'", TokenType.WorksheetName));
                context.ToggleIsInSheetName();
                context.NewToken();
                return true;
            }
            return false;
        }
예제 #3
0
        public override bool Handle(char c, Token tokenSeparator, TokenizerContext context, ITokenIndexProvider tokenIndexProvider)
        {
            if (context.IsInString)
            {
                if (IsDoubleQuote(tokenSeparator, tokenIndexProvider.Index, context))
                {
                    tokenIndexProvider.MoveIndexPointerForward();
                    context.AppendToCurrentToken(c);
                    return(true);
                }
                if (!tokenSeparator.TokenTypeIsSet(TokenType.String))
                {
                    context.AppendToCurrentToken(c);
                    return(true);
                }
            }

            if (tokenSeparator.TokenTypeIsSet(TokenType.String))
            {
                if (context.LastToken != null && context.LastToken.Value.TokenTypeIsSet(TokenType.OpeningEnumerable))
                {
                    context.AppendToCurrentToken(c);
                    context.ToggleIsInString();
                    return(true);
                }
                if (context.LastToken != null && context.LastToken.Value.TokenTypeIsSet(TokenType.String))
                {
                    context.AddToken(!context.CurrentTokenHasValue
                        ? new Token(string.Empty, TokenType.StringContent)
                        : new Token(context.CurrentToken, TokenType.StringContent));
                }
                context.AddToken(new Token("\"", TokenType.String));
                context.ToggleIsInString();
                context.NewToken();
                return(true);
            }
            return(false);
        }
예제 #4
0
 /// <summary>
 /// Handles the single-quote character for worksheet names.
 /// </summary>
 /// <param name="c">The character to handle.</param>
 /// <param name="tokenSeparator">The token separator to handle.</param>
 /// <param name="context">The tokenization context.</param>
 /// <param name="tokenIndexProvider">The <see cref="ITokenIndexProvider"/>.</param>
 /// <returns>True if the token separator was handled, false otherwise.</returns>
 public override bool Handle(char c, Token tokenSeparator, TokenizerContext context, ITokenIndexProvider tokenIndexProvider)
 {
     if (context.IsInSheetName)
     {
         if (base.IsDoubleQuote(tokenSeparator, tokenIndexProvider.Index, context))
         {
             tokenIndexProvider.MoveIndexPointerForward();
             context.AppendToCurrentToken(c);
             return(true);
         }
         if (tokenSeparator.TokenType != TokenType.WorksheetName)
         {
             context.AppendToCurrentToken(c);
             return(true);
         }
     }
     if (tokenSeparator.TokenType == TokenType.WorksheetName)
     {
         context.AppendToCurrentToken(c);
         context.ToggleIsInSheetName();
         return(true);
     }
     return(false);
 }