From: Daniel Karbach Date: Sun, 26 Aug 2012 14:31:34 +0000 (+0200) Subject: added function to convert token types to strings X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=7427922bc0db720e35219f7520827bd9b9db6a31;p=l2e.git added function to convert token types to strings --- diff --git a/src/loader/Tokenizer.h b/src/loader/Tokenizer.h index f761e5f..7a776a4 100644 --- a/src/loader/Tokenizer.h +++ b/src/loader/Tokenizer.h @@ -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; }