Exemple #1
0
 public override bool Handle(char c, Token tokenSeparator, TokenizerContext context, ITokenIndexProvider tokenIndexProvider)
 {
     if (context.IsInSheetName || context.IsInSheetName)
     {
         return(false);
     }
     if (tokenSeparator.TokenTypeIsSet(TokenType.OpeningBracket))
     {
         context.AppendToCurrentToken(c);
         context.BracketCount++;
         return(true);
     }
     if (tokenSeparator.TokenTypeIsSet(TokenType.ClosingBracket))
     {
         context.AppendToCurrentToken(c);
         context.BracketCount--;
         return(true);
     }
     if (context.BracketCount > 0)
     {
         context.AppendToCurrentToken(c);
         return(true);
     }
     return(false);
 }
        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);
        }
Exemple #3
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);
     }
 }
Exemple #5
0
 public override bool Handle(char c, Token tokenSeparator, TokenizerContext context, ITokenIndexProvider tokenIndexProvider)
 {
     if (tokenSeparator.TokenType == TokenType.OpeningBracket)
     {
         context.AppendToCurrentToken(c);
         context.BracketCount++;
         return true;
     }
     if (tokenSeparator.TokenType == TokenType.ClosingBracket)
     {
         context.AppendToCurrentToken(c);
         context.BracketCount--;
         return true;
     }
     if (context.BracketCount > 0)
     {
         context.AppendToCurrentToken(c);
         return true;
     }
     return false;
 }
Exemple #6
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);
        }
Exemple #7
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);
 }