1 using System;
2
3 namespace XPathTokens
4 {
5 public const int END = 0;
6 public const int OR = 1;
7 public const int AND = 2;
8 public const int EQ = 3;
9 public const int NEQ = 4;
10 public const int LEQ = 5;
11 public const int GEQ = 6;
12 public const int LESS = 7;
13 public const int GREATER = 8;
14 public const int PLUS = 9;
15 public const int MINUS = 10;
16 public const int STAR = 11;
17 public const int DIV = 12;
18 public const int MOD = 13;
19 public const int UNION = 14;
20 public const int SLASHSLASH = 15;
21 public const int SLASH = 16;
22 public const int DOTDOT = 17;
23 public const int DOT = 18;
24 public const int COLONCOLON = 19;
25 public const int COLON = 20;
26 public const int DOLLAR = 21;
27 public const int COMMA = 22;
28 public const int ANCESTOR = 23;
29 public const int ANCESTOR_OR_SELF = 24;
30 public const int ATTRIBUTE = 25;
31 public const int CHILD = 26;
32 public const int DESCENDANT = 27;
33 public const int DESCENDANT_OR_SELF = 28;
34 public const int FOLLOWING = 29;
35 public const int FOLLOWING_SIBLING = 30;
36 public const int NAMESPACE = 31;
37 public const int PARENT = 32;
38 public const int PRECEDING = 33;
39 public const int PRECEDING_SIBLING = 34;
40 public const int SELF = 35;
41 public const int AT = 36;
42 public const int LBRACKET = 37;
43 public const int RBRACKET = 38;
44 public const int PROCESSING_INSTRUCTION = 39;
45 public const int LPAREN = 40;
46 public const int RPAREN = 41;
47 public const int COMMENT = 42;
48 public const int TEXT = 43;
49 public const int NODE = 44;
50 public const int DQSTRING = 45;
51 public const int SQSTRING = 46;
52 public const int NUMBER = 47;
53 public const int NAME = 48;
54 internal class TokenMap
55 {
56 static TokenMap() :
57 instance(new TokenMap())
58 {
59 }
60 public static TokenMap& Instance()
61 {
62 return *instance;
63 }
64 public int GetTokenId(const ustring& tokenName)
65 {
66 System.Collections.Map<ustring, int>.ConstIterator it = tokenIdMap.CFind(tokenName);
67 if (it != tokenIdMap.CEnd())
68 {
69 return it->second;
70 }
71 else
72 {
73 return -1;
74 }
75 }
76 public ustring GetTokenName(int tokenId)
77 {
78 return tokenNameList[tokenId];
79 }
80 public ustring GetTokenInfo(int tokenId)
81 {
82 return tokenInfoList[tokenId];
83 }
84 private TokenMap()
85 {
86 tokenIdMap[u"ANCESTOR"] = 23;
87 tokenIdMap[u"ANCESTOR_OR_SELF"] = 24;
88 tokenIdMap[u"AND"] = 2;
89 tokenIdMap[u"AT"] = 36;
90 tokenIdMap[u"ATTRIBUTE"] = 25;
91 tokenIdMap[u"CHILD"] = 26;
92 tokenIdMap[u"COLON"] = 20;
93 tokenIdMap[u"COLONCOLON"] = 19;
94 tokenIdMap[u"COMMA"] = 22;
95 tokenIdMap[u"COMMENT"] = 42;
96 tokenIdMap[u"DESCENDANT"] = 27;
97 tokenIdMap[u"DESCENDANT_OR_SELF"] = 28;
98 tokenIdMap[u"DIV"] = 12;
99 tokenIdMap[u"DOLLAR"] = 21;
100 tokenIdMap[u"DOT"] = 18;
101 tokenIdMap[u"DOTDOT"] = 17;
102 tokenIdMap[u"DQSTRING"] = 45;
103 tokenIdMap[u"EQ"] = 3;
104 tokenIdMap[u"FOLLOWING"] = 29;
105 tokenIdMap[u"FOLLOWING_SIBLING"] = 30;
106 tokenIdMap[u"GEQ"] = 6;
107 tokenIdMap[u"GREATER"] = 8;
108 tokenIdMap[u"LBRACKET"] = 37;
109 tokenIdMap[u"LEQ"] = 5;
110 tokenIdMap[u"LESS"] = 7;
111 tokenIdMap[u"LPAREN"] = 40;
112 tokenIdMap[u"MINUS"] = 10;
113 tokenIdMap[u"MOD"] = 13;
114 tokenIdMap[u"NAME"] = 48;
115 tokenIdMap[u"NAMESPACE"] = 31;
116 tokenIdMap[u"NEQ"] = 4;
117 tokenIdMap[u"NODE"] = 44;
118 tokenIdMap[u"NUMBER"] = 47;
119 tokenIdMap[u"OR"] = 1;
120 tokenIdMap[u"PARENT"] = 32;
121 tokenIdMap[u"PLUS"] = 9;
122 tokenIdMap[u"PRECEDING"] = 33;
123 tokenIdMap[u"PRECEDING_SIBLING"] = 34;
124 tokenIdMap[u"PROCESSING_INSTRUCTION"] = 39;
125 tokenIdMap[u"RBRACKET"] = 38;
126 tokenIdMap[u"RPAREN"] = 41;
127 tokenIdMap[u"SELF"] = 35;
128 tokenIdMap[u"SLASH"] = 16;
129 tokenIdMap[u"SLASHSLASH"] = 15;
130 tokenIdMap[u"SQSTRING"] = 46;
131 tokenIdMap[u"STAR"] = 11;
132 tokenIdMap[u"TEXT"] = 43;
133 tokenIdMap[u"UNION"] = 14;
134 tokenNameList.Add(u"END");
135 tokenInfoList.Add(u"end of file");
136 tokenNameList.Add(u"OR");
137 tokenInfoList.Add(u"\'or\'");
138 tokenNameList.Add(u"AND");
139 tokenInfoList.Add(u"\'and\'");
140 tokenNameList.Add(u"EQ");
141 tokenInfoList.Add(u"\'=\'");
142 tokenNameList.Add(u"NEQ");
143 tokenInfoList.Add(u"\'!=\'");
144 tokenNameList.Add(u"LEQ");
145 tokenInfoList.Add(u"\'<=\'");
146 tokenNameList.Add(u"GEQ");
147 tokenInfoList.Add(u"\'>=\'");
148 tokenNameList.Add(u"LESS");
149 tokenInfoList.Add(u"\'<\'");
150 tokenNameList.Add(u"GREATER");
151 tokenInfoList.Add(u"\'>\'");
152 tokenNameList.Add(u"PLUS");
153 tokenInfoList.Add(u"\'+\'");
154 tokenNameList.Add(u"MINUS");
155 tokenInfoList.Add(u"\'-\'");
156 tokenNameList.Add(u"STAR");
157 tokenInfoList.Add(u"\'*");
158 tokenNameList.Add(u"DIV");
159 tokenInfoList.Add(u"\'div\'");
160 tokenNameList.Add(u"MOD");
161 tokenInfoList.Add(u"\'mod\'");
162 tokenNameList.Add(u"UNION");
163 tokenInfoList.Add(u"\'|\'");
164 tokenNameList.Add(u"SLASHSLASH");
165 tokenInfoList.Add(u"\'//\'");
166 tokenNameList.Add(u"SLASH");
167 tokenInfoList.Add(u"\'/\'");
168 tokenNameList.Add(u"DOTDOT");
169 tokenInfoList.Add(u"\'..\'");
170 tokenNameList.Add(u"DOT");
171 tokenInfoList.Add(u"\'.\'");
172 tokenNameList.Add(u"COLONCOLON");
173 tokenInfoList.Add(u"\'::\'");
174 tokenNameList.Add(u"COLON");
175 tokenInfoList.Add(u"\':\'");
176 tokenNameList.Add(u"DOLLAR");
177 tokenInfoList.Add(u"\'$\'");
178 tokenNameList.Add(u"COMMA");
179 tokenInfoList.Add(u"\',\'");
180 tokenNameList.Add(u"ANCESTOR");
181 tokenInfoList.Add(u"\'ancestor\'");
182 tokenNameList.Add(u"ANCESTOR_OR_SELF");
183 tokenInfoList.Add(u"\'ancestor-or-self\'");
184 tokenNameList.Add(u"ATTRIBUTE");
185 tokenInfoList.Add(u"\'attribute\'");
186 tokenNameList.Add(u"CHILD");
187 tokenInfoList.Add(u"\'child\'");
188 tokenNameList.Add(u"DESCENDANT");
189 tokenInfoList.Add(u"\'descendant\'");
190 tokenNameList.Add(u"DESCENDANT_OR_SELF");
191 tokenInfoList.Add(u"\'descendant-or-self\'");
192 tokenNameList.Add(u"FOLLOWING");
193 tokenInfoList.Add(u"\'following\'");
194 tokenNameList.Add(u"FOLLOWING_SIBLING");
195 tokenInfoList.Add(u"\'following-sibling\'");
196 tokenNameList.Add(u"NAMESPACE");
197 tokenInfoList.Add(u"\'namespace\'");
198 tokenNameList.Add(u"PARENT");
199 tokenInfoList.Add(u"\'parent\'");
200 tokenNameList.Add(u"PRECEDING");
201 tokenInfoList.Add(u"\'preceding\'");
202 tokenNameList.Add(u"PRECEDING_SIBLING");
203 tokenInfoList.Add(u"\'preceding-sibling\'");
204 tokenNameList.Add(u"SELF");
205 tokenInfoList.Add(u"\'self\'");
206 tokenNameList.Add(u"AT");
207 tokenInfoList.Add(u"\'@\'");
208 tokenNameList.Add(u"LBRACKET");
209 tokenInfoList.Add(u"\'[\'");
210 tokenNameList.Add(u"RBRACKET");
211 tokenInfoList.Add(u"\']\'");
212 tokenNameList.Add(u"PROCESSING_INSTRUCTION");
213 tokenInfoList.Add(u"\'processing-instruction\'");
214 tokenNameList.Add(u"LPAREN");
215 tokenInfoList.Add(u"\'(\'");
216 tokenNameList.Add(u"RPAREN");
217 tokenInfoList.Add(u"\')\'");
218 tokenNameList.Add(u"COMMENT");
219 tokenInfoList.Add(u"\'comment\'");
220 tokenNameList.Add(u"TEXT");
221 tokenInfoList.Add(u"\'text\'");
222 tokenNameList.Add(u"NODE");
223 tokenInfoList.Add(u"\'node\'");
224 tokenNameList.Add(u"DQSTRING");
225 tokenInfoList.Add(u"string");
226 tokenNameList.Add(u"SQSTRING");
227 tokenInfoList.Add(u"string");
228 tokenNameList.Add(u"NUMBER");
229 tokenInfoList.Add(u"number");
230 tokenNameList.Add(u"NAME");
231 tokenInfoList.Add(u"name");
232 }
233 private static System.UniquePtr<TokenMap> instance;
234 private System.Collections.Map<ustring, int> tokenIdMap;
235 private System.Collections.List<ustring> tokenNameList;
236 private System.Collections.List<ustring> tokenInfoList;
237 }
238 public int GetTokenId(const ustring& tokenName)
239 {
240 return TokenMap.Instance().GetTokenId(tokenName);
241 }
242 public ustring GetTokenName(int tokenId)
243 {
244 return TokenMap.Instance().GetTokenName(tokenId);
245 }
246 public ustring GetTokenInfo(int tokenId)
247 {
248 return TokenMap.Instance().GetTokenInfo(tokenId);
249 }
250 }