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;
        }
 private static void HandleAddressSeparatorToken(char c, Token tokenSeparator, TokenizerContext context)
 {
     if (context.LastToken != null && context.LastToken.Value.Value == ")")
     {
         context.AddToken(tokenSeparator);
     }
     else
     {
         context.AppendToCurrentToken(c);
     }
 }
示例#4
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);
        }