1
2
3
4 #include <sngcm/cmlexer/ContainerFileTokens.hpp>
5 #include <map>
6
7 namespace ContainerFileTokens
8 {
9 std::map<std::u32string, int> tokenIdMap;
10
11 void InitTokenIdMap()
12 {
13 tokenIdMap[U"ACTIVEPROJECT"] = 14;
14 tokenIdMap[U"ASSIGN"] = 17;
15 tokenIdMap[U"DOT"] = 19;
16 tokenIdMap[U"FILEPATH"] = 16;
17 tokenIdMap[U"ID"] = 15;
18 tokenIdMap[U"LIBRARY"] = 11;
19 tokenIdMap[U"PROGRAM"] = 8;
20 tokenIdMap[U"PROJECT"] = 1;
21 tokenIdMap[U"REFERENCE"] = 3;
22 tokenIdMap[U"RESOURCE"] = 5;
23 tokenIdMap[U"SEMICOLON"] = 18;
24 tokenIdMap[U"SOLUTION"] = 2;
25 tokenIdMap[U"SOURCE"] = 4;
26 tokenIdMap[U"TARGET"] = 7;
27 tokenIdMap[U"TEXT"] = 6;
28 tokenIdMap[U"UNITTEST"] = 13;
29 tokenIdMap[U"WINAPP"] = 10;
30 tokenIdMap[U"WINGUIAPP"] = 9;
31 tokenIdMap[U"WINLIB"] = 12;
32 }
33
34 int GetTokenId(const std::u32string& tokenName)
35 {
36 auto it = tokenIdMap.find(tokenName);
37 if (it != tokenIdMap.cend())
38 {
39 return it->second;
40 }
41 else
42 {
43 return -1;
44 }
45 }
46
47 const char* tokenName[] =
48 {
49 "END",
50 "PROJECT",
51 "SOLUTION",
52 "REFERENCE",
53 "SOURCE",
54 "RESOURCE",
55 "TEXT",
56 "TARGET",
57 "PROGRAM",
58 "WINGUIAPP",
59 "WINAPP",
60 "LIBRARY",
61 "WINLIB",
62 "UNITTEST",
63 "ACTIVEPROJECT",
64 "ID",
65 "FILEPATH",
66 "ASSIGN",
67 "SEMICOLON",
68 "DOT"
69 };
70
71 const char* GetTokenName(int tokenId)
72 {
73 return tokenName[tokenId];
74 }
75
76 const char* tokenInfo[] =
77 {
78 "end of file",
79 "'project'",
80 "'solution'",
81 "'reference'",
82 "'source'",
83 "'resource'",
84 "'text'",
85 "'target'",
86 "'program'",
87 "'winguiapp'",
88 "'winapp'",
89 "'library'",
90 "'winlib'",
91 "'unitTest'",
92 "'activeProject'",
93 "identifier",
94 "file path",
95 "'='",
96 "';'",
97 "'.'"
98 };
99
100 const char* GetTokenInfo(int tokenId)
101 {
102 return tokenInfo[tokenId];
103 }
104
105 struct Initializer
106 {
107 Initializer() { InitTokenIdMap(); }
108 };
109
110 Initializer initializer;
111 }