1
2
3
4
5
6 #ifndef SOULNG_LEXER_KEYWORD_INCLUDED
7 #define SOULNG_LEXER_KEYWORD_INCLUDED
8 #include <soulng/lexer/Token.hpp>
9 #include <map>
10
11 namespace soulng { namespace lexer {
12
13 struct Keyword
14 {
15 Keyword() : str(nullptr), tokenID(INVALID_TOKEN) {}
16 Keyword(const char32_t* str_, int tokenID_) : str(str_), tokenID(tokenID_) { }
17 const char32_t* str;
18 int tokenID;
19 };
20
21 class KeywordMap
22 {
23 public:
24 KeywordMap(const Keyword* keywords_);
25 int GetKeywordToken(const Lexeme& lexeme) const;
26 private:
27 const Keyword* keywords;
28 std::map<Lexeme, int> keywordMap;
29 };
30
31 } }
32
33 #endif // SOULNG_LEXER_KEYWORD_INCLUDED