Пример #1
0
            public IToken PublishCurrentTokenString()
            {
                IToken tokenToReturn = null;

                switch (currentStringTokenType)
                {
                case TokenType.number:
                    tokenToReturn = new NumberToken(tokenString);
                    break;

                case TokenType.infixOperator:
                    tokenToReturn = new OperatorToken(tokenString, TokenType.infixOperator);
                    break;

                case TokenType.suffixOperator:
                    tokenToReturn = new OperatorToken(tokenString, TokenType.suffixOperator);
                    break;

                case TokenType.charString:
                    tokenString = tokenString.ToUpper();
                    if (FunctionToken.Library.Contains(tokenString))
                    {
                        tokenToReturn = new FunctionToken(tokenString);
                    }
                    else if (VariableToken.VariableLibrary.Contains(tokenString))
                    {
                        tokenToReturn = new VariableToken(tokenString);
                    }
                    else if (UnitToken.Units.Contains(tokenString))
                    {
                        tokenToReturn = new UnitToken(tokenString);
                    }
                    else if (KeywordToken.Keywords.Contains(tokenString))
                    {
                        tokenToReturn = new KeywordToken(tokenString);
                    }
                    break;

                case TokenType.openBrace:
                    tokenToReturn = new SyntaxToken(tokenString, TokenType.openBrace);
                    break;

                case TokenType.closedBrace:
                    tokenToReturn = new SyntaxToken(tokenString, TokenType.closedBrace);
                    break;

                case TokenType.argSeperator:
                    tokenToReturn = new SyntaxToken(tokenString, TokenType.argSeperator);
                    break;
                }
                return(tokenToReturn);
            }
Пример #2
0
 public IToken PublishCurrentTokenString()
 {
     IToken tokenToReturn = null ;
     switch (currentStringTokenType) {
     case TokenType.number:
         tokenToReturn = new NumberToken(tokenString);
         break;
     case TokenType.infixOperator:
         tokenToReturn = new OperatorToken(tokenString, TokenType.infixOperator);
         break;
     case TokenType.suffixOperator:
         tokenToReturn = new OperatorToken(tokenString, TokenType.suffixOperator);
         break;
     case TokenType.charString:
         tokenString = tokenString.ToUpper();
         if (FunctionToken.Library.Contains(tokenString)) {
             tokenToReturn = new FunctionToken(tokenString);
         } else if (VariableToken.VariableLibrary.Contains(tokenString)) {
             tokenToReturn = new VariableToken(tokenString);
         } else if(UnitToken.Units.Contains(tokenString)){
             tokenToReturn = new UnitToken(tokenString);
         } else if (KeywordToken.Keywords.Contains(tokenString)) {
             tokenToReturn = new KeywordToken(tokenString);
         }
         break;
         case TokenType.openBrace:
         tokenToReturn = new SyntaxToken(tokenString, TokenType.openBrace);
         break;
         case TokenType.closedBrace:
         tokenToReturn = new SyntaxToken(tokenString, TokenType.closedBrace);
         break;
         case TokenType.argSeperator:
         tokenToReturn = new SyntaxToken(tokenString, TokenType.argSeperator);
         break;
     }
     return tokenToReturn;
 }