1
2 /***************************************************************************************
3 * Copyright (c) Jonas Bonér, Alexandre Vasseur. All rights reserved. *
4 * http://aspectwerkz.codehaus.org *
5 * ---------------------------------------------------------------------------------- *
6 * The software in this package is published under the terms of the LGPL license *
7 * a copy of which has been included with this distribution in the license.txt file. *
8 **************************************************************************************/
9 package org.codehaus.aspectwerkz.annotation.expression.ast;
10 import java.lang.reflect.Modifier;
11 import java.io.Reader;
12 import java.io.StringReader;
13
14 public class AnnotationParserTokenManager implements AnnotationParserConstants
15 {
16 public static java.io.PrintStream debugStream = System.out;
17 public static void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
18 private static final int jjStopStringLiteralDfa_0(int pos, long active0)
19 {
20 switch (pos)
21 {
22 case 0:
23 if ((active0 & 0x8L) != 0L)
24 return 5;
25 return -1;
26 default :
27 return -1;
28 }
29 }
30 private static final int jjStartNfa_0(int pos, long active0)
31 {
32 return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
33 }
34 static private final int jjStopAtPos(int pos, int kind)
35 {
36 jjmatchedKind = kind;
37 jjmatchedPos = pos;
38 return pos + 1;
39 }
40 static private final int jjStartNfaWithStates_0(int pos, int kind, int state)
41 {
42 jjmatchedKind = kind;
43 jjmatchedPos = pos;
44 try { curChar = input_stream.readChar(); }
45 catch(java.io.IOException e) { return pos + 1; }
46 return jjMoveNfa_0(state, pos + 1);
47 }
48 static private final int jjMoveStringLiteralDfa0_0()
49 {
50 switch(curChar)
51 {
52 case 10:
53 return jjStopAtPos(0, 13);
54 case 13:
55 return jjMoveStringLiteralDfa1_0(0x4000000L);
56 case 40:
57 return jjStopAtPos(0, 14);
58 case 41:
59 return jjStopAtPos(0, 15);
60 case 44:
61 return jjStopAtPos(0, 18);
62 case 46:
63 return jjStartNfaWithStates_0(0, 3, 5);
64 case 61:
65 return jjStopAtPos(0, 19);
66 case 123:
67 return jjStopAtPos(0, 16);
68 case 125:
69 return jjStopAtPos(0, 17);
70 default :
71 return jjMoveNfa_0(0, 0);
72 }
73 }
74 static private final int jjMoveStringLiteralDfa1_0(long active0)
75 {
76 try { curChar = input_stream.readChar(); }
77 catch(java.io.IOException e) {
78 jjStopStringLiteralDfa_0(0, active0);
79 return 1;
80 }
81 switch(curChar)
82 {
83 case 10:
84 if ((active0 & 0x4000000L) != 0L)
85 return jjStopAtPos(1, 26);
86 break;
87 default :
88 break;
89 }
90 return jjStartNfa_0(0, active0);
91 }
92 static private final void jjCheckNAdd(int state)
93 {
94 if (jjrounds[state] != jjround)
95 {
96 jjstateSet[jjnewStateCnt++] = state;
97 jjrounds[state] = jjround;
98 }
99 }
100 static private final void jjAddStates(int start, int end)
101 {
102 do {
103 jjstateSet[jjnewStateCnt++] = jjnextStates[start];
104 } while (start++ != end);
105 }
106 static private final void jjCheckNAddTwoStates(int state1, int state2)
107 {
108 jjCheckNAdd(state1);
109 jjCheckNAdd(state2);
110 }
111 static private final void jjCheckNAddStates(int start, int end)
112 {
113 do {
114 jjCheckNAdd(jjnextStates[start]);
115 } while (start++ != end);
116 }
117 static private final void jjCheckNAddStates(int start)
118 {
119 jjCheckNAdd(jjnextStates[start]);
120 jjCheckNAdd(jjnextStates[start + 1]);
121 }
122 static final long[] jjbitVec0 = {
123 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
124 };
125 static private final int jjMoveNfa_0(int startState, int curPos)
126 {
127 int[] nextStates;
128 int startsAt = 0;
129 jjnewStateCnt = 60;
130 int i = 1;
131 jjstateSet[0] = startState;
132 int j, kind = 0x7fffffff;
133 for (;;)
134 {
135 if (++jjround == 0x7fffffff)
136 ReInitRounds();
137 if (curChar < 64)
138 {
139 long l = 1L << curChar;
140 MatchLoop: do
141 {
142 switch(jjstateSet[--i])
143 {
144 case 0:
145 if ((0x3ff081800000000L & l) != 0L)
146 {
147 if (kind > 22)
148 kind = 22;
149 jjCheckNAddTwoStates(36, 37);
150 }
151 else if (curChar == 39)
152 jjstateSet[jjnewStateCnt++] = 30;
153 else if (curChar == 34)
154 jjCheckNAddTwoStates(27, 28);
155 else if (curChar == 46)
156 jjCheckNAdd(5);
157 else if (curChar == 45)
158 jjstateSet[jjnewStateCnt++] = 1;
159 if ((0x3ff000000000000L & l) != 0L)
160 jjCheckNAddStates(0, 6);
161 if ((0x3fe000000000000L & l) != 0L)
162 {
163 if (kind > 4)
164 kind = 4;
165 jjCheckNAddTwoStates(2, 3);
166 }
167 else if (curChar == 48)
168 {
169 if (kind > 4)
170 kind = 4;
171 jjCheckNAddStates(7, 9);
172 }
173 break;
174 case 1:
175 if ((0x3fe000000000000L & l) == 0L)
176 break;
177 if (kind > 4)
178 kind = 4;
179 jjCheckNAddTwoStates(2, 3);
180 break;
181 case 2:
182 if ((0x3ff000000000000L & l) == 0L)
183 break;
184 if (kind > 4)
185 kind = 4;
186 jjCheckNAddTwoStates(2, 3);
187 break;
188 case 4:
189 if (curChar == 46)
190 jjCheckNAdd(5);
191 break;
192 case 5:
193 if ((0x3ff000000000000L & l) == 0L)
194 break;
195 if (kind > 7)
196 kind = 7;
197 jjCheckNAddStates(10, 12);
198 break;
199 case 7:
200 if ((0x280000000000L & l) != 0L)
201 jjCheckNAdd(8);
202 break;
203 case 8:
204 if ((0x3ff000000000000L & l) == 0L)
205 break;
206 if (kind > 7)
207 kind = 7;
208 jjCheckNAddTwoStates(8, 9);
209 break;
210 case 26:
211 if (curChar == 34)
212 jjCheckNAddTwoStates(27, 28);
213 break;
214 case 27:
215 if ((0xfffffffbffffdbffL & l) != 0L)
216 jjCheckNAddTwoStates(27, 28);
217 break;
218 case 28:
219 if (curChar == 34 && kind > 11)
220 kind = 11;
221 break;
222 case 29:
223 if (curChar == 39)
224 jjstateSet[jjnewStateCnt++] = 30;
225 break;
226 case 30:
227 if ((0xfffffffbffffdbffL & l) != 0L)
228 jjstateSet[jjnewStateCnt++] = 31;
229 break;
230 case 31:
231 if (curChar == 39 && kind > 12)
232 kind = 12;
233 break;
234 case 33:
235 if ((0x3ff081800000000L & l) == 0L)
236 break;
237 if (kind > 21)
238 kind = 21;
239 jjCheckNAddTwoStates(33, 34);
240 break;
241 case 34:
242 if (curChar == 46)
243 jjCheckNAdd(35);
244 break;
245 case 35:
246 if ((0x3ff081800000000L & l) == 0L)
247 break;
248 if (kind > 21)
249 kind = 21;
250 jjCheckNAddTwoStates(34, 35);
251 break;
252 case 36:
253 if ((0x3ff081800000000L & l) == 0L)
254 break;
255 if (kind > 22)
256 kind = 22;
257 jjCheckNAddTwoStates(36, 37);
258 break;
259 case 37:
260 if (curChar == 46)
261 jjCheckNAdd(38);
262 break;
263 case 38:
264 if ((0x3ff081800000000L & l) == 0L)
265 break;
266 if (kind > 22)
267 kind = 22;
268 jjCheckNAddTwoStates(37, 38);
269 break;
270 case 39:
271 if ((0x3ff000000000000L & l) != 0L)
272 jjCheckNAddStates(0, 6);
273 break;
274 case 40:
275 if ((0x3ff000000000000L & l) != 0L)
276 jjCheckNAddTwoStates(40, 41);
277 break;
278 case 41:
279 if (curChar != 46)
280 break;
281 if (kind > 7)
282 kind = 7;
283 jjCheckNAddStates(13, 15);
284 break;
285 case 42:
286 if ((0x3ff000000000000L & l) == 0L)
287 break;
288 if (kind > 7)
289 kind = 7;
290 jjCheckNAddStates(13, 15);
291 break;
292 case 44:
293 if ((0x280000000000L & l) != 0L)
294 jjCheckNAdd(45);
295 break;
296 case 45:
297 if ((0x3ff000000000000L & l) == 0L)
298 break;
299 if (kind > 7)
300 kind = 7;
301 jjCheckNAddTwoStates(45, 9);
302 break;
303 case 46:
304 if ((0x3ff000000000000L & l) != 0L)
305 jjCheckNAddTwoStates(46, 47);
306 break;
307 case 48:
308 if ((0x280000000000L & l) != 0L)
309 jjCheckNAdd(49);
310 break;
311 case 49:
312 if ((0x3ff000000000000L & l) == 0L)
313 break;
314 if (kind > 7)
315 kind = 7;
316 jjCheckNAddTwoStates(49, 9);
317 break;
318 case 50:
319 if ((0x3ff000000000000L & l) != 0L)
320 jjCheckNAddStates(16, 18);
321 break;
322 case 52:
323 if ((0x280000000000L & l) != 0L)
324 jjCheckNAdd(53);
325 break;
326 case 53:
327 if ((0x3ff000000000000L & l) != 0L)
328 jjCheckNAddTwoStates(53, 9);
329 break;
330 case 54:
331 if (curChar != 48)
332 break;
333 if (kind > 4)
334 kind = 4;
335 jjCheckNAddStates(7, 9);
336 break;
337 case 56:
338 if ((0x3ff000000000000L & l) == 0L)
339 break;
340 if (kind > 5)
341 kind = 5;
342 jjAddStates(19, 20);
343 break;
344 case 58:
345 if ((0xff000000000000L & l) == 0L)
346 break;
347 if (kind > 6)
348 kind = 6;
349 jjCheckNAddTwoStates(58, 59);
350 break;
351 default : break;
352 }
353 } while(i != startsAt);
354 }
355 else if (curChar < 128)
356 {
357 long l = 1L << (curChar & 077);
358 MatchLoop: do
359 {
360 switch(jjstateSet[--i])
361 {
362 case 0:
363 if ((0x7fffffe87fffffeL & l) != 0L)
364 {
365 if (kind > 22)
366 kind = 22;
367 jjCheckNAddTwoStates(36, 37);
368 }
369 else if (curChar == 64)
370 jjCheckNAdd(33);
371 if (curChar == 70)
372 jjstateSet[jjnewStateCnt++] = 24;
373 else if (curChar == 84)
374 jjstateSet[jjnewStateCnt++] = 20;
375 else if (curChar == 102)
376 jjstateSet[jjnewStateCnt++] = 16;
377 else if (curChar == 116)
378 jjstateSet[jjnewStateCnt++] = 12;
379 break;
380 case 3:
381 if ((0x100000001000L & l) != 0L && kind > 4)
382 kind = 4;
383 break;
384 case 6:
385 if ((0x2000000020L & l) != 0L)
386 jjAddStates(21, 22);
387 break;
388 case 9:
389 if ((0x5000000050L & l) != 0L && kind > 7)
390 kind = 7;
391 break;
392 case 10:
393 if (curChar == 101 && kind > 10)
394 kind = 10;
395 break;
396 case 11:
397 if (curChar == 117)
398 jjCheckNAdd(10);
399 break;
400 case 12:
401 if (curChar == 114)
402 jjstateSet[jjnewStateCnt++] = 11;
403 break;
404 case 13:
405 if (curChar == 116)
406 jjstateSet[jjnewStateCnt++] = 12;
407 break;
408 case 14:
409 if (curChar == 115)
410 jjCheckNAdd(10);
411 break;
412 case 15:
413 if (curChar == 108)
414 jjstateSet[jjnewStateCnt++] = 14;
415 break;
416 case 16:
417 if (curChar == 97)
418 jjstateSet[jjnewStateCnt++] = 15;
419 break;
420 case 17:
421 if (curChar == 102)
422 jjstateSet[jjnewStateCnt++] = 16;
423 break;
424 case 18:
425 if (curChar == 69 && kind > 10)
426 kind = 10;
427 break;
428 case 19:
429 if (curChar == 85)
430 jjCheckNAdd(18);
431 break;
432 case 20:
433 if (curChar == 82)
434 jjstateSet[jjnewStateCnt++] = 19;
435 break;
436 case 21:
437 if (curChar == 84)
438 jjstateSet[jjnewStateCnt++] = 20;
439 break;
440 case 22:
441 if (curChar == 83)
442 jjCheckNAdd(18);
443 break;
444 case 23:
445 if (curChar == 76)
446 jjstateSet[jjnewStateCnt++] = 22;
447 break;
448 case 24:
449 if (curChar == 65)
450 jjstateSet[jjnewStateCnt++] = 23;
451 break;
452 case 25:
453 if (curChar == 70)
454 jjstateSet[jjnewStateCnt++] = 24;
455 break;
456 case 27:
457 if ((0xffffffffefffffffL & l) != 0L)
458 jjAddStates(23, 24);
459 break;
460 case 30:
461 if ((0xffffffffefffffffL & l) != 0L)
462 jjstateSet[jjnewStateCnt++] = 31;
463 break;
464 case 32:
465 if (curChar == 64)
466 jjCheckNAdd(33);
467 break;
468 case 33:
469 if ((0x7fffffe87fffffeL & l) == 0L)
470 break;
471 if (kind > 21)
472 kind = 21;
473 jjCheckNAddTwoStates(33, 34);
474 break;
475 case 35:
476 if ((0x7fffffe87fffffeL & l) == 0L)
477 break;
478 if (kind > 21)
479 kind = 21;
480 jjCheckNAddTwoStates(34, 35);
481 break;
482 case 36:
483 if ((0x7fffffe87fffffeL & l) == 0L)
484 break;
485 if (kind > 22)
486 kind = 22;
487 jjCheckNAddTwoStates(36, 37);
488 break;
489 case 38:
490 if ((0x7fffffe87fffffeL & l) == 0L)
491 break;
492 if (kind > 22)
493 kind = 22;
494 jjCheckNAddTwoStates(37, 38);
495 break;
496 case 43:
497 if ((0x2000000020L & l) != 0L)
498 jjAddStates(25, 26);
499 break;
500 case 47:
501 if ((0x2000000020L & l) != 0L)
502 jjAddStates(27, 28);
503 break;
504 case 51:
505 if ((0x2000000020L & l) != 0L)
506 jjAddStates(29, 30);
507 break;
508 case 55:
509 if ((0x100000001000000L & l) != 0L)
510 jjCheckNAdd(56);
511 break;
512 case 56:
513 if ((0x7e0000007eL & l) == 0L)
514 break;
515 if (kind > 5)
516 kind = 5;
517 jjCheckNAddTwoStates(56, 57);
518 break;
519 case 57:
520 if ((0x100000001000L & l) != 0L && kind > 5)
521 kind = 5;
522 break;
523 case 59:
524 if ((0x100000001000L & l) != 0L && kind > 6)
525 kind = 6;
526 break;
527 default : break;
528 }
529 } while(i != startsAt);
530 }
531 else
532 {
533 int i2 = (curChar & 0xff) >> 6;
534 long l2 = 1L << (curChar & 077);
535 MatchLoop: do
536 {
537 switch(jjstateSet[--i])
538 {
539 case 27:
540 if ((jjbitVec0[i2] & l2) != 0L)
541 jjAddStates(23, 24);
542 break;
543 case 30:
544 if ((jjbitVec0[i2] & l2) != 0L)
545 jjstateSet[jjnewStateCnt++] = 31;
546 break;
547 default : break;
548 }
549 } while(i != startsAt);
550 }
551 if (kind != 0x7fffffff)
552 {
553 jjmatchedKind = kind;
554 jjmatchedPos = curPos;
555 kind = 0x7fffffff;
556 }
557 ++curPos;
558 if ((i = jjnewStateCnt) == (startsAt = 60 - (jjnewStateCnt = startsAt)))
559 return curPos;
560 try { curChar = input_stream.readChar(); }
561 catch(java.io.IOException e) { return curPos; }
562 }
563 }
564 static final int[] jjnextStates = {
565 40, 41, 46, 47, 50, 51, 9, 55, 58, 59, 5, 6, 9, 42, 43, 9,
566 50, 51, 9, 56, 57, 7, 8, 27, 28, 44, 45, 48, 49, 52, 53,
567 };
568 public static final String[] jjstrLiteralImages = {
569 "", null, null, "\56", null, null, null, null, null, null, null, null, null,
570 "\12", "\50", "\51", "\173", "\175", "\54", "\75", null, null, null, null, null, null,
571 "\15\12", };
572 public static final String[] lexStateNames = {
573 "DEFAULT",
574 };
575 static final long[] jjtoToken = {
576 0x46ffcf9L,
577 };
578 static final long[] jjtoSkip = {
579 0x6L,
580 };
581 static protected SimpleCharStream input_stream;
582 static private final int[] jjrounds = new int[60];
583 static private final int[] jjstateSet = new int[120];
584 static protected char curChar;
585 public AnnotationParserTokenManager(SimpleCharStream stream)
586 {
587 if (input_stream != null)
588 throw new TokenMgrError("ERROR: Second call to constructor of static lexer. You must use ReInit() to initialize the static variables.", TokenMgrError.STATIC_LEXER_ERROR);
589 input_stream = stream;
590 }
591 public AnnotationParserTokenManager(SimpleCharStream stream, int lexState)
592 {
593 this(stream);
594 SwitchTo(lexState);
595 }
596 static public void ReInit(SimpleCharStream stream)
597 {
598 jjmatchedPos = jjnewStateCnt = 0;
599 curLexState = defaultLexState;
600 input_stream = stream;
601 ReInitRounds();
602 }
603 static private final void ReInitRounds()
604 {
605 int i;
606 jjround = 0x80000001;
607 for (i = 60; i-- > 0;)
608 jjrounds[i] = 0x80000000;
609 }
610 static public void ReInit(SimpleCharStream stream, int lexState)
611 {
612 ReInit(stream);
613 SwitchTo(lexState);
614 }
615 static public void SwitchTo(int lexState)
616 {
617 if (lexState >= 1 || lexState < 0)
618 throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
619 else
620 curLexState = lexState;
621 }
622
623 static protected Token jjFillToken()
624 {
625 Token t = Token.newToken(jjmatchedKind);
626 t.kind = jjmatchedKind;
627 String im = jjstrLiteralImages[jjmatchedKind];
628 t.image = (im == null) ? input_stream.GetImage() : im;
629 t.beginLine = input_stream.getBeginLine();
630 t.beginColumn = input_stream.getBeginColumn();
631 t.endLine = input_stream.getEndLine();
632 t.endColumn = input_stream.getEndColumn();
633 return t;
634 }
635
636 static int curLexState = 0;
637 static int defaultLexState = 0;
638 static int jjnewStateCnt;
639 static int jjround;
640 static int jjmatchedPos;
641 static int jjmatchedKind;
642
643 public static Token getNextToken()
644 {
645 int kind;
646 Token specialToken = null;
647 Token matchedToken;
648 int curPos = 0;
649
650 EOFLoop :
651 for (;;)
652 {
653 try
654 {
655 curChar = input_stream.BeginToken();
656 }
657 catch(java.io.IOException e)
658 {
659 jjmatchedKind = 0;
660 matchedToken = jjFillToken();
661 return matchedToken;
662 }
663
664 try { input_stream.backup(0);
665 while (curChar <= 32 && (0x100000200L & (1L << curChar)) != 0L)
666 curChar = input_stream.BeginToken();
667 }
668 catch (java.io.IOException e1) { continue EOFLoop; }
669 jjmatchedKind = 0x7fffffff;
670 jjmatchedPos = 0;
671 curPos = jjMoveStringLiteralDfa0_0();
672 if (jjmatchedKind != 0x7fffffff)
673 {
674 if (jjmatchedPos + 1 < curPos)
675 input_stream.backup(curPos - jjmatchedPos - 1);
676 if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)
677 {
678 matchedToken = jjFillToken();
679 return matchedToken;
680 }
681 else
682 {
683 continue EOFLoop;
684 }
685 }
686 int error_line = input_stream.getEndLine();
687 int error_column = input_stream.getEndColumn();
688 String error_after = null;
689 boolean EOFSeen = false;
690 try { input_stream.readChar(); input_stream.backup(1); }
691 catch (java.io.IOException e1) {
692 EOFSeen = true;
693 error_after = curPos <= 1 ? "" : input_stream.GetImage();
694 if (curChar == '\n' || curChar == '\r') {
695 error_line++;
696 error_column = 0;
697 }
698 else
699 error_column++;
700 }
701 if (!EOFSeen) {
702 input_stream.backup(1);
703 error_after = curPos <= 1 ? "" : input_stream.GetImage();
704 }
705 throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
706 }
707 }
708
709 }