1
2
3
4
5
6 #include <soulng/lexer/TrivialLexer.hpp>
7
8 TrivialLexer::TrivialLexer(const std::u32string& content_, const std::string& fileName_, int fileIndex_) : Lexer(content_, fileName_, fileIndex_)
9 {
10 }
11
12 TrivialLexer::TrivialLexer(const char32_t* start_, const char32_t* end_, const std::string& fileName_, int fileIndex_) : Lexer(start_, end_, fileName_, fileIndex_)
13 {
14 }
15
16 int TrivialLexer::NextState(int state, char32_t c)
17 {
18 token.id = static_cast<int>(c);
19 token.match = lexeme;
20 if (c == '\n')
21 {
22 ++line;
23 }
24 return -1;
25 }
26
27
28 std::string GetTrivialTokenInfo(int tokenId)
29 {
30 if (tokenId == soulng::lexer::END_TOKEN)
31 {
32 return "end of file";
33 }
34 return std::to_string(tokenId);
35 }
36