1
2
3
4 #include <sng2html/sng2html/ProjectFileTokens.hpp>
5 #include <map>
6
7 namespace ProjectFileTokens
8 {
9 std::map<std::u32string, int> tokenIdMap;
10
11 void InitTokenIdMap()
12 {
13 tokenIdMap[U"DOT"] = 5;
14 tokenIdMap[U"FILEPATH"] = 4;
15 tokenIdMap[U"ID"] = 3;
16 tokenIdMap[U"PROJECT"] = 1;
17 tokenIdMap[U"SEMICOLON"] = 6;
18 tokenIdMap[U"SOURCE"] = 2;
19 }
20
21 int GetTokenId(const std::u32string& tokenName)
22 {
23 auto it = tokenIdMap.find(tokenName);
24 if (it != tokenIdMap.cend())
25 {
26 return it->second;
27 }
28 else
29 {
30 return -1;
31 }
32 }
33
34 const char* tokenName[] =
35 {
36 "END",
37 "PROJECT",
38 "SOURCE",
39 "ID",
40 "FILEPATH",
41 "DOT",
42 "SEMICOLON"
43 };
44
45 const char* GetTokenName(int tokenId)
46 {
47 return tokenName[tokenId];
48 }
49
50 const char* tokenInfo[] =
51 {
52 "end of file",
53 "'project'",
54 "'source'",
55 "identifier",
56 "file path",
57 "'.'",
58 "';'"
59 };
60
61 const char* GetTokenInfo(int tokenId)
62 {
63 return tokenInfo[tokenId];
64 }
65
66 struct Initializer
67 {
68 Initializer() { InitTokenIdMap(); }
69 };
70
71 Initializer initializer;
72 }