View Javadoc

1   // $ANTLR 2.7.2: "groovy.g" -> "GroovyRecognizer.java"$
2   
3   package org.codehaus.groovy.antlr.parser;
4   import org.codehaus.groovy.antlr.*;
5   import java.util.*;
6   import java.io.InputStream;
7   import java.io.Reader;
8   import antlr.InputBuffer;
9   import antlr.LexerSharedInputState;
10  
11  import antlr.TokenBuffer;
12  import antlr.TokenStreamException;
13  import antlr.TokenStreamIOException;
14  import antlr.ANTLRException;
15  import antlr.LLkParser;
16  import antlr.Token;
17  import antlr.TokenStream;
18  import antlr.RecognitionException;
19  import antlr.NoViableAltException;
20  import antlr.MismatchedTokenException;
21  import antlr.SemanticException;
22  import antlr.ParserSharedInputState;
23  import antlr.collections.impl.BitSet;
24  import antlr.collections.AST;
25  import java.util.Hashtable;
26  import antlr.ASTFactory;
27  import antlr.ASTPair;
28  import antlr.collections.impl.ASTArray;
29  
30  /*** JSR-241 Groovy Recognizer
31   *
32   * Run 'java Main [-showtree] directory-full-of-groovy-files'
33   *
34   * [The -showtree option pops up a Swing frame that shows
35   *  the AST constructed from the parser.]
36   *
37   * Contributing authors:
38   *              John Mitchell           johnm@non.net
39   *              Terence Parr            parrt@magelang.com
40   *              John Lilley             jlilley@empathy.com
41   *              Scott Stanchfield       thetick@magelang.com
42   *              Markus Mohnen           mohnen@informatik.rwth-aachen.de
43   *              Peter Williams          pete.williams@sun.com
44   *              Allan Jacobs            Allan.Jacobs@eng.sun.com
45   *              Steve Messick           messick@redhills.com
46   *              James Strachan          jstrachan@protique.com
47   *              John Pybus              john@pybus.org
48   *              John Rose               rose00@mac.com
49   *              Jeremy Rayner           groovy@ross-rayner.com
50   *
51   * Version 1.00 December 9, 1997 -- initial release
52   * Version 1.01 December 10, 1997
53   *              fixed bug in octal def (0..7 not 0..8)
54   * Version 1.10 August 1998 (parrt)
55   *              added tree construction
56   *              fixed definition of WS,comments for mac,pc,unix newlines
57   *              added unary plus
58   * Version 1.11 (Nov 20, 1998)
59   *              Added "shutup" option to turn off last ambig warning.
60   *              Fixed inner class def to allow named class defs as statements
61   *              synchronized requires compound not simple statement
62   *              add [] after builtInType DOT class in primaryExpression
63   *              "const" is reserved but not valid..removed from modifiers
64   * Version 1.12 (Feb 2, 1999)
65   *              Changed LITERAL_xxx to xxx in tree grammar.
66   *              Updated java.g to use tokens {...} now for 2.6.0 (new feature).
67   *
68   * Version 1.13 (Apr 23, 1999)
69   *              Didn't have (stat)? for else clause in tree parser.
70   *              Didn't gen ASTs for interface extends.  Updated tree parser too.
71   *              Updated to 2.6.0.
72   * Version 1.14 (Jun 20, 1999)
73   *              Allowed final/abstract on local classes.
74   *              Removed local interfaces from methods
75   *              Put instanceof precedence where it belongs...in relationalExpr
76   *                      It also had expr not type as arg; fixed it.
77   *              Missing ! on SEMI in classBlock
78   *              fixed: (expr) + "string" was parsed incorrectly (+ as unary plus).
79   *              fixed: didn't like Object[].class in parser or tree parser
80   * Version 1.15 (Jun 26, 1999)
81   *              Screwed up rule with instanceof in it. :(  Fixed.
82   *              Tree parser didn't like (expr).something; fixed.
83   *              Allowed multiple inheritance in tree grammar. oops.
84   * Version 1.16 (August 22, 1999)
85   *              Extending an interface built a wacky tree: had extra EXTENDS.
86   *              Tree grammar didn't allow multiple superinterfaces.
87   *              Tree grammar didn't allow empty var initializer: {}
88   * Version 1.17 (October 12, 1999)
89   *              ESC lexer rule allowed 399 max not 377 max.
90   *              java.tree.g didn't handle the expression of synchronized
91   *              statements.
92   * Version 1.18 (August 12, 2001)
93   *              Terence updated to Java 2 Version 1.3 by
94   *              observing/combining work of Allan Jacobs and Steve
95   *              Messick.  Handles 1.3 src.  Summary:
96   *              o  primary didn't include boolean.class kind of thing
97   *              o  constructor calls parsed explicitly now:
98   *                 see explicitConstructorInvocation
99   *              o  add strictfp modifier
100  *              o  missing objBlock after new expression in tree grammar
101  *              o  merged local class definition alternatives, moved after declaration
102  *              o  fixed problem with ClassName.super.field
103  *              o  reordered some alternatives to make things more efficient
104  *              o  long and double constants were not differentiated from int/float
105  *              o  whitespace rule was inefficient: matched only one char
106  *              o  add an examples directory with some nasty 1.3 cases
107  *              o  made Main.java use buffered IO and a Reader for Unicode support
108  *              o  supports UNICODE?
109  *                 Using Unicode charVocabulay makes code file big, but only
110  *                 in the bitsets at the end. I need to make ANTLR generate
111  *                 unicode bitsets more efficiently.
112  * Version 1.19 (April 25, 2002)
113  *              Terence added in nice fixes by John Pybus concerning floating
114  *              constants and problems with super() calls.  John did a nice
115  *              reorg of the primary/postfix expression stuff to read better
116  *              and makes f.g.super() parse properly (it was METHOD_CALL not
117  *              a SUPER_CTOR_CALL).  Also:
118  *
119  *              o  "finally" clause was a root...made it a child of "try"
120  *              o  Added stuff for asserts too for Java 1.4, but *commented out*
121  *                 as it is not backward compatible.
122  *
123  * Version 1.20 (October 27, 2002)
124  *
125  *        Terence ended up reorging John Pybus' stuff to
126  *        remove some nondeterminisms and some syntactic predicates.
127  *        Note that the grammar is stricter now; e.g., this(...) must
128  *      be the first statement.
129  *
130  *        Trinary ?: operator wasn't working as array name:
131  *                (isBig ? bigDigits : digits)[i];
132  *
133  *        Checked parser/tree parser on source for
134  *                Resin-2.0.5, jive-2.1.1, jdk 1.3.1, Lucene, antlr 2.7.2a4,
135  *              and the 110k-line jGuru server source.
136  *
137  * Version 1.21 (October 17, 2003)
138  *  Fixed lots of problems including:
139  *  Ray Waldin: add typeDefinition to interfaceBlock in java.tree.g
140  *  He found a problem/fix with floating point that start with 0
141  *  Ray also fixed problem that (int.class) was not recognized.
142  *  Thorsten van Ellen noticed that \n are allowed incorrectly in strings.
143  *  TJP fixed CHAR_LITERAL analogously.
144  *
145  * Version 1.21.2 (March, 2003)
146  *        Changes by Matt Quail to support generics (as per JDK1.5/JSR14)
147  *        Notes:
148  *        o We only allow the "extends" keyword and not the "implements"
149  *              keyword, since thats what JSR14 seems to imply.
150  *        o Thanks to Monty Zukowski for his help on the antlr-interest
151  *              mail list.
152  *        o Thanks to Alan Eliasen for testing the grammar over his
153  *              Fink source base
154  *
155  * Version 1.22 (July, 2004)
156  *        Changes by Michael Studman to support Java 1.5 language extensions
157  *        Notes:
158  *        o Added support for annotations types
159  *        o Finished off Matt Quail's generics enhancements to support bound type arguments
160  *        o Added support for new for statement syntax
161  *        o Added support for static import syntax
162  *        o Added support for enum types
163  *        o Tested against JDK 1.5 source base and source base of jdigraph project
164  *        o Thanks to Matt Quail for doing the hard part by doing most of the generics work
165  *
166  * Version 1.22.1 (July 28, 2004)
167  *        Bug/omission fixes for Java 1.5 language support
168  *        o Fixed tree structure bug with classOrInterface - thanks to Pieter Vangorpto for
169  *              spotting this
170  *        o Fixed bug where incorrect handling of SR and BSR tokens would cause type
171  *              parameters to be recognised as type arguments.
172  *        o Enabled type parameters on constructors, annotations on enum constants
173  *              and package definitions
174  *        o Fixed problems when parsing if ((char.class.equals(c))) {} - solution by Matt Quail at Cenqua
175  *
176  * Version 1.22.2 (July 28, 2004)
177  *        Slight refactoring of Java 1.5 language support
178  *        o Refactored for/"foreach" productions so that original literal "for" literal
179  *          is still used but the for sub-clauses vary by token type
180  *        o Fixed bug where type parameter was not included in generic constructor's branch of AST
181  *
182  * Version 1.22.3 (August 26, 2004)
183  *        Bug fixes as identified by Michael Stahl; clean up of tabs/spaces
184  *        and other refactorings
185  *        o Fixed typeParameters omission in identPrimary and newStatement
186  *        o Replaced GT reconcilliation code with simple semantic predicate
187  *        o Adapted enum/assert keyword checking support from Michael Stahl's java15 grammar
188  *        o Refactored typeDefinition production and field productions to reduce duplication
189  *
190  * Version 1.22.4 (October 21, 2004)
191  *    Small bux fixes
192  *    o Added typeArguments to explicitConstructorInvocation, e.g. new <String>MyParameterised()
193  *    o Added typeArguments to postfixExpression productions for anonymous inner class super
194  *      constructor invocation, e.g. new Outer().<String>super()
195  *    o Fixed bug in array declarations identified by Geoff Roy
196  *
197  * Version 1.22.4.g.1
198  *    o I have taken java.g for Java1.5 from Michael Studman (1.22.4)
199  *      and have applied the groovy.diff from java.g (1.22) by John Rose
200  *      back onto the new root (1.22.4) - Jeremy Rayner (Jan 2005)
201  *    o for a map of the task see... 
202  *      http://groovy.javanicus.com/java-g.png
203  *
204  * This grammar is in the PUBLIC DOMAIN
205  */
206 public class GroovyRecognizer extends antlr.LLkParser       implements GroovyTokenTypes
207  {
208 
209         /*** This factory is the correct way to wire together a Groovy parser and lexer. */
210     public static GroovyRecognizer make(GroovyLexer lexer) {
211         GroovyRecognizer parser = new GroovyRecognizer(lexer.plumb());
212         // TODO: set up a common error-handling control block, to avoid excessive tangle between these guys
213         parser.lexer = lexer;
214         lexer.parser = parser;
215         parser.setASTNodeClass("org.codehaus.groovy.antlr.GroovySourceAST");
216         parser.warningList = new ArrayList();
217         return parser;
218     }
219     // Create a scanner that reads from the input stream passed to us...
220     public static GroovyRecognizer make(InputStream in) { return make(new GroovyLexer(in)); }
221     public static GroovyRecognizer make(Reader in) { return make(new GroovyLexer(in)); }
222     public static GroovyRecognizer make(InputBuffer in) { return make(new GroovyLexer(in)); }
223     public static GroovyRecognizer make(LexerSharedInputState in) { return make(new GroovyLexer(in)); }
224     
225     private static GroovySourceAST dummyVariableToforceClassLoaderToFindASTClass = new GroovySourceAST();
226 
227     List warningList;
228     public List getWarningList() { return warningList; }
229     
230     GroovyLexer lexer;
231     public GroovyLexer getLexer() { return lexer; }
232     public void setFilename(String f) { super.setFilename(f); lexer.setFilename(f); }
233     private SourceBuffer sourceBuffer;
234     public void setSourceBuffer(SourceBuffer sourceBuffer) {
235         this.sourceBuffer = sourceBuffer;
236     }
237 
238     /*** Create an AST node with the token type and text passed in, but
239      *  with the same background information as another supplied Token (e.g. line numbers)
240      * to be used in place of antlr tree construction syntax,
241      * i.e. #[TOKEN,"text"]  becomes  create(TOKEN,"text",anotherToken)
242      *
243      * todo - change antlr.ASTFactory to do this instead...
244      */
245     public AST create(int type, String txt, Token first, Token last) {
246         AST t = astFactory.create(type,txt);
247         if ( t != null && first != null) {
248             // first copy details from first token
249             t.initialize(first);
250             // then ensure that type and txt are specific to this new node
251             t.initialize(type,txt);
252         }
253 
254         if ((t instanceof GroovySourceAST) && last != null) {
255             GroovySourceAST node = (GroovySourceAST)t;
256             node.setLast(last);
257             // This is a good point to call node.setSnippet(),
258             // but it bulks up the AST too much for production code.
259         }
260         return t;
261     }
262 
263 
264     // stuff to adjust ANTLR's tracing machinery
265     public static boolean tracing = false;  // only effective if antlr.Tool is run with -traceParser
266     public void traceIn(String rname) throws TokenStreamException {
267         if (!GroovyRecognizer.tracing)  return;
268         super.traceIn(rname);
269     }
270     public void traceOut(String rname) throws TokenStreamException {
271         if (!GroovyRecognizer.tracing)  return;
272         if (returnAST != null)  rname += returnAST.toStringList();
273         super.traceOut(rname);
274     }
275         
276     // Error handling.  This is a funnel through which parser errors go, when the parser can suggest a solution.
277     public void requireFailed(String problem, String solution) throws SemanticException {
278         // TODO: Needs more work.
279         Token lt = null;
280         try { lt = LT(1); }
281         catch (TokenStreamException ee) { }
282         if (lt == null)  lt = Token.badToken;
283         throw new SemanticException(problem + ";\n   solution: " + solution,
284                                     getFilename(), lt.getLine(), lt.getColumn());
285     }
286 
287     public void addWarning(String warning, String solution) {
288         Token lt = null;
289         try { lt = LT(1); }
290         catch (TokenStreamException ee) { }
291         if (lt == null)  lt = Token.badToken;
292 
293         Map row = new HashMap();
294         row.put("warning" ,warning);
295         row.put("solution",solution);
296         row.put("filename",getFilename());
297         row.put("line"    ,new Integer(lt.getLine()));
298         row.put("column"  ,new Integer(lt.getColumn()));
299         // System.out.println(row);
300         warningList.add(row);
301     }
302 
303     // Convenience method for checking of expected error syndromes.
304     private void require(boolean z, String problem, String solution) throws SemanticException {
305         if (!z)  requireFailed(problem, solution);
306     }
307 
308 
309     // Query a name token to see if it begins with a capital letter.
310     // This is used to tell the difference (w/o symbol table access) between {String x} and {println x}.
311     private boolean isUpperCase(Token x) {
312         if (x == null || x.getType() != IDENT)  return false;  // cannot happen?
313         String xtext = x.getText();
314         return (xtext.length() > 0 && Character.isUpperCase(xtext.charAt(0)));
315     }
316 
317     private AST currentClass = null;  // current enclosing class (for constructor recognition)
318     // Query a name token to see if it is identical with the current class name.
319     // This is used to distinguish constructors from other methods.
320     private boolean isConstructorIdent(Token x) {
321         if (currentClass == null)  return false;
322         if (currentClass.getType() != IDENT)  return false;  // cannot happen?
323         String cname = currentClass.getText();
324 
325         if (x == null || x.getType() != IDENT)  return false;  // cannot happen?
326         return cname.equals(x.getText());
327     }
328 
329     // Scratch variable for last 'sep' token.
330     // Written by the 'sep' rule, read only by immediate callers of 'sep'.
331     // (Not entirely clean, but better than a million xx=sep occurrences.)
332     private int sepToken = EOF;
333 
334     // Scratch variable for last argument list; tells whether there was a label.
335     // Written by 'argList' rule, read only by immediate callers of 'argList'.
336     private boolean argListHasLabels = false;
337 
338     // Scratch variable, holds most recently completed pathExpression.
339     // Read only by immediate callers of 'pathExpression' and 'expression'.
340     private AST lastPathExpression = null;
341 
342     // Inherited attribute pushed into most expression rules.
343     // If not zero, it means that the left context of the expression
344     // being parsed is a statement boundary or an initializer sign '='.
345     // Only such expressions are allowed to reach across newlines
346     // to pull in an LCURLY and appended block.
347     private final int LC_STMT = 1, LC_INIT = 2;
348 
349     /***
350      * Counts the number of LT seen in the typeArguments production.
351      * It is used in semantic predicates to ensure we have seen
352      * enough closing '>' characters; which actually may have been
353      * either GT, SR or BSR tokens.
354      */
355     private int ltCounter = 0;
356     
357     /* This symbol is used to work around a known ANTLR limitation.
358      * In a loop with syntactic predicate, ANTLR needs help knowing
359      * that the loop exit is a second alternative.
360      * Example usage:  ( (LCURLY)=> block | {ANTLR_LOOP_EXIT}? )*
361      * Probably should be an ANTLR RFE.
362      */
363     ////// Original comment in Java grammar:
364     // Unfortunately a syntactic predicate can only select one of
365     // multiple alternatives on the same level, not break out of
366     // an enclosing loop, which is why this ugly hack (a fake
367     // empty alternative with always-false semantic predicate)
368     // is necessary.
369     private static final boolean ANTLR_LOOP_EXIT = false;
370 
371 protected GroovyRecognizer(TokenBuffer tokenBuf, int k) {
372   super(tokenBuf,k);
373   tokenNames = _tokenNames;
374   buildTokenTypeASTClassMap();
375   astFactory = new ASTFactory(getTokenTypeToASTClassMap());
376 }
377 
378 public GroovyRecognizer(TokenBuffer tokenBuf) {
379   this(tokenBuf,3);
380 }
381 
382 protected GroovyRecognizer(TokenStream lexer, int k) {
383   super(lexer,k);
384   tokenNames = _tokenNames;
385   buildTokenTypeASTClassMap();
386   astFactory = new ASTFactory(getTokenTypeToASTClassMap());
387 }
388 
389 public GroovyRecognizer(TokenStream lexer) {
390   this(lexer,3);
391 }
392 
393 public GroovyRecognizer(ParserSharedInputState state) {
394   super(state,3);
395   tokenNames = _tokenNames;
396   buildTokenTypeASTClassMap();
397   astFactory = new ASTFactory(getTokenTypeToASTClassMap());
398 }
399 
400 	public final void compilationUnit() throws RecognitionException, TokenStreamException {
401 		
402 		returnAST = null;
403 		ASTPair currentAST = new ASTPair();
404 		AST compilationUnit_AST = null;
405 		
406 		{
407 		switch ( LA(1)) {
408 		case SH_COMMENT:
409 		{
410 			match(SH_COMMENT);
411 			break;
412 		}
413 		case EOF:
414 		case FINAL:
415 		case ABSTRACT:
416 		case STRICTFP:
417 		caseg> LITERAL_package:
418 		case LITERAL_import:
419 		case LITERAL_static:
420 		case LITERAL_def:
421 		case AT:
422 		case IDENT:
423 		case LBRACK:
424 		case LPAREN:
425 		case LITERAL_class:
426 		case LITERAL_interface:
427 		case LITERAL_enum:
428 		case LITERAL_super:
429 		case LITERAL_void:
430 		case LITERAL_boolean:
431 		case LITERAL_byte:
432 		case LITERAL_char:
433 		case LITERAL_short:
434 		case LITERAL_int:
435 		case LITERAL_float:
436 		case LITERAL_long:
437 		case LITERAL_double:
438 		case LITERAL_any:
439 		case STAR:
440 		case LITERAL_private:
441 		case LITERAL_public:
442 		case LITERAL_protected:
443 		case LITERAL_transient:
444 		case LITERAL_native:
445 		case LITERAL_threadsafe:
446 		case LITERAL_synchronized:
447 		case LITERAL_volatile:
448 		case LCURLY:
449 		case SEMI:
450 		case NLS:
451 		case LITERAL_this:
452 		case STRING_LITERAL:
453 		case LITERAL_if:
454 		case LITERAL_while:
455 		case LITERAL_with:
456 		case LITERAL_switch:
457 		case LITERAL_for:
458 		case LITERAL_return:
459 		case LITERAL_break:
460 		case LITERAL_continue:
461 		case LITERAL_throw:
462 		case LITERAL_assert:
463 		case PLUS:
464 		case MINUS:
465 		case LITERAL_try:
466 		case INC:
467 		case DEC:
468 		case BNOT:
469 		case LNOT:
470 		case DOLLAR:
471 		case STRING_CTOR_START:
472 		case LITERAL_new:
473 		case LITERAL_true:
474 		case LITERAL_false:
475 		case LITERAL_null:
476 		case NUM_INT:
477 		case NUM_FLOAT:
478 		case NUM_LONG:
479 		case NUM_DOUBLE:
480 		case NUM_BIG_INT:
481 		case NUM_BIG_DECIMAL:
482 		{
483 			break;
484 		}
485 		default:
486 		{
487 			throw new NoViableAltException(LT(1), getFilename());
488 		}
489 		}
490 		}
491 		nls();
492 		{
493 		boolean synPredMatched5 = false;
494 		if (((LA(1)==LITERAL_package||LA(1)==AT) && (LA(2)==IDENT) && (_tokenSet_0.member(LA(3))))) {
495 			int _m5 = mark();
496 			synPredMatched5 = true;
497 			inputState.guessing++;
498 			try {
499 				{
500 				annotationsOpt();
501 				match(LITERAL_package);
502 				}
503 			}
504 			catch (RecognitionException pe) {
505 				synPredMatched5 = false;
506 			}
507 			rewind(_m5);
508 			inputState.guessing--;
509 		}
510 		if ( synPredMatched5 ) {
511 			packageDefinition();
512 			astFactory.addASTChild(currentAST, returnAST);
513 		}
514 		else if ((_tokenSet_1.member(LA(1))) && (_tokenSet_2.member(LA(2))) && (_tokenSet_3.member(LA(3)))) {
515 			{
516 			switch ( LA(1)) {
517 			case FINAL:
518 			case ABSTRACT:
519 			case STRICTFP:
520 			case LITERAL_import:
521 			case LITERAL_static:
522 			case LITERAL_def:
523 			case AT:
524 			case IDENT:
525 			case LBRACK:
526 			case LPAREN:
527 			case LITERAL_class:
528 			case LITERAL_interface:
529 			case LITERAL_enum:
530 			case LITERAL_super:
531 			case LITERAL_void:
532 			case LITERAL_boolean:
533 			case LITERAL_byte:
534 			case LITERAL_char:
535 			case LITERAL_short:
536 			case LITERAL_int:
537 			case LITERAL_float:
538 			case LITERAL_long:
539 			case LITERAL_double:
540 			case LITERAL_any:
541 			case STAR:
542 			case LITERAL_private:
543 			case LITERAL_public:
544 			case LITERAL_protected:
545 			case LITERAL_transient:
546 			case LITERAL_native:
547 			case LITERAL_threadsafe:
548 			case LITERAL_synchronized:
549 			case LITERAL_volatile:
550 			case LCURLY:
551 			case LITERAL_this:
552 			case STRING_LITERAL:
553 			case LITERAL_if:
554 			case LITERAL_while:
555 			case LITERAL_with:
556 			case LITERAL_switch:
557 			case LITERAL_for:
558 			case LITERAL_return:
559 			case LITERAL_break:
560 			case LITERAL_continue:
561 			case LITERAL_throw:
562 			case LITERAL_assert:
563 			case PLUS:
564 			case MINUS:
565 			case LITERAL_try:
566 			case INC:
567 			case DEC:
568 			case BNOT:
569 			case LNOT:
570 			case DOLLAR:
571 			case STRING_CTOR_START:
572 			case LITERAL_new:
573 			case LITERAL_true:
574 			case LITERAL_false:
575 			case LITERAL_null:
576 			case NUM_INT:
577 			case NUM_FLOAT:
578 			case NUM_LONG:
579 			case NUM_DOUBLE:
580 			case NUM_BIG_INT:
581 			case NUM_BIG_DECIMAL:
582 			{
583 				statement(EOF);
584 				astFactory.addASTChild(currentAST, returnAST);
585 				break;
586 			}
587 			case EOF:
588 			case SEMI:
589 			case NLS:
590 			{
591 				break;
592 			}
593 			default:
594 			{
595 				throw new NoViableAltException(LT(1), getFilename());
596 			}
597 			}
598 			}
599 		}
600 		else {
601 			throw new NoViableAltException(LT(1), getFilename());
602 		}
603 		
604 		}
605 		{
606 		_loop9:
607 		do {
608 			if ((LA(1)==SEMI||LA(1)==NLS)) {
609 				sep();
610 				{
611 				switch ( LA(1)) {
612 				case FINAL:
613 				case ABSTRACT:
614 				case STRICTFP:
615 				case LITERAL_import:
616 				case LITERAL_static:
617 				case LITERAL_def:
618 				case AT:
619 				case IDENT:
620 				case LBRACK:
621 				case LPAREN:
622 				case LITERAL_class:
623 				case LITERAL_interface:
624 				case LITERAL_enum:
625 				case LITERAL_super:
626 				case LITERAL_void:
627 				case LITERAL_boolean:
628 				case LITERAL_byte:
629 				case LITERAL_char:
630 				case LITERAL_short:
631 				case LITERAL_int:
632 				case LITERAL_float:
633 				case LITERAL_long:
634 				case LITERAL_double:
635 				case LITERAL_any:
636 				case STAR:
637 				case LITERAL_private:
638 				case LITERAL_public:
639 				case LITERAL_protected:
640 				case LITERAL_transient:
641 				case LITERAL_native:
642 				case LITERAL_threadsafe:
643 				case LITERAL_synchronized:
644 				case LITERAL_volatile:
645 				case LCURLY:
646 				case LITERAL_this:
647 				case STRING_LITERAL:
648 				case LITERAL_if:
649 				case LITERAL_while:
650 				case LITERAL_with:
651 				case LITERAL_switch:
652 				case LITERAL_for:
653 				case LITERAL_return:
654 				case LITERAL_break:
655 				case LITERAL_continue:
656 				case LITERAL_throw:
657 				case LITERAL_assert:
658 				case PLUS:
659 				case MINUS:
660 				case LITERAL_try:
661 				case INC:
662 				case DEC:
663 				case BNOT:
664 				case LNOT:
665 				case DOLLAR:
666 				case STRING_CTOR_START:
667 				case LITERAL_new:
668 				case LITERAL_true:
669 				case LITERAL_false:
670 				case LITERAL_null:
671 				case NUM_INT:
672 				case NUM_FLOAT:
673 				case NUM_LONG:
674 				case NUM_DOUBLE:
675 				case NUM_BIG_INT:
676 				case NUM_BIG_DECIMAL:
677 				{
678 					statement(sepToken);
679 					astFactory.addASTChild(currentAST, returnAST);
680 					break;
681 				}
682 				case EOF:
683 				case SEMI:
684 				case NLS:
685 				{
686 					break;
687 				}
688 				default:
689 				{
690 					throw new NoViableAltException(LT(1), getFilename());
691 				}
692 				}
693 				}
694 			}
695 			else {
696 				break _loop9;
697 			}
698 			
699 		} while (true);
700 		}
701 		match(Token.EOF_TYPE);
702 		compilationUnit_AST = (AST)currentAST.root;
703 		returnAST = compilationUnit_AST;
704 	}
705 	
706 /*** Zero or more insignificant newlines, all gobbled up and thrown away. */
707 	public final void nls() throws RecognitionException, TokenStreamException {
708 		
709 		returnAST = null;
710 		ASTPair currentAST = new ASTPair();
711 		AST nls_AST = null;
712 		
713 		{
714 		if ((LA(1)==NLS) && (_tokenSet_4.member(LA(2))) && (_tokenSet_5.member(LA(3)))) {
715 			match(NLS);
716 		}
717 		else if ((_tokenSet_4.member(LA(1))) && (_tokenSet_5.member(LA(2))) && (_tokenSet_5.member(LA(3)))) {
718 		}
719 		else {
720 			throw new NoViableAltException(LT(1), getFilename());
721 		}
722 		
723 		}
724 		returnAST = nls_AST;
725 	}
726 	
727 	public final void annotationsOpt() throws RecognitionException, TokenStreamException {
728 		
729 		returnAST = null;
730 		ASTPair currentAST = new ASTPair();
731 		AST annotationsOpt_AST = null;
732 		Token first = LT(1);
733 		
734 		{
735 		_loop79:
736 		do {
737 			if ((LA(1)==AT)) {
738 				annotation();
739 				astFactory.addASTChild(currentAST, returnAST);
740 				nls();
741 			}
742 			else {
743 				break _loop79;
744 			}
745 			
746 		} while (true);
747 		}
748 		if ( inputState.guessing==0 ) {
749 			annotationsOpt_AST = (AST)currentAST.root;
750 			annotationsOpt_AST = (AST)astFactory.make( (new ASTArray(2)).add(create(ANNOTATIONS,"ANNOTATIONS",first,LT(1))).add(annotationsOpt_AST));
751 			currentAST.root = annotationsOpt_AST;
752 			currentAST.child = annotationsOpt_AST!=null &&annotationsOpt_AST.getFirstChild()!=null ?
753 				annotationsOpt_AST.getFirstChild() : annotationsOpt_AST;
754 			currentAST.advanceChildToEnd();
755 		}
756 		annotationsOpt_AST = (AST)currentAST.root;
757 		returnAST = annotationsOpt_AST;
758 	}
759 	
760 	public> final void packageDefinition() throws RecognitionException, TokenStreamException {
761 		
762 		returnAST = null;
763 		ASTPair currentAST = new ASTPair();
764 		AST packageDefinition_AST = null;
765 		Token  p = null;
766 		AST p_AST = null;
767 		
768 		annotationsOpt();
769 		astFactory.addASTChild(currentAST, returnAST);
770 		p = LT(1);
771 		p_AST = astFactory.create(p);
772 		astFactory.makeASTRoot(currentAST, p_AST);
773 		match(LITERAL_package);
774 		if ( inputState.guessing==0 ) {
775 			p_AST.setType(PACKAGE_DEF);
776 		}
777 		identifier();
778 		astFactory.addASTChild(currentAST, returnAST);
779 		packageDefinition_AST = (AST)currentAST.root;
780 		returnAST = packageDefinition_AST;
781 	}
782 	
783 /*** A statement is an element of a block.
784  *  Typical statements are declarations (which are scoped to the block)
785  *  and expressions.
786  */
787 	public final void statement(
788 		int prevToken
789 	) throws RecognitionException, TokenStreamException {
790 		
791 		returnAST = null;
792 		ASTPair currentAST = new ASTPair();
793 		AST statement_AST = null;
794 		AST pfx_AST = null;
795 		AST m_AST = null;
796 		Token  sp = null;
797 		AST sp_AST = null;
798 		
799 		switch ( LA(1)) {
800 		case LITERAL_if:
801 		{
802 			AST tmp4_AST = null;
803 			tmp4_AST = astFactory.create(LT(1));
804 			astFactory.makeASTRoot(currentAST, tmp4_AST);
805 			match(LITERAL_if);
806 			match(LPAREN);
807 			assignmentLessExpression();
808 			astFactory.addASTChild(currentAST, returnAST);
809 			match(RPAREN);
810 			nlsWarn();
811 			compatibleBodyStatement();
812 			astFactory.addASTChild(currentAST, returnAST);
813 			{
814 			boolean synPredMatched251 = false;
815 			if (((_tokenSet_6.member(LA(1))) && (_tokenSet_7.member(LA(2))) && (_tokenSet_8.member(LA(3))))) {
816 				int _m251 = mark();
817 				synPredMatched251 = true;
818 				inputState.guessing++;
819 				try {
820 					{
821 					{
822 					switch ( LA(1)) {
823 					case SEMI:
824 					case NLS:
825 					{
826 						sep();
827 						break;
828 					}
829 					case LITERAL_else:
830 					{
831 						break;
832 					}
833 					default:
834 					{
835 						throw new NoViableAltException(LT(1), getFilename());
836 					}
837 					}
838 					}
839 					match(LITERAL_else);
840 					}
841 				}
842 				catch (RecognitionException pe) {
843 					synPredMatched251 = false;
844 				}
845 				rewind(_m251);
846 				inputState.guessing--;
847 			}
848 			if ( synPredMatched251 ) {
849 				{
850 				switch ( LA(1)) {
851 				case SEMI:
852 				case NLS:
853 				{
854 					sep();
855 					break;
856 				}
857 				case LITERAL_else:
858 				{
859 					break;
860 				}
861 				default:
862 				{
863 					throw new NoViableAltException(LT(1), getFilename());
864 				}
865 				}
866 				}
867 				match(LITERAL_else);
868 				nlsWarn();
869 				compatibleBodyStatement();
870 				astFactory.addASTChild(currentAST, returnAST);
871 			}
872 			else if ((_tokenSet_9.member(LA(1))) && (_tokenSet_10.member(LA(2))) && (_tokenSet_11.member(LA(3)))) {
873 			}
874 			else {
875 				throw new NoViableAltException(LT(1), getFilename());
876 			}
877 			
878 			}
879 			statement_AST = (AST)currentAST.root;
880 			break;
881 		}
882 		case LITERAL_for:
883 		{
884 			forStatement();
885 			astFactory.addASTChild(currentAST, returnAST);
886 			statement_AST = (AST)currentAST.root;
887 			break;
888 		}
889 		case LITERAL_while:
890 		{
891 			AST tmp8_AST = null;
892 			tmp8_AST = astFactory.create(LT(1));
893 			astFactory.makeASTRoot(currentAST, tmp8_AST);
894 			match(LITERAL_while);
895 			match(LPAREN);
896 			strictContextExpression();
897 			astFactory.addASTChild(currentAST, returnAST);
898 			match(RPAREN);
899 			nlsWarn();
900 			compatibleBodyStatement();
901 			astFactory.addASTChild(currentAST, returnAST);
902 			statement_AST = (AST)currentAST.root;
903 			break;
904 		}
905 		case LITERAL_with:
906 		{
907 			AST tmp11_AST = null;
908 			tmp11_AST = astFactory.create(LT(1));
909 			astFactory.makeASTRoot(currentAST, tmp11_AST);
910 			match(LITERAL_with);
911 			match(LPAREN);
912 			strictContextExpression();
913 			astFactory.addASTChild(currentAST, returnAST);
914 			match(RPAREN);
915 			nlsWarn();
916 			compoundStatement();
917 			astFactory.addASTChild(currentAST, returnAST);
918 			statement_AST = (AST)currentAST.root;
919 			break;
920 		}
921 		case STAR:
922 		{
923 			sp = LT(1);
924 			sp_AST = astFactory.create(sp);
925 			astFactory.makeASTRoot(currentAST, sp_AST);
926 			match(STAR);
927 			nls();
928 			if ( inputState.guessing==0 ) {
929 				sp_AST.setType(SPREAD_ARG);
930 			}
931 			expressionStatement(EOF);
932 			astFactory.addASTChild(currentAST, returnAST);
933 			statement_AST = (AST)currentAST.root;
934 			break;
935 		}
936 		case LITERAL_import:
937 		{
938 			importStatement();
939 			astFactory.addASTChild(currentAST, returnAST);
940 			statement_AST = (AST)currentAST.root;
941 			break;
942 		}
943 		case LITERAL_switch:
944 		{
945 			AST tmp14_AST = null;
946 			tmp14_AST = astFactory.create(LT(1));
947 			astFactory.makeASTRoot(currentAST, tmp14_AST);
948 			match(LITERAL_switch);
949 			match(LPAREN);
950 			strictContextExpression();
951 			astFactory.addASTChild(currentAST, returnAST);
952 			match(RPAREN);
953 			nlsWarn();
954 			match(LCURLY);
955 			nls();
956 			{
957 			_loop254:
958 			do {
959 				if ((LA(1)==LITERAL_default||LA(1)==LITERAL_case)) {
960 					casesGroup();
961 					astFactory.addASTChild(currentAST, returnAST);
962 				}
963 				else {
964 					break _loop254;
965 				}
966 				
967 			} while (true);
968 			}
969 			match(RCURLY);
970 			statement_AST = (AST)currentAST.root;
971 			break;
972 		}
973 		case LITERAL_try:
974 		{
975 			tryBlock();
976 			astFactory.addASTChild(currentAST, returnAST);
977 			statement_AST = (AST)currentAST.root;
978 			break;
979 		}
980 		case LITERAL_return:
981 		case LITERAL_break:
982 		case LITERAL_continue:
983 		case LITERAL_throw:
984 		case LITERAL_assert:
985 		{
986 			branchStatement();
987 			astFactory.addASTChild(currentAST, returnAST);
988 			statement_AST = (AST)currentAST.root;
989 			break;
990 		}
991 		default:
992 			boolean synPredMatched242 = false;
993 			if (((_tokenSet_12.member(LA(1))) && (_tokenSet_13.member(LA(2))) && (_tokenSet_14.member(LA(3))))) {
994 				int _m242 = mark();
995 				synPredMatched242 = true;
996 				inputState.guessing++;
997 				try {
998 					{
999 					declarationStart();
1000 					}
1001 				}
1002 				catch (RecognitionException pe) {
1003 					synPredMatched242 = false;
1004 				}
1005 				rewind(_m242);
1006 				inputState.guessing--;
1007 			}
1008 			if ( synPredMatched242 ) {
1009 				declaration();
1010 				astFactory.addASTChild(currentAST, returnAST);
1011 				statement_AST = (AST)currentAST.root;
1012 			}
1013 			else {
1014 				boolean synPredMatched244 = false;
1015 				if (((LA(1)==IDENT) && (LA(2)==COLON) && (_tokenSet_15.member(LA(3))))) {
1016 					int _m244 = mark();
1017 					synPredMatched244 = true;
1018 					inputState.guessing++;
1019 					try {
1020 						{
1021 						match(IDENT);
1022 						match(COLON);
1023 						}
1024 					}
1025 					catch (RecognitionException pe) {
1026 						synPredMatched244 = false;
1027 					}
1028 					rewind(_m244);
1029 					inputState.guessing--;
1030 				}
1031 				if ( synPredMatched244 ) {
1032 					statementLabelPrefix();
1033 					pfx_AST = (AST)returnAST;
1034 					if ( inputState.guessing==0 ) {
1035 						statement_AST = (AST)currentAST.root;
1036 						statement_AST = pfx_AST;
1037 						currentAST.root = statement_AST;
1038 						currentAST.child = statement_AST!=null &&statement_AST.getFirstChild()!=null ?
1039 							statement_AST.getFirstChild() : statement_AST;
1040 						currentAST.advanceChildToEnd();
1041 					}
1042 					{
1043 					boolean synPredMatched247 = false;
1044 					if (((LA(1)==LCURLY) && (_tokenSet_16.member(LA(2))) && (_tokenSet_8.member(LA(3))))) {
1045 						int _m247 = mark();
1046 						synPredMatched247 = true;
1047 						inputState.guessing++;
1048 						try {
1049 							{
1050 							match(LCURLY);
1051 							}
1052 						}
1053 						catch (RecognitionException pe) {
1054 							synPredMatched247 = false;
1055 						}
1056 						rewind(_m247);
1057 						inputState.guessing--;
1058 					}
1059 					if ( synPredMatched247 ) {
1060 						openOrClosableBlock();
1061 						astFactory.addASTChild(currentAST, returnAST);
1062 					}
1063 					else if ((_tokenSet_17.member(LA(1))) && (_tokenSet_8.member(LA(2))) && (_tokenSet_18.member(LA(3)))) {
1064 						statement(COLON);
1065 						astFactory.addASTChild(currentAST, returnAST);
1066 					}
1067 					else {
1068 						throw new NoViableAltException(LT(1), getFilename());
1069 					}
1070 					
1071 					}
1072 					statement_AST = (AST)currentAST.root;
1073 				}
1074 				else if ((_tokenSet_19.member(LA(1))) && (_tokenSet_8.member(LA(2))) && (_tokenSet_20.member(LA(3)))) {
1075 					expressionStatement(prevToken);
1076 					astFactory.addASTChild(currentAST, returnAST);
1077 					statement_AST = (AST)currentAST.root;
1078 				}
1079 				else if ((_tokenSet_21.member(LA(1))) && (_tokenSet_22.member(LA(2))) && (_tokenSet_23.member(LA(3)))) {
1080 					modifiersOpt();
1081 					m_AST = (AST)returnAST;
1082 					typeDefinitionInternal(m_AST);
1083 					astFactory.addASTChild(currentAST, returnAST);
1084 					statement_AST = (AST)currentAST.root;
1085 				}
1086 				else if ((LA(1)==LITERAL_synchronized) && (LA(2)==LPAREN)) {
1087 					AST tmp19_AST = null;
1088 					tmp19_AST = astFactory.create(LT(1));
1089 					astFactory.makeASTRoot(currentAST, tmp19_AST);
1090 					match(LITERAL_synchronized);
1091 					match(LPAREN);
1092 					strictContextExpression();
1093 					astFactory.addASTChild(currentAST, returnAST);
1094 					match(RPAREN);
1095 					nlsWarn();
1096 					compoundStatement();
1097 					astFactory.addASTChild(currentAST, returnAST);
1098 					statement_AST = (AST)currentAST.root;
1099 				}
1100 			else {
1101 				throw new NoViableAltException(LT(1), getFilename());
1102 			}
1103 			}}
1104 			returnAST = statement_AST;
1105 		}
1106 		
1107 /*** A statement separator is either a semicolon or a significant newline. 
1108  *  Any number of additional (insignificant) newlines may accompany it.
1109  */
1110 	public final void sep() throws RecognitionException, TokenStreamException {
1111 		
1112 		returnAST = null;
1113 		ASTPair currentAST = new ASTPair();
1114 		AST sep_AST = null;
1115 		
1116 		switch ( LA(1)) {
1117 		case SEMI:
1118 		{
1119 			match(SEMI);
1120 			{
1121 			_loop475:
1122 			do {
1123 				if ((LA(1)==NLS) && (_tokenSet_24.member(LA(2))) && (_tokenSet_20.member(LA(3)))) {
1124 					match(NLS);
1125 				}
1126 				else {
1127 					break _loop475;
1128 				}
1129 				
1130 			} while (true);
1131 			}
1132 			if ( inputState.guessing==0 ) {
1133 				sepToken = SEMI;
1134 			}
1135 			break;
1136 		}
1137 		case NLS:
1138 		{
1139 			match(NLS);
1140 			if ( inputState.guessing==0 ) {
1141 				sepToken = NLS;
1142 			}
1143 			{
1144 			_loop479:
1145 			do {
1146 				if ((LA(1)==SEMI) && (_tokenSet_24.member(LA(2))) && (_tokenSet_20.member(LA(3)))) {
1147 					match(SEMI);
1148 					{
1149 					_loop478:
1150 					do {
1151 						if ((LA(1)==NLS) && (_tokenSet_24.member(LA(2))) && (_tokenSet_20.member(LA(3)))) {
1152 							match(NLS);
1153 						}
1154 						else {
1155 							break _loop478;
1156 						}
1157 						
1158 					} while (true);
1159 					}
1160 					if ( inputState.guessing==0 ) {
1161 						sepToken = SEMI;
1162 					}
1163 				}
1164 				else {
1165 					break _loop479;
1166 				}
1167 				
1168 			} while (true);
1169 			}
1170 			break;
1171 		}
1172 		default:
1173 		{
1174 			throw new NoViableAltException(LT(1), getFilename());
1175 		}
1176 		}
1177 		returnAST = sep_AST;
1178 	}
1179 	
1180 /*** A Groovy script or simple expression.  Can be anything legal inside {...}. */
1181 	public final void snippetUnit() throws RecognitionException, TokenStreamException {
1182 		
1183 		returnAST = null;
1184 		ASTPair currentAST = new ASTPair();
1185 		AST snippetUnit_AST = null;
1186 		
1187 		nls();
1188 		blockBody(EOF);
1189 		astFactory.addASTChild(currentAST, returnAST);
1190 		snippetUnit_AST = (AST)currentAST.root;
1191 		returnAST = snippetUnit_AST;
1192 	}
1193 	
1194 /*** A block body is a parade of zero or more statements or expressions. */
1195 	public final void blockBody(
1196 		int prevToken
1197 	) throws RecognitionException, TokenStreamException {
1198 		
1199 		returnAST = null;
1200 		ASTPair currentAST = new ASTPair();
1201 		AST blockBody_AST = null;
1202 		
1203 		{
1204 		switch ( LA(1)) {
1205 		case FINAL:
1206 		case ABSTRACT:
1207 		case STRICTFP:
1208 		case LITERAL_import:
1209 		case LITERAL_static:
1210 		case LITERAL_def:
1211 		case AT:
1212 		case IDENT:
1213 		case LBRACK:
1214 		case LPAREN:
1215 		case LITERAL_class:
1216 		case LITERAL_interface:
1217 		case LITERAL_enum:
1218 		case LITERAL_super:
1219 		case LITERAL_void:
1220 		case LITERAL_boolean:
1221 		case LITERAL_byte:
1222 		case LITERAL_char:
1223 		case LITERAL_short:
1224 		case LITERAL_int:
1225 		case LITERAL_float:
1226 		case LITERAL_long:
1227 		case LITERAL_double:
1228 		case LITERAL_any:
1229 		case STAR:
1230 		case LITERAL_private:
1231 		case LITERAL_public:
1232 		case LITERAL_protected:
1233 		case LITERAL_transient:
1234 		case LITERAL_native:
1235 		case LITERAL_threadsafe:
1236 		case LITERAL_synchronized:
1237 		case LITERAL_volatile:
1238 		case LCURLY:
1239 		case LITERAL_this:
1240 		case STRING_LITERAL:
1241 		case LITERAL_if:
1242 		case LITERAL_while:
1243 		case LITERAL_with:
1244 		case LITERAL_switch:
1245 		case LITERAL_for:
1246 		case LITERAL_return:
1247 		case LITERAL_break:
1248 		case LITERAL_continue:
1249 		case LITERAL_throw:
1250 		case LITERAL_assert:
1251 		case PLUS:
1252 		case MINUS:
1253 		case LITERAL_try:
1254 		case INC:
1255 		case DEC:
1256 		case BNOT:
1257 		case LNOT:
1258 		case DOLLAR:
1259 		case STRING_CTOR_START:
1260 		case LITERAL_new:
1261 		case LITERAL_true:
1262 		case LITERAL_false:
1263 		case LITERAL_null:
1264 		case NUM_INT:
1265 		case NUM_FLOAT:
1266 		case NUM_LONG:
1267 		case NUM_DOUBLE:
1268 		case NUM_BIG_INT:
1269 		case NUM_BIG_DECIMAL:
1270 		{
1271 			statement(prevToken);
1272 			astFactory.addASTChild(currentAST, returnAST);
1273 			break;
1274 		}
1275 		case EOF:
1276 		case RCURLY:
1277 		case SEMI:
1278 		case NLS:
1279 		{
1280 			break;
1281 		}
1282 		default:
1283 		{
1284 			throw new NoViableAltException(LT(1), getFilename());
1285 		}
1286 		}
1287 		}
1288 		{
1289 		_loop236:
1290 		do {
1291 			if ((LA(1)==SEMI||LA(1)==NLS)) {
1292 				sep();
1293 				{
1294 				switch ( LA(1)) {
1295 				case FINAL:
1296 				case ABSTRACT:
1297 				case STRICTFP:
1298 				case LITERAL_import:
1299 				case LITERAL_static:
1300 				case LITERAL_def:
1301 				case AT:
1302 				case IDENT:
1303 				case LBRACK:
1304 				case LPAREN:
1305 				case LITERAL_class:
1306 				case LITERAL_interface:
1307 				case LITERAL_enum:
1308 				case LITERAL_super:
1309 				case LITERAL_void:
1310 				case LITERAL_boolean:
1311 				case LITERAL_byte:
1312 				case LITERAL_char:
1313 				case LITERAL_short:
1314 				case LITERAL_int:
1315 				case LITERAL_float:
1316 				case LITERAL_long:
1317 				case LITERAL_double:
1318 				case LITERAL_any:
1319 				case STAR:
1320 				case LITERAL_private:
1321 				case LITERAL_public:
1322 				case LITERAL_protected:
1323 				case LITERAL_transient:
1324 				case LITERAL_native:
1325 				case LITERAL_threadsafe:
1326 				case LITERAL_synchronized:
1327 				case LITERAL_volatile:
1328 				case LCURLY:
1329 				case LITERAL_this:
1330 				case STRING_LITERAL:
1331 				case LITERAL_if:
1332 				case LITERAL_while:
1333 				case LITERAL_with:
1334 				case LITERAL_switch:
1335 				case LITERAL_for:
1336 				case LITERAL_return:
1337 				case LITERAL_break:
1338 				case LITERAL_continue:
1339 				case LITERAL_throw:
1340 				case LITERAL_assert:
1341 				case PLUS:
1342 				case MINUS:
1343 				case LITERAL_try:
1344 				case INC:
1345 				case DEC:
1346 				case BNOT:
1347 				case LNOT:
1348 				case DOLLAR:
1349 				case STRING_CTOR_START:
1350 				case LITERAL_new:
1351 				case LITERAL_true:
1352 				case LITERAL_false:
1353 				case LITERAL_null:
1354 				case NUM_INT:
1355 				case NUM_FLOAT:
1356 				case NUM_LONG:
1357 				case NUM_DOUBLE:
1358 				case NUM_BIG_INT:
1359 				case NUM_BIG_DECIMAL:
1360 				{
1361 					statement(sepToken);
1362 					astFactory.addASTChild(currentAST, returnAST);
1363 					break;
1364 				}
1365 				case EOF:
1366 				case RCURLY:
1367 				case SEMI:
1368 				case NLS:
1369 				{
1370 					break;
1371 				}
1372 				default:
1373 				{
1374 					throw new NoViableAltException(LT(1), getFilename());
1375 				}
1376 				}
1377 				}
1378 			}
1379 			else {
1380 				break _loop236;
1381 			}
1382 			
1383 		} while (true);
1384 		}
1385 		blockBody_AST = (AST)currentAST.root;
1386 		returnAST = blockBody_AST;
1387 	}
1388 	
1389 	public final void identifier() throws RecognitionException, TokenStreamException {
1390 		
1391 		returnAST = null;
1392 		ASTPair currentAST = new ASTPair();
1393 		AST identifier_AST = null;
1394 		
1395 		AST tmp27_AST = null;
1396 		tmp27_AST = astFactory.create(LT(1));
1397 		astFactory.addASTChild(currentAST, tmp27_AST);
1398 		match(IDENT);
1399 		{
1400 		_loop62:
1401 		do {
1402 			if ((LA(1)==DOT)) {
1403 				AST tmp28_AST = null;
1404 				tmp28_AST = astFactory.create(LT(1));
1405 				astFactory.makeASTRoot(currentAST, tmp28_AST);
1406 				match(DOT);
1407 				nls();
1408 				AST tmp29_AST = null;
1409 				tmp29_AST = astFactory.create(LT(1));
1410 				astFactory.addASTChild(currentAST, tmp29_AST);
1411 				match(IDENT);
1412 			}
1413 			else {
1414 				break _loop62;
1415 			}
1416 			
1417 		} while (true);
1418 		}
1419 		identifier_AST = (AST)currentAST.root;
1420 		returnAST = identifier_AST;
1421 	}
1422 	
1423 	public final void importStatement() throws RecognitionException, TokenStreamException {
1424 		
1425 		returnAST = null;
1426 		ASTPair currentAST = new ASTPair();
1427 		AST importStatement_AST = null;
1428 		Token  i = null;
1429 		AST i_AST = null;
1430 		boolean isStatic = false;
1431 		
1432 		i = LT(1);
1433 		i_AST = astFactory.create(i);
1434 		astFactory.makeASTRoot(currentAST, i_AST);
1435 		match(LITERAL_import);
1436 		if ( inputState.guessing==0 ) {
1437 			i_AST.setType(IMPORT);
1438 		}
1439 		{
1440 		switch ( LA(1)) {
1441 		case LITERAL_static:
1442 		{
1443 			match(LITERAL_static);
1444 			if ( inputState.guessing==0 ) {
1445 				i_AST.setType(STATIC_IMPORT);
1446 			}
1447 			break;
1448 		}
1449 		case IDENT:
1450 		{
1451 			break;
1452 		}
1453 		default:
1454 		{
1455 			throw new NoViableAltException(LT(1), getFilename());
1456 		}
1457 		}
1458 		}
1459 		identifierStar();
1460 		astFactory.addASTChild(currentAST, returnAST);
1461 		importStatement_AST = (AST)currentAST.root;
1462 		returnAST = importStatement_AST;
1463 	}
1464 	
1465 	public final void identifierStar() throws RecognitionException, TokenStreamException {
1466 		
1467 		returnAST = null;
1468 		ASTPair currentAST = new ASTPair();
1469 		AST identifierStar_AST = null;
1470 		
1471 		AST tmp31_AST = null;
1472 		tmp31_AST = astFactory.create(LT(1));
1473 		astFactory.addASTChild(currentAST, tmp31_AST);
1474 		match(IDENT);
1475 		{
1476 		_loop65:
1477 		do {
1478 			if ((LA(1)==DOT) && (LA(2)==IDENT||LA(2)==NLS) && (_tokenSet_25.member(LA(3)))) {
1479 				AST tmp32_AST = null;
1480 				tmp32_AST = astFactory.create(LT(1));
1481 				astFactory.makeASTRoot(currentAST, tmp32_AST);
1482 				match(DOT);
1483 				nls();
1484 				AST tmp33_AST = null;
1485 				tmp33_AST = astFactory.create(LT(1));
1486 				astFactory.addASTChild(currentAST, tmp33_AST);
1487 				match(IDENT);
1488 			}
1489 			else {
1490 				break _loop65;
1491 			}
1492 			
1493 		} while (true);
1494 		}
1495 		{
1496 		switch ( LA(1)) {
1497 		case DOT:
1498 		{
1499 			AST tmp34_AST = null;
1500 			tmp34_AST = astFactory.create(LT(1));
1501 			astFactory.makeASTRoot(currentAST, tmp34_AST);
1502 			match(DOT);
1503 			nls();
1504 			AST tmp35_AST = null;
1505 			tmp35_AST = astFactory.create(LT(1));
1506 			astFactory.addASTChild(currentAST, tmp35_AST);
1507 			match(STAR);
1508 			break;
1509 		}
1510 		case LITERAL_as:
1511 		{
1512 			AST tmp36_AST = null;
1513 			tmp36_AST = astFactory.create(LT(1));
1514 			astFactory.makeASTRoot(currentAST, tmp36_AST);
1515 			match(LITERAL_as);
1516 			nls();
1517 			AST tmp37_AST = null;
1518 			tmp37_AST = astFactory.create(LT(1));
1519 			astFactory.addASTChild(currentAST, tmp37_AST);
1520 			match(IDENT);
1521 			break;
1522 		}
1523 		case EOF:
1524 		case RCURLY:
1525 		case SEMI:
1526 		case NLS:
1527 		case LITERAL_default:
1528 		case LITERAL_else:
1529 		case LITERAL_case:
1530 		{
1531 			break;
1532 		}
1533 		default:
1534 		{
1535 			throw new NoViableAltException(LT(1), getFilename());
1536 		}
1537 		}
1538 		}
1539 		identifierStar_AST = (AST)currentAST.root;
1540 		returnAST = identifierStar_AST;
1541 	}
1542 	
1543 	protected final void typeDefinitionInternal(
1544 		AST mods
1545 	) throws RecognitionException, TokenStreamException {
1546 		
1547 		returnAST = null;
1548 		ASTPair currentAST = new ASTPair();
1549 		AST typeDefinitionInternal_AST = null;
1550 		AST cd_AST = null;
1551 		AST id_AST = null;
1552 		AST ed_AST = null;
1553 		AST ad_AST = null;
1554 		
1555 		switch ( LA(1)) {
1556 		case LITERAL_class:
1557 		{
1558 			classDefinition(mods);
1559 			cd_AST = (AST)returnAST;
1560 			astFactory.addASTChild(currentAST, returnAST);
1561 			if ( inputState.guessing==0 ) {
1562 				typeDefinitionInternal_AST = (AST)currentAST.root;
1563 				typeDefinitionInternal_AST = cd_AST;
1564 				currentAST.root = typeDefinitionInternal_AST;
1565 				currentAST.child = typeDefinitionInternal_AST!=null &&typeDefinitionInternal_AST.getFirstChild()!=null ?
1566 					typeDefinitionInternal_AST.getFirstChild() : typeDefinitionInternal_AST;
1567 				currentAST.advanceChildToEnd();
1568 			}
1569 			typeDefinitionInternal_AST = (AST)currentAST.root;
1570 			break;
1571 		}
1572 		case LITERAL_interface:
1573 		{
1574 			interfaceDefinition(mods);
1575 			id_AST = (AST)returnAST;
1576 			astFactory.addASTChild(currentAST, returnAST);
1577 			if ( inputState.guessing==0 ) {
1578 				typeDefinitionInternal_AST = (AST)currentAST.root;
1579 				typeDefinitionInternal_AST = id_AST;
1580 				currentAST.root = typeDefinitionInternal_AST;
1581 				currentAST.child = typeDefinitionInternal_AST!=null &&typeDefinitionInternal_AST.getFirstChild()!=null ?
1582 					typeDefinitionInternal_AST.getFirstChild() : typeDefinitionInternal_AST;
1583 				currentAST.advanceChildToEnd();
1584 			}
1585 			typeDefinitionInternal_AST = (AST)currentAST.root;
1586 			break;
1587 		}
1588 		case LITERAL_enum:
1589 		{
1590 			enumDefinition(mods);
1591 			ed_AST = (AST)returnAST;
1592 			astFactory.addASTChild(currentAST, returnAST);
1593 			if ( inputState.guessing==0 ) {
1594 				typeDefinitionInternal_AST = (AST)currentAST.root;
1595 				typeDefinitionInternal_AST = ed_AST;
1596 				currentAST.root = typeDefinitionInternal_AST;
1597 				currentAST.child = typeDefinitionInternal_AST!=null &&typeDefinitionInternal_AST.getFirstChild()!=null ?
1598 					typeDefinitionInternal_AST.getFirstChild() : typeDefinitionInternal_AST;
1599 				currentAST.advanceChildToEnd();
1600 			}
1601 			typeDefinitionInternal_AST = (AST)currentAST.root;
1602 			break;
1603 		}
1604 		case AT:
1605 		{
1606 			annotationDefinition(mods);
1607 			ad_AST = (AST)returnAST;
1608 			astFactory.addASTChild(currentAST, returnAST);
1609 			if ( inputState.guessing==0 ) {
1610 				typeDefinitionInternal_AST = (AST)currentAST.root;
1611 				typeDefinitionInternal_AST = ad_AST;
1612 				currentAST.root = typeDefinitionInternal_AST;
1613 				currentAST.child = typeDefinitionInternal_AST!=null &&typeDefinitionInternal_AST.getFirstChild()!=null ?
1614 					typeDefinitionInternal_AST.getFirstChild() : typeDefinitionInternal_AST;
1615 				currentAST.advanceChildToEnd();
1616 			}
1617 			typeDefinitionInternal_AST = (AST)currentAST.root;
1618 			break;
1619 		}
1620 		default:
1621 		{
1622 			throw new NoViableAltException(LT(1), getFilename());
1623 		}
1624 		}
1625 		returnAST = typeDefinitionInternal_AST;
1626 	}
1627 	
1628 	public final void classDefinition(
1629 		AST modifiers
1630 	) throws RecognitionException, TokenStreamException {
1631 		
1632 		returnAST = null;
1633 		ASTPair currentAST = new ASTPair();
1634 		AST classDefinition_AST = null;
1635 		AST tp_AST = null;
1636 		AST sc_AST = null;
1637 		AST ic_AST = null;
1638 		AST cb_AST = null;
1639 		Token first = LT(1);AST prevCurrentClass = currentClass;
1640 		
1641 		match(LITERAL_class);
1642 		AST tmp39_AST = null;
1643 		tmp39_AST = astFactory.create(LT(1));
1644 		match(IDENT);
1645 		nls();
1646 		if ( inputState.guessing==0 ) {
1647 			currentClass = tmp39_AST;
1648 		}
1649 		{
1650 		switch ( LA(1)) {
1651 		case LT:
1652 		{
1653 			typeParameters();
1654 			tp_AST = (AST)returnAST;
1655 			break;
1656 		}
1657 		case LITERAL_extends:
1658 		case LCURLY:
1659 		case LITERAL_implements:
1660 		{
1661 			break;
1662 		}
1663 		default:
1664 		{
1665 			throw new NoViableAltException(LT(1), getFilename());
1666 		}
1667 		}
1668 		}