KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejen > ext > parsers > java_1_2 > JavaParser


1 /* Generated By:JJTree&JavaCC: Do not edit this line. JavaParser.java */
2 package org.ejen.ext.parsers.java_1_2;
3
4 public class JavaParser/* @bgen(jjtree)*/implements JavaParserTreeConstants, JavaParserConstants {/* @bgen(jjtree)*/
5     protected static JJTJavaParserState jjtree = new JJTJavaParserState();
6
7     /*****************************************
8      * THE JAVA LANGUAGE GRAMMAR STARTS HERE *
9      *****************************************/

10
11     /*
12      * Program structuring syntax follows.
13      */

14     static final public SimpleNode CompilationUnit() throws ParseException {
15
16         /* @bgen(jjtree) CompilationUnit */
17         SimpleNode jjtn000 = new SimpleNode(JJTCOMPILATIONUNIT);
18         boolean jjtc000 = true;
19
20         jjtree.openNodeScope(jjtn000);
21         try {
22             switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
23             case PACKAGE:
24                 PackageDeclaration();
25                 break;
26
27             default:
28                 jj_la1[0] = jj_gen;
29                 ;
30             }
31             label_1:
32             while (true) {
33                 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
34                 case IMPORT:
35                     ;
36                     break;
37
38                 default:
39                     jj_la1[1] = jj_gen;
40                     break label_1;
41                 }
42                 ImportDeclaration();
43             }
44             label_2:
45             while (true) {
46                 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
47                 case ABSTRACT:
48                 case CLASS:
49                 case FINAL:
50                 case INTERFACE:
51                 case PUBLIC:
52                 case STRICTFP:
53                 case SEMICOLON:
54                     ;
55                     break;
56
57                 default:
58                     jj_la1[2] = jj_gen;
59                     break label_2;
60                 }
61                 TypeDeclaration();
62             }
63             jj_consume_token(0);
64             jjtree.closeNodeScope(jjtn000, true);
65             jjtc000 = false; {
66                 if (true) {
67                     return jjtn000;
68                 }
69             }
70         } catch (Throwable JavaDoc jjte000) {
71             if (jjtc000) {
72                 jjtree.clearNodeScope(jjtn000);
73                 jjtc000 = false;
74             } else {
75                 jjtree.popNode();
76             }
77             if (jjte000 instanceof RuntimeException JavaDoc) { {
78                     if (true) {
79                         throw (RuntimeException JavaDoc) jjte000;
80                     }
81                 }
82             }
83             if (jjte000 instanceof ParseException) { {
84                     if (true) {
85                         throw (ParseException) jjte000;
86                     }
87                 }
88             } {
89                 if (true) {
90                     throw (Error JavaDoc) jjte000;
91                 }
92             }
93         }
94         finally {
95             if (jjtc000) {
96                 jjtree.closeNodeScope(jjtn000, true);
97             }
98         }
99         throw new Error JavaDoc("Missing return statement in function");
100     }
101
102     static final public void PackageDeclaration() throws ParseException {
103
104         /* @bgen(jjtree) PackageDeclaration */
105         SimpleNode jjtn000 = new SimpleNode(JJTPACKAGEDECLARATION);
106         boolean jjtc000 = true;
107
108         jjtree.openNodeScope(jjtn000);
109         try {
110             jj_consume_token(PACKAGE);
111             Name();
112             jj_consume_token(SEMICOLON);
113         } catch (Throwable JavaDoc jjte000) {
114             if (jjtc000) {
115                 jjtree.clearNodeScope(jjtn000);
116                 jjtc000 = false;
117             } else {
118                 jjtree.popNode();
119             }
120             if (jjte000 instanceof RuntimeException JavaDoc) { {
121                     if (true) {
122                         throw (RuntimeException JavaDoc) jjte000;
123                     }
124                 }
125             }
126             if (jjte000 instanceof ParseException) { {
127                     if (true) {
128                         throw (ParseException) jjte000;
129                     }
130                 }
131             } {
132                 if (true) {
133                     throw (Error JavaDoc) jjte000;
134                 }
135             }
136         }
137         finally {
138             if (jjtc000) {
139                 jjtree.closeNodeScope(jjtn000, true);
140             }
141         }
142     }
143
144     static final public void ImportDeclaration() throws ParseException {
145
146         /* @bgen(jjtree) ImportDeclaration */
147         SimpleNode jjtn000 = new SimpleNode(JJTIMPORTDECLARATION);
148         boolean jjtc000 = true;
149
150         jjtree.openNodeScope(jjtn000);
151         try {
152             jj_consume_token(IMPORT);
153             Name();
154             switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
155             case DOT:
156                 jj_consume_token(DOT);
157                 jj_consume_token(STAR);
158                 break;
159
160             default:
161                 jj_la1[3] = jj_gen;
162                 ;
163             }
164             jj_consume_token(SEMICOLON);
165         } catch (Throwable JavaDoc jjte000) {
166             if (jjtc000) {
167                 jjtree.clearNodeScope(jjtn000);
168                 jjtc000 = false;
169             } else {
170                 jjtree.popNode();
171             }
172             if (jjte000 instanceof RuntimeException JavaDoc) { {
173                     if (true) {
174                         throw (RuntimeException JavaDoc) jjte000;
175                     }
176                 }
177             }
178             if (jjte000 instanceof ParseException) { {
179                     if (true) {
180                         throw (ParseException) jjte000;
181                     }
182                 }
183             } {
184                 if (true) {
185                     throw (Error JavaDoc) jjte000;
186                 }
187             }
188         }
189         finally {
190             if (jjtc000) {
191                 jjtree.closeNodeScope(jjtn000, true);
192             }
193         }
194     }
195
196     static final public void TypeDeclaration() throws ParseException {
197
198         /* @bgen(jjtree) TypeDeclaration */
199         SimpleNode jjtn000 = new SimpleNode(JJTTYPEDECLARATION);
200         boolean jjtc000 = true;
201
202         jjtree.openNodeScope(jjtn000);
203         try {
204             if (jj_2_1(2147483647)) {
205                 ClassDeclaration();
206             } else {
207                 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
208                 case ABSTRACT:
209                 case INTERFACE:
210                 case PUBLIC:
211                 case STRICTFP:
212                     InterfaceDeclaration();
213                     break;
214
215                 case SEMICOLON:
216                     jj_consume_token(SEMICOLON);
217                     break;
218
219                 default:
220                     jj_la1[4] = jj_gen;
221                     jj_consume_token(-1);
222                     throw new ParseException();
223                 }
224             }
225         } catch (Throwable JavaDoc jjte000) {
226             if (jjtc000) {
227                 jjtree.clearNodeScope(jjtn000);
228                 jjtc000 = false;
229             } else {
230                 jjtree.popNode();
231             }
232             if (jjte000 instanceof RuntimeException JavaDoc) { {
233                     if (true) {
234                         throw (RuntimeException JavaDoc) jjte000;
235                     }
236                 }
237             }
238             if (jjte000 instanceof ParseException) { {
239                     if (true) {
240                         throw (ParseException) jjte000;
241                     }
242                 }
243             } {
244                 if (true) {
245                     throw (Error JavaDoc) jjte000;
246                 }
247             }
248         }
249         finally {
250             if (jjtc000) {
251                 jjtree.closeNodeScope(jjtn000, true);
252             }
253         }
254     }
255
256     /*
257      * Declaration syntax follows.
258      */

