]> git.localhorst.tv Git - l2e.git/commitdiff
added function to convert token types to strings
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 26 Aug 2012 14:31:34 +0000 (16:31 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 26 Aug 2012 14:31:34 +0000 (16:31 +0200)
src/loader/Tokenizer.h

index f761e5fb725d590cc057b8709a4d94ca8bca091c..7a776a450d49049e06cb98243d81b1e6a9ad5aab 100644 (file)
@@ -75,61 +75,47 @@ private:
 
 };
 
-
-std::ostream &operator <<(std::ostream &out, Tokenizer::Token::Type t) {
+inline const char *TokenTypeToString(Tokenizer::Token::Type t) {
        switch (t) {
                case Tokenizer::Token::ANGLE_BRACKET_OPEN:
-                       out << "ANGLE_BRACKET_OPEN";
-                       break;
+                       return "ANGLE_BRACKET_OPEN";
                case Tokenizer::Token::ANGLE_BRACKET_CLOSE:
-                       out << "ANGLE_BRACKET_CLOSE";
-                       break;
+                       return "ANGLE_BRACKET_CLOSE";
                case Tokenizer::Token::CHEVRON_OPEN:
-                       out << "CHEVRON_OPEN";
-                       break;
+                       return "CHEVRON_OPEN";
                case Tokenizer::Token::CHEVRON_CLOSE:
-                       out << "CHEVRON_CLOSE";
-                       break;
+                       return "CHEVRON_CLOSE";
                case Tokenizer::Token::COLON:
-                       out << "COLON";
-                       break;
+                       return "COLON";
                case Tokenizer::Token::COMMA:
-                       out << "COMMA";
-                       break;
+                       return "COMMA";
                case Tokenizer::Token::BRACKET_OPEN:
-                       out << "BRACKET_OPEN";
-                       break;
+                       return "BRACKET_OPEN";
                case Tokenizer::Token::BRACKET_CLOSE:
-                       out << "BRACKET_CLOSE";
-                       break;
+                       return "BRACKET_CLOSE";
                case Tokenizer::Token::NUMBER:
-                       out << "NUMBER";
-                       break;
+                       return "NUMBER";
                case Tokenizer::Token::STRING:
-                       out << "STRING";
-                       break;
+                       return "STRING";
                case Tokenizer::Token::KEYWORD_EXPORT:
-                       out << "KEYWORD_EXPORT";
-                       break;
+                       return "KEYWORD_EXPORT";
                case Tokenizer::Token::KEYWORD_FALSE:
-                       out << "KEYWORD_FALSE";
-                       break;
+                       return "KEYWORD_FALSE";
                case Tokenizer::Token::KEYWORD_INCLUDE:
-                       out << "KEYWORD_INCLUDE";
-                       break;
+                       return "KEYWORD_INCLUDE";
                case Tokenizer::Token::KEYWORD_TRUE:
-                       out << "KEYWORD_TRUE";
-                       break;
+                       return "KEYWORD_TRUE";
                case Tokenizer::Token::IDENTIFIER:
-                       out << "IDENTIFIER";
-                       break;
+                       return "IDENTIFIER";
                case Tokenizer::Token::TYPE_NAME:
-                       out << "TYPE_NAME";
-                       break;
+                       return "TYPE_NAME";
                default:
-                       out << "UNKNOWN";
-                       break;
+                       return "UNKNOWN";
        }
+}
+
+std::ostream &operator <<(std::ostream &out, Tokenizer::Token::Type t) {
+       out << TokenTypeToString(t);
        return out;
 }