Qt 4.8
qtokenlookup.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtXmlPatterns module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 /* C++ code produced by gperf version 3.0.3 */
42 /* Command-line: gperf TokenLookup.gperf */
43 /* Computed positions: -k'1,3,$' */
44 
45 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
46  && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
47  && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
48  && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
49  && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
50  && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
51  && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
52  && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
53  && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
54  && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
55  && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
56  && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
57  && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
58  && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
59  && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
60  && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
61  && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
62  && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
63  && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
64  && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
65  && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
66  && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
67  && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
68 /* The character set is not based on ISO-646. */
69 #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
70 #endif
71 
72 #line 107 "TokenLookup.gperf"
73 
74 
76 
77 namespace QPatternist
78 {
79 
80 #line 101 "TokenLookup.gperf"
81 struct TokenMap
82 {
83  const char *name;
85 }
86 
87 
88 /* The strings below are in UTF-16 encoding. Subsequently, each ASCII
89  * character is stored as the ASCII character, followed by a null byte.
90  * Sorted alphabetically. */;
91 /* maximum key range = 228, duplicates = 0 */
92 
94 {
95 private:
96  static inline unsigned int hash (const char *str, unsigned int len);
97 public:
98  static const struct TokenMap *value (const char *str, unsigned int len);
99 };
100 
101 inline unsigned int
102 TokenLookup::hash (register const char *str, register unsigned int len)
103 {
104  static const unsigned char asso_values[] =
105  {
106  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
107  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
108  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
109  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
110  230, 230, 230, 230, 230, 25, 230, 230, 230, 230,
111  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
112  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
113  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
114  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
115  230, 230, 230, 230, 230, 230, 230, 0, 2, 5,
116  25, 0, 20, 20, 35, 85, 230, 230, 40, 110,
117  25, 65, 80, 0, 60, 5, 10, 0, 55, 5,
118  20, 0, 230, 230, 230, 230, 230, 230, 230, 230,
119  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
120  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
121  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
122  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
123  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
124  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
125  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
126  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
127  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
128  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
129  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
130  230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
131  230, 230, 230, 230, 230, 230
132  };
133  register int hval = len;
134 
135  switch (hval)
136  {
137  default:
138  hval += asso_values[(unsigned char)str[2]];
139  /*FALLTHROUGH*/
140  case 2:
141  case 1:
142  hval += asso_values[(unsigned char)str[0]];
143  break;
144  }
145  return hval + asso_values[(unsigned char)str[len - 1]];
146 }
147 
148 const struct TokenMap *
149 TokenLookup::value (register const char *str, register unsigned int len)
150 {
151  enum
152  {
153  TOTAL_KEYWORDS = 99,
154  MIN_WORD_LENGTH = 2,
155  MAX_WORD_LENGTH = 22,
156  MIN_HASH_VALUE = 2,
157  MAX_HASH_VALUE = 229
158  };
159 
160  static const struct TokenMap wordlist[] =
161  {
162  {"",ERROR}, {"",ERROR},
163 #line 152 "TokenLookup.gperf"
164  {"eq", EQ},
165  {"",ERROR},
166 #line 130 "TokenLookup.gperf"
167  {"by", BY},
168 #line 153 "TokenLookup.gperf"
169  {"every", EVERY},
170  {"",ERROR},
171 #line 123 "TokenLookup.gperf"
172  {"as", AS},
173  {"",ERROR},
174 #line 148 "TokenLookup.gperf"
175  {"else", ELSE},
176 #line 217 "TokenLookup.gperf"
177  {"where", WHERE},
178 #line 204 "TokenLookup.gperf"
179  {"stable", STABLE},
180 #line 126 "TokenLookup.gperf"
181  {"at", AT},
182  {"",ERROR},
183 #line 131 "TokenLookup.gperf"
184  {"case", CASE},
185  {"",ERROR},
186 #line 129 "TokenLookup.gperf"
187  {"boundary-space", BOUNDARY_SPACE},
188 #line 147 "TokenLookup.gperf"
189  {"element", ELEMENT},
190 #line 132 "TokenLookup.gperf"
191  {"castable", CASTABLE},
192 #line 127 "TokenLookup.gperf"
193  {"attribute", ATTRIBUTE},
194  {"",ERROR},
195 #line 154 "TokenLookup.gperf"
196  {"except", EXCEPT},
197 #line 161 "TokenLookup.gperf"
198  {"ge", GE},
199  {"",ERROR},
200 #line 133 "TokenLookup.gperf"
201  {"cast", CAST},
202 #line 210 "TokenLookup.gperf"
203  {"treat", TREAT},
204 #line 218 "TokenLookup.gperf"
205  {"xquery", XQUERY},
206 #line 181 "TokenLookup.gperf"
207  {"ne", NE},
208  {"",ERROR},
209 #line 198 "TokenLookup.gperf"
210  {"satisfies", SATISFIES},
211  {"",ERROR}, {"",ERROR},
212 #line 163 "TokenLookup.gperf"
213  {"gt", GT},
214 #line 151 "TokenLookup.gperf"
215  {"encoding", ENCODING},
216 #line 124 "TokenLookup.gperf"
217  {"ascending", ASCENDING},
218  {"",ERROR},
219 #line 125 "TokenLookup.gperf"
220  {"assign", ASSIGN},
221 #line 139 "TokenLookup.gperf"
222  {"declare", DECLARE},
223 #line 162 "TokenLookup.gperf"
224  {"greatest", GREATEST},
225 #line 208 "TokenLookup.gperf"
226  {"then", THEN},
227  {"",ERROR},
228 #line 121 "TokenLookup.gperf"
229  {"ancestor-or-self", ANCESTOR_OR_SELF},
230 #line 175 "TokenLookup.gperf"
231  {"le", LE},
232 #line 146 "TokenLookup.gperf"
233  {"document-node", DOCUMENT_NODE},
234 #line 207 "TokenLookup.gperf"
235  {"text", TEXT},
236  {"",ERROR},
237 #line 201 "TokenLookup.gperf"
238  {"schema", SCHEMA},
239  {"",ERROR},
240 #line 145 "TokenLookup.gperf"
241  {"document", DOCUMENT},
242  {"",ERROR},
243 #line 141 "TokenLookup.gperf"
244  {"descendant", DESCENDANT},
245  {"",ERROR},
246 #line 177 "TokenLookup.gperf"
247  {"lt", LT},
248 #line 122 "TokenLookup.gperf"
249  {"and", AND},
250 #line 182 "TokenLookup.gperf"
251  {"node", NODE},
252 #line 174 "TokenLookup.gperf"
253  {"least", LEAST},
254 #line 199 "TokenLookup.gperf"
255  {"schema-attribute", SCHEMA_ATTRIBUTE},
256  {"",ERROR},
257 #line 155 "TokenLookup.gperf"
258  {"external", EXTERNAL},
259  {"",ERROR},
260 #line 143 "TokenLookup.gperf"
261  {"descending", DESCENDING},
262 #line 184 "TokenLookup.gperf"
263  {"no-preserve", NO_PRESERVE},
264 #line 140 "TokenLookup.gperf"
265  {"default", DEFAULT},
266 #line 176 "TokenLookup.gperf"
267  {"let", LET},
268 #line 200 "TokenLookup.gperf"
269  {"schema-element", SCHEMA_ELEMENT},
270  {"",ERROR}, {"",ERROR},
271 #line 137 "TokenLookup.gperf"
272  {"construction", CONSTRUCTION},
273 #line 142 "TokenLookup.gperf"
274  {"descendant-or-self", DESCENDANT_OR_SELF},
275 #line 202 "TokenLookup.gperf"
276  {"self", SELF},
277 #line 183 "TokenLookup.gperf"
278  {"no-inherit", NO_INHERIT},
279  {"",ERROR},
280 #line 158 "TokenLookup.gperf"
281  {"follows", FOLLOWS},
282 #line 120 "TokenLookup.gperf"
283  {"ancestor", ANCESTOR},
284  {"",ERROR}, {"",ERROR}, {"",ERROR},
285 #line 209 "TokenLookup.gperf"
286  {"to", TO},
287 #line 160 "TokenLookup.gperf"
288  {"function", FUNCTION},
289 #line 135 "TokenLookup.gperf"
290  {"collation", COLLATION},
291  {"",ERROR},
292 #line 205 "TokenLookup.gperf"
293  {"strict", STRICT},
294  {"",ERROR},
295 #line 173 "TokenLookup.gperf"
296  {"lax", LAX},
297  {"",ERROR},
298 #line 149 "TokenLookup.gperf"
299  {"empty", EMPTY},
300  {"",ERROR},
301 #line 185 "TokenLookup.gperf"
302  {"of", OF},
303 #line 195 "TokenLookup.gperf"
304  {"preserve", PRESERVE},
305 #line 156 "TokenLookup.gperf"
306  {"following", FOLLOWING},
307  {"",ERROR}, {"",ERROR},
308 #line 171 "TokenLookup.gperf"
309  {"is", IS},
310 #line 192 "TokenLookup.gperf"
311  {"precedes", PRECEDES},
312 #line 150 "TokenLookup.gperf"
313  {"empty-sequence", EMPTY_SEQUENCE},
314  {"",ERROR}, {"",ERROR},
315 #line 157 "TokenLookup.gperf"
316  {"following-sibling", FOLLOWING_SIBLING},
317 #line 169 "TokenLookup.gperf"
318  {"instance", INSTANCE},
319 #line 213 "TokenLookup.gperf"
320  {"unordered", UNORDERED},
321 #line 128 "TokenLookup.gperf"
322  {"base-uri", BASEURI},
323 #line 197 "TokenLookup.gperf"
324  {"return", RETURN},
325  {"",ERROR},
326 #line 214 "TokenLookup.gperf"
327  {"validate", VALIDATE},
328  {"",ERROR},
329 #line 138 "TokenLookup.gperf"
330  {"copy-namespaces", COPY_NAMESPACES},
331 #line 186 "TokenLookup.gperf"
332  {"option", OPTION},
333 #line 165 "TokenLookup.gperf"
334  {"if", IF},
335  {"",ERROR},
336 #line 193 "TokenLookup.gperf"
337  {"preceding", PRECEDING},
338  {"",ERROR}, {"",ERROR},
339 #line 168 "TokenLookup.gperf"
340  {"in", IN},
341  {"",ERROR},
342 #line 170 "TokenLookup.gperf"
343  {"intersect", INTERSECT},
344 #line 212 "TokenLookup.gperf"
345  {"union", UNION},
346  {"",ERROR},
347 #line 194 "TokenLookup.gperf"
348  {"preceding-sibling", PRECEDING_SIBLING},
349 #line 188 "TokenLookup.gperf"
350  {"ordering", ORDERING},
351 #line 203 "TokenLookup.gperf"
352  {"some", SOME},
353 #line 134 "TokenLookup.gperf"
354  {"child", CHILD},
355  {"",ERROR},
356 #line 187 "TokenLookup.gperf"
357  {"ordered", ORDERED},
358 #line 215 "TokenLookup.gperf"
359  {"variable", VARIABLE},
360  {"",ERROR}, {"",ERROR}, {"",ERROR},
361 #line 190 "TokenLookup.gperf"
362  {"or", OR},
363  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
364 #line 136 "TokenLookup.gperf"
365  {"comment", COMMENT},
366  {"",ERROR}, {"",ERROR},
367 #line 211 "TokenLookup.gperf"
368  {"typeswitch", TYPESWITCH},
369  {"",ERROR},
370 #line 167 "TokenLookup.gperf"
371  {"inherit", INHERIT},
372 #line 144 "TokenLookup.gperf"
373  {"div", DIV},
374  {"",ERROR}, {"",ERROR},
375 #line 179 "TokenLookup.gperf"
376  {"module", MODULE},
377  {"",ERROR},
378 #line 159 "TokenLookup.gperf"
379  {"for", FOR},
380 #line 180 "TokenLookup.gperf"
381  {"namespace", NAMESPACE},
382  {"",ERROR}, {"",ERROR},
383 #line 216 "TokenLookup.gperf"
384  {"version", VERSION},
385  {"",ERROR}, {"",ERROR},
386 #line 206 "TokenLookup.gperf"
387  {"strip", STRIP},
388  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
389 #line 189 "TokenLookup.gperf"
390  {"order", ORDER},
391 #line 191 "TokenLookup.gperf"
392  {"parent", PARENT},
393  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
394  {"",ERROR}, {"",ERROR},
395 #line 178 "TokenLookup.gperf"
396  {"mod", MOD},
397  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
398  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
399  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
400  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
401  {"",ERROR},
402 #line 166 "TokenLookup.gperf"
403  {"import", IMPORT},
404  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
405  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
406  {"",ERROR}, {"",ERROR},
407 #line 196 "TokenLookup.gperf"
408  {"processing-instruction", PROCESSING_INSTRUCTION},
409  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
410  {"",ERROR}, {"",ERROR},
411 #line 172 "TokenLookup.gperf"
412  {"item", ITEM},
413  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
414  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
415  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
416  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
417  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
418  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
419  {"",ERROR}, {"",ERROR}, {"",ERROR}, {"",ERROR},
420  {"",ERROR},
421 #line 164 "TokenLookup.gperf"
422  {"idiv", IDIV}
423  };
424 
425  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
426  {
427  register int key = hash (str, len);
428 
429  if (key <= MAX_HASH_VALUE && key >= 0)
430  {
431  register const char *s = wordlist[key].name;
432 
433  if (*str == *s && !strcmp (str + 1, s + 1))
434  return &wordlist[key];
435  }
436  }
437  return 0;
438 }
439 #line 219 "TokenLookup.gperf"
440 
441 
442 } /* Close the QPatternist namespace. */
443 
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
static unsigned int hash(const char *str, unsigned int len)
const Tokenizer::TokenType token
The namespace for the internal API of QtXmlPatterns.
static const struct TokenMap * value(const char *str, unsigned int len)
int key