259     static final public void ClassDeclaration() throws ParseException {
260
261         /* @bgen(jjtree) ClassDeclaration */
262         SimpleNode jjtn000 = new SimpleNode(JJTCLASSDECLARATION);
263         boolean jjtc000 = true;
264
265         jjtree.openNodeScope(jjtn000);
266         try {
267             label_3:
268             while (true) {
269                 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
270                 case ABSTRACT:
271                 case FINAL:
272                 case PUBLIC:
273                 case STRICTFP:
274                     ;
275                     break;
276
277                 default:
278                     jj_la1[5] = jj_gen;
279                     break label_3;
280                 }
281                 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
282                 case ABSTRACT:
283                     jj_consume_token(ABSTRACT);
284                     break;
285
286                 case FINAL:
287                     jj_consume_token(FINAL);
288                     break;
289
290                 case PUBLIC:
291                     jj_consume_token(PUBLIC);
292                     break;
293
294                 case STRICTFP:
295                     jj_consume_token(STRICTFP);
296                     break;
297
298                 default:
299                     jj_la1[6] = jj_gen;
300                     jj_consume_token(-1);
301                     throw new ParseException();
302                 }
303             }
304             UnmodifiedClassDeclaration();
305         } catch (Throwable JavaDoc jjte000) {
306             if (jjtc000) {
307                 jjtree.clearNodeScope(jjtn000);
308                 jjtc000 = false;
309             } else {
310                 jjtree.popNode();
311             }
312             if (jjte000 instanceof RuntimeException JavaDoc) { {
313                     if (true) {
314                         throw (RuntimeException JavaDoc) jjte000;
315                     }
316                 }
317             }
318             if (jjte000 instanceof ParseException) { {
319                     if (true) {
320                         throw (ParseException) jjte000;
321                     }
322                 }
323             } {
324                 if (true) {
325                     throw (Error JavaDoc) jjte000;
326                 }
327             }
328         }
329         finally {
330             if (jjtc000) {
331                 jjtree.closeNodeScope(jjtn000, true);
332             }
333         }
334     }
335
336     static final public void UnmodifiedClassDeclaration() throws ParseException {
337
338         /* @bgen(jjtree) UnmodifiedClassDeclaration */
339         SimpleNode jjtn000 = new SimpleNode(JJTUNMODIFIEDCLASSDECLARATION);
340         boolean jjtc000 = true;
341
342         jjtree.openNodeScope(jjtn000);
343         try {
344             jj_consume_token(CLASS);
345             jj_consume_token(IDENTIFIER);
346             switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
347             case EXTENDS:
348                 jj_consume_token(EXTENDS);
349                 Name();
350                 break;
351
352             default:
353                 jj_la1[7] = jj_gen;
354                 ;
355             }
356             switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
357             case IMPLEMENTS:
358                 jj_consume_token(IMPLEMENTS);
359                 NameList();
360                 break;
361
362             default:
363                 jj_la1[8] = jj_gen;
364                 ;
365             }
366             ClassBody();
367         } catch (Throwable JavaDoc jjte000) {
368             if (jjtc000) {
369                 jjtree.clearNodeScope(jjtn000);
370                 jjtc000 = false;
371             } else {
372                 jjtree.popNode();
373             }
374             if (jjte000 instanceof RuntimeException JavaDoc) { {
375                     if (true) {
376                         throw (RuntimeException JavaDoc) jjte000;
377                     }
378                 }
379             }
380             if (jjte000 instanceof ParseException) { {
381                     if (true) {
382                         throw (ParseException) jjte000;
383                     }
384                 }
385             } {
386                 if (true) {
387                     throw (Error JavaDoc) jjte000;
388                 }
389             }
390         }
391         finally {
392             if (jjtc000) {
393                 jjtree.closeNodeScope(jjtn000, true);
394             }
395         }
396     }
397
398     static final public void ClassBody() throws ParseException {
399
400         /* @bgen(jjtree) ClassBody */
401         SimpleNode jjtn000 = new SimpleNode(JJTCLASSBODY);
402         boolean jjtc000 = true;
403
404         jjtree.openNodeScope(jjtn000);
405         try {
406             jj_consume_token(LBRACE);
407             label_4:
408             while (true) {
409                 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
410                 case ABSTRACT:
411                 case BOOLEAN:
412                 case BYTE:
413                 case CHAR:
414                 case CLASS:
415                 case DOUBLE:
416                 case FINAL:
417                 case FLOAT:
418                 case INT:
419                 case INTERFACE:
420                 case LONG:
421                 case NATIVE:
422                 case PRIVATE:
423                 case PROTECTED:
424                 case PUBLIC:
425                 case SHORT:
426                 case STATIC:
427                 case SYNCHRONIZED:
428                 case TRANSIENT:
429                 case VOID:
430                 case VOLATILE:
431                 case STRICTFP:
432                 case IDENTIFIER:
433                 case LBRACE:
434                     ;
435                     break;
436
437                 default:
438                     jj_la1[9] = jj_gen;
439                     break label_4;
440                 }
441                 ClassBodyDeclaration();
442             }
443             jj_consume_token(RBRACE);
444         } catch (Throwable JavaDoc jjte000) {
445             if (jjtc000) {
446                 jjtree.clearNodeScope(jjtn000);
447                 jjtc000 = false;
448             } else {
449                 jjtree.popNode();
450             }
451             if (jjte000 instanceof RuntimeException JavaDoc) { {
452                     if (true) {
453                         throw (RuntimeException JavaDoc) jjte000;
454                     }
455                 }
456             }
457             if (jjte000 instanceof ParseException) { {
458                     if (true) {
459                         throw (ParseException) jjte000;
460                     }
461                 }
462             } {
463                 if (true) {
464                     throw (Error JavaDoc) jjte000;
465                 }
466             }
467         }
468         finally {
469             if (jjtc000) {
470                 jjtree.closeNodeScope(jjtn000, true);
471             }
472         }
473     }
474
475     static final public void NestedClassDeclaration() throws ParseException {
476
477         /* @bgen(jjtree) NestedClassDeclaration */
478         SimpleNode jjtn000 = new SimpleNode(JJTNESTEDCLASSDECLARATION);
479         boolean jjtc000 = true;
480
481         jjtree.openNodeScope(jjtn000);
482         try {
483             label_5:
484             while (true) {
485                 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
486                 case ABSTRACT:
487                 case FINAL:
488                 case PRIVATE:
489                 case PROTECTED:
490                 case PUBLIC:
491                 case STATIC:
492                 case STRICTFP:
493                     ;
494                     break;
495
496                 default:
497                     jj_la1[10] = jj_gen;
498                     break label_5;
499                 }
500                 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
501                 case STATIC:
502                     jj_consume_token(STATIC);
503                     break;
504
505                 case ABSTRACT:
506                     jj_consume_token(ABSTRACT);
507                     break;
508
509                 case FINAL:
510                     jj_consume_token(FINAL);
511                     break;
512
513                 case PUBLIC:
514                     jj_consume_token(PUBLIC);
515                     break;
516
517                 case PROTECTED:
518                     jj_consume_token(PROTECTED);
519                     break;
520
521                 case PRIVATE:
522                     jj_consume_token(PRIVATE);
523                     break;
524
525                 case STRICTFP:
526                     jj_consume_token(STRICTFP);
527                     break;
528
529                 default:
530                     jj_la1[11] = jj_gen;
531                     jj_consume_token(-1);
532                     throw new ParseException();
533                 }
534             }
535             UnmodifiedClassDeclaration();
536         } catch (Throwable JavaDoc jjte000) {
537             if (jjtc000) {
538                 jjtree.clearNodeScope(jjtn000);
539                 jjtc000 = false;
540             } else {
541                 jjtree.popNode();
542             }
543             if (jjte000 instanceof RuntimeException JavaDoc) { {
544                     if (true) {
545                         throw (RuntimeException JavaDoc) jjte000;
546                     }
547                 }
548             }
549             if (jjte000 instanceof ParseException) { {
550                     if (true) {
551                         throw (ParseException) jjte000;
552                     }
553                 }
554             } {
555                 if (true) {
556                     throw (Error JavaDoc) jjte000;
557                 }
558             }
559         }
560         finally {
561             if (jjtc000) {
562                 jjtree.closeNodeScope(jjtn000, true);
563             }
564         }
565     }
566
567     static final public void ClassBodyDeclaration() throws ParseException {
568
569         /* @bgen(jjtree) ClassBodyDeclaration */
570         SimpleNode jjtn000 = new SimpleNode(JJTCLASSBODYDECLARATION);
571         boolean jjtc000 = true;
572
573         jjtree.openNodeScope(jjtn000);
574         try {
575             if (jj_2_2(2)) {
576                 Initializer();
577             } else if (jj_2_3(2147483647)) {
578                 NestedClassDeclaration();
579             } else if (jj_2_4(2147483647)) {
580                 NestedInterfaceDeclaration();
581             } else if (jj_2_5(2147483647)) {
582                 ConstructorDeclaration();
583             } else if (jj_2_6(2147483647)) {
584                 MethodDeclaration();
585             } else {
586                 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
587                 case BOOLEAN:
588                 case BYTE:
589                 case CHAR:
590                 case DOUBLE:
591                 case FINAL:
592                 case FLOAT:
593                 case INT:
594                 case LONG:
595                 case PRIVATE:
596                 case PROTECTED:
597                 case PUBLIC:
598                 case SHORT:
599                 case STATIC:
600                 case TRANSIENT:
601                 case VOLATILE:
602                 case IDENTIFIER:
603                     FieldDeclaration();
604                     break;
605
606                 default:
607                     jj_la1[12] = jj_gen;
608                     jj_consume_token(-1);
609                     throw new ParseException();
610                 }
611             }
612         } catch (Throwable JavaDoc jjte000) {
613             if (jjtc000) {
614                 jjtree.clearNodeScope(jjtn000);
615                 jjtc000 = false;
616             } else {
617                 jjtree.popNode();
618             }
619             if (jjte000 instanceof RuntimeException JavaDoc) { {
620                     if (true) {
621                         throw (RuntimeException JavaDoc) jjte000;
622                     }
623                 }
624             }
625             if (jjte000 instanceof ParseException) { {
626                     if (true) {
627                         throw (ParseException) jjte000;
628                     }
629                 }
630             } {
631                 if (true) {
632                     throw (Error JavaDoc) jjte000;
633                 }
634             }
635         }
636         finally {
637             if (jjtc000) {
638                 jjtree.closeNodeScope(jjtn000, true);
639             }
640         }
641     }
642
643     // This production is to determine lookahead only.
644
static final public void MethodDeclarationLookahead() throws ParseException {
645
646         /* @bgen(jjtree) MethodDeclarationLookahead */
647         SimpleNode jjtn000 = new SimpleNode(JJTMETHODDECLARATIONLOOKAHEAD);
648         boolean jjtc000 = true;
649
650         jjtree.openNodeScope(jjtn000);
651         try {
652             label_6:
653             while (true) {
654                 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
655                 case ABSTRACT:
656                 case FINAL:
657                 case NATIVE:
658                 case PRIVATE:
659                 case PROTECTED:
660                 case PUBLIC:
661                 case STATIC:
662                 case SYNCHRONIZED:
663                 case STRICTFP:
664                     ;
665                     break;
666
667                 default:
668                     jj_la1[13] = jj_gen;
669                     break label_6;
670                 }
671                 switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
672                 case PUBLIC:
673                     jj_consume_token(PUBLIC);
674                     break;
675
676                 case PROTECTED:
677                     jj_consume_token(PROTECTED);
678                     break;
679
680                 case PRIVATE:
681                     jj_consume_token(PRIVATE);
682                     break;
683
684                 case STATIC:
685                     jj_consume_token(STATIC);
686                     break;
687
688                 case ABSTRACT:
689                     jj_consume_token(ABSTRACT);
690                     break;
691
692                 case FINAL:
693                     jj_consume_token(FINAL);
694                     break;
695
696                 case NATIVE:
697                     jj_consume_token(NATIVE);
698                     break;
699
700                 case SYNCHRONIZED:
701                     jj_consume_token(SYNCHRONIZED);
702                     break;
703
704                 case STRICTFP:
705                     jj_consume_token(STRICTFP);
706                     break;
707
708                 default:
709                     jj_la1[14] = jj_gen;
710                     jj_consume_token(-1);
711                     throw new ParseException();
712                 }
713             }
714             ResultType();
715             jj_consume_token(IDENTIFIER);
716             jj_consume_token(LPAREN);
717         } catch (Throwable JavaDoc jjte000) {
718             if (jjtc000) {
719                 jjtree.clearNodeScope(jjtn000);
720                 jjtc000 = false;
721             } else {
722                 jjtree.popNode();
723             }
724             if (jjte000 instanceof RuntimeException