4 * Created on: Aug 26, 2012
8 #ifndef LOADER_TOKENIZER_H_
9 #define LOADER_TOKENIZER_H_
20 Tokenizer(std::istream &in) : in(in), isPutback(false) { }
23 Tokenizer(const Tokenizer &);
24 Tokenizer &operator =(const Tokenizer &);
31 ANGLE_BRACKET_OPEN = '{',
32 ANGLE_BRACKET_CLOSE = '}',
49 Token() : type(UNKNOWN), number(0) { }
50 Token(Type t) : type(t), number(0) { }
60 void Putback(const Token &);
67 Token ReadIdentifier();
69 bool CheckKeyword(Token &);
78 inline const char *TokenTypeToString(Tokenizer::Token::Type t) {
80 case Tokenizer::Token::ANGLE_BRACKET_OPEN:
81 return "ANGLE_BRACKET_OPEN";
82 case Tokenizer::Token::ANGLE_BRACKET_CLOSE:
83 return "ANGLE_BRACKET_CLOSE";
84 case Tokenizer::Token::CHEVRON_OPEN:
85 return "CHEVRON_OPEN";
86 case Tokenizer::Token::CHEVRON_CLOSE:
87 return "CHEVRON_CLOSE";
88 case Tokenizer::Token::COLON:
90 case Tokenizer::Token::COMMA:
92 case Tokenizer::Token::BRACKET_OPEN:
93 return "BRACKET_OPEN";
94 case Tokenizer::Token::BRACKET_CLOSE:
95 return "BRACKET_CLOSE";
96 case Tokenizer::Token::NUMBER:
98 case Tokenizer::Token::STRING:
100 case Tokenizer::Token::KEYWORD_EXPORT:
101 return "KEYWORD_EXPORT";
102 case Tokenizer::Token::KEYWORD_FALSE:
103 return "KEYWORD_FALSE";
104 case Tokenizer::Token::KEYWORD_INCLUDE:
105 return "KEYWORD_INCLUDE";
106 case Tokenizer::Token::KEYWORD_TRUE:
107 return "KEYWORD_TRUE";
108 case Tokenizer::Token::IDENTIFIER:
110 case Tokenizer::Token::TYPE_NAME:
117 std::ostream &operator <<(std::ostream &out, Tokenizer::Token::Type t) {
118 out << TokenTypeToString(t);
124 #endif /* LOADER_TOKENIZER_H_ */