From: Daniel Karbach Date: Sun, 26 Aug 2012 13:31:49 +0000 (+0200) Subject: added output function for token types X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=d1c2bdda89b4e5542fd09eaa548e5365f20c592a;p=l2e.git added output function for token types --- diff --git a/src/loader/Tokenizer.h b/src/loader/Tokenizer.h index f363af7..f761e5f 100644 --- a/src/loader/Tokenizer.h +++ b/src/loader/Tokenizer.h @@ -9,6 +9,7 @@ #define LOADER_TOKENIZER_H_ #include +#include #include namespace loader { @@ -74,6 +75,64 @@ private: }; + +std::ostream &operator <<(std::ostream &out, Tokenizer::Token::Type t) { + switch (t) { + case Tokenizer::Token::ANGLE_BRACKET_OPEN: + out << "ANGLE_BRACKET_OPEN"; + break; + case Tokenizer::Token::ANGLE_BRACKET_CLOSE: + out << "ANGLE_BRACKET_CLOSE"; + break; + case Tokenizer::Token::CHEVRON_OPEN: + out << "CHEVRON_OPEN"; + break; + case Tokenizer::Token::CHEVRON_CLOSE: + out << "CHEVRON_CLOSE"; + break; + case Tokenizer::Token::COLON: + out << "COLON"; + break; + case Tokenizer::Token::COMMA: + out << "COMMA"; + break; + case Tokenizer::Token::BRACKET_OPEN: + out << "BRACKET_OPEN"; + break; + case Tokenizer::Token::BRACKET_CLOSE: + out << "BRACKET_CLOSE"; + break; + case Tokenizer::Token::NUMBER: + out << "NUMBER"; + break; + case Tokenizer::Token::STRING: + out << "STRING"; + break; + case Tokenizer::Token::KEYWORD_EXPORT: + out << "KEYWORD_EXPORT"; + break; + case Tokenizer::Token::KEYWORD_FALSE: + out << "KEYWORD_FALSE"; + break; + case Tokenizer::Token::KEYWORD_INCLUDE: + out << "KEYWORD_INCLUDE"; + break; + case Tokenizer::Token::KEYWORD_TRUE: + out << "KEYWORD_TRUE"; + break; + case Tokenizer::Token::IDENTIFIER: + out << "IDENTIFIER"; + break; + case Tokenizer::Token::TYPE_NAME: + out << "TYPE_NAME"; + break; + default: + out << "UNKNOWN"; + break; + } + return out; +} + } #endif /* LOADER_TOKENIZER_H_ */