|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2001-2004 Roberto Raggi |
|
4 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
5 ** All rights reserved. |
|
6 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
7 ** |
|
8 ** This file is part of the qt3to4 porting application of the Qt Toolkit. |
|
9 ** |
|
10 ** $QT_BEGIN_LICENSE:LGPL$ |
|
11 ** No Commercial Usage |
|
12 ** This file contains pre-release code and may not be distributed. |
|
13 ** You may use this file in accordance with the terms and conditions |
|
14 ** contained in the Technology Preview License Agreement accompanying |
|
15 ** this package. |
|
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, Nokia gives you certain additional |
|
26 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
28 ** |
|
29 ** If you have questions regarding the use of this file, please contact |
|
30 ** Nokia at qt-info@nokia.com. |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** |
|
39 ** $QT_END_LICENSE$ |
|
40 ** |
|
41 ****************************************************************************/ |
|
42 |
|
43 #include "cpplexer.h" |
|
44 #include <QChar> |
|
45 #include <ctype.h> |
|
46 |
|
47 QT_BEGIN_NAMESPACE |
|
48 |
|
49 using namespace TokenEngine; |
|
50 |
|
51 CppLexer::CppLexer() |
|
52 : m_buffer(0), m_ptr(0), m_len(0) |
|
53 { |
|
54 setupScanTable(); |
|
55 } |
|
56 |
|
57 void CppLexer::setupScanTable() |
|
58 { |
|
59 s_scan_keyword_table[0] = &CppLexer::scanKeyword0; |
|
60 s_scan_keyword_table[1] = &CppLexer::scanKeyword0; |
|
61 s_scan_keyword_table[2] = &CppLexer::scanKeyword2; |
|
62 s_scan_keyword_table[3] = &CppLexer::scanKeyword3; |
|
63 s_scan_keyword_table[4] = &CppLexer::scanKeyword4; |
|
64 s_scan_keyword_table[5] = &CppLexer::scanKeyword5; |
|
65 s_scan_keyword_table[6] = &CppLexer::scanKeyword6; |
|
66 s_scan_keyword_table[7] = &CppLexer::scanKeyword7; |
|
67 s_scan_keyword_table[8] = &CppLexer::scanKeyword8; |
|
68 s_scan_keyword_table[9] = &CppLexer::scanKeyword9; |
|
69 s_scan_keyword_table[10] = &CppLexer::scanKeyword10; |
|
70 s_scan_keyword_table[11] = &CppLexer::scanKeyword11; |
|
71 s_scan_keyword_table[12] = &CppLexer::scanKeyword12; |
|
72 s_scan_keyword_table[13] = &CppLexer::scanKeyword0; |
|
73 s_scan_keyword_table[14] = &CppLexer::scanKeyword14; |
|
74 s_scan_keyword_table[15] = &CppLexer::scanKeyword0; |
|
75 s_scan_keyword_table[16] = &CppLexer::scanKeyword16; |
|
76 |
|
77 memset(s_attr_table, 0, 256); |
|
78 |
|
79 for (int i=0; i<128; ++i) { |
|
80 switch (i) { |
|
81 case ':': |
|
82 case '*': |
|
83 case '/': |
|
84 case '%': |
|
85 case '^': |
|
86 case '=': |
|
87 case '!': |
|
88 case '&': |
|
89 case '|': |
|
90 case '+': |
|
91 case '<': |
|
92 case '>': |
|
93 case '-': |
|
94 case '.': |
|
95 s_scan_table[i] = &CppLexer::scanOperator; |
|
96 break; |
|
97 |
|
98 case '\r': |
|
99 case '\n': |
|
100 s_scan_table[i] = &CppLexer::scanNewline; |
|
101 break; |
|
102 |
|
103 case '\'': |
|
104 s_scan_table[i] = &CppLexer::scanCharLiteral; |
|
105 break; |
|
106 |
|
107 case '"': |
|
108 s_scan_table[i] = &CppLexer::scanStringLiteral; |
|
109 break; |
|
110 |
|
111 default: |
|
112 if (isspace(i)) { |
|
113 s_scan_table[i] = &CppLexer::scanWhiteSpaces; |
|
114 s_attr_table[i] |= A_Whitespace; |
|
115 } else if (isalpha(i) || i == '_') { |
|
116 s_scan_table[i] = &CppLexer::scanIdentifier; |
|
117 s_attr_table[i] |= A_Alpha; |
|
118 } else if (isdigit(i)) { |
|
119 s_scan_table[i] = &CppLexer::scanNumberLiteral; |
|
120 s_attr_table[i] |= A_Digit; |
|
121 } else |
|
122 s_scan_table[i] = &CppLexer::scanChar; |
|
123 } |
|
124 } |
|
125 |
|
126 s_scan_table[128] = &CppLexer::scanUnicodeChar; |
|
127 } |
|
128 |
|
129 QVector<Type> CppLexer::lex(TokenSectionSequence tokenSectionSequence) |
|
130 { |
|
131 QVector<Type> tokenTypes; |
|
132 tokenTypes.reserve(tokenSectionSequence.count()); |
|
133 TokenSectionSequenceIterator it(tokenSectionSequence); |
|
134 while(it.nextToken()) { |
|
135 tokenTypes.append(identify(it.tokenTempRef())); |
|
136 } |
|
137 return tokenTypes; |
|
138 } |
|
139 |
|
140 Type CppLexer::identify(const TokenTempRef &tokenTempRef) |
|
141 { |
|
142 Q_ASSERT(tokenTempRef.length() >= 0 ); |
|
143 m_buffer = tokenTempRef.constData(); |
|
144 m_len = tokenTempRef.length(); |
|
145 m_ptr = 0; |
|
146 const unsigned char ch = m_buffer[0]; |
|
147 int kind = 0; |
|
148 (this->*s_scan_table[ch < 128 ? ch : 128])(&kind); |
|
149 return (Type)kind; |
|
150 } |
|
151 |
|
152 void CppLexer::scanKeyword0(int *kind) |
|
153 { |
|
154 *kind = Token_identifier; |
|
155 } |
|
156 |
|
157 void CppLexer::scanKeyword2(int *kind) |
|
158 { |
|
159 switch (m_buffer[m_ptr]) { |
|
160 case 'i': |
|
161 if (m_buffer[m_ptr+1] == 'f') |
|
162 { |
|
163 *kind = Token_if; |
|
164 return; |
|
165 } |
|
166 break; |
|
167 |
|
168 case 'd': |
|
169 if (m_buffer[m_ptr+1] == 'o') |
|
170 { |
|
171 *kind = Token_do; |
|
172 return; |
|
173 } |
|
174 break; |
|
175 |
|
176 case 'o': |
|
177 if (m_buffer[m_ptr+1] == 'r') |
|
178 { |
|
179 *kind = Token_or; |
|
180 return; |
|
181 } |
|
182 break; |
|
183 |
|
184 } |
|
185 *kind = Token_identifier; |
|
186 } |
|
187 |
|
188 void CppLexer::scanKeyword3(int *kind) |
|
189 { |
|
190 switch (m_buffer[m_ptr]) { |
|
191 case 'a': |
|
192 if (m_buffer[m_ptr+1] == 'n' && |
|
193 m_buffer[m_ptr+2] == 'd') |
|
194 { |
|
195 *kind = Token_and; |
|
196 return; |
|
197 } |
|
198 if (m_buffer[m_ptr+1] == 's' && |
|
199 m_buffer[m_ptr+2] == 'm') |
|
200 { |
|
201 *kind = Token_asm; |
|
202 return; |
|
203 } |
|
204 break; |
|
205 |
|
206 case 'f': |
|
207 if (m_buffer[m_ptr+1] == 'o' && |
|
208 m_buffer[m_ptr+2] == 'r') |
|
209 { |
|
210 *kind = Token_for; |
|
211 return; |
|
212 } |
|
213 break; |
|
214 |
|
215 case 'i': |
|
216 if (m_buffer[m_ptr+1] == 'n' && |
|
217 m_buffer[m_ptr+2] == 't') |
|
218 { |
|
219 *kind = Token_int; |
|
220 return; |
|
221 } |
|
222 break; |
|
223 |
|
224 case 'n': |
|
225 if (m_buffer[m_ptr+1] == 'e' && |
|
226 m_buffer[m_ptr+2] == 'w') |
|
227 { |
|
228 *kind = Token_new; |
|
229 return; |
|
230 } |
|
231 if (m_buffer[m_ptr+1] == 'o' && |
|
232 m_buffer[m_ptr+2] == 't') |
|
233 { |
|
234 *kind = Token_not; |
|
235 return; |
|
236 } |
|
237 break; |
|
238 |
|
239 case 't': |
|
240 if (m_buffer[m_ptr+1] == 'r' && |
|
241 m_buffer[m_ptr+2] == 'y') |
|
242 { |
|
243 *kind = Token_try; |
|
244 return; |
|
245 } |
|
246 break; |
|
247 |
|
248 case 'x': |
|
249 if (m_buffer[m_ptr+1] == 'o' && |
|
250 m_buffer[m_ptr+2] == 'r') |
|
251 { |
|
252 *kind = Token_xor; |
|
253 return; |
|
254 } |
|
255 break; |
|
256 |
|
257 } |
|
258 *kind = Token_identifier; |
|
259 } |
|
260 |
|
261 void CppLexer::scanKeyword4(int *kind) |
|
262 { |
|
263 switch (m_buffer[m_ptr]) { |
|
264 case 'a': |
|
265 if (m_buffer[m_ptr+1] == 'u' && |
|
266 m_buffer[m_ptr+2] == 't' && |
|
267 m_buffer[m_ptr+3] == 'o') |
|
268 { |
|
269 *kind = Token_auto; |
|
270 return; |
|
271 } |
|
272 break; |
|
273 |
|
274 case 'c': |
|
275 if (m_buffer[m_ptr+1] == 'a' && |
|
276 m_buffer[m_ptr+2] == 's' && |
|
277 m_buffer[m_ptr+3] == 'e') |
|
278 { |
|
279 *kind = Token_case; |
|
280 return; |
|
281 } |
|
282 if (m_buffer[m_ptr+1] == 'h' && |
|
283 m_buffer[m_ptr+2] == 'a' && |
|
284 m_buffer[m_ptr+3] == 'r') |
|
285 { |
|
286 *kind = Token_char; |
|
287 return; |
|
288 } |
|
289 break; |
|
290 |
|
291 case 'b': |
|
292 if (m_buffer[m_ptr+1] == 'o' && |
|
293 m_buffer[m_ptr+2] == 'o' && |
|
294 m_buffer[m_ptr+3] == 'l') |
|
295 { |
|
296 *kind = Token_bool; |
|
297 return; |
|
298 } |
|
299 break; |
|
300 |
|
301 case 'e': |
|
302 if (m_buffer[m_ptr+1] == 'l' && |
|
303 m_buffer[m_ptr+2] == 's' && |
|
304 m_buffer[m_ptr+3] == 'e') |
|
305 { |
|
306 *kind = Token_else; |
|
307 return; |
|
308 } |
|
309 if (m_buffer[m_ptr+1] == 'm' && |
|
310 m_buffer[m_ptr+2] == 'i' && |
|
311 m_buffer[m_ptr+3] == 't') |
|
312 { |
|
313 *kind = Token_emit; |
|
314 return; |
|
315 } |
|
316 if (m_buffer[m_ptr+1] == 'n' && |
|
317 m_buffer[m_ptr+2] == 'u' && |
|
318 m_buffer[m_ptr+3] == 'm') |
|
319 { |
|
320 *kind = Token_enum; |
|
321 return; |
|
322 } |
|
323 break; |
|
324 |
|
325 case 'g': |
|
326 if (m_buffer[m_ptr+1] == 'o' && |
|
327 m_buffer[m_ptr+2] == 't' && |
|
328 m_buffer[m_ptr+3] == 'o') |
|
329 { |
|
330 *kind = Token_goto; |
|
331 return; |
|
332 } |
|
333 break; |
|
334 |
|
335 case 'l': |
|
336 if (m_buffer[m_ptr+1] == 'o' && |
|
337 m_buffer[m_ptr+2] == 'n' && |
|
338 m_buffer[m_ptr+3] == 'g') |
|
339 { |
|
340 *kind = Token_long; |
|
341 return; |
|
342 } |
|
343 break; |
|
344 |
|
345 case 't': |
|
346 if (m_buffer[m_ptr+1] == 'h' && |
|
347 m_buffer[m_ptr+2] == 'i' && |
|
348 m_buffer[m_ptr+3] == 's') |
|
349 { |
|
350 *kind = Token_this; |
|
351 return; |
|
352 } |
|
353 break; |
|
354 |
|
355 case 'v': |
|
356 if (m_buffer[m_ptr+1] == 'o' && |
|
357 m_buffer[m_ptr+2] == 'i' && |
|
358 m_buffer[m_ptr+3] == 'd') |
|
359 { |
|
360 *kind = Token_void; |
|
361 return; |
|
362 } |
|
363 break; |
|
364 |
|
365 } |
|
366 *kind = Token_identifier; |
|
367 } |
|
368 |
|
369 void CppLexer::scanKeyword5(int *kind) |
|
370 { |
|
371 switch (m_buffer[m_ptr]) { |
|
372 case 'c': |
|
373 if (m_buffer[m_ptr+1] == 'a' && |
|
374 m_buffer[m_ptr+2] == 't' && |
|
375 m_buffer[m_ptr+3] == 'c' && |
|
376 m_buffer[m_ptr+4] == 'h') |
|
377 { |
|
378 *kind = Token_catch; |
|
379 return; |
|
380 } |
|
381 if (m_buffer[m_ptr+1] == 'l' && |
|
382 m_buffer[m_ptr+2] == 'a' && |
|
383 m_buffer[m_ptr+3] == 's' && |
|
384 m_buffer[m_ptr+4] == 's') |
|
385 { |
|
386 *kind = Token_class; |
|
387 return; |
|
388 } |
|
389 if (m_buffer[m_ptr+1] == 'o' && |
|
390 m_buffer[m_ptr+2] == 'm' && |
|
391 m_buffer[m_ptr+3] == 'p' && |
|
392 m_buffer[m_ptr+4] == 'l') |
|
393 { |
|
394 *kind = Token_compl; |
|
395 return; |
|
396 } |
|
397 if (m_buffer[m_ptr+1] == 'o' && |
|
398 m_buffer[m_ptr+2] == 'n' && |
|
399 m_buffer[m_ptr+3] == 's' && |
|
400 m_buffer[m_ptr+4] == 't') |
|
401 { |
|
402 *kind = Token_const; |
|
403 return; |
|
404 } |
|
405 break; |
|
406 |
|
407 case 'b': |
|
408 if (m_buffer[m_ptr+1] == 'i' && |
|
409 m_buffer[m_ptr+2] == 't' && |
|
410 m_buffer[m_ptr+3] == 'o' && |
|
411 m_buffer[m_ptr+4] == 'r') |
|
412 { |
|
413 *kind = Token_bitor; |
|
414 return; |
|
415 } |
|
416 if (m_buffer[m_ptr+1] == 'r' && |
|
417 m_buffer[m_ptr+2] == 'e' && |
|
418 m_buffer[m_ptr+3] == 'a' && |
|
419 m_buffer[m_ptr+4] == 'k') |
|
420 { |
|
421 *kind = Token_break; |
|
422 return; |
|
423 } |
|
424 break; |
|
425 |
|
426 case 'f': |
|
427 if (m_buffer[m_ptr+1] == 'l' && |
|
428 m_buffer[m_ptr+2] == 'o' && |
|
429 m_buffer[m_ptr+3] == 'a' && |
|
430 m_buffer[m_ptr+4] == 't') |
|
431 { |
|
432 *kind = Token_float; |
|
433 return; |
|
434 } |
|
435 break; |
|
436 |
|
437 case 'o': |
|
438 if (m_buffer[m_ptr+1] == 'r' && |
|
439 m_buffer[m_ptr+2] == '_' && |
|
440 m_buffer[m_ptr+3] == 'e' && |
|
441 m_buffer[m_ptr+4] == 'q') |
|
442 { |
|
443 *kind = Token_or_eq; |
|
444 return; |
|
445 } |
|
446 break; |
|
447 |
|
448 case 's': |
|
449 if (m_buffer[m_ptr+1] == 'h' && |
|
450 m_buffer[m_ptr+2] == 'o' && |
|
451 m_buffer[m_ptr+3] == 'r' && |
|
452 m_buffer[m_ptr+4] == 't') |
|
453 { |
|
454 *kind = Token_short; |
|
455 return; |
|
456 } |
|
457 if (m_buffer[m_ptr+1] == 'l' && |
|
458 m_buffer[m_ptr+2] == 'o' && |
|
459 m_buffer[m_ptr+3] == 't' && |
|
460 m_buffer[m_ptr+4] == 's') |
|
461 { |
|
462 *kind = Token_slots; |
|
463 return; |
|
464 } |
|
465 break; |
|
466 |
|
467 case 'u': |
|
468 if (m_buffer[m_ptr+1] == 'n' && |
|
469 m_buffer[m_ptr+2] == 'i' && |
|
470 m_buffer[m_ptr+3] == 'o' && |
|
471 m_buffer[m_ptr+4] == 'n') |
|
472 { |
|
473 *kind = Token_union; |
|
474 return; |
|
475 } |
|
476 if (m_buffer[m_ptr+1] == 's' && |
|
477 m_buffer[m_ptr+2] == 'i' && |
|
478 m_buffer[m_ptr+3] == 'n' && |
|
479 m_buffer[m_ptr+4] == 'g') |
|
480 { |
|
481 *kind = Token_using; |
|
482 return; |
|
483 } |
|
484 break; |
|
485 |
|
486 case 't': |
|
487 if (m_buffer[m_ptr+1] == 'h' && |
|
488 m_buffer[m_ptr+2] == 'r' && |
|
489 m_buffer[m_ptr+3] == 'o' && |
|
490 m_buffer[m_ptr+4] == 'w') |
|
491 { |
|
492 *kind = Token_throw; |
|
493 return; |
|
494 } |
|
495 break; |
|
496 |
|
497 case 'w': |
|
498 if (m_buffer[m_ptr+1] == 'h' && |
|
499 m_buffer[m_ptr+2] == 'i' && |
|
500 m_buffer[m_ptr+3] == 'l' && |
|
501 m_buffer[m_ptr+4] == 'e') |
|
502 { |
|
503 *kind = Token_while; |
|
504 return; |
|
505 } |
|
506 break; |
|
507 |
|
508 } |
|
509 *kind = Token_identifier; |
|
510 } |
|
511 |
|
512 void CppLexer::scanKeyword6(int *kind) |
|
513 { |
|
514 switch (m_buffer[m_ptr]) { |
|
515 case 'a': |
|
516 if (m_buffer[m_ptr+1] == 'n' && |
|
517 m_buffer[m_ptr+2] == 'd' && |
|
518 m_buffer[m_ptr+3] == '_' && |
|
519 m_buffer[m_ptr+4] == 'e' && |
|
520 m_buffer[m_ptr+5] == 'q') |
|
521 { |
|
522 *kind = Token_and_eq; |
|
523 return; |
|
524 } |
|
525 break; |
|
526 |
|
527 case 'b': |
|
528 if (m_buffer[m_ptr+1] == 'i' && |
|
529 m_buffer[m_ptr+2] == 't' && |
|
530 m_buffer[m_ptr+3] == 'a' && |
|
531 m_buffer[m_ptr+4] == 'n' && |
|
532 m_buffer[m_ptr+5] == 'd') |
|
533 { |
|
534 *kind = Token_bitand; |
|
535 return; |
|
536 } |
|
537 break; |
|
538 |
|
539 case 'e': |
|
540 if (m_buffer[m_ptr+1] == 'x' && |
|
541 m_buffer[m_ptr+2] == 'p' && |
|
542 m_buffer[m_ptr+3] == 'o' && |
|
543 m_buffer[m_ptr+4] == 'r' && |
|
544 m_buffer[m_ptr+5] == 't') |
|
545 { |
|
546 *kind = Token_export; |
|
547 return; |
|
548 } |
|
549 if (m_buffer[m_ptr+1] == 'x' && |
|
550 m_buffer[m_ptr+2] == 't' && |
|
551 m_buffer[m_ptr+3] == 'e' && |
|
552 m_buffer[m_ptr+4] == 'r' && |
|
553 m_buffer[m_ptr+5] == 'n') |
|
554 { |
|
555 *kind = Token_extern; |
|
556 return; |
|
557 } |
|
558 break; |
|
559 |
|
560 case 'd': |
|
561 if (m_buffer[m_ptr+1] == 'e' && |
|
562 m_buffer[m_ptr+2] == 'l' && |
|
563 m_buffer[m_ptr+3] == 'e' && |
|
564 m_buffer[m_ptr+4] == 't' && |
|
565 m_buffer[m_ptr+5] == 'e') |
|
566 { |
|
567 *kind = Token_delete; |
|
568 return; |
|
569 } |
|
570 if (m_buffer[m_ptr+1] == 'o' && |
|
571 m_buffer[m_ptr+2] == 'u' && |
|
572 m_buffer[m_ptr+3] == 'b' && |
|
573 m_buffer[m_ptr+4] == 'l' && |
|
574 m_buffer[m_ptr+5] == 'e') |
|
575 { |
|
576 *kind = Token_double; |
|
577 return; |
|
578 } |
|
579 break; |
|
580 |
|
581 case 'f': |
|
582 if (m_buffer[m_ptr+1] == 'r' && |
|
583 m_buffer[m_ptr+2] == 'i' && |
|
584 m_buffer[m_ptr+3] == 'e' && |
|
585 m_buffer[m_ptr+4] == 'n' && |
|
586 m_buffer[m_ptr+5] == 'd') |
|
587 { |
|
588 *kind = Token_friend; |
|
589 return; |
|
590 } |
|
591 break; |
|
592 |
|
593 case 'i': |
|
594 if (m_buffer[m_ptr+1] == 'n' && |
|
595 m_buffer[m_ptr+2] == 'l' && |
|
596 m_buffer[m_ptr+3] == 'i' && |
|
597 m_buffer[m_ptr+4] == 'n' && |
|
598 m_buffer[m_ptr+5] == 'e') |
|
599 { |
|
600 *kind = Token_inline; |
|
601 return; |
|
602 } |
|
603 break; |
|
604 |
|
605 case 'K': |
|
606 if (m_buffer[m_ptr+1] == '_' && |
|
607 m_buffer[m_ptr+2] == 'D' && |
|
608 m_buffer[m_ptr+3] == 'C' && |
|
609 m_buffer[m_ptr+4] == 'O' && |
|
610 m_buffer[m_ptr+5] == 'P') |
|
611 { |
|
612 *kind = Token_K_DCOP; |
|
613 return; |
|
614 } |
|
615 break; |
|
616 |
|
617 case 'n': |
|
618 if (m_buffer[m_ptr+1] == 'o' && |
|
619 m_buffer[m_ptr+2] == 't' && |
|
620 m_buffer[m_ptr+3] == '_' && |
|
621 m_buffer[m_ptr+4] == 'e' && |
|
622 m_buffer[m_ptr+5] == 'q') |
|
623 { |
|
624 *kind = Token_not_eq; |
|
625 return; |
|
626 } |
|
627 break; |
|
628 |
|
629 case 'p': |
|
630 if (m_buffer[m_ptr+1] == 'u' && |
|
631 m_buffer[m_ptr+2] == 'b' && |
|
632 m_buffer[m_ptr+3] == 'l' && |
|
633 m_buffer[m_ptr+4] == 'i' && |
|
634 m_buffer[m_ptr+5] == 'c') |
|
635 { |
|
636 *kind = Token_public; |
|
637 return; |
|
638 } |
|
639 break; |
|
640 |
|
641 case 's': |
|
642 if (m_buffer[m_ptr+1] == 'i' && |
|
643 m_buffer[m_ptr+2] == 'g' && |
|
644 m_buffer[m_ptr+3] == 'n' && |
|
645 m_buffer[m_ptr+4] == 'e' && |
|
646 m_buffer[m_ptr+5] == 'd') |
|
647 { |
|
648 *kind = Token_signed; |
|
649 return; |
|
650 } |
|
651 if (m_buffer[m_ptr+1] == 'i' && |
|
652 m_buffer[m_ptr+2] == 'z' && |
|
653 m_buffer[m_ptr+3] == 'e' && |
|
654 m_buffer[m_ptr+4] == 'o' && |
|
655 m_buffer[m_ptr+5] == 'f') |
|
656 { |
|
657 *kind = Token_sizeof; |
|
658 return; |
|
659 } |
|
660 if (m_buffer[m_ptr+1] == 't' && |
|
661 m_buffer[m_ptr+2] == 'a' && |
|
662 m_buffer[m_ptr+3] == 't' && |
|
663 m_buffer[m_ptr+4] == 'i' && |
|
664 m_buffer[m_ptr+5] == 'c') |
|
665 { |
|
666 *kind = Token_static; |
|
667 return; |
|
668 } |
|
669 if (m_buffer[m_ptr+1] == 't' && |
|
670 m_buffer[m_ptr+2] == 'r' && |
|
671 m_buffer[m_ptr+3] == 'u' && |
|
672 m_buffer[m_ptr+4] == 'c' && |
|
673 m_buffer[m_ptr+5] == 't') |
|
674 { |
|
675 *kind = Token_struct; |
|
676 return; |
|
677 } |
|
678 if (m_buffer[m_ptr+1] == 'w' && |
|
679 m_buffer[m_ptr+2] == 'i' && |
|
680 m_buffer[m_ptr+3] == 't' && |
|
681 m_buffer[m_ptr+4] == 'c' && |
|
682 m_buffer[m_ptr+5] == 'h') |
|
683 { |
|
684 *kind = Token_switch; |
|
685 return; |
|
686 } |
|
687 break; |
|
688 |
|
689 case 'r': |
|
690 if (m_buffer[m_ptr+1] == 'e' && |
|
691 m_buffer[m_ptr+2] == 't' && |
|
692 m_buffer[m_ptr+3] == 'u' && |
|
693 m_buffer[m_ptr+4] == 'r' && |
|
694 m_buffer[m_ptr+5] == 'n') |
|
695 { |
|
696 *kind = Token_return; |
|
697 return; |
|
698 } |
|
699 break; |
|
700 |
|
701 case 't': |
|
702 if (m_buffer[m_ptr+1] == 'y' && |
|
703 m_buffer[m_ptr+2] == 'p' && |
|
704 m_buffer[m_ptr+3] == 'e' && |
|
705 m_buffer[m_ptr+4] == 'i' && |
|
706 m_buffer[m_ptr+5] == 'd') |
|
707 { |
|
708 *kind = Token_typeid; |
|
709 return; |
|
710 } |
|
711 break; |
|
712 |
|
713 case 'x': |
|
714 if (m_buffer[m_ptr+1] == 'o' && |
|
715 m_buffer[m_ptr+2] == 'r' && |
|
716 m_buffer[m_ptr+3] == '_' && |
|
717 m_buffer[m_ptr+4] == 'e' && |
|
718 m_buffer[m_ptr+5] == 'q') |
|
719 { |
|
720 *kind = Token_xor_eq; |
|
721 return; |
|
722 } |
|
723 break; |
|
724 |
|
725 case 'k': |
|
726 if (m_buffer[m_ptr+1] == '_' && |
|
727 m_buffer[m_ptr+2] == 'd' && |
|
728 m_buffer[m_ptr+3] == 'c' && |
|
729 m_buffer[m_ptr+4] == 'o' && |
|
730 m_buffer[m_ptr+5] == 'p') |
|
731 { |
|
732 *kind = Token_k_dcop; |
|
733 return; |
|
734 } |
|
735 break; |
|
736 |
|
737 } |
|
738 *kind = Token_identifier; |
|
739 } |
|
740 |
|
741 void CppLexer::scanKeyword7(int *kind) |
|
742 { |
|
743 switch (m_buffer[m_ptr]) { |
|
744 case 'd': |
|
745 if (m_buffer[m_ptr+1] == 'e' && |
|
746 m_buffer[m_ptr+2] == 'f' && |
|
747 m_buffer[m_ptr+3] == 'a' && |
|
748 m_buffer[m_ptr+4] == 'u' && |
|
749 m_buffer[m_ptr+5] == 'l' && |
|
750 m_buffer[m_ptr+6] == 't') |
|
751 { |
|
752 *kind = Token_default; |
|
753 return; |
|
754 } |
|
755 break; |
|
756 |
|
757 case 'm': |
|
758 if (m_buffer[m_ptr+1] == 'u' && |
|
759 m_buffer[m_ptr+2] == 't' && |
|
760 m_buffer[m_ptr+3] == 'a' && |
|
761 m_buffer[m_ptr+4] == 'b' && |
|
762 m_buffer[m_ptr+5] == 'l' && |
|
763 m_buffer[m_ptr+6] == 'e') |
|
764 { |
|
765 *kind = Token_mutable; |
|
766 return; |
|
767 } |
|
768 break; |
|
769 |
|
770 case 'p': |
|
771 if (m_buffer[m_ptr+1] == 'r' && |
|
772 m_buffer[m_ptr+2] == 'i' && |
|
773 m_buffer[m_ptr+3] == 'v' && |
|
774 m_buffer[m_ptr+4] == 'a' && |
|
775 m_buffer[m_ptr+5] == 't' && |
|
776 m_buffer[m_ptr+6] == 'e') |
|
777 { |
|
778 *kind = Token_private; |
|
779 return; |
|
780 } |
|
781 break; |
|
782 #if 0 |
|
783 case 's': |
|
784 if (m_buffer[m_ptr+1] == 'i' && |
|
785 m_buffer[m_ptr+2] == 'g' && |
|
786 m_buffer[m_ptr+3] == 'n' && |
|
787 m_buffer[m_ptr+4] == 'a' && |
|
788 m_buffer[m_ptr+5] == 'l' && |
|
789 m_buffer[m_ptr+6] == 's') |
|
790 { |
|
791 *kind = Token_signals; |
|
792 return; |
|
793 } |
|
794 break; |
|
795 #endif |
|
796 case 't': |
|
797 if (m_buffer[m_ptr+1] == 'y' && |
|
798 m_buffer[m_ptr+2] == 'p' && |
|
799 m_buffer[m_ptr+3] == 'e' && |
|
800 m_buffer[m_ptr+4] == 'd' && |
|
801 m_buffer[m_ptr+5] == 'e' && |
|
802 m_buffer[m_ptr+6] == 'f') |
|
803 { |
|
804 *kind = Token_typedef; |
|
805 return; |
|
806 } |
|
807 break; |
|
808 |
|
809 case 'v': |
|
810 if (m_buffer[m_ptr+1] == 'i' && |
|
811 m_buffer[m_ptr+2] == 'r' && |
|
812 m_buffer[m_ptr+3] == 't' && |
|
813 m_buffer[m_ptr+4] == 'u' && |
|
814 m_buffer[m_ptr+5] == 'a' && |
|
815 m_buffer[m_ptr+6] == 'l') |
|
816 { |
|
817 *kind = Token_virtual; |
|
818 return; |
|
819 } |
|
820 break; |
|
821 } |
|
822 *kind = Token_identifier; |
|
823 } |
|
824 |
|
825 void CppLexer::scanKeyword8(int *kind) |
|
826 { |
|
827 switch (m_buffer[m_ptr]) { |
|
828 case '_': |
|
829 if (m_buffer[m_ptr+1] == '_' && |
|
830 m_buffer[m_ptr+2] == 't' && |
|
831 m_buffer[m_ptr+3] == 'y' && |
|
832 m_buffer[m_ptr+4] == 'p' && |
|
833 m_buffer[m_ptr+5] == 'e' && |
|
834 m_buffer[m_ptr+6] == 'o' && |
|
835 m_buffer[m_ptr+7] == 'f') |
|
836 { |
|
837 *kind = Token___typeof; |
|
838 return; |
|
839 } |
|
840 break; |
|
841 |
|
842 case 'c': |
|
843 if (m_buffer[m_ptr+1] == 'o' && |
|
844 m_buffer[m_ptr+2] == 'n' && |
|
845 m_buffer[m_ptr+3] == 't' && |
|
846 m_buffer[m_ptr+4] == 'i' && |
|
847 m_buffer[m_ptr+5] == 'n' && |
|
848 m_buffer[m_ptr+6] == 'u' && |
|
849 m_buffer[m_ptr+7] == 'e') |
|
850 { |
|
851 *kind = Token_continue; |
|
852 return; |
|
853 } |
|
854 break; |
|
855 |
|
856 case 'e': |
|
857 if (m_buffer[m_ptr+1] == 'x' && |
|
858 m_buffer[m_ptr+2] == 'p' && |
|
859 m_buffer[m_ptr+3] == 'l' && |
|
860 m_buffer[m_ptr+4] == 'i' && |
|
861 m_buffer[m_ptr+5] == 'c' && |
|
862 m_buffer[m_ptr+6] == 'i' && |
|
863 m_buffer[m_ptr+7] == 't') |
|
864 { |
|
865 *kind = Token_explicit; |
|
866 return; |
|
867 } |
|
868 break; |
|
869 |
|
870 case 'o': |
|
871 if (m_buffer[m_ptr+1] == 'p' && |
|
872 m_buffer[m_ptr+2] == 'e' && |
|
873 m_buffer[m_ptr+3] == 'r' && |
|
874 m_buffer[m_ptr+4] == 'a' && |
|
875 m_buffer[m_ptr+5] == 't' && |
|
876 m_buffer[m_ptr+6] == 'o' && |
|
877 m_buffer[m_ptr+7] == 'r') |
|
878 { |
|
879 *kind = Token_operator; |
|
880 return; |
|
881 } |
|
882 break; |
|
883 |
|
884 case 'Q': |
|
885 if (m_buffer[m_ptr+1] == '_' && |
|
886 m_buffer[m_ptr+2] == 'O' && |
|
887 m_buffer[m_ptr+3] == 'B' && |
|
888 m_buffer[m_ptr+4] == 'J' && |
|
889 m_buffer[m_ptr+5] == 'E' && |
|
890 m_buffer[m_ptr+6] == 'C' && |
|
891 m_buffer[m_ptr+7] == 'T') |
|
892 { |
|
893 *kind = Token_Q_OBJECT; |
|
894 return; |
|
895 } |
|
896 break; |
|
897 |
|
898 case 'r': |
|
899 if (m_buffer[m_ptr+1] == 'e' && |
|
900 m_buffer[m_ptr+2] == 'g' && |
|
901 m_buffer[m_ptr+3] == 'i' && |
|
902 m_buffer[m_ptr+4] == 's' && |
|
903 m_buffer[m_ptr+5] == 't' && |
|
904 m_buffer[m_ptr+6] == 'e' && |
|
905 m_buffer[m_ptr+7] == 'r') |
|
906 { |
|
907 *kind = Token_register; |
|
908 return; |
|
909 } |
|
910 break; |
|
911 |
|
912 case 'u': |
|
913 if (m_buffer[m_ptr+1] == 'n' && |
|
914 m_buffer[m_ptr+2] == 's' && |
|
915 m_buffer[m_ptr+3] == 'i' && |
|
916 m_buffer[m_ptr+4] == 'g' && |
|
917 m_buffer[m_ptr+5] == 'n' && |
|
918 m_buffer[m_ptr+6] == 'e' && |
|
919 m_buffer[m_ptr+7] == 'd') |
|
920 { |
|
921 *kind = Token_unsigned; |
|
922 return; |
|
923 } |
|
924 break; |
|
925 |
|
926 case 't': |
|
927 if (m_buffer[m_ptr+1] == 'e' && |
|
928 m_buffer[m_ptr+2] == 'm' && |
|
929 m_buffer[m_ptr+3] == 'p' && |
|
930 m_buffer[m_ptr+4] == 'l' && |
|
931 m_buffer[m_ptr+5] == 'a' && |
|
932 m_buffer[m_ptr+6] == 't' && |
|
933 m_buffer[m_ptr+7] == 'e') |
|
934 { |
|
935 *kind = Token_template; |
|
936 return; |
|
937 } |
|
938 if (m_buffer[m_ptr+1] == 'y' && |
|
939 m_buffer[m_ptr+2] == 'p' && |
|
940 m_buffer[m_ptr+3] == 'e' && |
|
941 m_buffer[m_ptr+4] == 'n' && |
|
942 m_buffer[m_ptr+5] == 'a' && |
|
943 m_buffer[m_ptr+6] == 'm' && |
|
944 m_buffer[m_ptr+7] == 'e') |
|
945 { |
|
946 *kind = Token_typename; |
|
947 return; |
|
948 } |
|
949 break; |
|
950 |
|
951 case 'v': |
|
952 if (m_buffer[m_ptr+1] == 'o' && |
|
953 m_buffer[m_ptr+2] == 'l' && |
|
954 m_buffer[m_ptr+3] == 'a' && |
|
955 m_buffer[m_ptr+4] == 't' && |
|
956 m_buffer[m_ptr+5] == 'i' && |
|
957 m_buffer[m_ptr+6] == 'l' && |
|
958 m_buffer[m_ptr+7] == 'e') |
|
959 { |
|
960 *kind = Token_volatile; |
|
961 return; |
|
962 } |
|
963 break; |
|
964 |
|
965 } |
|
966 *kind = Token_identifier; |
|
967 } |
|
968 |
|
969 void CppLexer::scanKeyword9(int *kind) |
|
970 { |
|
971 switch (m_buffer[m_ptr]) { |
|
972 case 'p': |
|
973 if (m_buffer[m_ptr+1] == 'r' && |
|
974 m_buffer[m_ptr+2] == 'o' && |
|
975 m_buffer[m_ptr+3] == 't' && |
|
976 m_buffer[m_ptr+4] == 'e' && |
|
977 m_buffer[m_ptr+5] == 'c' && |
|
978 m_buffer[m_ptr+6] == 't' && |
|
979 m_buffer[m_ptr+7] == 'e' && |
|
980 m_buffer[m_ptr+8] == 'd') |
|
981 { |
|
982 *kind = Token_protected; |
|
983 return; |
|
984 } |
|
985 break; |
|
986 |
|
987 case 'n': |
|
988 if (m_buffer[m_ptr+1] == 'a' && |
|
989 m_buffer[m_ptr+2] == 'm' && |
|
990 m_buffer[m_ptr+3] == 'e' && |
|
991 m_buffer[m_ptr+4] == 's' && |
|
992 m_buffer[m_ptr+5] == 'p' && |
|
993 m_buffer[m_ptr+6] == 'a' && |
|
994 m_buffer[m_ptr+7] == 'c' && |
|
995 m_buffer[m_ptr+8] == 'e') |
|
996 { |
|
997 *kind = Token_namespace; |
|
998 return; |
|
999 } |
|
1000 break; |
|
1001 |
|
1002 } |
|
1003 *kind = Token_identifier; |
|
1004 } |
|
1005 |
|
1006 void CppLexer::scanKeyword10(int *kind) |
|
1007 { |
|
1008 switch (m_buffer[m_ptr]) { |
|
1009 case 'c': |
|
1010 if (m_buffer[m_ptr+1] == 'o' && |
|
1011 m_buffer[m_ptr+2] == 'n' && |
|
1012 m_buffer[m_ptr+3] == 's' && |
|
1013 m_buffer[m_ptr+4] == 't' && |
|
1014 m_buffer[m_ptr+5] == '_' && |
|
1015 m_buffer[m_ptr+6] == 'c' && |
|
1016 m_buffer[m_ptr+7] == 'a' && |
|
1017 m_buffer[m_ptr+8] == 's' && |
|
1018 m_buffer[m_ptr+9] == 't') |
|
1019 { |
|
1020 *kind = Token_const_cast; |
|
1021 return; |
|
1022 } |
|
1023 break; |
|
1024 |
|
1025 } |
|
1026 *kind = Token_identifier; |
|
1027 } |
|
1028 |
|
1029 void CppLexer::scanKeyword11(int *kind) |
|
1030 { |
|
1031 switch (m_buffer[m_ptr]) { |
|
1032 case 's': |
|
1033 if (m_buffer[m_ptr+1] == 't' && |
|
1034 m_buffer[m_ptr+2] == 'a' && |
|
1035 m_buffer[m_ptr+3] == 't' && |
|
1036 m_buffer[m_ptr+4] == 'i' && |
|
1037 m_buffer[m_ptr+5] == 'c' && |
|
1038 m_buffer[m_ptr+6] == '_' && |
|
1039 m_buffer[m_ptr+7] == 'c' && |
|
1040 m_buffer[m_ptr+8] == 'a' && |
|
1041 m_buffer[m_ptr+9] == 's' && |
|
1042 m_buffer[m_ptr+10] == 't') |
|
1043 { |
|
1044 *kind = Token_static_cast; |
|
1045 return; |
|
1046 } |
|
1047 break; |
|
1048 |
|
1049 } |
|
1050 *kind = Token_identifier; |
|
1051 } |
|
1052 |
|
1053 void CppLexer::scanKeyword12(int *kind) |
|
1054 { |
|
1055 switch (m_buffer[m_ptr]) { |
|
1056 case 'd': |
|
1057 if (m_buffer[m_ptr+1] == 'y' && |
|
1058 m_buffer[m_ptr+2] == 'n' && |
|
1059 m_buffer[m_ptr+3] == 'a' && |
|
1060 m_buffer[m_ptr+4] == 'm' && |
|
1061 m_buffer[m_ptr+5] == 'i' && |
|
1062 m_buffer[m_ptr+6] == 'c' && |
|
1063 m_buffer[m_ptr+7] == '_' && |
|
1064 m_buffer[m_ptr+8] == 'c' && |
|
1065 m_buffer[m_ptr+9] == 'a' && |
|
1066 m_buffer[m_ptr+10] == 's' && |
|
1067 m_buffer[m_ptr+11] == 't') |
|
1068 { |
|
1069 *kind = Token_dynamic_cast; |
|
1070 return; |
|
1071 } |
|
1072 break; |
|
1073 |
|
1074 } |
|
1075 *kind = Token_identifier; |
|
1076 } |
|
1077 |
|
1078 void CppLexer::scanKeyword14(int *kind) |
|
1079 { |
|
1080 switch (m_buffer[m_ptr]) { |
|
1081 case 'k': |
|
1082 if (m_buffer[m_ptr+1] == '_' && |
|
1083 m_buffer[m_ptr+2] == 'd' && |
|
1084 m_buffer[m_ptr+3] == 'c' && |
|
1085 m_buffer[m_ptr+4] == 'o' && |
|
1086 m_buffer[m_ptr+5] == 'p' && |
|
1087 m_buffer[m_ptr+6] == '_' && |
|
1088 m_buffer[m_ptr+7] == 's' && |
|
1089 m_buffer[m_ptr+8] == 'i' && |
|
1090 m_buffer[m_ptr+9] == 'g' && |
|
1091 m_buffer[m_ptr+10] == 'n' && |
|
1092 m_buffer[m_ptr+11] == 'a' && |
|
1093 m_buffer[m_ptr+12] == 'l' && |
|
1094 m_buffer[m_ptr+13] == 's') |
|
1095 { |
|
1096 *kind = Token_k_dcop_signals; |
|
1097 return; |
|
1098 } |
|
1099 break; |
|
1100 |
|
1101 } |
|
1102 *kind = Token_identifier; |
|
1103 } |
|
1104 |
|
1105 void CppLexer::scanKeyword16(int *kind) |
|
1106 { |
|
1107 switch (m_buffer[m_ptr]) { |
|
1108 case 'r': |
|
1109 if (m_buffer[m_ptr+1] == 'e' && |
|
1110 m_buffer[m_ptr+2] == 'i' && |
|
1111 m_buffer[m_ptr+3] == 'n' && |
|
1112 m_buffer[m_ptr+4] == 't' && |
|
1113 m_buffer[m_ptr+5] == 'e' && |
|
1114 m_buffer[m_ptr+6] == 'r' && |
|
1115 m_buffer[m_ptr+7] == 'p' && |
|
1116 m_buffer[m_ptr+8] == 'r' && |
|
1117 m_buffer[m_ptr+9] == 'e' && |
|
1118 m_buffer[m_ptr+10] == 't' && |
|
1119 m_buffer[m_ptr+11] == '_' && |
|
1120 m_buffer[m_ptr+12] == 'c' && |
|
1121 m_buffer[m_ptr+13] == 'a' && |
|
1122 m_buffer[m_ptr+14] == 's' && |
|
1123 m_buffer[m_ptr+15] == 't') |
|
1124 { |
|
1125 *kind = Token_reinterpret_cast; |
|
1126 return; |
|
1127 } |
|
1128 break; |
|
1129 |
|
1130 } |
|
1131 *kind = Token_identifier; |
|
1132 } |
|
1133 |
|
1134 |
|
1135 |
|
1136 void CppLexer::scanChar(int *kind) |
|
1137 { |
|
1138 *kind = m_buffer[m_ptr++]; |
|
1139 } |
|
1140 |
|
1141 void CppLexer::scanWhiteSpaces(int *kind) |
|
1142 { |
|
1143 *kind = Token_whitespaces; |
|
1144 } |
|
1145 |
|
1146 void CppLexer::scanNewline(int *kind) |
|
1147 { |
|
1148 *kind = '\n'; |
|
1149 } |
|
1150 |
|
1151 void CppLexer::scanUnicodeChar(int *kind) |
|
1152 { |
|
1153 *kind = m_buffer[0]; |
|
1154 } |
|
1155 |
|
1156 void CppLexer::scanCharLiteral(int *kind) |
|
1157 { |
|
1158 *kind = Token_char_literal; |
|
1159 } |
|
1160 |
|
1161 void CppLexer::scanStringLiteral(int *kind) |
|
1162 { |
|
1163 *kind = Token_string_literal; |
|
1164 } |
|
1165 |
|
1166 void CppLexer::scanIdentifier(int *kind) |
|
1167 { |
|
1168 if (m_len <16) |
|
1169 (this->*s_scan_keyword_table[m_len])(kind); |
|
1170 else |
|
1171 (this->*s_scan_keyword_table[0])(kind); |
|
1172 } |
|
1173 |
|
1174 void CppLexer::scanNumberLiteral(int *kind) |
|
1175 { |
|
1176 *kind = Token_number_literal; |
|
1177 } |
|
1178 |
|
1179 void CppLexer::scanOperator(int *kind) |
|
1180 { |
|
1181 switch (m_buffer[m_ptr]) { |
|
1182 case ':': |
|
1183 if (m_buffer[m_ptr+1] == ':') { |
|
1184 *kind = Token_scope; |
|
1185 return; |
|
1186 } |
|
1187 break; |
|
1188 |
|
1189 case '*': |
|
1190 case '/': |
|
1191 case '%': |
|
1192 case '^': |
|
1193 if (m_buffer[m_ptr+1] == '=') { |
|
1194 *kind = Token_assign; |
|
1195 return; |
|
1196 } |
|
1197 break; |
|
1198 |
|
1199 case '=': |
|
1200 case '!': |
|
1201 if (m_buffer[m_ptr+1] == '=') { |
|
1202 *kind = Token_eq; |
|
1203 return; |
|
1204 } |
|
1205 break; |
|
1206 |
|
1207 case '&': |
|
1208 if (m_buffer[m_ptr+1] == '&') { |
|
1209 *kind = Token_and; |
|
1210 return; |
|
1211 } else if (m_buffer[m_ptr+1] == '=') { |
|
1212 *kind = Token_assign; |
|
1213 return; |
|
1214 } |
|
1215 break; |
|
1216 |
|
1217 case '|': |
|
1218 if (m_buffer[m_ptr+1] == '|' ) { |
|
1219 *kind = Token_or; |
|
1220 return; |
|
1221 } else if (m_buffer[m_ptr+1] == '=') { |
|
1222 *kind = Token_assign; |
|
1223 return; |
|
1224 } |
|
1225 break; |
|
1226 |
|
1227 case '+': |
|
1228 if (m_buffer[m_ptr+1] == '+' ) { |
|
1229 *kind = Token_incr; |
|
1230 return; |
|
1231 } else if (m_buffer[m_ptr+1] == '=') { |
|
1232 *kind = Token_assign; |
|
1233 return; |
|
1234 } |
|
1235 break; |
|
1236 |
|
1237 case '<': |
|
1238 if (m_buffer[m_ptr+1] == '<') { |
|
1239 if (m_buffer[m_ptr+2] == '=') { |
|
1240 *kind = Token_assign; |
|
1241 return; |
|
1242 } |
|
1243 *kind = Token_shift; |
|
1244 return; |
|
1245 } else if (m_buffer[m_ptr+1] == '=') { |
|
1246 *kind = Token_leq; |
|
1247 return; |
|
1248 } |
|
1249 break; |
|
1250 |
|
1251 case '>': |
|
1252 if (m_buffer[m_ptr+1] == '>') { |
|
1253 if (m_buffer[m_ptr+2] == '=') { |
|
1254 *kind = Token_assign; |
|
1255 return; |
|
1256 } |
|
1257 *kind = Token_shift; |
|
1258 return; |
|
1259 } else if (m_buffer[m_ptr+1] == '=') { |
|
1260 *kind = Token_geq; |
|
1261 return; |
|
1262 } |
|
1263 break; |
|
1264 |
|
1265 case '-': |
|
1266 if (m_buffer[m_ptr+1] == '>') { |
|
1267 if (m_buffer[m_ptr+2] == '*') { |
|
1268 *kind = Token_ptrmem; |
|
1269 return; |
|
1270 } |
|
1271 *kind = Token_arrow; |
|
1272 return; |
|
1273 } else if (m_buffer[m_ptr+1] == '-') { |
|
1274 *kind = Token_decr; |
|
1275 return; |
|
1276 } else if (m_buffer[m_ptr+1] == '=') { |
|
1277 *kind = Token_assign; |
|
1278 return; |
|
1279 } |
|
1280 break; |
|
1281 |
|
1282 case '.': |
|
1283 if (m_buffer[m_ptr+1] == '.' && m_buffer[m_ptr+2] == '.') { |
|
1284 *kind = Token_ellipsis; |
|
1285 return; |
|
1286 } else if (m_buffer[m_ptr+1] == '*') { |
|
1287 *kind = Token_ptrmem; |
|
1288 return; |
|
1289 } |
|
1290 break; |
|
1291 |
|
1292 } |
|
1293 |
|
1294 *kind = m_buffer[m_ptr++]; |
|
1295 } |
|
1296 |
|
1297 QT_END_NAMESPACE |