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
11 import java.lang.reflect.Modifier;
12 import java.io.Reader;
13 import java.io.StringReader;
14
15 /***
16 * The annotation parser.
17 *
18 * @author <a href="mailto:jboner@codehaus.org">Jonas Bonér</a>
19 */
20 public class AnnotationParser
21 protected static JJTAnnotationParserState jjtree = new JJTAnnotationParserState();
22 public ASTRoot parse(String annotation) throws ParseException {
23 return parse(new StringReader(annotation));
24 }
25
26 public ASTRoot parse(Reader reader) throws ParseException {
27 ReInit(reader);
28 return Root();
29 }
30
31 /***
32 * Entry point.
33 */
34 static final public ASTRoot Root() throws ParseException {
35
36 ASTRoot jjtn000 = new ASTRoot(JJTROOT);
37 boolean jjtc000 = true;
38 jjtree.openNodeScope(jjtn000);
39 try {
40 Annotation();
41 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
42 case 0:
43 jj_consume_token(0);
44 break;
45 case 26:
46 jj_consume_token(26);
47 break;
48 case NEWLINE:
49 jj_consume_token(NEWLINE);
50 break;
51 default:
52 jj_la1[0] = jj_gen;
53 jj_consume_token(-1);
54 throw new ParseException();
55 }
56 jjtree.closeNodeScope(jjtn000, true);
57 jjtc000 = false;
58 {if (true) return jjtn000;}
59 } catch (Throwable jjte000) {
60 if (jjtc000) {
61 jjtree.clearNodeScope(jjtn000);
62 jjtc000 = false;
63 } else {
64 jjtree.popNode();
65 }
66 if (jjte000 instanceof RuntimeException) {
67 {if (true) throw (RuntimeException)jjte000;}
68 }
69 if (jjte000 instanceof ParseException) {
70 {if (true) throw (ParseException)jjte000;}
71 }
72 {if (true) throw (Error)jjte000;}
73 } finally {
74 if (jjtc000) {
75 jjtree.closeNodeScope(jjtn000, true);
76 }
77 }
78 throw new Error("Missing return statement in function");
79 }
80
81 /***
82 * Annotation.
83 */
84 static final public void Annotation() throws ParseException {
85
86 ASTAnnotation jjtn000 = new ASTAnnotation(JJTANNOTATION);
87 boolean jjtc000 = true;
88 jjtree.openNodeScope(jjtn000);
89 try {
90 if (jj_2_2(3)) {
91 jj_consume_token(ANNOTATION);
92 jj_consume_token(LEFT_PARENTHEZIS);
93 if (jj_2_1(4)) {
94 KeyValuePairList();
95 } else {
96 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
97 case INTEGER:
98 case HEXNUMBER:
99 case OCTNUMBER:
100 case FLOAT:
101 case BOOLEAN:
102 case STRING:
103 case CHAR:
104 case LEFT_BRACKET:
105 case JAVA_TYPE:
106 Value();
107 break;
108 default:
109 jj_la1[1] = jj_gen;
110 jj_consume_token(-1);
111 throw new ParseException();
112 }
113 }
114 jj_consume_token(RIGHT_PARENTHEZIS);
115 } else if (jj_2_3(2)) {
116 jj_consume_token(ANNOTATION);
117 jj_consume_token(LEFT_PARENTHEZIS);
118 jj_consume_token(RIGHT_PARENTHEZIS);
119 } else {
120 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
121 case ANNOTATION:
122 jj_consume_token(ANNOTATION);
123 break;
124 default:
125 jj_la1[2] = jj_gen;
126 jj_consume_token(-1);
127 throw new ParseException();
128 }
129 }
130 } catch (Throwable jjte000) {
131 if (jjtc000) {
132 jjtree.clearNodeScope(jjtn000);
133 jjtc000 = false;
134 } else {
135 jjtree.popNode();
136 }
137 if (jjte000 instanceof RuntimeException) {
138 {if (true) throw (RuntimeException)jjte000;}
139 }
140 if (jjte000 instanceof ParseException) {
141 {if (true) throw (ParseException)jjte000;}
142 }
143 {if (true) throw (Error)jjte000;}
144 } finally {
145 if (jjtc000) {
146 jjtree.closeNodeScope(jjtn000, true);
147 }
148 }
149 }
150
151 /***
152 * KeyValuePairList.
153 */
154 static final public void KeyValuePairList() throws ParseException {
155 KeyValuePair();
156 label_1:
157 while (true) {
158 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
159 case COMMA:
160 case JAVA_TYPE:
161 ;
162 break;
163 default:
164 jj_la1[3] = jj_gen;
165 break label_1;
166 }
167 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
168 case COMMA:
169 jj_consume_token(COMMA);
170 break;
171 default:
172 jj_la1[4] = jj_gen;
173 ;
174 }
175 KeyValuePair();
176 }
177 }
178
179 /***
180 * KeyValuePair.
181 */
182 static final public void KeyValuePair() throws ParseException {
183
184 ASTKeyValuePair jjtn000 = new ASTKeyValuePair(JJTKEYVALUEPAIR);
185 boolean jjtc000 = true;
186 jjtree.openNodeScope(jjtn000);Token key, value;
187 try {
188 key = jj_consume_token(JAVA_TYPE);
189 jjtn000.setKey(key.image);
190 jj_consume_token(EQUALS);
191 Value();
192 } catch (Throwable jjte000) {
193 if (jjtc000) {
194 jjtree.clearNodeScope(jjtn000);
195 jjtc000 = false;
196 } else {
197 jjtree.popNode();
198 }
199 if (jjte000 instanceof RuntimeException) {
200 {if (true) throw (RuntimeException)jjte000;}
201 }
202 if (jjte000 instanceof ParseException) {
203 {if (true) throw (ParseException)jjte000;}
204 }
205 {if (true) throw (Error)jjte000;}
206 } finally {
207 if (jjtc000) {
208 jjtree.closeNodeScope(jjtn000, true);
209 }
210 }
211 }
212
213 /***
214 * Value.
215 *
216 * @TODO: nested annotations
217 */
218 static final public void Value() throws ParseException {
219 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
220 case CHAR:
221 Char();
222 break;
223 case STRING:
224 String();
225 break;
226 case LEFT_BRACKET:
227 Array();
228 break;
229 case JAVA_TYPE:
230 Identifier();
231 break;
232 case BOOLEAN:
233 Boolean();
234 break;
235 case INTEGER:
236 Integer();
237 break;
238 case FLOAT:
239 Float();
240 break;
241 case HEXNUMBER:
242 Hex();
243 break;
244 case OCTNUMBER:
245 Oct();
246 break;
247 default:
248 jj_la1[5] = jj_gen;
249 jj_consume_token(-1);
250 throw new ParseException();
251 }
252 }
253
254 /***
255 * Identifier.
256 */
257 static final public void Identifier() throws ParseException {
258
259 ASTIdentifier jjtn000 = new ASTIdentifier(JJTIDENTIFIER);
260 boolean jjtc000 = true;
261 jjtree.openNodeScope(jjtn000);Token value;
262 try {
263 value = jj_consume_token(JAVA_TYPE);
264 jjtree.closeNodeScope(jjtn000, true);
265 jjtc000 = false;
266 jjtn000.setValue(value.image);
267 } finally {
268 if (jjtc000) {
269 jjtree.closeNodeScope(jjtn000, true);
270 }
271 }
272 }
273
274 /***
275 * Boolean.
276 */
277 static final public void Boolean() throws ParseException {
278
279 ASTBoolean jjtn000 = new ASTBoolean(JJTBOOLEAN);
280 boolean jjtc000 = true;
281 jjtree.openNodeScope(jjtn000);Token value;
282 try {
283 value = jj_consume_token(BOOLEAN);
284 jjtree.closeNodeScope(jjtn000, true);
285 jjtc000 = false;
286 jjtn000.setValue(value.image);
287 } finally {
288 if (jjtc000) {
289 jjtree.closeNodeScope(jjtn000, true);
290 }
291 }
292 }
293
294 /***
295 * Char.
296 */
297 static final public void Char() throws ParseException {
298
299 ASTChar jjtn000 = new ASTChar(JJTCHAR);
300 boolean jjtc000 = true;
301 jjtree.openNodeScope(jjtn000);Token value;
302 try {
303 value = jj_consume_token(CHAR);
304 jjtree.closeNodeScope(jjtn000, true);
305 jjtc000 = false;
306 jjtn000.setValue(value.image);
307 } finally {
308 if (jjtc000) {
309 jjtree.closeNodeScope(jjtn000, true);
310 }
311 }
312 }
313
314 /***
315 * String.
316 */
317 static final public void String() throws ParseException {
318
319 ASTString jjtn000 = new ASTString(JJTSTRING);
320 boolean jjtc000 = true;
321 jjtree.openNodeScope(jjtn000);Token value;
322 try {
323 value = jj_consume_token(STRING);
324 jjtree.closeNodeScope(jjtn000, true);
325 jjtc000 = false;
326 jjtn000.setValue(value.image);
327 } finally {
328 if (jjtc000) {
329 jjtree.closeNodeScope(jjtn000, true);
330 }
331 }
332 }
333
334 /***
335 * Array.
336 */
337 static final public void Array() throws ParseException {
338
339 ASTArray jjtn000 = new ASTArray(JJTARRAY);
340 boolean jjtc000 = true;
341 jjtree.openNodeScope(jjtn000);
342 try {
343 jj_consume_token(LEFT_BRACKET);
344 switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
345 case INTEGER:
346 case HEXNUMBER:
347 case OCTNUMBER:
348 case FLOAT:
349 case BOOLEAN:
350 case STRING:
351 case CHAR:
352 case LEFT_BRACKET:
353 case JAVA_TYPE:
354 Value();
355 label_2:
356 while (true) {
357 if (jj_2_4(2)) {
358 ;
359 } else {
360 break label_2;
361 }
362 jj_consume_token(COMMA);
363 Value();
364 }
365 break;
366 default:
367 jj_la1[6] = jj_gen;
368 ;
369 }
370 jj_consume_token(RIGHT_BRACKET);
371 } catch (Throwable jjte000) {
372 if (jjtc000) {
373 jjtree.clearNodeScope(jjtn000);
374 jjtc000 = false;
375 } else {
376 jjtree.popNode();
377 }
378 if (jjte000 instanceof RuntimeException) {
379 {if (true) throw (RuntimeException)jjte000;}
380 }
381 if (jjte000 instanceof ParseException) {
382 {if (true) throw (ParseException)jjte000;}
383 }
384 {if (true) throw (Error)jjte000;}
385 } finally {
386 if (jjtc000) {
387 jjtree.closeNodeScope(jjtn000, true);
388 }
389 }
390 }
391
392 /***
393 * Integer.
394 */
395 static final public void Integer() throws ParseException {
396
397 ASTInteger jjtn000 = new ASTInteger(JJTINTEGER);
398 boolean jjtc000 = true;
399 jjtree.openNodeScope(jjtn000);Token value;
400 try {
401 value = jj_consume_token(INTEGER);
402 jjtree.closeNodeScope(jjtn000, true);
403 jjtc000 = false;
404 jjtn000.setValue(value.image);
405 } finally {
406 if (jjtc000) {
407 jjtree.closeNodeScope(jjtn000, true);
408 }
409 }
410 }
411
412 /***
413 * Float.
414 */
415 static final public void Float() throws ParseException {
416
417 ASTFloat jjtn000 = new ASTFloat(JJTFLOAT);
418 boolean jjtc000 = true;
419 jjtree.openNodeScope(jjtn000);Token value;
420 try {
421 value = jj_consume_token(FLOAT);
422 jjtree.closeNodeScope(jjtn000, true);
423 jjtc000 = false;
424 jjtn000.setValue(value.image);
425 } finally {
426 if (jjtc000) {
427 jjtree.closeNodeScope(jjtn000, true);
428 }
429 }
430 }
431
432 /***
433 * Hex.
434 */
435 static final public void Hex() throws ParseException {
436
437 ASTHex jjtn000 = new ASTHex(JJTHEX);
438 boolean jjtc000 = true;
439 jjtree.openNodeScope(jjtn000);Token value;
440 try {
441 value = jj_consume_token(HEXNUMBER);
442 jjtree.closeNodeScope(jjtn000, true);
443 jjtc000 = false;
444 jjtn000.setValue(value.image);
445 } finally {
446 if (jjtc000) {
447 jjtree.closeNodeScope(jjtn000, true);
448 }
449 }
450 }
451
452 /***
453 * Oct.
454 */
455 static final public void Oct() throws ParseException {
456
457 ASTOct jjtn000 = new ASTOct(JJTOCT);
458 boolean jjtc000 = true;
459 jjtree.openNodeScope(jjtn000);Token value;
460 try {
461 value = jj_consume_token(OCTNUMBER);
462 jjtree.closeNodeScope(jjtn000, true);
463 jjtc000 = false;
464 jjtn000.setValue(value.image);
465 } finally {
466 if (jjtc000) {
467 jjtree.closeNodeScope(jjtn000, true);
468 }
469 }
470 }
471
472 static final private boolean jj_2_1(int xla) {
473 jj_la = xla; jj_lastpos = jj_scanpos = token;
474 try { return !jj_3_1(); }
475 catch(LookaheadSuccess ls) { return true; }
476 finally { jj_save(0, xla); }
477 }
478
479 static final private boolean jj_2_2(int xla) {
480 jj_la = xla; jj_lastpos = jj_scanpos = token;
481 try { return !jj_3_2(); }
482 catch(LookaheadSuccess ls) { return true; }
483 finally { jj_save(1, xla); }
484 }
485
486 static final private boolean jj_2_3(int xla) {
487 jj_la = xla; jj_lastpos = jj_scanpos = token;
488 try { return !jj_3_3(); }
489 catch(LookaheadSuccess ls) { return true; }
490 finally { jj_save(2, xla); }
491 }
492
493 static final private boolean jj_2_4(int xla) {
494 jj_la = xla; jj_lastpos = jj_scanpos = token;
495 try { return !jj_3_4(); }
496 catch(LookaheadSuccess ls) { return true; }
497 finally { jj_save(3, xla); }
498 }
499
500 static final private boolean jj_3R_14() {
501 if (jj_3R_23()) return true;
502 return false;
503 }
504
505 static final private boolean jj_3_3() {
506 if (jj_scan_token(ANNOTATION)) return true;
507 if (jj_scan_token(LEFT_PARENTHEZIS)) return true;
508 return false;
509 }
510
511 static final private boolean jj_3R_13() {
512 if (jj_3R_22()) return true;
513 return false;
514 }
515
516 static final private boolean jj_3R_12() {
517 if (jj_3R_21()) return true;
518 return false;
519 }
520
521 static final private boolean jj_3R_11() {
522 if (jj_3R_20()) return true;
523 return false;
524 }
525
526 static final private boolean jj_3_2() {
527 if (jj_scan_token(ANNOTATION)) return true;
528 if (jj_scan_token(LEFT_PARENTHEZIS)) return true;
529 Token xsp;
530 xsp = jj_scanpos;
531 if (jj_3_1()) {
532 jj_scanpos = xsp;
533 if (jj_3R_4()) return true;
534 }
535 return false;
536 }
537
538 static final private boolean jj_3R_10() {
539 if (jj_3R_19()) return true;
540 return false;
541 }
542
543 static final private boolean jj_3R_23() {
544 if (jj_scan_token(FLOAT)) return true;
545 return false;
546 }
547
548 static final private boolean jj_3R_9() {
549 if (jj_3R_18()) return true;
550 return false;
551 }
552
553 static final private boolean jj_3_4() {
554 if (jj_scan_token(COMMA)) return true;
555 if (jj_3R_5()) return true;
556 return false;
557 }
558
559 static final private boolean jj_3R_5() {
560 Token xsp;
561 xsp = jj_scanpos;
562 if (jj_3R_8()) {
563 jj_scanpos = xsp;
564 if (jj_3R_9()) {
565 jj_scanpos = xsp;
566 if (jj_3R_10()) {
567 jj_scanpos = xsp;
568 if (jj_3R_11()) {
569 jj_scanpos = xsp;
570 if (jj_3R_12()) {
571 jj_scanpos = xsp;
572 if (jj_3R_13()) {
573 jj_scanpos = xsp;
574 if (jj_3R_14()) {
575 jj_scanpos = xsp;
576 if (jj_3R_15()) {
577 jj_scanpos = xsp;
578 if (jj_3R_16()) return true;
579 }
580 }
581 }
582 }
583 }
584 }
585 }
586 }
587 return false;
588 }
589
590 static final private boolean jj_3R_8() {
591 if (jj_3R_17()) return true;
592 return false;
593 }
594
595 static final private boolean jj_3R_17() {
596 if (jj_scan_token(CHAR)) return true;
597 return false;
598 }
599
600 static final private boolean jj_3R_26() {
601 if (jj_3R_5()) return true;
602 return false;
603 }
604
605 static final private boolean jj_3_1() {
606 if (jj_3R_3()) return true;
607 return false;
608 }
609
610 static final private boolean jj_3R_22() {
611 if (jj_scan_token(INTEGER)) return true;
612 return false;
613 }
614
615 static final private boolean jj_3R_21() {
616 if (jj_scan_token(BOOLEAN)) return true;
617 return false;
618 }
619
620 static final private boolean jj_3R_25() {
621 if (jj_scan_token(OCTNUMBER)) return true;
622 return false;
623 }
624
625 static final private boolean jj_3R_6() {
626 if (jj_scan_token(JAVA_TYPE)) return true;
627 if (jj_scan_token(EQUALS)) return true;
628 if (jj_3R_5()) return true;
629 return false;
630 }
631
632 static final private boolean jj_3R_19() {
633 if (jj_scan_token(LEFT_BRACKET)) return true;
634 Token xsp;
635 xsp = jj_scanpos;
636 if (jj_3R_26()) jj_scanpos = xsp;
637 if (jj_scan_token(RIGHT_BRACKET)) return true;
638 return false;
639 }
640
641 static final private boolean jj_3R_4() {
642 if (jj_3R_5()) return true;
643 return false;
644 }
645
646 static final private boolean jj_3R_7() {
647 Token xsp;
648 xsp = jj_scanpos;
649 if (jj_scan_token(18)) jj_scanpos = xsp;
650 if (jj_3R_6()) return true;
651 return false;
652 }
653
654 static final private boolean jj_3R_20() {
655 if (jj_scan_token(JAVA_TYPE)) return true;
656 return false;
657 }
658
659 static final private boolean jj_3R_3() {
660 if (jj_3R_6()) return true;
661 Token xsp;
662 while (true) {
663 xsp = jj_scanpos;
664 if (jj_3R_7()) { jj_scanpos = xsp; break; }
665 }
666 return false;
667 }
668
669 static final private boolean jj_3R_24() {
670 if (jj_scan_token(HEXNUMBER)) return true;
671 return false;
672 }
673
674 static final private boolean jj_3R_18() {
675 if (jj_scan_token(STRING)) return true;
676 return false;
677 }
678
679 static final private boolean jj_3R_16() {
680 if (jj_3R_25()) return true;
681 return false;
682 }
683
684 static final private boolean jj_3R_15() {
685 if (jj_3R_24()) return true;
686 return false;
687 }
688
689 static private boolean jj_initialized_once = false;
690 static public AnnotationParserTokenManager token_source;
691 static SimpleCharStream jj_input_stream;
692 static public Token token, jj_nt;
693 static private int jj_ntk;
694 static private Token jj_scanpos, jj_lastpos;
695 static private int jj_la;
696 static public boolean lookingAhead = false;
697 static private boolean jj_semLA;
698 static private int jj_gen;
699 static final private int[] jj_la1 = new int[7];
700 static private int[] jj_la1_0;
701 static {
702 jj_la1_0();
703 }
704 private static void jj_la1_0() {
705 jj_la1_0 = new int[] {0x4002001,0x411cf0,0x200000,0x440000,0x40000,0x411cf0,0x411cf0,};
706 }
707 static final private JJCalls[] jj_2_rtns = new JJCalls[4];
708 static private boolean jj_rescan = false;
709 static private int jj_gc = 0;
710
711 public AnnotationParser(java.io.InputStream stream) {
712 if (jj_initialized_once) {
713 System.out.println("ERROR: Second call to constructor of static parser. You must");
714 System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
715 System.out.println(" during parser generation.");
716 throw new Error();
717 }
718 jj_initialized_once = true;
719 jj_input_stream = new SimpleCharStream(stream, 1, 1);
720 token_source = new AnnotationParserTokenManager(jj_input_stream);
721 token = new Token();
722 jj_ntk = -1;
723 jj_gen = 0;
724 for (int i = 0; i < 7; i++) jj_la1[i] = -1;
725 for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
726 }
727
728 static public void ReInit(java.io.InputStream stream) {
729 jj_input_stream.ReInit(stream, 1, 1);
730 token_source.ReInit(jj_input_stream);
731 token = new Token();
732 jj_ntk = -1;
733 jjtree.reset();
734 jj_gen = 0;
735 for (int i = 0; i < 7; i++) jj_la1[i] = -1;
736 for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
737 }
738
739 public AnnotationParser(java.io.Reader stream) {
740 if (jj_initialized_once) {
741 System.out.println("ERROR: Second call to constructor of static parser. You must");
742 System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
743 System.out.println(" during parser generation.");
744 throw new Error();
745 }
746 jj_initialized_once = true;
747 jj_input_stream = new SimpleCharStream(stream, 1, 1);
748 token_source = new AnnotationParserTokenManager(jj_input_stream);
749 token = new Token();
750 jj_ntk = -1;
751 jj_gen = 0;
752 for (int i = 0; i < 7; i++) jj_la1[i] = -1;
753 for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
754 }
755
756 static public void ReInit(java.io.Reader stream) {
757 jj_input_stream.ReInit(stream, 1, 1);
758 token_source.ReInit(jj_input_stream);
759 token = new Token();
760 jj_ntk = -1;
761 jjtree.reset();
762 jj_gen = 0;
763 for (int i = 0; i < 7; i++) jj_la1[i] = -1;
764 for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
765 }
766
767 public AnnotationParser(AnnotationParserTokenManager tm) {
768 if (jj_initialized_once) {
769 System.out.println("ERROR: Second call to constructor of static parser. You must");
770 System.out.println(" either use ReInit() or set the JavaCC option STATIC to false");
771 System.out.println(" during parser generation.");
772 throw new Error();
773 }
774 jj_initialized_once = true;
775 token_source = tm;
776 token = new Token();
777 jj_ntk = -1;
778 jj_gen = 0;
779 for (int i = 0; i < 7; i++) jj_la1[i] = -1;
780 for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
781 }
782
783 public void ReInit(AnnotationParserTokenManager tm) {
784 token_source = tm;
785 token = new Token();
786 jj_ntk = -1;
787 jjtree.reset();
788 jj_gen = 0;
789 for (int i = 0; i < 7; i++) jj_la1[i] = -1;
790 for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();
791 }
792
793 static final private Token jj_consume_token(int kind) throws ParseException {
794 Token oldToken;
795 if ((oldToken = token).next != null) token = token.next;
796 else token = token.next = token_source.getNextToken();
797 jj_ntk = -1;
798 if (token.kind == kind) {
799 jj_gen++;
800 if (++jj_gc > 100) {
801 jj_gc = 0;
802 for (int i = 0; i < jj_2_rtns.length; i++) {
803 JJCalls c = jj_2_rtns[i];
804 while (c != null) {
805 if (c.gen < jj_gen) c.first = null;
806 c = c.next;
807 }
808 }
809 }
810 return token;
811 }
812 token = oldToken;
813 jj_kind = kind;
814 throw generateParseException();
815 }
816
817 static private final class LookaheadSuccess extends java.lang.Error { }
818 static final private LookaheadSuccess jj_ls = new LookaheadSuccess();
819 static final private boolean jj_scan_token(int kind) {
820 if (jj_scanpos == jj_lastpos) {
821 jj_la--;
822 if (jj_scanpos.next == null) {
823 jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
824 } else {
825 jj_lastpos = jj_scanpos = jj_scanpos.next;
826 }
827 } else {
828 jj_scanpos = jj_scanpos.next;
829 }
830 if (jj_rescan) {
831 int i = 0; Token tok = token;
832 while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
833 if (tok != null) jj_add_error_token(kind, i);
834 }
835 if (jj_scanpos.kind != kind) return true;
836 if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
837 return false;
838 }
839
840 static final public Token getNextToken() {
841 if (token.next != null) token = token.next;
842 else token = token.next = token_source.getNextToken();
843 jj_ntk = -1;
844 jj_gen++;
845 return token;
846 }
847
848 static final public Token getToken(int index) {
849 Token t = lookingAhead ? jj_scanpos : token;
850 for (int i = 0; i < index; i++) {
851 if (t.next != null) t = t.next;
852 else t = t.next = token_source.getNextToken();
853 }
854 return t;
855 }
856
857 static final private int jj_ntk() {
858 if ((jj_nt=token.next) == null)
859 return (jj_ntk = (token.next=token_source.getNextToken()).kind);
860 else
861 return (jj_ntk = jj_nt.kind);
862 }
863
864 static private java.util.Vector jj_expentries = new java.util.Vector();
865 static private int[] jj_expentry;
866 static private int jj_kind = -1;
867 static private int[] jj_lasttokens = new int[100];
868 static private int jj_endpos;
869
870 static private void jj_add_error_token(int kind, int pos) {
871 if (pos >= 100) return;
872 if (pos == jj_endpos + 1) {
873 jj_lasttokens[jj_endpos++] = kind;
874 } else if (jj_endpos != 0) {
875 jj_expentry = new int[jj_endpos];
876 for (int i = 0; i < jj_endpos; i++) {
877 jj_expentry[i] = jj_lasttokens[i];
878 }
879 boolean exists = false;
880 for (java.util.Enumeration e = jj_expentries.elements(); e.hasMoreElements();) {
881 int[] oldentry = (int[])(e.nextElement());
882 if (oldentry.length == jj_expentry.length) {
883 exists = true;
884 for (int i = 0; i < jj_expentry.length; i++) {
885 if (oldentry[i] != jj_expentry[i]) {
886 exists = false;
887 break;
888 }
889 }
890 if (exists) break;
891 }
892 }
893 if (!exists) jj_expentries.addElement(jj_expentry);
894 if (pos != 0) jj_lasttokens[(jj_endpos = pos) - 1] = kind;
895 }
896 }
897
898 static public ParseException generateParseException() {
899 jj_expentries.removeAllElements();
900 boolean[] la1tokens = new boolean[27];
901 for (int i = 0; i < 27; i++) {
902 la1tokens[i] = false;
903 }
904 if (jj_kind >= 0) {
905 la1tokens[jj_kind] = true;
906 jj_kind = -1;
907 }
908 for (int i = 0; i < 7; i++) {
909 if (jj_la1[i] == jj_gen) {
910 for (int j = 0; j < 32; j++) {
911 if ((jj_la1_0[i] & (1<<j)) != 0) {
912 la1tokens[j] = true;
913 }
914 }
915 }
916 }
917 for (int i = 0; i < 27; i++) {
918 if (la1tokens[i]) {
919 jj_expentry = new int[1];
920 jj_expentry[0] = i;
921 jj_expentries.addElement(jj_expentry);
922 }
923 }
924 jj_endpos = 0;
925 jj_rescan_token();
926 jj_add_error_token(0, 0);
927 int[][] exptokseq = new int[jj_expentries.size()][];
928 for (int i = 0; i < jj_expentries.size(); i++) {
929 exptokseq[i] = (int[])jj_expentries.elementAt(i);
930 }
931 return new ParseException(token, exptokseq, tokenImage);
932 }
933
934 static final public void enable_tracing() {
935 }
936
937 static final public void disable_tracing() {
938 }
939
940 static final private void jj_rescan_token() {
941 jj_rescan = true;
942 for (int i = 0; i < 4; i++) {
943 JJCalls p = jj_2_rtns[i];
944 do {
945 if (p.gen > jj_gen) {
946 jj_la = p.arg; jj_lastpos = jj_scanpos = p.first;
947 switch (i) {
948 case 0: jj_3_1(); break;
949 case 1: jj_3_2(); break;
950 case 2: jj_3_3(); break;
951 case 3: jj_3_4(); break;
952 }
953 }
954 p = p.next;
955 } while (p != null);
956 }
957 jj_rescan = false;
958 }
959
960 static final private void jj_save(int index, int xla) {
961 JJCalls p = jj_2_rtns[index];
962 while (p.gen > jj_gen) {
963 if (p.next == null) { p = p.next = new JJCalls(); break; }
964 p = p.next;
965 }
966 p.gen = jj_gen + xla - jj_la; p.first = token; p.arg = xla;
967 }
968
969 static final class JJCalls {
970 int gen;
971 Token first;
972 int arg;
973 JJCalls next;
974 }
975
976 }