示例#1
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;
        }
示例#2
0
 /// <summary>
 /// Handles a tokenseparator.
 /// </summary>
 /// <param name="c"></param>
 /// <param name="tokenSeparator"></param>
 /// <param name="context"></param>
 /// <param name="tokenIndexProvider"></param>
 /// <returns>Returns true if the tokenseparator was handled.</returns>
 public static bool Handle(char c, Token tokenSeparator, TokenizerContext context, ITokenIndexProvider tokenIndexProvider)
 {
     foreach(var handler in _handlers)
     {
         if(handler.Handle(c, tokenSeparator, context, tokenIndexProvider))
         {
             return true;
         }
     }
     return false;
 }
 /// <summary>
 /// Handles a tokenseparator.
 /// </summary>
 /// <param name="c"></param>
 /// <param name="tokenSeparator"></param>
 /// <param name="context"></param>
 /// <param name="tokenIndexProvider"></param>
 /// <returns>Returns true if the tokenseparator was handled.</returns>
 public bool Handle(char c, Token tokenSeparator, TokenizerContext context, ITokenIndexProvider tokenIndexProvider)
 {
     foreach (var handler in _handlers)
     {
         if (handler.Handle(c, tokenSeparator, context, tokenIndexProvider))
         {
             return(true);
         }
     }
     return(false);
 }
 public override bool Handle(char c, Token tokenSeparator, TokenizerContext context, ITokenIndexProvider tokenIndexProvider)
 {
     // two operators in sequence could be "<=" or ">="
     if (IsPartOfMultipleCharSeparator(context, c))
     {
         var sOp = context.LastToken.Value + c.ToString(CultureInfo.InvariantCulture);
         var op = _tokenSeparatorProvider.Tokens[sOp];
         context.ReplaceLastToken(op);
         context.NewToken();
         return true;
     }
     return false;
 }
示例#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;
 }
        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);
        }
 public override bool Handle(char c, Token tokenSeparator, TokenizerContext context, ITokenIndexProvider tokenIndexProvider)
 {
     // two operators in sequence could be "<=" or ">="
     if (IsPartOfMultipleCharSeparator(context, c))
     {
         var sOp = context.LastToken.Value + c.ToString();
         var op  = _tokenSeparatorProvider.Tokens[sOp];
         context.ReplaceLastToken(op);
         context.NewToken();
         return(true);
     }
     return(false);
 }
示例#8
0
 public abstract bool Handle(char c, Token tokenSeparator, TokenizerContext context, ITokenIndexProvider tokenIndexProvider);
示例#9
0

        
示例#10
0

        
示例#11
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);
        }
示例#12
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);
 }