KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > parser > Parser


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  * Tom Tromey - patch for readTable(String) as described in http://bugs.eclipse.org/bugs/show_bug.cgi?id=32196
11  *******************************************************************************/

12 package org.eclipse.jdt.internal.compiler.parser;
13
14 import java.io.*;
15 import java.util.ArrayList JavaDoc;
16 import java.util.Collections JavaDoc;
17 import java.util.Iterator JavaDoc;
18 import java.util.List JavaDoc;
19 import java.util.Locale JavaDoc;
20 import java.util.MissingResourceException JavaDoc;
21 import java.util.ResourceBundle JavaDoc;
22
23 import org.eclipse.jdt.core.compiler.CharOperation;
24 import org.eclipse.jdt.core.compiler.InvalidInputException;
25 import org.eclipse.jdt.internal.compiler.ASTVisitor;
26 import org.eclipse.jdt.internal.compiler.CompilationResult;
27 import org.eclipse.jdt.internal.compiler.ast.*;
28 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
29 import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
30 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
31 import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
32 import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
33 import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
34 import org.eclipse.jdt.internal.compiler.lookup.Binding;
35 import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers;
36 import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
37 import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
38 import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
39 import org.eclipse.jdt.internal.compiler.parser.diagnose.DiagnoseParser;
40 import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
41 import org.eclipse.jdt.internal.compiler.problem.AbortCompilationUnit;
42 import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
43 import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
44 import org.eclipse.jdt.internal.compiler.util.Messages;
45 import org.eclipse.jdt.internal.compiler.util.Util;
46
47 public class Parser implements ParserBasicInformation, TerminalTokens, OperatorIds, TypeIds {
48     protected static final int THIS_CALL = ExplicitConstructorCall.This;
49     protected static final int SUPER_CALL = ExplicitConstructorCall.Super;
50
51     public static char asb[] = null;
52     public static char asr[] = null;
53     //ast stack
54
protected final static int AstStackIncrement = 100;
55     public static char base_action[] = null;
56     public static final int BracketKinds = 3;
57     
58     public static short check_table[] = null;
59     public static final int CurlyBracket = 2;
60     private static final boolean DEBUG = false;
61     private static final boolean DEBUG_AUTOMATON = false;
62     private static final String JavaDoc EOF_TOKEN = "$eof" ; //$NON-NLS-1$
63
private static final String JavaDoc ERROR_TOKEN = "$error" ; //$NON-NLS-1$
64
//expression stack
65
protected final static int ExpressionStackIncrement = 100;
66
67     protected final static int GenericsStackIncrement = 10;
68     
69     private final static String JavaDoc FILEPREFIX = "parser"; //$NON-NLS-1$
70
public static char in_symb[] = null;
71     private static final String JavaDoc INVALID_CHARACTER = "Invalid Character" ; //$NON-NLS-1$
72
public static char lhs[] = null;
73
74     public static String JavaDoc name[] = null;
75     public static char nasb[] = null;
76     public static char nasr[] = null;
77     public static char non_terminal_index[] = null;
78     private final static String JavaDoc READABLE_NAMES_FILE = "readableNames"; //$NON-NLS-1$
79
private final static String JavaDoc READABLE_NAMES_FILE_NAME =
80         "org.eclipse.jdt.internal.compiler.parser." + READABLE_NAMES_FILE; //$NON-NLS-1$
81
public static String JavaDoc readableName[] = null;
82     
83     public static byte rhs[] = null;
84     
85     public static int[] reverse_index = null;
86     public static char[] recovery_templates_index = null;
87     public static char[] recovery_templates = null;
88     public static char[] statements_recovery_filter = null;
89     
90     public static long rules_compliance[] = null;
91     
92     public static final int RoundBracket = 0;
93     
94     public static byte scope_la[] = null;
95     public static char scope_lhs[] = null;
96     
97     public static char scope_prefix[] = null;
98     public static char scope_rhs[] = null;
99     public static char scope_state[] = null;
100
101     public static char scope_state_set[] = null;
102     public static char scope_suffix[] = null;
103     public static final int SquareBracket = 1;
104         
105     //internal data for the automat
106
protected final static int StackIncrement = 255;
107     
108     public static char term_action[] = null;
109     public static byte term_check[] = null;
110
111     public static char terminal_index[] = null;
112
113     private static final String JavaDoc UNEXPECTED_EOF = "Unexpected End Of File" ; //$NON-NLS-1$
114
public static boolean VERBOSE_RECOVERY = false;
115
116
117
118     protected int astLengthPtr;
119     protected int[] astLengthStack;
120     protected int astPtr;
121     protected ASTNode[] astStack = new ASTNode[AstStackIncrement];
122     public CompilationUnitDeclaration compilationUnit; /*the result from parse()*/
123     protected RecoveredElement currentElement;
124     public int currentToken;
125     protected boolean diet = false; //tells the scanner to jump over some parts of the code/expressions like method bodies
126
protected int dietInt = 0; // if > 0 force the none-diet-parsing mode (even if diet if requested) [field parsing with anonymous inner classes...]
127
protected int endPosition; //accurate only when used ! (the start position is pushed into intStack while the end the current one)
128
protected int endStatementPosition;
129     protected int expressionLengthPtr;
130     protected int[] expressionLengthStack;
131     protected int expressionPtr;
132     protected Expression[] expressionStack = new Expression[ExpressionStackIncrement];
133     public int firstToken ; // handle for multiple parsing goals
134

135     // generics management
136
protected int genericsIdentifiersLengthPtr;
137     protected int[] genericsIdentifiersLengthStack = new int[GenericsStackIncrement];
138     protected int genericsLengthPtr;
139     protected int[] genericsLengthStack = new int[GenericsStackIncrement];
140     protected int genericsPtr;
141     protected ASTNode[] genericsStack = new ASTNode[GenericsStackIncrement];
142     
143     protected boolean hasError;
144     protected boolean hasReportedError;
145
146     //identifiers stacks
147
protected int identifierLengthPtr;
148     protected int[] identifierLengthStack;
149     protected long[] identifierPositionStack;
150     protected int identifierPtr;
151     protected char[][] identifierStack;
152     
153     protected boolean ignoreNextOpeningBrace;
154     //positions , dimensions , .... (int stacks)
155
protected int intPtr;
156     protected int[] intStack;
157     public int lastAct ; //handle for multiple parsing goals
158

159     //error recovery management
160
protected int lastCheckPoint;
161     protected int lastErrorEndPosition;
162     protected int lastErrorEndPositionBeforeRecovery = -1;
163     protected int lastIgnoredToken, nextIgnoredToken;
164     protected int listLength; // for recovering some incomplete list (interfaces, throws or parameters)
165
protected int listTypeParameterLength; // for recovering some incomplete list (type parameters)
166
protected int lParenPos,rParenPos; //accurate only when used !
167
protected int modifiers;
168     protected int modifiersSourceStart;
169     protected int[] nestedMethod; //the ptr is nestedType
170
protected int nestedType, dimensions;
171     ASTNode [] noAstNodes = new ASTNode[AstStackIncrement];
172     Expression [] noExpressions = new Expression[ExpressionStackIncrement];
173     //modifiers dimensions nestedType etc.......
174
protected boolean optimizeStringLiterals =true;
175     protected CompilerOptions options;
176     protected ProblemReporter problemReporter;
177     protected int rBraceStart, rBraceEnd, rBraceSuccessorStart; //accurate only when used !
178
protected int realBlockPtr;
179     protected int[] realBlockStack;
180     protected int recoveredStaticInitializerStart;
181     public ReferenceContext referenceContext;
182     public boolean reportOnlyOneSyntaxError = false;
183     public boolean reportSyntaxErrorIsRequired = true;
184     protected boolean restartRecovery;
185     
186     // statement recovery
187
// public boolean statementRecoveryEnabled = true;
188
public boolean methodRecoveryActivated = false;
189     protected boolean statementRecoveryActivated = false;
190     protected TypeDeclaration[] recoveredTypes;
191     protected int recoveredTypePtr;
192     protected int nextTypeStart;
193     protected TypeDeclaration pendingRecoveredType;
194     
195     public RecoveryScanner recoveryScanner;
196     
197     //scanner token
198
public Scanner scanner;
199     protected int[] stack = new int[StackIncrement];
200     protected int stateStackTop;
201     protected int synchronizedBlockSourceStart;
202     protected int[] variablesCounter;
203
204     protected boolean checkExternalizeStrings;
205     protected boolean recordStringLiterals;
206     
207     // javadoc
208
public Javadoc javadoc;
209     public JavadocParser javadocParser;
210     // used for recovery
211
protected int lastJavadocEnd;
212     
213     static {
214         try{
215             initTables();
216         } catch(java.io.IOException JavaDoc ex){
217             throw new ExceptionInInitializerError JavaDoc(ex.getMessage());
218         }
219     }
220 public static int asi(int state) {
221
222     return asb[original_state(state)];
223 }
224 public final static short base_check(int i) {
225     return check_table[i - (NUM_RULES + 1)];
226 }
227 private final static void buildFile(String JavaDoc filename, List JavaDoc listToDump) {
228     BufferedWriter writer = null;
229     try {
230         writer = new BufferedWriter(new FileWriter(filename));
231         for (Iterator JavaDoc iterator = listToDump.iterator(); iterator.hasNext(); ) {
232             writer.write(String.valueOf(iterator.next()));
233         }
234         writer.flush();
235     } catch(IOException e) {
236         // ignore
237
} finally {
238         if (writer != null) {
239             try {
240                 writer.close();
241             } catch (IOException e1) {
242                 // ignore
243
}
244         }
245     }
246     System.out.println(filename + " creation complete"); //$NON-NLS-1$
247
}
248 private final static String JavaDoc[] buildFileForName(String JavaDoc filename, String JavaDoc contents) {
249     String JavaDoc[] result = new String JavaDoc[contents.length()];
250     result[0] = null;
251     int resultCount = 1;
252     
253     StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
254     
255     int start = contents.indexOf("name[]"); //$NON-NLS-1$
256
start = contents.indexOf('\"', start);
257     int end = contents.indexOf("};", start); //$NON-NLS-1$
258

259     contents = contents.substring(start, end);
260     
261     boolean addLineSeparator = false;
262     int tokenStart = -1;
263     StringBuffer JavaDoc currentToken = new StringBuffer JavaDoc();
264     for (int i = 0; i < contents.length(); i++) {
265         char c = contents.charAt(i);
266         if(c == '\"') {
267             if(tokenStart == -1) {
268                 tokenStart = i + 1;
269             } else {
270                 if(addLineSeparator) {
271                     buffer.append('\n');
272                     result[resultCount++] = currentToken.toString();
273                     currentToken = new StringBuffer JavaDoc();
274                 }
275                 String JavaDoc token = contents.substring(tokenStart, i);
276                 if(token.equals(ERROR_TOKEN)){
277                     token = INVALID_CHARACTER;
278                 } else if(token.equals(EOF_TOKEN)) {
279                     token = UNEXPECTED_EOF;
280                 }
281                 buffer.append(token);
282                 currentToken.append(token);
283                 addLineSeparator = true;
284                 tokenStart = -1;
285             }
286         }
287         if(tokenStart == -1 && c == '+'){
288             addLineSeparator = false;
289         }
290     }
291     if(currentToken.length() > 0) {
292         result[resultCount++] = currentToken.toString();
293     }
294     
295     buildFileForTable(filename, buffer.toString().toCharArray());
296     
297     System.arraycopy(result, 0, result = new String JavaDoc[resultCount], 0, resultCount);
298     return result;
299 }
300 private static void buildFileForReadableName(
301     String JavaDoc file,
302     char[] newLhs,
303     char[] newNonTerminalIndex,
304     String JavaDoc[] newName,
305     String JavaDoc[] tokens) {
306
307     ArrayList JavaDoc entries = new ArrayList JavaDoc();
308     
309     boolean[] alreadyAdded = new boolean[newName.length];
310     
311     for (int i = 0; i < tokens.length; i = i + 3) {
312         if("1".equals(tokens[i])) { //$NON-NLS-1$
313
int index = newNonTerminalIndex[newLhs[Integer.parseInt(tokens[i + 1])]];
314             StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
315             if(!alreadyAdded[index]) {
316                 alreadyAdded[index] = true;
317                 buffer.append(newName[index]);
318                 buffer.append('=');
319                 buffer.append(tokens[i+2].trim());
320                 buffer.append('\n');
321                 entries.add(String.valueOf(buffer));
322             }
323         }
324     }
325     int i = 1;
326     while(!INVALID_CHARACTER.equals(newName[i])) i++;
327     i++;
328     for (; i < alreadyAdded.length; i++) {
329         if(!alreadyAdded[i]) {
330             System.out.println(newName[i] + " has no readable name"); //$NON-NLS-1$
331
}
332     }
333     Collections.sort(entries);
334     buildFile(file, entries);
335 }
336 private static void buildFilesForRecoveryTemplates(
337     String JavaDoc indexFilename,
338     String JavaDoc templatesFilename,
339     char[] newTerminalIndex,
340     char[] newNonTerminalIndex,
341     String JavaDoc[] newName,
342     char[] newLhs,
343     String JavaDoc[] tokens) {
344     
345     int[] newReverse = computeReverseTable(newTerminalIndex, newNonTerminalIndex, newName);
346     
347     char[] newRecoveyTemplatesIndex = new char[newNonTerminalIndex.length];
348     char[] newRecoveyTemplates = new char[newNonTerminalIndex.length];
349     int newRecoveyTemplatesPtr = 0;
350     
351     for (int i = 0; i < tokens.length; i = i + 3) {
352         if("3".equals(tokens[i])) { //$NON-NLS-1$
353
int length = newRecoveyTemplates.length;
354             if(length == newRecoveyTemplatesPtr + 1) {
355                 System.arraycopy(newRecoveyTemplates, 0, newRecoveyTemplates = new char[length * 2], 0, length);
356             }
357             newRecoveyTemplates[newRecoveyTemplatesPtr++] = 0;
358             
359             int index = newLhs[Integer.parseInt(tokens[i + 1])];
360             
361             newRecoveyTemplatesIndex[index] = (char)newRecoveyTemplatesPtr;
362             
363             String JavaDoc token = tokens[i + 2].trim();
364             java.util.StringTokenizer JavaDoc st = new java.util.StringTokenizer JavaDoc(new String JavaDoc(token), " "); //$NON-NLS-1$
365
String JavaDoc[] terminalNames = new String JavaDoc[st.countTokens()];
366             int t = 0;
367             while (st.hasMoreTokens()) {
368                 terminalNames[t++] = st.nextToken();
369             }
370             
371             for (int j = 0; j < terminalNames.length; j++) {
372                 int symbol = getSymbol(terminalNames[j], newName, newReverse);
373                 if(symbol > -1) {
374                     length = newRecoveyTemplates.length;
375                     if(length == newRecoveyTemplatesPtr + 1) {
376                         System.arraycopy(newRecoveyTemplates, 0, newRecoveyTemplates = new char[length * 2], 0, length);
377                     }
378                     newRecoveyTemplates[newRecoveyTemplatesPtr++] = (char)symbol;
379                 }
380             }
381         }
382     }
383     newRecoveyTemplates[newRecoveyTemplatesPtr++] = 0;
384     System.arraycopy(newRecoveyTemplates, 0, newRecoveyTemplates = new char[newRecoveyTemplatesPtr], 0, newRecoveyTemplatesPtr);
385     
386     buildFileForTable(indexFilename, newRecoveyTemplatesIndex);
387     buildFileForTable(templatesFilename, newRecoveyTemplates);
388 }
389 private static void buildFilesForStatementsRecoveryFilter(
390         String JavaDoc filename,
391         char[] newNonTerminalIndex,
392         char[] newLhs,
393         String JavaDoc[] tokens) {
394         
395         char[] newStatementsRecoveryFilter = new char[newNonTerminalIndex.length];
396         
397         for (int i = 0; i < tokens.length; i = i + 3) {
398             if("4".equals(tokens[i])) { //$NON-NLS-1$
399
int index = newLhs[Integer.parseInt(tokens[i + 1])];
400                 
401                 newStatementsRecoveryFilter[index] = 1;
402             }
403         }
404         buildFileForTable(filename, newStatementsRecoveryFilter);
405     }
406 private static void buildFileForCompliance(
407         String JavaDoc file,
408         int length,
409         String JavaDoc[] tokens) {
410
411         byte[] result = new byte[length * 8];
412         
413         for (int i = 0; i < tokens.length; i = i + 3) {
414             if("2".equals(tokens[i])) { //$NON-NLS-1$
415
int index = Integer.parseInt(tokens[i + 1]);
416                 String JavaDoc token = tokens[i + 2].trim();
417                 long compliance = 0;
418                 if("1.4".equals(token)) { //$NON-NLS-1$
419
compliance = ClassFileConstants.JDK1_4;
420                 } else if("1.5".equals(token)) { //$NON-NLS-1$
421
compliance = ClassFileConstants.JDK1_5;
422                 } else if("recovery".equals(token)) { //$NON-NLS-1$
423
compliance = ClassFileConstants.JDK_DEFERRED;
424                 }
425                 
426                 int j = index * 8;
427                 result[j] = (byte)(compliance >>> 56);
428                 result[j + 1] = (byte)(compliance >>> 48);
429                 result[j + 2] = (byte)(compliance >>> 40);
430                 result[j + 3] = (byte)(compliance >>> 32);
431                 result[j + 4] = (byte)(compliance >>> 24);
432                 result[j + 5] = (byte)(compliance >>> 16);
433                 result[j + 6] = (byte)(compliance >>> 8);
434                 result[j + 7] = (byte)(compliance);
435             }
436         }
437
438         buildFileForTable(file, result);
439     }
440 private final static void buildFileForTable(String JavaDoc filename, byte[] bytes) {
441     java.io.FileOutputStream JavaDoc stream = null;
442     try {
443         stream = new java.io.FileOutputStream JavaDoc(filename);
444         stream.write(bytes);
445     } catch(IOException e) {
446         // ignore
447
} finally {
448         if (stream != null) {
449             try {
450                 stream.close();
451             } catch (IOException e) {
452                 // ignore
453
}
454         }
455     }
456     System.out.println(filename + " creation complete"); //$NON-NLS-1$
457
}
458 private final static void buildFileForTable(String JavaDoc filename, char[] chars) {
459     byte[] bytes = new byte[chars.length * 2];
460     for (int i = 0; i < chars.length; i++) {
461         bytes[2 * i] = (byte) (chars[i] >>> 8);
462         bytes[2 * i + 1] = (byte) (chars[i] & 0xFF);
463     }
464
465     java.io.FileOutputStream JavaDoc stream = null;
466     try {
467         stream = new java.io.FileOutputStream JavaDoc(filename);
468         stream.write(bytes);
469     } catch(IOException e) {
470         // ignore
471
} finally {
472         if (stream != null) {
473             try {
474                 stream.close();
475             } catch (IOException e) {
476                 // ignore
477
}
478         }
479     }
480     System.out.println(filename + " creation complete"); //$NON-NLS-1$
481
}
482 private final static byte[] buildFileOfByteFor(String JavaDoc filename, String JavaDoc tag, String JavaDoc[] tokens) {
483
484     //transform the String tokens into chars before dumping then into file
485

486     int i = 0;
487     //read upto the tag
488
while (!tokens[i++].equals(tag)){/*empty*/}
489     //read upto the }
490

491     byte[] bytes = new byte[tokens.length]; //can't be bigger
492
int ic = 0;
493     String JavaDoc token;
494     while (!(token = tokens[i++]).equals("}")) { //$NON-NLS-1$
495
int c = Integer.parseInt(token);
496         bytes[ic++] = (byte) c;
497     }
498
499     //resize
500
System.arraycopy(bytes, 0, bytes = new byte[ic], 0, ic);
501
502     buildFileForTable(filename, bytes);
503     return bytes;
504 }
505 private final static char[] buildFileOfIntFor(String JavaDoc filename, String JavaDoc tag, String JavaDoc[] tokens) {
506
507     //transform the String tokens into chars before dumping then into file
508

509     int i = 0;
510     //read upto the tag
511
while (!tokens[i++].equals(tag)){/*empty*/}
512     //read upto the }
513

514     char[] chars = new char[tokens.length]; //can't be bigger
515
int ic = 0;
516     String JavaDoc token;
517     while (!(token = tokens[i++]).equals("}")) { //$NON-NLS-1$
518
int c = Integer.parseInt(token);
519         chars[ic++] = (char) c;
520     }
521
522     //resize
523
System.arraycopy(chars, 0, chars = new char[ic], 0, ic);
524
525     buildFileForTable(filename, chars);
526     return chars;
527 }
528 private final static void buildFileOfShortFor(String JavaDoc filename, String JavaDoc tag, String JavaDoc[] tokens) {
529
530     //transform the String tokens into chars before dumping then into file
531

532     int i = 0;
533     //read upto the tag
534
while (!tokens[i++].equals(tag)){/*empty*/}
535     //read upto the }
536

537     char[] chars = new char[tokens.length]; //can't be bigger
538
int ic = 0;
539     String JavaDoc token;
540     while (!(token = tokens[i++]).equals("}")) { //$NON-NLS-1$
541
int c = Integer.parseInt(token);
542         chars[ic++] = (char) (c + 32768);
543     }
544
545     //resize
546
System.arraycopy(chars, 0, chars = new char[ic], 0, ic);
547
548     buildFileForTable(filename, chars);
549 }
550 public final static void buildFilesFromLPG(String JavaDoc dataFilename, String JavaDoc dataFilename2) {
551
552     //RUN THIS METHOD TO GENERATE PARSER*.RSC FILES
553

554     //build from the lpg javadcl.java files that represents the parser tables
555
//lhs check_table asb asr symbol_index
556

557     //[org.eclipse.jdt.internal.compiler.parser.Parser.buildFilesFromLPG("d:/leapfrog/grammar/javadcl.java")]
558
char[] contents = CharOperation.NO_CHAR;
559     try {
560         contents = Util.getFileCharContent(new File(dataFilename), null);
561     } catch (IOException ex) {
562         System.out.println(Messages.parser_incorrectPath);
563         return;
564     }
565     java.util.StringTokenizer JavaDoc st =
566         new java.util.StringTokenizer JavaDoc(new String JavaDoc(contents), " \t\n\r[]={,;"); //$NON-NLS-1$
567
String JavaDoc[] tokens = new String JavaDoc[st.countTokens()];
568     int j = 0;
569     while (st.hasMoreTokens()) {
570         tokens[j++] = st.nextToken();
571     }
572     final String JavaDoc prefix = FILEPREFIX;
573     int i = 0;
574     
575     char[] newLhs = buildFileOfIntFor(prefix + (++i) + ".rsc", "lhs", tokens); //$NON-NLS-1$ //$NON-NLS-2$
576
buildFileOfShortFor(prefix + (++i) + ".rsc", "check_table", tokens); //$NON-NLS-2$ //$NON-NLS-1$
577
buildFileOfIntFor(prefix + (++i) + ".rsc", "asb", tokens); //$NON-NLS-2$ //$NON-NLS-1$
578
buildFileOfIntFor(prefix + (++i) + ".rsc", "asr", tokens); //$NON-NLS-2$ //$NON-NLS-1$
579
buildFileOfIntFor(prefix + (++i) + ".rsc", "nasb", tokens); //$NON-NLS-2$ //$NON-NLS-1$
580
buildFileOfIntFor(prefix + (++i) + ".rsc", "nasr", tokens); //$NON-NLS-2$ //$NON-NLS-1$
581
char[] newTerminalIndex = buildFileOfIntFor(prefix + (++i) + ".rsc", "terminal_index", tokens); //$NON-NLS-2$ //$NON-NLS-1$
582
char[] newNonTerminalIndex = buildFileOfIntFor(prefix + (++i) + ".rsc", "non_terminal_index", tokens); //$NON-NLS-1$ //$NON-NLS-2$
583
buildFileOfIntFor(prefix + (++i) + ".rsc", "term_action", tokens); //$NON-NLS-2$ //$NON-NLS-1$
584

585     buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_prefix", tokens); //$NON-NLS-2$ //$NON-NLS-1$
586
buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_suffix", tokens); //$NON-NLS-2$ //$NON-NLS-1$
587
buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_lhs", tokens); //$NON-NLS-2$ //$NON-NLS-1$
588
buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_state_set", tokens); //$NON-NLS-2$ //$NON-NLS-1$
589
buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_rhs", tokens); //$NON-NLS-2$ //$NON-NLS-1$
590
buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_state", tokens); //$NON-NLS-2$ //$NON-NLS-1$
591
buildFileOfIntFor(prefix + (++i) + ".rsc", "in_symb", tokens); //$NON-NLS-2$ //$NON-NLS-1$
592

593     byte[] newRhs = buildFileOfByteFor(prefix + (++i) + ".rsc", "rhs", tokens); //$NON-NLS-2$ //$NON-NLS-1$
594
buildFileOfByteFor(prefix + (++i) + ".rsc", "term_check", tokens); //$NON-NLS-2$ //$NON-NLS-1$
595
buildFileOfByteFor(prefix + (++i) + ".rsc", "scope_la", tokens); //$NON-NLS-2$ //$NON-NLS-1$
596

597     String JavaDoc[] newName = buildFileForName(prefix + (++i) + ".rsc", new String JavaDoc(contents)); //$NON-NLS-1$
598

599     contents = CharOperation.NO_CHAR;
600     try {
601         contents = Util.getFileCharContent(new File(dataFilename2), null);
602     } catch (IOException ex) {
603         System.out.println(Messages.parser_incorrectPath);
604         return;
605     }
606     st = new java.util.StringTokenizer JavaDoc(new String JavaDoc(contents), "\t\n\r#"); //$NON-NLS-1$
607
tokens = new String JavaDoc[st.countTokens()];
608     j = 0;
609     while (st.hasMoreTokens()) {
610         tokens[j++] = st.nextToken();
611     }
612     
613     buildFileForCompliance(prefix + (++i) + ".rsc", newRhs.length, tokens);//$NON-NLS-1$
614
buildFileForReadableName(READABLE_NAMES_FILE+".properties", newLhs, newNonTerminalIndex, newName, tokens);//$NON-NLS-1$
615

616     buildFilesForRecoveryTemplates(
617             prefix + (++i) + ".rsc", //$NON-NLS-1$
618
prefix + (++i) + ".rsc", //$NON-NLS-1$
619
newTerminalIndex,
620             newNonTerminalIndex,
621             newName,
622             newLhs,
623             tokens);
624     
625     buildFilesForStatementsRecoveryFilter(
626             prefix + (++i) + ".rsc", //$NON-NLS-1$
627
newNonTerminalIndex,
628             newLhs,
629             tokens);
630
631     
632     System.out.println(Messages.parser_moveFiles);
633 }
634 public static int in_symbol(int state) {
635     return in_symb[original_state(state)];
636 }
637 public final static void initTables() throws java.io.IOException JavaDoc {
638
639     final String JavaDoc prefix = FILEPREFIX;
640     int i = 0;
641     lhs = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
642
char[] chars = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
643
check_table = new short[chars.length];
644     for (int c = chars.length; c-- > 0;) {
645         check_table[c] = (short) (chars[c] - 32768);
646     }
647     asb = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
648
asr = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
649
nasb = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
650
nasr = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
651
terminal_index = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
652
non_terminal_index = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
653
term_action = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
654

655     scope_prefix = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
656
scope_suffix = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
657
scope_lhs = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
658
scope_state_set = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
659
scope_rhs = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
660
scope_state = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
661
in_symb = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
662

663     rhs = readByteTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
664
term_check = readByteTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
665
scope_la = readByteTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
666

667     name = readNameTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
668

669     rules_compliance = readLongTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
670

671     readableName = readReadableNameTable(READABLE_NAMES_FILE_NAME);
672     
673     reverse_index = computeReverseTable(terminal_index, non_terminal_index, name);
674     
675     recovery_templates_index = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
676
recovery_templates = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
677

678     statements_recovery_filter = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
679

680     base_action = lhs;
681 }
682 public static int nasi(int state) {
683     return nasb[original_state(state)];
684 }
685 public static int ntAction(int state, int sym) {
686     return base_action[state + sym];
687 }
688 protected static int original_state(int state) {
689     return -base_check(state);
690 }
691 protected static int[] computeReverseTable(char[] newTerminalIndex, char[] newNonTerminalIndex, String JavaDoc[] newName) {
692     int[] newReverseTable = new int[newName.length];
693     for (int j = 0; j < newName.length; j++) {
694         found : {
695             for (int k = 0; k < newTerminalIndex.length; k++) {
696                 if(newTerminalIndex[k] == j) {
697                     newReverseTable[j] = k;
698                     break found;
699                 }
700             }
701             for (int k = 0; k < newNonTerminalIndex.length; k++) {
702                 if(newNonTerminalIndex[k] == j) {
703                     newReverseTable[j] = -k;
704                     break found;
705                 }
706             }
707         }
708     }
709     return newReverseTable;
710 }
711
712 private static int getSymbol(String JavaDoc terminalName, String JavaDoc[] newName, int[] newReverse) {
713     for (int j = 0; j < newName.length; j++) {
714         if(terminalName.equals(newName[j])) {
715             return newReverse[j];
716         }
717     }
718     return -1;
719 }
720
721 protected static byte[] readByteTable(String JavaDoc filename) throws java.io.IOException JavaDoc {
722
723     //files are located at Parser.class directory
724

725     InputStream stream = Parser.class.getResourceAsStream(filename);
726     if (stream == null) {
727         throw new java.io.IOException JavaDoc(Messages.bind(Messages.parser_missingFile, filename));
728     }
729     byte[] bytes = null;
730     try {
731         stream = new BufferedInputStream(stream);
732         bytes = Util.getInputStreamAsByteArray(stream, -1);
733     } finally {
734         try {
735             stream.close();
736         } catch (IOException e) {
737             // ignore
738
}
739     }
740     return bytes;
741 }
742     
743 protected static String JavaDoc[] readNameTable(String JavaDoc filename) throws java.io.IOException JavaDoc {
744     char[] contents = readTable(filename);
745     char[][] nameAsChar = CharOperation.splitOn('\n', contents);
746
747     String JavaDoc[] result = new String JavaDoc[nameAsChar.length + 1];
748     result[0] = null;
749     for (int i = 0; i < nameAsChar.length; i++) {
750         result[i + 1] = new String JavaDoc(nameAsChar[i]);
751     }
752     
753     return result;
754 }
755 protected static String JavaDoc[] readReadableNameTable(String JavaDoc filename) {
756     String JavaDoc[] result = new String JavaDoc[name.length];
757
758     ResourceBundle JavaDoc bundle;
759     try {
760         bundle = ResourceBundle.getBundle(filename, Locale.getDefault());
761     } catch(MissingResourceException JavaDoc e) {
762         System.out.println("Missing resource : " + filename.replace('.', '/') + ".properties for locale " + Locale.getDefault()); //$NON-NLS-1$//$NON-NLS-2$
763
throw e;
764     }
765     for (int i = 0; i < NT_OFFSET + 1; i++) {
766         result[i] = name[i];
767     }
768     for (int i = NT_OFFSET; i < name.length; i++) {
769         try {
770             String JavaDoc n = bundle.getString(name[i]);
771             if(n != null && n.length() > 0) {
772                 result[i] = n;
773             } else {
774                 result[i] = name[i];
775             }
776         } catch(MissingResourceException JavaDoc e) {
777             result[i] = name[i];
778         }
779     }
780     return result;
781 }
782 protected static char[] readTable(String JavaDoc filename) throws java.io.IOException JavaDoc {
783
784     //files are located at Parser.class directory
785

786     InputStream stream = Parser.class.getResourceAsStream(filename);
787     if (stream == null) {
788         throw new java.io.IOException JavaDoc(Messages.bind(Messages.parser_missingFile, filename));
789     }
790     byte[] bytes = null;
791     try {
792         stream = new BufferedInputStream(stream);
793         bytes = Util.getInputStreamAsByteArray(stream, -1);
794     } finally {
795         try {
796             stream.close();
797         } catch (IOException e) {
798             // ignore
799
}
800     }
801
802     //minimal integrity check (even size expected)
803
int length = bytes.length;
804     if ((length & 1) != 0)
805         throw new java.io.IOException JavaDoc(Messages.bind(Messages.parser_corruptedFile, filename));
806
807     // convert bytes into chars
808
char[] chars = new char[length / 2];
809     int i = 0;
810     int charIndex = 0;
811
812     while (true) {
813         chars[charIndex++] = (char) (((bytes[i++] & 0xFF) << 8) + (bytes[i++] & 0xFF));
814         if (i == length)
815             break;
816     }
817     return chars;
818 }
819 protected static long[] readLongTable(String JavaDoc filename) throws java.io.IOException JavaDoc {
820
821     //files are located at Parser.class directory
822

823     InputStream stream = Parser.class.getResourceAsStream(filename);
824     if (stream == null) {
825         throw new java.io.IOException JavaDoc(Messages.bind(Messages.parser_missingFile, filename));
826     }
827     byte[] bytes = null;
828     try {
829         stream = new BufferedInputStream(stream);
830         bytes = Util.getInputStreamAsByteArray(stream, -1);
831     } finally {
832         try {
833             stream.close();
834         } catch (IOException e) {
835             // ignore
836
}
837     }
838
839     //minimal integrity check (even size expected)
840
int length = bytes.length;
841     if (length % 8 != 0)
842         throw new java.io.IOException JavaDoc(Messages.bind(Messages.parser_corruptedFile, filename));
843
844     // convert bytes into longs
845
long[] longs = new long[length / 8];
846     int i = 0;
847     int longIndex = 0;
848
849     while (true) {
850         longs[longIndex++] =
851           (((long) (bytes[i++] & 0xFF)) << 56)
852         + (((long) (bytes[i++] & 0xFF)) << 48)
853         + (((long) (bytes[i++] & 0xFF)) << 40)
854         + (((long) (bytes[i++] & 0xFF)) << 32)
855         + (((long) (bytes[i++] & 0xFF)) << 24)
856         + (((long) (bytes[i++] & 0xFF)) << 16)
857         + (((long) (bytes[i++] & 0xFF)) << 8)
858         + (bytes[i++] & 0xFF);
859         
860         if (i == length)
861             break;
862     }
863     return longs;
864 }
865 public static int tAction(int state, int sym) {
866     return term_action[term_check[base_action[state]+sym] == sym ? base_action[state] + sym : base_action[state]];
867 }
868
869 public Parser(ProblemReporter problemReporter, boolean optimizeStringLiterals) {
870         
871     this.problemReporter = problemReporter;
872     this.options = problemReporter.options;
873     this.optimizeStringLiterals = optimizeStringLiterals;
874     this.initializeScanner();
875     this.astLengthStack = new int[50];
876     this.expressionLengthStack = new int[30];
877     this.intStack = new int[50];
878     this.identifierStack = new char[30][];
879     this.identifierLengthStack = new int[30];
880     this.nestedMethod = new int[30];
881     this.realBlockStack = new int[30];
882     this.identifierPositionStack = new long[30];
883     this.variablesCounter = new int[30];
884     
885     // javadoc support
886
this.javadocParser = createJavadocParser();
887 }
888 protected void annotationRecoveryCheckPoint(int start, int end) {
889     if(this.lastCheckPoint > start && this.lastCheckPoint < end) {
890         this.lastCheckPoint = end + 1;
891     }
892 }
893 public void arrayInitializer(int length) {
894     //length is the size of the array Initializer
895
//expressionPtr points on the last elt of the arrayInitializer,
896
// in other words, it has not been decremented yet.
897

898     ArrayInitializer ai = new ArrayInitializer();
899     if (length != 0) {
900         this.expressionPtr -= length;
901         System.arraycopy(this.expressionStack, this.expressionPtr + 1, ai.expressions = new Expression[length], 0, length);
902     }
903     pushOnExpressionStack(ai);
904     //positionning
905
ai.sourceEnd = this.endStatementPosition;
906     ai.sourceStart = this.intStack[this.intPtr--];
907 }
908 protected void blockReal() {
909     // See consumeLocalVariableDeclarationStatement in case of change: duplicated code
910
// increment the amount of declared variables for this block
911
this.realBlockStack[this.realBlockPtr]++;
912 }
913 /*
914  * Build initial recovery state.
915  * Recovery state is inferred from the current state of the parser (reduced node stack).
916  */

917 public RecoveredElement buildInitialRecoveryState(){
918
919     /* initialize recovery by retrieving available reduced nodes
920      * also rebuild bracket balance
921      */

922     this.lastCheckPoint = 0;
923     this.lastErrorEndPositionBeforeRecovery = this.scanner.currentPosition;
924
925     RecoveredElement element = null;
926     if (this.referenceContext instanceof CompilationUnitDeclaration){
927         element = new RecoveredUnit(this.compilationUnit, 0, this);
928         
929         /* ignore current stack state, since restarting from the beginnning
930            since could not trust simple brace count */

931         if (true){ // experimenting restart recovery from scratch
932
this.compilationUnit.currentPackage = null;
933             this.compilationUnit.imports = null;
934             this.compilationUnit.types = null;
935             this.currentToken = 0;
936             this.listLength = 0;
937             this.listTypeParameterLength = 0;
938             this.endPosition = 0;
939             this.endStatementPosition = 0;
940             return element;
941         }
942         if (this.compilationUnit.currentPackage != null){
943             this.lastCheckPoint = this.compilationUnit.currentPackage.declarationSourceEnd+1;
944         }
945         if (this.compilationUnit.imports != null){
946             this.lastCheckPoint = this.compilationUnit.imports[this.compilationUnit.imports.length -1].declarationSourceEnd+1;
947         }
948     } else {
949         if (this.referenceContext instanceof AbstractMethodDeclaration){
950             element = new RecoveredMethod((AbstractMethodDeclaration) this.referenceContext, null, 0, this);
951             this.lastCheckPoint = ((AbstractMethodDeclaration) this.referenceContext).bodyStart;
952             if(this.statementRecoveryActivated) {
953                 element = element.add(new Block(0), 0);
954             }
955         } else {
956             /* Initializer bodies are parsed in the context of the type declaration, we must thus search it inside */
957             if (this.referenceContext instanceof TypeDeclaration){
958                 TypeDeclaration type = (TypeDeclaration) this.referenceContext;
959                 for (int i = 0; i < type.fields.length; i++){
960                     FieldDeclaration field = type.fields[i];
961                     if (field != null
962                         && field.getKind() == AbstractVariableDeclaration.INITIALIZER
963                         && field.declarationSourceStart <= this.scanner.initialPosition
964                         && this.scanner.initialPosition <= field.declarationSourceEnd
965                         && this.scanner.eofPosition <= field.declarationSourceEnd+1){
966                         element = new RecoveredInitializer(field, null, 1, this);
967                         this.lastCheckPoint = field.declarationSourceStart;
968                         break;
969                     }
970                 }
971             }
972         }
973     }
974
975     if (element == null) return element;
976     
977     for(int i = 0; i <= this.astPtr; i++){
978         ASTNode node = this.astStack[i];
979         if (node instanceof AbstractMethodDeclaration){
980             AbstractMethodDeclaration method = (AbstractMethodDeclaration) node;
981             if (method.declarationSourceEnd == 0){
982                 element = element.add(method, 0);
983                 this.lastCheckPoint = method.bodyStart;
984             } else {
985                 element = element.add(method, 0);
986                 this.lastCheckPoint = method.declarationSourceEnd + 1;
987             }
988             continue;
989         }
990         if (node instanceof Initializer){
991             Initializer initializer = (Initializer) node;
992             if (initializer.declarationSourceEnd == 0){
993                 element = element.add(initializer, 1);
994                 this.lastCheckPoint = initializer.sourceStart;
995             } else {
996                 element = element.add(initializer, 0);
997                 this.lastCheckPoint = initializer.declarationSourceEnd + 1;
998             }
999             continue;
1000        }
1001        if (node instanceof FieldDeclaration){
1002            FieldDeclaration field = (FieldDeclaration) node;
1003            if (field.declarationSourceEnd == 0){
1004                element = element.add(field, 0);
1005                if (field.initialization == null){
1006                    this.lastCheckPoint = field.sourceEnd + 1;
1007                } else {
1008                    this.lastCheckPoint = field.initialization.sourceEnd + 1;
1009                }
1010            } else {
1011                element = element.add(field, 0);
1012                this.lastCheckPoint = field.declarationSourceEnd + 1;
1013            }
1014            continue;
1015        }
1016        if (node instanceof TypeDeclaration){
1017            TypeDeclaration type = (TypeDeclaration) node;
1018            if (type.declarationSourceEnd == 0){
1019                element = element.add(type, 0);
1020                this.lastCheckPoint = type.bodyStart;
1021            } else {
1022                element = element.add(type, 0);
1023                this.lastCheckPoint = type.declarationSourceEnd + 1;
1024            }
1025            continue;
1026        }
1027        if (node instanceof ImportReference){
1028            ImportReference importRef = (ImportReference) node;
1029            element = element.add(importRef, 0);
1030            this.lastCheckPoint = importRef.declarationSourceEnd + 1;
1031        }
1032        if(this.statementRecoveryActivated) {
1033            if(node instanceof Block) {
1034                Block block = (Block) node;
1035                element = element.add(block, 0);
1036                this.lastCheckPoint = block.sourceEnd + 1;
1037            } else if(node instanceof LocalDeclaration) {
1038                LocalDeclaration statement = (LocalDeclaration) node;
1039                element = element.add(statement, 0);
1040                this.lastCheckPoint = statement.sourceEnd + 1;
1041            } else if(node instanceof Expression) {
1042                if(node instanceof Assignment ||
1043                        node instanceof PrefixExpression ||
1044                        node instanceof PostfixExpression ||
1045                        node instanceof MessageSend ||
1046                        node instanceof AllocationExpression) {
1047                    // recover only specific expressions
1048
Expression statement = (Expression) node;
1049                    element = element.add(statement, 0);
1050                    if(statement.statementEnd != -1) {
1051                        this.lastCheckPoint = statement.statementEnd + 1;
1052                    } else {
1053                        this.lastCheckPoint = statement.sourceEnd + 1;
1054                    }
1055                }
1056            } else if(node instanceof Statement) {
1057                Statement statement = (Statement) node;
1058                element = element.add(statement, 0);
1059                this.lastCheckPoint = statement.sourceEnd + 1;
1060            }
1061        }
1062    }
1063    
1064    if (this.statementRecoveryActivated) {
1065        if (this.pendingRecoveredType != null &&
1066                this.scanner.startPosition - 1 <= this.pendingRecoveredType.declarationSourceEnd) {
1067            // Add the pending type to the AST if this type isn't already added in the AST.
1068
element = element.add(this.pendingRecoveredType, 0);
1069            this.lastCheckPoint = this.pendingRecoveredType.declarationSourceEnd + 1;
1070            this.pendingRecoveredType = null;
1071        }
1072    }
1073    return element;
1074}
1075
1076protected void checkAndSetModifiers(int flag){
1077    /*modify the current modifiers buffer.
1078    When the startPosition of the modifiers is 0
1079    it means that the modifier being parsed is the first
1080    of a list of several modifiers. The startPosition
1081    is zeroed when a copy of modifiers-buffer is push
1082    onto the this.astStack. */

1083
1084    if ((this.modifiers & flag) != 0){ // duplicate modifier
1085
this.modifiers |= ExtraCompilerModifiers.AccAlternateModifierProblem;
1086    }
1087    this.modifiers |= flag;
1088            
1089    if (this.modifiersSourceStart < 0) this.modifiersSourceStart = this.scanner.startPosition;
1090}
1091public void checkComment() {
1092
1093    // discard obsolete comments while inside methods or fields initializer (see bug 74369)
1094
if (!(this.diet && this.dietInt==0) && this.scanner.commentPtr >= 0) {
1095        flushCommentsDefinedPriorTo(this.endStatementPosition);
1096    }
1097    
1098    int lastComment = this.scanner.commentPtr;
1099    
1100    if (this.modifiersSourceStart >= 0) {
1101        // eliminate comments located after modifierSourceStart if positionned
1102
while (lastComment >= 0 && this.scanner.commentStarts[lastComment] > this.modifiersSourceStart) lastComment--;
1103    }
1104    if (lastComment >= 0) {
1105        // consider all remaining leading comments to be part of current declaration
1106
this.modifiersSourceStart = this.scanner.commentStarts[0];
1107    
1108        // check deprecation in last comment if javadoc (can be followed by non-javadoc comments which are simply ignored)
1109
while (lastComment >= 0 && this.scanner.commentStops[lastComment] < 0) lastComment--; // non javadoc comment have negative end positions
1110
if (lastComment >= 0 && this.javadocParser != null) {
1111            int commentEnd = this.scanner.commentStops[lastComment] - 1; //stop is one over,
1112
// do not report problem before last parsed comment while recovering code...
1113
this.javadocParser.reportProblems = this.currentElement == null || commentEnd > this.lastJavadocEnd;
1114            if (this.javadocParser.checkDeprecation(lastComment)) {
1115                checkAndSetModifiers(ClassFileConstants.AccDeprecated);
1116            }
1117            this.javadoc = this.javadocParser.docComment; // null if check javadoc is not activated
1118
if (currentElement == null) this.lastJavadocEnd = commentEnd;
1119        }
1120    }
1121}
1122protected void checkNonNLSAfterBodyEnd(int declarationEnd){
1123    if(this.scanner.currentPosition - 1 <= declarationEnd) {
1124        this.scanner.eofPosition = declarationEnd < Integer.MAX_VALUE ? declarationEnd + 1 : declarationEnd;
1125        try {
1126            while(this.scanner.getNextToken() != TokenNameEOF){/*empty*/}
1127        } catch (InvalidInputException e) {
1128            // Nothing to do
1129
}
1130    }
1131}
1132protected void classInstanceCreation(boolean isQualified) {
1133    // ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt
1134

1135    // ClassBodyopt produces a null item on the astStak if it produces NO class body
1136
// An empty class body produces a 0 on the length stack.....
1137

1138    AllocationExpression alloc;
1139    int length;
1140    if (((length = this.astLengthStack[this.astLengthPtr--]) == 1)
1141        && (this.astStack[this.astPtr] == null)) {
1142        //NO ClassBody
1143
this.astPtr--;
1144        if (isQualified) {
1145            alloc = new QualifiedAllocationExpression();
1146        } else {
1147            alloc = new AllocationExpression();
1148        }
1149        alloc.sourceEnd = this.endPosition; //the position has been stored explicitly
1150

1151        if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
1152            this.expressionPtr -= length;
1153            System.arraycopy(
1154                this.expressionStack,
1155                this.expressionPtr + 1,
1156                alloc.arguments = new Expression[length],
1157                0,
1158                length);
1159        }
1160        alloc.type = getTypeReference(0);
1161        
1162        //the default constructor with the correct number of argument
1163
//will be created and added by the TC (see createsInternalConstructorWithBinding)
1164
alloc.sourceStart = this.intStack[this.intPtr--];
1165        pushOnExpressionStack(alloc);
1166    } else {
1167        dispatchDeclarationInto(length);
1168        TypeDeclaration anonymousTypeDeclaration = (TypeDeclaration)this.astStack[this.astPtr];
1169        anonymousTypeDeclaration.declarationSourceEnd = this.endStatementPosition;
1170        anonymousTypeDeclaration.bodyEnd = this.endStatementPosition;
1171        if (anonymousTypeDeclaration.allocation != null) {
1172            anonymousTypeDeclaration.allocation.sourceEnd = this.endStatementPosition;
1173        }
1174        if (length == 0 && !containsComment(anonymousTypeDeclaration.bodyStart, anonymousTypeDeclaration.bodyEnd)) {
1175            anonymousTypeDeclaration.bits |= ASTNode.UndocumentedEmptyBlock;
1176        }
1177        this.astPtr--;
1178        this.astLengthPtr--;
1179
1180        // mark initializers with local type mark if needed
1181
markInitializersWithLocalType(anonymousTypeDeclaration);
1182    }
1183}
1184protected void concatExpressionLists() {
1185    this.expressionLengthStack[--this.expressionLengthPtr]++;
1186}
1187protected void concatGenericsLists() {
1188    this.genericsLengthStack[this.genericsLengthPtr - 1] += this.genericsLengthStack[this.genericsLengthPtr--];
1189}
1190protected void concatNodeLists() {
1191    /*
1192     * This is a case where you have two sublists into the this.astStack that you want
1193     * to merge in one list. There is no action required on the this.astStack. The only
1194     * thing you need to do is merge the two lengths specified on the astStackLength.
1195     * The top two length are for example:
1196     * ... p n
1197     * and you want to result in a list like:
1198     * ... n+p
1199     * This means that the p could be equals to 0 in case there is no astNode pushed
1200     * on the this.astStack.
1201     * Look at the InterfaceMemberDeclarations for an example.
1202     */

1203
1204    this.astLengthStack[this.astLengthPtr - 1] += this.astLengthStack[this.astLengthPtr--];
1205}
1206protected void consumeAdditionalBound() {
1207    pushOnGenericsStack(getTypeReference(this.intStack[this.intPtr--]));
1208}
1209protected void consumeAdditionalBound1() {
1210    // nothing to be done.
1211
// The reference type1 is consumed by consumeReferenceType1 method.
1212
}
1213protected void consumeAdditionalBoundList() {
1214    concatGenericsLists();
1215}
1216protected void consumeAdditionalBoundList1() {
1217    concatGenericsLists();
1218}
1219protected void consumeAllocationHeader() {
1220    // ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt
1221

1222    // ClassBodyopt produces a null item on the astStak if it produces NO class body
1223
// An empty class body produces a 0 on the length stack.....
1224

1225    if (this.currentElement == null){
1226        return; // should never occur, this consumeRule is only used in recovery mode
1227
}
1228    if (this.currentToken == TokenNameLBRACE){
1229        // beginning of an anonymous type
1230
TypeDeclaration anonymousType = new TypeDeclaration(this.compilationUnit.compilationResult);
1231        anonymousType.name = CharOperation.NO_CHAR;
1232        anonymousType.bits |= (ASTNode.IsAnonymousType|ASTNode.IsLocalType);
1233        anonymousType.sourceStart = this.intStack[this.intPtr--];
1234        anonymousType.sourceEnd = this.rParenPos; // closing parenthesis
1235
QualifiedAllocationExpression alloc = new QualifiedAllocationExpression(anonymousType);
1236        alloc.type = getTypeReference(0);
1237        alloc.sourceStart = anonymousType.sourceStart;
1238        alloc.sourceEnd = anonymousType.sourceEnd ;
1239        this.lastCheckPoint = anonymousType.bodyStart = this.scanner.currentPosition;
1240        this.currentElement = this.currentElement.add(anonymousType, 0);
1241        this.lastIgnoredToken = -1;
1242        this.currentToken = 0; // opening brace already taken into account
1243
return;
1244    }
1245    this.lastCheckPoint = this.scanner.startPosition; // force to restart at this exact position
1246
this.restartRecovery = true; // request to restart from here on
1247
}
1248protected void consumeAnnotationAsModifier() {
1249    Expression expression = this.expressionStack[this.expressionPtr];
1250    int sourceStart = expression.sourceStart;
1251    if (this.modifiersSourceStart < 0) {
1252        this.modifiersSourceStart = sourceStart;
1253    }
1254}
1255protected void consumeAnnotationName() {
1256    if(this.currentElement != null) {
1257        int start = this.intStack[this.intPtr];
1258        int end = (int) (this.identifierPositionStack[this.identifierPtr] & 0x00000000FFFFFFFFL);
1259        annotationRecoveryCheckPoint(start, end);
1260    }
1261    this.recordStringLiterals = false;
1262}
1263protected void consumeAnnotationTypeDeclaration() {
1264    int length;
1265    if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
1266        //there are length declarations
1267
//dispatch according to the type of the declarations
1268
dispatchDeclarationInto(length);
1269    }
1270
1271    TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
1272    
1273    // mark initializers with local type mark if needed
1274
markInitializersWithLocalType(typeDecl);
1275
1276    //convert constructor that do not have the type's name into methods
1277
typeDecl.checkConstructors(this);
1278    
1279    //always add <clinit> (will be remove at code gen time if empty)
1280
if (this.scanner.containsAssertKeyword) {
1281        typeDecl.bits |= ASTNode.ContainsAssertion;
1282    }
1283    typeDecl.addClinit();
1284    typeDecl.bodyEnd = this.endStatementPosition;
1285    if (length == 0 && !containsComment(typeDecl.bodyStart, typeDecl.bodyEnd)) {
1286        typeDecl.bits |= ASTNode.UndocumentedEmptyBlock;
1287    }
1288    typeDecl.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
1289}
1290protected void consumeAnnotationTypeDeclarationHeader() {
1291    if (this.currentElement != null) {
1292        this.restartRecovery = true; // used to avoid branching back into the regular automaton
1293
}
1294    // flush the comments related to the annotation type header
1295
this.scanner.commentPtr = -1;
1296}
1297protected void consumeAnnotationTypeDeclarationHeaderName() {
1298    // consumeAnnotationTypeDeclarationHeader ::= Modifiers '@' PushModifiers interface Identifier
1299
// consumeAnnotationTypeDeclarationHeader ::= '@' PushModifiers interface Identifier
1300
TypeDeclaration annotationTypeDeclaration = new TypeDeclaration(this.compilationUnit.compilationResult);
1301    if (this.nestedMethod[this.nestedType] == 0) {
1302        if (this.nestedType != 0) {
1303            annotationTypeDeclaration.bits |= ASTNode.IsMemberType;
1304        }
1305    } else {
1306        // Record that the block has a declaration for local types
1307
annotationTypeDeclaration.bits |= ASTNode.IsLocalType;
1308        markEnclosingMemberWithLocalType();
1309        blockReal();
1310    }
1311
1312    //highlight the name of the type
1313
long pos = this.identifierPositionStack[this.identifierPtr];
1314    annotationTypeDeclaration.sourceEnd = (int) pos;
1315    annotationTypeDeclaration.sourceStart = (int) (pos >>> 32);
1316    annotationTypeDeclaration.name = this.identifierStack[this.identifierPtr--];
1317    this.identifierLengthPtr--;
1318
1319    //compute the declaration source too
1320
// 'interface' push two int positions: the beginning of the class token and its end.
1321
// we want to keep the beginning position but get rid of the end position
1322
// it is only used for the ClassLiteralAccess positions.
1323
this.intPtr--; // remove the start position of the interface token
1324
this.intPtr--; // remove the end position of the interface token
1325

1326    annotationTypeDeclaration.modifiersSourceStart = this.intStack[this.intPtr--];
1327    annotationTypeDeclaration.modifiers = this.intStack[this.intPtr--] | ClassFileConstants.AccAnnotation | ClassFileConstants.AccInterface;
1328    if (annotationTypeDeclaration.modifiersSourceStart >= 0) {
1329        annotationTypeDeclaration.declarationSourceStart = annotationTypeDeclaration.modifiersSourceStart;
1330        this.intPtr--; // remove the position of the '@' token as we have modifiers
1331
} else {
1332        int atPosition = this.intStack[this.intPtr--];
1333        // remove the position of the '@' token as we don't have modifiers
1334
annotationTypeDeclaration.declarationSourceStart = atPosition;
1335    }
1336
1337    // Store secondary info
1338
if ((annotationTypeDeclaration.bits & ASTNode.IsMemberType) == 0 && (annotationTypeDeclaration.bits & ASTNode.IsLocalType) == 0) {
1339        if (this.compilationUnit != null && !CharOperation.equals(annotationTypeDeclaration.name, this.compilationUnit.getMainTypeName())) {
1340            annotationTypeDeclaration.bits |= ASTNode.IsSecondaryType;
1341        }
1342    }
1343
1344    // consume annotations
1345
int length;
1346    if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
1347        System.arraycopy(
1348            this.expressionStack,
1349            (this.expressionPtr -= length) + 1,
1350            annotationTypeDeclaration.annotations = new Annotation[length],
1351            0,
1352            length);
1353    }
1354    annotationTypeDeclaration.bodyStart = annotationTypeDeclaration.sourceEnd + 1;
1355
1356    // javadoc
1357
annotationTypeDeclaration.javadoc = this.javadoc;
1358    this.javadoc = null;
1359    pushOnAstStack(annotationTypeDeclaration);
1360    if(!this.statementRecoveryActivated &&
1361            options.sourceLevel < ClassFileConstants.JDK1_5 &&
1362            this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
1363        this.problemReporter().invalidUsageOfAnnotationDeclarations(annotationTypeDeclaration);
1364    }
1365    
1366    // recovery
1367
if (this.currentElement != null){
1368        this.lastCheckPoint = annotationTypeDeclaration.bodyStart;
1369        this.currentElement = this.currentElement.add(annotationTypeDeclaration, 0);
1370        this.lastIgnoredToken = -1;
1371    }
1372}
1373protected void consumeAnnotationTypeMemberDeclaration() {
1374    // AnnotationTypeMemberDeclaration ::= AnnotationTypeMemberDeclarationHeader AnnotationTypeMemberHeaderExtendedDims DefaultValueopt ';'
1375
AnnotationMethodDeclaration annotationTypeMemberDeclaration = (AnnotationMethodDeclaration) this.astStack[this.astPtr];
1376    annotationTypeMemberDeclaration.modifiers |= ExtraCompilerModifiers.AccSemicolonBody;
1377    // store the this.endPosition (position just before the '}') in case there is
1378
// a trailing comment behind the end of the method
1379
int declarationEndPosition = flushCommentsDefinedPriorTo(this.endStatementPosition);
1380    annotationTypeMemberDeclaration.bodyStart = this.endStatementPosition;
1381    annotationTypeMemberDeclaration.bodyEnd = declarationEndPosition;
1382    annotationTypeMemberDeclaration.declarationSourceEnd = declarationEndPosition;
1383}
1384protected void consumeAnnotationTypeMemberDeclarations() {
1385    // AnnotationTypeMemberDeclarations ::= AnnotationTypeMemberDeclarations AnnotationTypeMemberDeclaration
1386
concatNodeLists();
1387}
1388protected void consumeArgumentList() {
1389    // ArgumentList ::= ArgumentList ',' Expression
1390
concatExpressionLists();
1391}
1392protected void consumeArguments() {
1393    // Arguments ::= '(' ArgumentListopt ')'
1394
// nothing to do, the expression stack is already updated
1395
pushOnIntStack(rParenPos);
1396}
1397protected void consumeArrayAccess(boolean unspecifiedReference) {
1398    // ArrayAccess ::= Name '[' Expression ']' ==> true
1399
// ArrayAccess ::= PrimaryNoNewArray '[' Expression ']' ==> false
1400

1401
1402    //optimize push/pop
1403
Expression exp;
1404    if (unspecifiedReference) {
1405        exp =
1406            this.expressionStack[this.expressionPtr] =
1407                new ArrayReference(
1408                    getUnspecifiedReferenceOptimized(),
1409                    this.expressionStack[this.expressionPtr]);
1410    } else {
1411        this.expressionPtr--;
1412        this.expressionLengthPtr--;
1413        exp =
1414            this.expressionStack[this.expressionPtr] =
1415                new ArrayReference(
1416                    this.expressionStack[this.expressionPtr],
1417                    this.expressionStack[this.expressionPtr + 1]);
1418    }
1419    exp.sourceEnd = this.endStatementPosition;
1420}
1421protected void consumeArrayCreationExpressionWithInitializer() {
1422    // ArrayCreationWithArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializer
1423
// ArrayCreationWithArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializer
1424

1425    int length;
1426    ArrayAllocationExpression arrayAllocation = new ArrayAllocationExpression();
1427    this.expressionLengthPtr -- ;
1428    arrayAllocation.initializer = (ArrayInitializer) this.expressionStack[this.expressionPtr--];
1429        
1430    arrayAllocation.type = getTypeReference(0);
1431    arrayAllocation.type.bits |= ASTNode.IgnoreRawTypeCheck; // no need to worry about raw type usage
1432
length = (this.expressionLengthStack[this.expressionLengthPtr--]);
1433    this.expressionPtr -= length ;
1434    System.arraycopy(
1435        this.expressionStack,
1436        this.expressionPtr+1,
1437        arrayAllocation.dimensions = new Expression[length],
1438        0,
1439        length);
1440    arrayAllocation.sourceStart = this.intStack[this.intPtr--];
1441    if (arrayAllocation.initializer == null) {
1442        arrayAllocation.sourceEnd = this.endStatementPosition;
1443    } else {
1444        arrayAllocation.sourceEnd = arrayAllocation.initializer.sourceEnd ;
1445    }
1446    pushOnExpressionStack(arrayAllocation);
1447}
1448protected void consumeArrayCreationExpressionWithoutInitializer() {
1449    // ArrayCreationWithoutArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs
1450
// ArrayCreationWithoutArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs
1451

1452    int length;
1453    ArrayAllocationExpression arrayAllocation = new ArrayAllocationExpression();
1454    arrayAllocation.type = getTypeReference(0);
1455    arrayAllocation.type.bits |= ASTNode.IgnoreRawTypeCheck; // no need to worry about raw type usage
1456
length = (this.expressionLengthStack[this.expressionLengthPtr--]);
1457    this.expressionPtr -= length ;
1458    System.arraycopy(
1459        this.expressionStack,
1460        this.expressionPtr+1,
1461        arrayAllocation.dimensions = new Expression[length],
1462        0,
1463        length);
1464    arrayAllocation.sourceStart = this.intStack[this.intPtr--];
1465    if (arrayAllocation.initializer == null) {
1466        arrayAllocation.sourceEnd = this.endStatementPosition;
1467    } else {
1468        arrayAllocation.sourceEnd = arrayAllocation.initializer.sourceEnd ;
1469    }
1470    pushOnExpressionStack(arrayAllocation);
1471}
1472protected void consumeArrayCreationHeader() {
1473    // nothing to do
1474
}
1475protected void consumeArrayInitializer() {
1476    // ArrayInitializer ::= '{' VariableInitializers '}'
1477
// ArrayInitializer ::= '{' VariableInitializers , '}'
1478

1479    arrayInitializer(this.expressionLengthStack[this.expressionLengthPtr--]);
1480}
1481protected void consumeArrayTypeWithTypeArgumentsName() {
1482    this.genericsIdentifiersLengthStack[this.genericsIdentifiersLengthPtr] += this.identifierLengthStack[this.identifierLengthPtr];
1483    pushOnGenericsLengthStack(0); // handle type arguments
1484
}
1485protected void consumeAssertStatement() {
1486    // AssertStatement ::= 'assert' Expression ':' Expression ';'
1487
this.expressionLengthPtr-=2;
1488    pushOnAstStack(new AssertStatement(this.expressionStack[this.expressionPtr--], this.expressionStack[this.expressionPtr--], this.intStack[this.intPtr--]));
1489}
1490protected void consumeAssignment() {
1491    // Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression
1492
//optimize the push/pop
1493

1494    int op = this.intStack[this.intPtr--] ; //<--the encoded operator
1495

1496    this.expressionPtr -- ; this.expressionLengthPtr -- ;
1497    this.expressionStack[this.expressionPtr] =
1498        (op != EQUAL ) ?
1499            new CompoundAssignment(
1500                this.expressionStack[this.expressionPtr] ,
1501                this.expressionStack[this.expressionPtr+1],
1502                op,
1503                this.scanner.startPosition - 1) :
1504            new Assignment(
1505                this.expressionStack[this.expressionPtr] ,
1506                this.expressionStack[this.expressionPtr+1],
1507                this.scanner.startPosition - 1);
1508                
1509    if (this.pendingRecoveredType != null) {
1510        // Used only in statements recovery.
1511
// This is not a real assignment but a placeholder for an existing anonymous type.
1512
// The assignment must be replace by the anonymous type.
1513
if (this.pendingRecoveredType.allocation != null &&
1514                this.scanner.startPosition - 1 <= this.pendingRecoveredType.declarationSourceEnd) {
1515            this.expressionStack[this.expressionPtr] = this.pendingRecoveredType.allocation;
1516            this.pendingRecoveredType = null;
1517            return;
1518        }
1519        this.pendingRecoveredType = null;
1520    }
1521}
1522protected void consumeAssignmentOperator(int pos) {
1523    // AssignmentOperator ::= '='
1524
// AssignmentOperator ::= '*='
1525
// AssignmentOperator ::= '/='
1526
// AssignmentOperator ::= '%='
1527
// AssignmentOperator ::= '+='
1528
// AssignmentOperator ::= '-='
1529
// AssignmentOperator ::= '<<='
1530
// AssignmentOperator ::= '>>='
1531
// AssignmentOperator ::= '>>>='
1532
// AssignmentOperator ::= '&='
1533
// AssignmentOperator ::= '^='
1534
// AssignmentOperator ::= '|='
1535

1536    pushOnIntStack(pos);
1537}
1538protected void consumeBinaryExpression(int op) {
1539    // MultiplicativeExpression ::= MultiplicativeExpression '*' UnaryExpression
1540
// MultiplicativeExpression ::= MultiplicativeExpression '/' UnaryExpression
1541
// MultiplicativeExpression ::= MultiplicativeExpression '%' UnaryExpression
1542
// AdditiveExpression ::= AdditiveExpression '+' MultiplicativeExpression
1543
// AdditiveExpression ::= AdditiveExpression '-' MultiplicativeExpression
1544
// ShiftExpression ::= ShiftExpression '<<' AdditiveExpression
1545
// ShiftExpression ::= ShiftExpression '>>' AdditiveExpression
1546
// ShiftExpression ::= ShiftExpression '>>>' AdditiveExpression
1547
// RelationalExpression ::= RelationalExpression '<' ShiftExpression
1548
// RelationalExpression ::= RelationalExpression '>' ShiftExpression
1549
// RelationalExpression ::= RelationalExpression '<=' ShiftExpression
1550
// RelationalExpression ::= RelationalExpression '>=' ShiftExpression
1551
// AndExpression ::= AndExpression '&' EqualityExpression
1552
// ExclusiveOrExpression ::= ExclusiveOrExpression '^' AndExpression
1553
// InclusiveOrExpression ::= InclusiveOrExpression '|' ExclusiveOrExpression
1554
// ConditionalAndExpression ::= ConditionalAndExpression '&&' InclusiveOrExpression
1555
// ConditionalOrExpression ::= ConditionalOrExpression '||' ConditionalAndExpression
1556

1557    //optimize the push/pop
1558

1559    this.expressionPtr--;
1560    this.expressionLengthPtr--;
1561    Expression expr1 = this.expressionStack[this.expressionPtr];
1562    Expression expr2 = this.expressionStack[this.expressionPtr + 1];
1563    switch(op) {
1564        case OR_OR :
1565            this.expressionStack[this.expressionPtr] =
1566                new OR_OR_Expression(
1567                    expr1,
1568                    expr2,
1569                    op);
1570            break;
1571        case AND_AND :
1572            this.expressionStack[this.expressionPtr] =
1573                new AND_AND_Expression(
1574                    expr1,
1575                    expr2,
1576                    op);
1577            break;
1578        case PLUS :
1579            // look for "string1" + "string2"
1580
if (this.optimizeStringLiterals) {
1581                if (expr1 instanceof StringLiteral) {
1582                    if (expr2 instanceof CharLiteral) { // string+char
1583
this.expressionStack[this.expressionPtr] =
1584                            ((StringLiteral) expr1).extendWith((CharLiteral) expr2);
1585                    } else if (expr2 instanceof StringLiteral) { //string+string
1586
this.expressionStack[this.expressionPtr] =
1587                            ((StringLiteral) expr1).extendWith((StringLiteral) expr2);
1588                    } else {
1589                        this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
1590                    }
1591                } else if (expr1 instanceof CombinedBinaryExpression) {
1592                    CombinedBinaryExpression cursor;
1593                    // left branch is comprised of PLUS BEs
1594
// cursor is shifted upwards, while needed BEs are added
1595
// on demand; past the arityMax-th
1596
// consecutive BE, a CBE is inserted that holds a
1597
// full-fledged references table
1598
if ((cursor = (CombinedBinaryExpression)expr1).arity <
1599                                cursor.arityMax) {
1600                        cursor.left = new BinaryExpression(cursor.left,
1601                                cursor.right, PLUS);
1602                        cursor.arity++;
1603                    } else {
1604                        cursor.left = new CombinedBinaryExpression(cursor.left,
1605                                cursor.right, PLUS, cursor.arity);
1606                        cursor.arity = 0;
1607                        cursor.tuneArityMax();
1608                    }
1609                    cursor.right = expr2;
1610                    cursor.sourceEnd = expr2.sourceEnd;
1611                    this.expressionStack[this.expressionPtr] = cursor;
1612                    // BE_INSTRUMENTATION: neutralized in the released code
1613
// cursor.depthTracker = ((BinaryExpression)cursor.left).
1614
// depthTracker + 1;
1615
} else if (expr1 instanceof BinaryExpression &&
1616                            // single out the a + b case, which is a BE
1617
// instead of a CBE (slightly more than a half of
1618
// strings concatenation are one-deep binary
1619
// expressions)
1620
((expr1.bits & ASTNode.OperatorMASK) >>
1621                            ASTNode.OperatorSHIFT) == OperatorIds.PLUS) {
1622                    this.expressionStack[this.expressionPtr] =
1623                        new CombinedBinaryExpression(expr1, expr2, PLUS, 1);
1624                } else {
1625                    this.expressionStack[this.expressionPtr] =
1626                        new BinaryExpression(expr1, expr2, PLUS);
1627                }
1628            } else if (expr1 instanceof StringLiteral) {
1629                if (expr2 instanceof StringLiteral) {
1630                    // string + string
1631
this.expressionStack[this.expressionPtr] =
1632                        ((StringLiteral) expr1).extendsWith((StringLiteral) expr2);
1633                } else {
1634                    // single out the a + b case
1635
this.expressionStack[this.expressionPtr] =
1636                        new BinaryExpression(expr1, expr2, PLUS);
1637                }
1638            } else if (expr1 instanceof CombinedBinaryExpression) {
1639                    CombinedBinaryExpression cursor;
1640                    int numberOfParens = (expr1.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
1641                    // shift cursor; create BE/CBE as needed
1642
if ((cursor = (CombinedBinaryExpression)expr1).arity <
1643                                cursor.arityMax) {
1644                        cursor.left = new BinaryExpression(cursor.left,
1645                                cursor.right, PLUS);
1646                        if (numberOfParens != 0) {
1647                            // clear the bits on cursor and put them back on cursor.left
1648
cursor.bits &= ~ASTNode.ParenthesizedMASK;
1649                            cursor.left.bits &= ~ASTNode.ParenthesizedMASK;
1650                            cursor.left.bits |= numberOfParens << ASTNode.ParenthesizedSHIFT;
1651                        }
1652                        cursor.arity++;
1653                    } else {
1654                        cursor.left = new CombinedBinaryExpression(cursor.left,
1655                                cursor.right, PLUS, cursor.arity);
1656                        if (numberOfParens != 0) {
1657                            // clear the bits on cursor and put them back on cursor.left
1658
cursor.bits &= ~ASTNode.ParenthesizedMASK;
1659                            cursor.left.bits &= ~ASTNode.ParenthesizedMASK;
1660                            cursor.left.bits |= numberOfParens << ASTNode.ParenthesizedSHIFT;
1661                        }
1662                        cursor.arity = 0;
1663                        cursor.tuneArityMax();
1664                    }
1665                    cursor.right = expr2;
1666                    cursor.sourceEnd = expr2.sourceEnd;
1667                    // BE_INSTRUMENTATION: neutralized in the released code
1668
// cursor.depthTracker = ((BinaryExpression)cursor.left).
1669
// depthTracker + 1;
1670
this.expressionStack[this.expressionPtr] = cursor;
1671            } else if (expr1 instanceof BinaryExpression
1672                    && ((expr1.bits & ASTNode.OperatorMASK) >>
1673                            ASTNode.OperatorSHIFT) == OperatorIds.PLUS) {
1674                // single out the a + b case
1675
this.expressionStack[this.expressionPtr] =
1676                    new CombinedBinaryExpression(expr1, expr2, PLUS, 1);
1677            } else {
1678                this.expressionStack[this.expressionPtr] =
1679                    new BinaryExpression(expr1, expr2, PLUS);
1680            }
1681            break;
1682        case LESS :
1683            this.intPtr--;
1684            this.expressionStack[this.expressionPtr] =
1685                new BinaryExpression(
1686                    expr1,
1687                    expr2,
1688                    op);
1689            break;
1690        default :
1691            this.expressionStack[this.expressionPtr] =
1692                new BinaryExpression(
1693                    expr1,
1694                    expr2,
1695                    op);
1696    }
1697}
1698/**
1699 * @param op binary operator
1700 */

1701protected void consumeBinaryExpressionWithName(int op) {
1702    pushOnExpressionStack(getUnspecifiedReferenceOptimized());
1703    this.expressionPtr--;
1704    this.expressionLengthPtr--;
1705    /*
1706    if (op == OR_OR) {
1707        this.expressionStack[this.expressionPtr] =
1708            new OR_OR_Expression(
1709                this.expressionStack[this.expressionPtr + 1],
1710                this.expressionStack[this.expressionPtr],
1711                op);
1712    } else {
1713        if (op == AND_AND) {
1714            this.expressionStack[this.expressionPtr] =
1715                new AND_AND_Expression(
1716                    this.expressionStack[this.expressionPtr + 1],
1717                    this.expressionStack[this.expressionPtr],
1718                    op);
1719        } else {
1720            // look for "string1" + "string2"
1721            if ((op == PLUS) && this.optimizeStringLiterals) {
1722                Expression expr1, expr2;
1723                expr1 = this.expressionStack[this.expressionPtr + 1];
1724                expr2 = this.expressionStack[this.expressionPtr];
1725                if (expr1 instanceof StringLiteral) {
1726                    if (expr2 instanceof CharLiteral) { // string+char
1727                        this.expressionStack[this.expressionPtr] =
1728                            ((StringLiteral) expr1).extendWith((CharLiteral) expr2);
1729                    } else if (expr2 instanceof StringLiteral) { //string+string
1730                        this.expressionStack[this.expressionPtr] =
1731                            ((StringLiteral) expr1).extendWith((StringLiteral) expr2);
1732                    } else {
1733                        this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
1734                    }
1735                } else {
1736                    this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
1737                }
1738            } else {
1739                this.expressionStack[this.expressionPtr] =
1740                    new BinaryExpression(
1741                        this.expressionStack[this.expressionPtr + 1],
1742                        this.expressionStack[this.expressionPtr],
1743                        op);
1744            }
1745        }
1746    }
1747    */

1748    Expression expr1 = this.expressionStack[this.expressionPtr + 1];
1749    Expression expr2 = this.expressionStack[this.expressionPtr];
1750    // Note: we do not attempt to promote BinaryExpression-s to
1751
// IndexedBinaryExpression-s here since expr1 always holds a name
1752
switch(op) {
1753        case OR_OR :
1754            this.expressionStack[this.expressionPtr] =
1755                new OR_OR_Expression(
1756                    expr1,
1757                    expr2,
1758                    op);
1759            break;
1760        case AND_AND :
1761            this.expressionStack[this.expressionPtr] =
1762                new AND_AND_Expression(
1763                    expr1,
1764                    expr2,
1765                    op);
1766            break;
1767        case PLUS :
1768            // look for "string1" + "string2"
1769
if (this.optimizeStringLiterals) {
1770                if (expr1 instanceof StringLiteral) {
1771                    if (expr2 instanceof CharLiteral) { // string+char
1772
this.expressionStack[this.expressionPtr] =
1773                            ((StringLiteral) expr1).extendWith((CharLiteral) expr2);
1774                    } else if (expr2 instanceof StringLiteral) { //string+string
1775
this.expressionStack[this.expressionPtr] =
1776                            ((StringLiteral) expr1).extendWith((StringLiteral) expr2);
1777                    } else {
1778                        this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
1779                    }
1780                } else {
1781                    this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
1782                }
1783            } else if (expr1 instanceof StringLiteral) {
1784                if (expr2 instanceof StringLiteral) {
1785                    // string + string
1786
this.expressionStack[this.expressionPtr] =
1787                        ((StringLiteral) expr1).extendsWith((StringLiteral) expr2);
1788                } else {
1789                    this.expressionStack[this.expressionPtr] =
1790                        new BinaryExpression(
1791                            expr1,
1792                            expr2,
1793                            op);
1794                }
1795            } else {
1796                this.expressionStack[this.expressionPtr] =
1797                    new BinaryExpression(
1798                        expr1,
1799                        expr2,
1800                        op);
1801            }
1802            break;
1803        case LESS :
1804            this.intPtr--;
1805            this.expressionStack[this.expressionPtr] =
1806                new BinaryExpression(
1807                    expr1,
1808                    expr2,
1809                    op);
1810            break;
1811        default :
1812            this.expressionStack[this.expressionPtr] =
1813                new BinaryExpression(
1814                    expr1,
1815                    expr2,
1816                    op);
1817    }
1818}
1819protected void consumeBlock() {
1820    // Block ::= OpenBlock '{' BlockStatementsopt '}'
1821
// simpler action for empty blocks
1822

1823    int statementsLength = this.astLengthStack[this.astLengthPtr--];
1824    Block block;
1825    if (statementsLength == 0) { // empty block
1826
block = new Block(0);
1827        block.sourceStart = this.intStack[this.intPtr--];
1828        block.sourceEnd = this.endStatementPosition;
1829        // check whether this block at least contains some comment in it
1830
if (!containsComment(block.sourceStart, block.sourceEnd)) {
1831            block.bits |= ASTNode.UndocumentedEmptyBlock;
1832        }
1833        this.realBlockPtr--; // still need to pop the block variable counter
1834
} else {
1835        block = new Block(this.realBlockStack[this.realBlockPtr--]);
1836        this.astPtr -= statementsLength;
1837        System.arraycopy(
1838            this.astStack,
1839            this.astPtr + 1,
1840            block.statements = new Statement[statementsLength],
1841            0,
1842            statementsLength);
1843        block.sourceStart = this.intStack[this.intPtr--];
1844        block.sourceEnd = this.endStatementPosition;
1845    }
1846    pushOnAstStack(block);
1847}
1848protected void consumeBlockStatements() {
1849    // BlockStatements ::= BlockStatements BlockStatement
1850
concatNodeLists();
1851}
1852protected void consumeCaseLabel() {
1853    // SwitchLabel ::= 'case' ConstantExpression ':'
1854
this.expressionLengthPtr--;
1855    Expression expression = this.expressionStack[this.expressionPtr--];
1856    pushOnAstStack(new CaseStatement(expression, expression.sourceEnd, this.intStack[this.intPtr--]));
1857}
1858protected void consumeCastExpressionLL1() {
1859    //CastExpression ::= '(' Expression ')' InsideCastExpressionLL1 UnaryExpressionNotPlusMinus
1860
// Expression is used in order to make the grammar LL1
1861

1862    //optimize push/pop
1863

1864    Expression cast,exp;
1865    this.expressionPtr--;
1866    this.expressionStack[this.expressionPtr] =
1867        cast = new CastExpression(
1868            exp=this.expressionStack[this.expressionPtr+1] ,
1869            getTypeReference(this.expressionStack[this.expressionPtr]));
1870    this.expressionLengthPtr -- ;
1871    updateSourcePosition(cast);
1872    cast.sourceEnd=exp.sourceEnd;
1873}
1874protected void consumeCastExpressionWithGenericsArray() {
1875    // CastExpression ::= PushLPAREN Name TypeArguments Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
1876

1877    Expression exp, cast, castType;
1878    int end = this.intStack[this.intPtr--];
1879
1880    int dim = this.intStack[this.intPtr--];
1881    pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
1882    
1883    this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType = getTypeReference(dim));
1884    intPtr--;
1885    castType.sourceEnd = end - 1;
1886    castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
1887    cast.sourceEnd = exp.sourceEnd;
1888}
1889protected void consumeCastExpressionWithNameArray() {
1890    // CastExpression ::= PushLPAREN Name Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
1891

1892    Expression exp, cast, castType;
1893    int end = this.intStack[this.intPtr--];
1894    
1895    // handle type arguments
1896
pushOnGenericsLengthStack(0);
1897    pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
1898    
1899    this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType = getTypeReference(this.intStack[this.intPtr--]));
1900    castType.sourceEnd = end - 1;
1901    castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
1902    cast.sourceEnd = exp.sourceEnd;
1903}
1904protected void consumeCastExpressionWithPrimitiveType() {
1905    // CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN InsideCastExpression UnaryExpression
1906

1907    //this.intStack : posOfLeftParen dim posOfRightParen
1908

1909    //optimize the push/pop
1910

1911    Expression exp, cast, castType;
1912    int end = this.intStack[this.intPtr--];
1913    this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType = getTypeReference(this.intStack[this.intPtr--]));
1914    castType.sourceEnd = end - 1;
1915    castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
1916    cast.sourceEnd = exp.sourceEnd;
1917}
1918protected ParameterizedQualifiedTypeReference computeQualifiedGenericsFromRightSide(TypeReference rightSide, int dim) {
1919    int nameSize = this.identifierLengthStack[this.identifierLengthPtr];
1920    int tokensSize = nameSize;
1921    if (rightSide instanceof ParameterizedSingleTypeReference) {
1922        tokensSize ++;
1923    } else if (rightSide instanceof SingleTypeReference) {
1924        tokensSize ++;
1925    } else if (rightSide instanceof ParameterizedQualifiedTypeReference) {
1926        tokensSize += ((QualifiedTypeReference) rightSide).tokens.length;
1927    } else if (rightSide instanceof QualifiedTypeReference) {
1928        tokensSize += ((QualifiedTypeReference) rightSide).tokens.length;
1929    }
1930    TypeReference[][] typeArguments = new TypeReference[tokensSize][];
1931    char[][] tokens = new char[tokensSize][];
1932    long[] positions = new long[tokensSize];
1933    if (rightSide instanceof ParameterizedSingleTypeReference) {
1934        ParameterizedSingleTypeReference singleParameterizedTypeReference = (ParameterizedSingleTypeReference) rightSide;
1935        tokens[nameSize] = singleParameterizedTypeReference.token;
1936        positions[nameSize] = (((long) singleParameterizedTypeReference.sourceStart) << 32) + singleParameterizedTypeReference.sourceEnd;
1937        typeArguments[nameSize] = singleParameterizedTypeReference.typeArguments;
1938    } else if (rightSide instanceof SingleTypeReference) {
1939        SingleTypeReference singleTypeReference = (SingleTypeReference) rightSide;
1940        tokens[nameSize] = singleTypeReference.token;
1941        positions[nameSize] = (((long) singleTypeReference.sourceStart) << 32) + singleTypeReference.sourceEnd;
1942    } else if (rightSide instanceof ParameterizedQualifiedTypeReference) {
1943        ParameterizedQualifiedTypeReference parameterizedTypeReference = (ParameterizedQualifiedTypeReference) rightSide;
1944        TypeReference[][] rightSideTypeArguments = parameterizedTypeReference.typeArguments;
1945        System.arraycopy(rightSideTypeArguments, 0, typeArguments, nameSize, rightSideTypeArguments.length);
1946        char[][] rightSideTokens = parameterizedTypeReference.tokens;
1947        System.arraycopy(rightSideTokens, 0, tokens, nameSize, rightSideTokens.length);
1948        long[] rightSidePositions = parameterizedTypeReference.sourcePositions;
1949        System.arraycopy(rightSidePositions, 0, positions, nameSize, rightSidePositions.length);
1950    } else if (rightSide instanceof QualifiedTypeReference) {
1951        QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReference) rightSide;
1952        char[][] rightSideTokens = qualifiedTypeReference.tokens;
1953        System.arraycopy(rightSideTokens, 0, tokens, nameSize, rightSideTokens.length);
1954        long[] rightSidePositions = qualifiedTypeReference.sourcePositions;
1955        System.arraycopy(rightSidePositions, 0, positions, nameSize, rightSidePositions.length);
1956    }
1957
1958    int currentTypeArgumentsLength = this.genericsLengthStack[this.genericsLengthPtr--];
1959    TypeReference[] currentTypeArguments = new TypeReference[currentTypeArgumentsLength];
1960    this.genericsPtr -= currentTypeArgumentsLength;
1961    System.arraycopy(this.genericsStack, this.genericsPtr + 1, currentTypeArguments, 0, currentTypeArgumentsLength);
1962    
1963    if (nameSize == 1) {
1964        tokens[0] = this.identifierStack[this.identifierPtr];
1965        positions[0] = this.identifierPositionStack[this.identifierPtr--];
1966        typeArguments[0] = currentTypeArguments;
1967    } else {
1968        this.identifierPtr -= nameSize;
1969        System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, nameSize);
1970        System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, nameSize);
1971        typeArguments[nameSize - 1] = currentTypeArguments;
1972    }
1973    this.identifierLengthPtr--;
1974    return new ParameterizedQualifiedTypeReference(tokens, typeArguments, dim, positions);
1975}
1976protected void consumeCastExpressionWithQualifiedGenericsArray() {
1977    // CastExpression ::= PushLPAREN Name OnlyTypeArguments '.' ClassOrInterfaceType Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
1978
Expression exp, cast, castType;
1979    int end = this.intStack[this.intPtr--];
1980
1981    int dim = this.intStack[this.intPtr--];
1982    TypeReference rightSide = getTypeReference(0);
1983    
1984    ParameterizedQualifiedTypeReference qualifiedParameterizedTypeReference = computeQualifiedGenericsFromRightSide(rightSide, dim);
1985    intPtr--;
1986    this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType = qualifiedParameterizedTypeReference);
1987    castType.sourceEnd = end - 1;
1988    castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
1989    cast.sourceEnd = exp.sourceEnd;
1990}
1991protected void consumeCatches() {
1992    // Catches ::= Catches CatchClause
1993
optimizedConcatNodeLists();
1994}
1995protected void consumeCatchHeader() {
1996    // CatchDeclaration ::= 'catch' '(' FormalParameter ')' '{'
1997

1998    if (this.currentElement == null){
1999        return; // should never occur, this consumeRule is only used in recovery mode
2000
}
2001    // current element should be a block due to the presence of the opening brace
2002
if (!(this.currentElement instanceof RecoveredBlock)){
2003        if(!(this.currentElement instanceof RecoveredMethod)) {
2004            return;
2005        }
2006        RecoveredMethod rMethod = (RecoveredMethod) this.currentElement;
2007        if(!(rMethod.methodBody == null && rMethod.bracketBalance > 0)) {
2008            return;
2009        }
2010    }
2011    
2012    Argument arg = (Argument)this.astStack[this.astPtr--];
2013    // convert argument to local variable
2014
LocalDeclaration localDeclaration = new LocalDeclaration(arg.name, arg.sourceStart, arg.sourceEnd);
2015    localDeclaration.type = arg.type;
2016    localDeclaration.declarationSourceStart = arg.declarationSourceStart;
2017    localDeclaration.declarationSourceEnd = arg.declarationSourceEnd;
2018    
2019    this.currentElement = this.currentElement.add(localDeclaration, 0);
2020    this.lastCheckPoint = this.scanner.startPosition; // force to restart at this exact position
2021
this.restartRecovery = true; // request to restart from here on
2022
this.lastIgnoredToken = -1;
2023}
2024protected void consumeClassBodyDeclaration() {
2025    // ClassBodyDeclaration ::= Diet Block
2026
//push an Initializer
2027
//optimize the push/pop
2028
this.nestedMethod[this.nestedType]--;
2029    Block block = (Block) this.astStack[this.astPtr];
2030    if (this.diet) block.bits &= ~ASTNode.UndocumentedEmptyBlock; // clear bit since was diet
2031
Initializer initializer = new Initializer(block, 0);
2032    this.intPtr--; // pop sourcestart left on the stack by consumeNestedMethod.
2033
initializer.bodyStart = this.intStack[this.intPtr--];
2034    this.realBlockPtr--; // pop the block variable counter left on the stack by consumeNestedMethod
2035
int javadocCommentStart = this.intStack[this.intPtr--];
2036    if (javadocCommentStart != -1) {
2037        initializer.declarationSourceStart = javadocCommentStart;
2038        initializer.javadoc = this.javadoc;
2039        this.javadoc = null;
2040    }
2041    this.astStack[this.astPtr] = initializer;
2042    initializer.bodyEnd = this.endPosition;
2043    initializer.sourceEnd = this.endStatementPosition;
2044    initializer.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
2045}
2046protected void consumeClassBodyDeclarations() {
2047    // ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration
2048
concatNodeLists();
2049}
2050protected void consumeClassBodyDeclarationsopt() {
2051    // ClassBodyDeclarationsopt ::= NestedType ClassBodyDeclarations
2052
this.nestedType-- ;
2053}
2054protected void consumeAnnotationTypeMemberDeclarationsopt() {
2055    this.nestedType-- ;
2056}
2057protected void consumeClassBodyopt() {
2058    // ClassBodyopt ::= $empty
2059
pushOnAstStack(null);
2060    this.endPosition = this.rParenPos;
2061}
2062protected void consumeClassDeclaration() {
2063    // ClassDeclaration ::= ClassHeader ClassBody
2064

2065    int length;
2066    if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
2067        //there are length declarations
2068
//dispatch according to the type of the declarations
2069
dispatchDeclarationInto(length);
2070    }
2071
2072    TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
2073
2074    // mark initializers with local type mark if needed
2075
markInitializersWithLocalType(typeDecl);
2076
2077    //convert constructor that do not have the type's name into methods
2078
boolean hasConstructor = typeDecl.checkConstructors(this);
2079    
2080    //add the default constructor when needed (interface don't have it)
2081
if (!hasConstructor) {
2082        switch(TypeDeclaration.kind(typeDecl.modifiers)) {
2083            case TypeDeclaration.CLASS_DECL :
2084            case TypeDeclaration.ENUM_DECL :
2085                boolean insideFieldInitializer = false;
2086                if (this.diet) {
2087                    for (int i = this.nestedType; i > 0; i--){
2088                        if (this.variablesCounter[i] > 0) {
2089                            insideFieldInitializer = true;
2090                            break;
2091                        }
2092                    }
2093                }
2094                typeDecl.createDefaultConstructor(!this.diet || insideFieldInitializer, true);
2095        }
2096    }
2097    //always add <clinit> (will be remove at code gen time if empty)
2098
if (this.scanner.containsAssertKeyword) {
2099        typeDecl.bits |= ASTNode.ContainsAssertion;
2100    }
2101    typeDecl.addClinit();
2102    typeDecl.bodyEnd = this.endStatementPosition;
2103    if (length == 0 && !containsComment(typeDecl.bodyStart, typeDecl.bodyEnd)) {
2104        typeDecl.bits |= ASTNode.UndocumentedEmptyBlock;
2105    }
2106
2107    typeDecl.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
2108}
2109protected void consumeClassHeader() {
2110    // ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt ClassHeaderImplementsopt
2111

2112    TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
2113    if (this.currentToken == TokenNameLBRACE) {
2114        typeDecl.bodyStart = this.scanner.currentPosition;
2115    }
2116    if (this.currentElement != null) {
2117        this.restartRecovery = true; // used to avoid branching back into the regular automaton
2118
}
2119    // flush the comments related to the class header
2120
this.scanner.commentPtr = -1;
2121}
2122protected void consumeClassHeaderExtends() {
2123    // ClassHeaderExtends ::= 'extends' ClassType
2124
//superclass
2125
TypeReference superClass = getTypeReference(0);
2126    // There is a class declaration on the top of stack
2127
TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
2128    typeDecl.superclass = superClass;
2129    superClass.bits |= ASTNode.IsSuperType;
2130    typeDecl.bodyStart = typeDecl.superclass.sourceEnd + 1;
2131    // recovery
2132
if (this.currentElement != null){
2133        this.lastCheckPoint = typeDecl.bodyStart;
2134    }
2135}
2136protected void consumeClassHeaderImplements() {
2137    // ClassHeaderImplements ::= 'implements' InterfaceTypeList
2138
int length = this.astLengthStack[this.astLengthPtr--];
2139    //super interfaces
2140
this.astPtr -= length;
2141    // There is a class declaration on the top of stack
2142
TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
2143    System.arraycopy(
2144        this.astStack,
2145        this.astPtr + 1,
2146        typeDecl.superInterfaces = new TypeReference[length],
2147        0,
2148        length);
2149    for (int i = 0, max = typeDecl.superInterfaces.length; i < max; i++) {
2150        typeDecl.superInterfaces[i].bits |= ASTNode.IsSuperType;
2151    }
2152    typeDecl.bodyStart = typeDecl.superInterfaces[length-1].sourceEnd + 1;
2153    this.listLength = 0; // reset after having read super-interfaces
2154
// recovery
2155
if (this.currentElement != null) { // is recovering
2156
this.lastCheckPoint = typeDecl.bodyStart;
2157    }
2158}
2159protected void consumeClassHeaderName1() {
2160    // ClassHeaderName1 ::= Modifiersopt 'class' 'Identifier'
2161
TypeDeclaration typeDecl = new TypeDeclaration(this.compilationUnit.compilationResult);
2162    if (this.nestedMethod[this.nestedType] == 0) {
2163        if (this.nestedType != 0) {
2164            typeDecl.bits |= ASTNode.IsMemberType;
2165        }
2166    } else {
2167        // Record that the block has a declaration for local types
2168
typeDecl.bits |= ASTNode.IsLocalType;
2169        markEnclosingMemberWithLocalType();
2170        blockReal();
2171    }
2172
2173    //highlight the name of the type
2174
long pos = this.identifierPositionStack[this.identifierPtr];
2175    typeDecl.sourceEnd = (int) pos;
2176    typeDecl.sourceStart = (int) (pos >>> 32);
2177    typeDecl.name = this.identifierStack[this.identifierPtr--];
2178    this.identifierLengthPtr--;
2179
2180    //compute the declaration source too
2181
// 'class' and 'interface' push two int positions: the beginning of the class token and its end.
2182
// we want to keep the beginning position but get rid of the end position
2183
// it is only used for the ClassLiteralAccess positions.
2184
typeDecl.declarationSourceStart = this.intStack[this.intPtr--];
2185    this.intPtr--; // remove the end position of the class token
2186

2187    typeDecl.modifiersSourceStart = this.intStack[this.intPtr--];
2188    typeDecl.modifiers = this.intStack[this.intPtr--];
2189    if (typeDecl.modifiersSourceStart >= 0) {
2190        typeDecl.declarationSourceStart = typeDecl.modifiersSourceStart;
2191    }
2192
2193    // Store secondary info
2194
if ((typeDecl.bits & ASTNode.IsMemberType) == 0 && (typeDecl.bits & ASTNode.IsLocalType) == 0) {
2195        if (this.compilationUnit != null && !CharOperation.equals(typeDecl.name, this.compilationUnit.getMainTypeName())) {
2196            typeDecl.bits |= ASTNode.IsSecondaryType;
2197        }
2198    }
2199
2200    // consume annotations
2201
int length;
2202    if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2203        System.arraycopy(
2204            this.expressionStack,
2205            (this.expressionPtr -= length) + 1,
2206            typeDecl.annotations = new Annotation[length],
2207            0,
2208            length);
2209    }
2210    typeDecl.bodyStart = typeDecl.sourceEnd + 1;
2211    pushOnAstStack(typeDecl);
2212
2213    this.listLength = 0; // will be updated when reading super-interfaces
2214
// recovery
2215
if (this.currentElement != null){
2216        this.lastCheckPoint = typeDecl.bodyStart;
2217        this.currentElement = this.currentElement.add(typeDecl, 0);
2218        this.lastIgnoredToken = -1;
2219    }
2220    // javadoc
2221
typeDecl.javadoc = this.javadoc;
2222    this.javadoc = null;
2223}
2224protected void consumeTypeHeaderNameWithTypeParameters() {
2225    // ClassHeaderName ::= ClassHeaderName1 TypeParameters
2226
// InterfaceHeaderName ::= InterfaceHeaderName1 TypeParameters
2227
TypeDeclaration typeDecl = (TypeDeclaration)this.astStack[this.astPtr];
2228
2229    // consume type parameters
2230
int length = this.genericsLengthStack[this.genericsLengthPtr--];
2231    this.genericsPtr -= length;
2232    System.arraycopy(this.genericsStack, this.genericsPtr + 1, typeDecl.typeParameters = new TypeParameter[length], 0, length);
2233
2234    typeDecl.bodyStart = typeDecl.typeParameters[length-1].declarationSourceEnd + 1;
2235    
2236    this.listTypeParameterLength = 0;
2237    
2238    if (this.currentElement != null) { // is recovering
2239
RecoveredType recoveredType = (RecoveredType) this.currentElement;
2240        recoveredType.pendingTypeParameters = null;
2241        
2242        this.lastCheckPoint = typeDecl.bodyStart;
2243    }
2244}
2245protected void consumeClassInstanceCreationExpression() {
2246    // ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt
2247
classInstanceCreation(false);
2248}
2249protected void consumeClassInstanceCreationExpressionName() {
2250    // ClassInstanceCreationExpressionName ::= Name '.'
2251
pushOnExpressionStack(getUnspecifiedReferenceOptimized());
2252}
2253protected void consumeClassInstanceCreationExpressionQualified() {
2254    // ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
2255
// ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
2256
classInstanceCreation(true);
2257
2258    this.expressionLengthPtr--;
2259    QualifiedAllocationExpression qae =
2260        (QualifiedAllocationExpression) this.expressionStack[this.expressionPtr--];
2261    qae.enclosingInstance = this.expressionStack[this.expressionPtr];
2262    this.expressionStack[this.expressionPtr] = qae;
2263    qae.sourceStart = qae.enclosingInstance.sourceStart;
2264}
2265protected void consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() {
2266    // ClassInstanceCreationExpression ::= Primary '.' 'new' TypeArguments SimpleName '(' ArgumentListopt ')' ClassBodyopt
2267
// ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' TypeArguments SimpleName '(' ArgumentListopt ')' ClassBodyopt
2268

2269    QualifiedAllocationExpression alloc;
2270    int length;
2271    if (((length = this.astLengthStack[this.astLengthPtr--]) == 1) && (this.astStack[this.astPtr] == null)) {
2272        //NO ClassBody
2273
this.astPtr--;
2274        alloc = new QualifiedAllocationExpression();
2275        alloc.sourceEnd = this.endPosition; //the position has been stored explicitly
2276

2277        if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2278            this.expressionPtr -= length;
2279            System.arraycopy(
2280                this.expressionStack,
2281                this.expressionPtr + 1,
2282                alloc.arguments = new Expression[length],
2283                0,
2284                length);
2285        }
2286        alloc.type = getTypeReference(0);
2287
2288        length = this.genericsLengthStack[this.genericsLengthPtr--];
2289        this.genericsPtr -= length;
2290        System.arraycopy(this.genericsStack, this.genericsPtr + 1, alloc.typeArguments = new TypeReference[length], 0, length);
2291        intPtr--;
2292
2293        //the default constructor with the correct number of argument
2294
//will be created and added by the TC (see createsInternalConstructorWithBinding)
2295
alloc.sourceStart = this.intStack[this.intPtr--];
2296        pushOnExpressionStack(alloc);
2297    } else {
2298        dispatchDeclarationInto(length);
2299        TypeDeclaration anonymousTypeDeclaration = (TypeDeclaration)this.astStack[this.astPtr];
2300        anonymousTypeDeclaration.declarationSourceEnd = this.endStatementPosition;
2301        anonymousTypeDeclaration.bodyEnd = this.endStatementPosition;
2302        if (length == 0 && !containsComment(anonymousTypeDeclaration.bodyStart, anonymousTypeDeclaration.bodyEnd)) {
2303            anonymousTypeDeclaration.bits |= ASTNode.UndocumentedEmptyBlock;
2304        }
2305        this.astPtr--;
2306        this.astLengthPtr--;
2307
2308        QualifiedAllocationExpression allocationExpression = anonymousTypeDeclaration.allocation;
2309        if (allocationExpression != null) {
2310            allocationExpression.sourceEnd = this.endStatementPosition;
2311            // handle type arguments
2312
length = this.genericsLengthStack[this.genericsLengthPtr--];
2313            this.genericsPtr -= length;
2314            System.arraycopy(this.genericsStack, this.genericsPtr + 1, allocationExpression.typeArguments = new TypeReference[length], 0, length);
2315            allocationExpression.sourceStart = intStack[intPtr--];
2316        }
2317        
2318        // mark initializers with local type mark if needed
2319
markInitializersWithLocalType(anonymousTypeDeclaration);
2320    }
2321
2322    this.expressionLengthPtr--;
2323    QualifiedAllocationExpression qae =
2324        (QualifiedAllocationExpression) this.expressionStack[this.expressionPtr--];
2325    qae.enclosingInstance = this.expressionStack[this.expressionPtr];
2326    this.expressionStack[this.expressionPtr] = qae;
2327    qae.sourceStart = qae.enclosingInstance.sourceStart;
2328}
2329protected void consumeClassInstanceCreationExpressionWithTypeArguments() {
2330    // ClassInstanceCreationExpression ::= 'new' TypeArguments ClassType '(' ArgumentListopt ')' ClassBodyopt
2331
AllocationExpression alloc;
2332    int length;
2333    if (((length = this.astLengthStack[this.astLengthPtr--]) == 1)
2334        && (this.astStack[this.astPtr] == null)) {
2335        //NO ClassBody
2336
this.astPtr--;
2337        alloc = new AllocationExpression();
2338        alloc.sourceEnd = this.endPosition; //the position has been stored explicitly
2339

2340        if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2341            this.expressionPtr -= length;
2342            System.arraycopy(
2343                this.expressionStack,
2344                this.expressionPtr + 1,
2345                alloc.arguments = new Expression[length],
2346                0,
2347                length);
2348        }
2349        alloc.type = getTypeReference(0);
2350
2351        length = this.genericsLengthStack[this.genericsLengthPtr--];
2352        this.genericsPtr -= length;
2353        System.arraycopy(this.genericsStack, this.genericsPtr + 1, alloc.typeArguments = new TypeReference[length], 0, length);
2354        intPtr--;
2355        
2356        //the default constructor with the correct number of argument
2357
//will be created and added by the TC (see createsInternalConstructorWithBinding)
2358
alloc.sourceStart = this.intStack[this.intPtr--];
2359        pushOnExpressionStack(alloc);
2360    } else {
2361        dispatchDeclarationInto(length);
2362        TypeDeclaration anonymousTypeDeclaration = (TypeDeclaration)this.astStack[this.astPtr];
2363        anonymousTypeDeclaration.declarationSourceEnd = this.endStatementPosition;
2364        anonymousTypeDeclaration.bodyEnd = this.endStatementPosition;
2365        if (length == 0 && !containsComment(anonymousTypeDeclaration.bodyStart, anonymousTypeDeclaration.bodyEnd)) {
2366            anonymousTypeDeclaration.bits |= ASTNode.UndocumentedEmptyBlock;
2367        }
2368        this.astPtr--;
2369        this.astLengthPtr--;
2370
2371        QualifiedAllocationExpression allocationExpression = anonymousTypeDeclaration.allocation;
2372        if (allocationExpression != null) {
2373            allocationExpression.sourceEnd = this.endStatementPosition;
2374            // handle type arguments
2375
length = this.genericsLengthStack[this.genericsLengthPtr--];
2376            this.genericsPtr -= length;
2377            System.arraycopy(this.genericsStack, this.genericsPtr + 1, allocationExpression.typeArguments = new TypeReference[length], 0, length);
2378            allocationExpression.sourceStart = intStack[intPtr--];
2379        }
2380        
2381        // mark initializers with local type mark if needed
2382
markInitializersWithLocalType(anonymousTypeDeclaration);
2383    }
2384}
2385protected void consumeClassOrInterface() {
2386    this.genericsIdentifiersLengthStack[this.genericsIdentifiersLengthPtr] += this.identifierLengthStack[this.identifierLengthPtr];
2387    pushOnGenericsLengthStack(0); // handle type arguments
2388
}
2389protected void consumeClassOrInterfaceName() {
2390    pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
2391    pushOnGenericsLengthStack(0); // handle type arguments
2392
}
2393protected void consumeClassTypeElt() {
2394    // ClassTypeElt ::= ClassType
2395
pushOnAstStack(getTypeReference(0));
2396    /* if incomplete thrown exception list, this.listLength counter will not have been reset,
2397        indicating that some items are available on the stack */

2398    this.listLength++;
2399}
2400protected void consumeClassTypeList() {
2401    // ClassTypeList ::= ClassTypeList ',' ClassTypeElt
2402
optimizedConcatNodeLists();
2403}
2404protected void consumeCompilationUnit() {
2405    // CompilationUnit ::= EnterCompilationUnit InternalCompilationUnit
2406
// do nothing by default
2407
}
2408protected void consumeConditionalExpression(int op) {
2409    // ConditionalExpression ::= ConditionalOrExpression '?' Expression ':' ConditionalExpression
2410
//optimize the push/pop
2411
this.intPtr -= 2;//consume position of the question mark
2412
this.expressionPtr -= 2;
2413    this.expressionLengthPtr -= 2;
2414    this.expressionStack[this.expressionPtr] =
2415        new ConditionalExpression(
2416            this.expressionStack[this.expressionPtr],
2417            this.expressionStack[this.expressionPtr + 1],
2418            this.expressionStack[this.expressionPtr + 2]);
2419}
2420/**
2421 * @param op
2422 */

2423protected void consumeConditionalExpressionWithName(int op) {
2424    // ConditionalExpression ::= Name '?' Expression ':' ConditionalExpression
2425
this.intPtr -= 2;//consume position of the question mark
2426
pushOnExpressionStack(getUnspecifiedReferenceOptimized());
2427    this.expressionPtr -= 2;
2428    this.expressionLengthPtr -= 2;
2429    this.expressionStack[this.expressionPtr] =
2430        new ConditionalExpression(
2431            this.expressionStack[this.expressionPtr + 2],
2432            this.expressionStack[this.expressionPtr],
2433            this.expressionStack[this.expressionPtr + 1]);
2434}
2435protected void consumeConstructorBlockStatements() {
2436    // ConstructorBody ::= NestedMethod '{' ExplicitConstructorInvocation BlockStatements '}'
2437
concatNodeLists(); // explictly add the first statement into the list of statements
2438
}
2439protected void consumeConstructorBody() {
2440    // ConstructorBody ::= NestedMethod '{' BlockStatementsopt '}'
2441
// ConstructorBody ::= NestedMethod '{' ExplicitConstructorInvocation '}'
2442
this.nestedMethod[this.nestedType] --;
2443}
2444protected void consumeConstructorDeclaration() {
2445    // ConstructorDeclaration ::= ConstructorHeader ConstructorBody
2446

2447    /*
2448    this.astStack : MethodDeclaration statements
2449    this.identifierStack : name
2450     ==>
2451    this.astStack : MethodDeclaration
2452    this.identifierStack :
2453    */

2454
2455    //must provide a default constructor call when needed
2456

2457    int length;
2458
2459    // pop the position of the { (body of the method) pushed in block decl
2460
this.intPtr--;
2461    this.intPtr--;
2462
2463    //statements
2464
this.realBlockPtr--;
2465    ExplicitConstructorCall constructorCall = null;
2466    Statement[] statements = null;
2467    if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
2468        this.astPtr -= length;
2469        if (this.astStack[this.astPtr + 1] instanceof ExplicitConstructorCall) {
2470            //avoid a isSomeThing that would only be used here BUT what is faster between two alternatives ?
2471
System.arraycopy(
2472                this.astStack,
2473                this.astPtr + 2,
2474                statements = new Statement[length - 1],
2475                0,
2476                length - 1);
2477            constructorCall = (ExplicitConstructorCall) this.astStack[this.astPtr + 1];
2478        } else { //need to add explicitly the super();
2479
System.arraycopy(
2480                this.astStack,
2481                this.astPtr + 1,
2482                statements = new Statement[length],
2483                0,
2484                length);
2485            constructorCall = SuperReference.implicitSuperConstructorCall();
2486        }
2487    } else {
2488        boolean insideFieldInitializer = false;
2489        if (this.diet) {
2490            for (int i = this.nestedType; i > 0; i--){
2491                if (this.variablesCounter[i] > 0) {
2492                    insideFieldInitializer = true;
2493                    break;
2494                }
2495            }
2496        }
2497        
2498        if (!this.diet || insideFieldInitializer){
2499            // add it only in non-diet mode, if diet_bodies, then constructor call will be added elsewhere.
2500
constructorCall = SuperReference.implicitSuperConstructorCall();
2501        }
2502    }
2503
2504    // now we know that the top of stack is a constructorDeclaration
2505
ConstructorDeclaration cd = (ConstructorDeclaration) this.astStack[this.astPtr];
2506    cd.constructorCall = constructorCall;
2507    cd.statements = statements;
2508
2509    //highlight of the implicit call on the method name
2510
if (constructorCall != null && cd.constructorCall.sourceEnd == 0) {
2511        cd.constructorCall.sourceEnd = cd.sourceEnd;
2512        cd.constructorCall.sourceStart = cd.sourceStart;
2513    }
2514
2515    if (!(this.diet && this.dietInt == 0)
2516            && statements == null
2517            && (constructorCall == null || constructorCall.isImplicitSuper())
2518            && !containsComment(cd.bodyStart, this.endPosition)) {
2519        cd.bits |= ASTNode.UndocumentedEmptyBlock;
2520    }
2521
2522    //watch for } that could be given as a unicode ! ( u007D is '}' )
2523
// store the this.endPosition (position just before the '}') in case there is
2524
// a trailing comment behind the end of the method
2525
cd.bodyEnd = this.endPosition;
2526    cd.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
2527}
2528protected void consumeConstructorHeader() {
2529    // ConstructorHeader ::= ConstructorHeaderName MethodHeaderParameters MethodHeaderThrowsClauseopt
2530

2531    AbstractMethodDeclaration method = (AbstractMethodDeclaration)this.astStack[this.astPtr];
2532
2533    if (this.currentToken == TokenNameLBRACE){
2534        method.bodyStart = this.scanner.currentPosition;
2535    }
2536    // recovery
2537
if (this.currentElement != null){
2538        if (this.currentToken == TokenNameSEMICOLON){ // for invalid constructors
2539
method.modifiers |= ExtraCompilerModifiers.AccSemicolonBody;
2540            method.declarationSourceEnd = this.scanner.currentPosition-1;
2541            method.bodyEnd = this.scanner.currentPosition-1;
2542            if (this.currentElement.parseTree() == method && this.currentElement.parent != null) {
2543                this.currentElement = this.currentElement.parent;
2544            }
2545        }
2546        this.restartRecovery = true; // used to avoid branching back into the regular automaton
2547
}
2548}
2549protected void consumeConstructorHeaderName() {
2550
2551    /* recovering - might be an empty message send */
2552    if (this.currentElement != null){
2553        if (this.lastIgnoredToken == TokenNamenew){ // was an allocation expression
2554
this.lastCheckPoint = this.scanner.startPosition; // force to restart at this exact position
2555
this.restartRecovery = true;
2556            return;
2557        }
2558    }
2559    
2560    // ConstructorHeaderName ::= Modifiersopt 'Identifier' '('
2561
ConstructorDeclaration cd = new ConstructorDeclaration(this.compilationUnit.compilationResult);
2562
2563    //name -- this is not really revelant but we do .....
2564
cd.selector = this.identifierStack[this.identifierPtr];
2565    long selectorSource = this.identifierPositionStack[this.identifierPtr--];
2566    this.identifierLengthPtr--;
2567
2568    //modifiers
2569
cd.declarationSourceStart = this.intStack[this.intPtr--];
2570    cd.modifiers = this.intStack[this.intPtr--];
2571    // consume annotations
2572
int length;
2573    if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2574        System.arraycopy(
2575            this.expressionStack,
2576            (this.expressionPtr -= length) + 1,
2577            cd.annotations = new Annotation[length],
2578            0,
2579            length);
2580    }
2581    // javadoc
2582
cd.javadoc = this.javadoc;
2583    this.javadoc = null;
2584
2585    //highlight starts at the selector starts
2586
cd.sourceStart = (int) (selectorSource >>> 32);
2587    pushOnAstStack(cd);
2588    cd.sourceEnd = this.lParenPos;
2589    cd.bodyStart = this.lParenPos+1;
2590    this.listLength = 0; // initialize this.listLength before reading parameters/throws
2591

2592    // recovery
2593
if (this.currentElement != null){
2594        this.lastCheckPoint = cd.bodyStart;
2595        if ((this.currentElement instanceof RecoveredType && this.lastIgnoredToken != TokenNameDOT)
2596            || cd.modifiers != 0){
2597            this.currentElement = this.currentElement.add(cd, 0);
2598            this.lastIgnoredToken = -1;
2599        }
2600    }
2601}
2602protected void consumeConstructorHeaderNameWithTypeParameters() {
2603
2604    /* recovering - might be an empty message send */
2605    if (this.currentElement != null){
2606        if (this.lastIgnoredToken == TokenNamenew){ // was an allocation expression
2607
this.lastCheckPoint = this.scanner.startPosition; // force to restart at this exact position
2608
this.restartRecovery = true;
2609            return;
2610        }
2611    }
2612    
2613    // ConstructorHeaderName ::= Modifiersopt TypeParameters 'Identifier' '('
2614
ConstructorDeclaration cd = new ConstructorDeclaration(this.compilationUnit.compilationResult);
2615
2616    //name -- this is not really revelant but we do .....
2617
cd.selector = this.identifierStack[this.identifierPtr];
2618    long selectorSource = this.identifierPositionStack[this.identifierPtr--];
2619    this.identifierLengthPtr--;
2620
2621    // consume type parameters
2622
int length = this.genericsLengthStack[this.genericsLengthPtr--];
2623    this.genericsPtr -= length;
2624    System.arraycopy(this.genericsStack, this.genericsPtr + 1, cd.typeParameters = new TypeParameter[length], 0, length);
2625    
2626    //modifiers
2627
cd.declarationSourceStart = this.intStack[this.intPtr--];
2628    cd.modifiers = this.intStack[this.intPtr--];
2629    // consume annotations
2630
if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2631        System.arraycopy(
2632            this.expressionStack,
2633            (this.expressionPtr -= length) + 1,
2634            cd.annotations = new Annotation[length],
2635            0,
2636            length);
2637    }
2638    // javadoc
2639
cd.javadoc = this.javadoc;
2640    this.javadoc = null;
2641
2642    //highlight starts at the selector starts
2643
cd.sourceStart = (int) (selectorSource >>> 32);
2644    pushOnAstStack(cd);
2645    cd.sourceEnd = this.lParenPos;
2646    cd.bodyStart = this.lParenPos+1;
2647    this.listLength = 0; // initialize this.listLength before reading parameters/throws
2648

2649    // recovery
2650
if (this.currentElement != null){
2651        this.lastCheckPoint = cd.bodyStart;
2652        if ((this.currentElement instanceof RecoveredType && this.lastIgnoredToken != TokenNameDOT)
2653            || cd.modifiers != 0){
2654            this.currentElement = this.currentElement.add(cd, 0);
2655            this.lastIgnoredToken = -1;
2656        }
2657    }
2658}
2659protected void consumeDefaultLabel() {
2660    // SwitchLabel ::= 'default' ':'
2661
pushOnAstStack(new CaseStatement(null, this.intStack[this.intPtr--], this.intStack[this.intPtr--]));
2662}
2663protected void consumeDefaultModifiers() {
2664    checkComment(); // might update modifiers with AccDeprecated
2665
pushOnIntStack(this.modifiers); // modifiers
2666
pushOnIntStack(
2667        this.modifiersSourceStart >= 0 ? this.modifiersSourceStart : this.scanner.startPosition);
2668    resetModifiers();
2669    pushOnExpressionStackLengthStack(0); // no annotation
2670
}
2671protected void consumeDiet() {
2672    // Diet ::= $empty
2673
checkComment();
2674    pushOnIntStack(this.modifiersSourceStart); // push the start position of a javadoc comment if there is one
2675
resetModifiers();
2676    jumpOverMethodBody();
2677}
2678protected void consumeDims() {
2679    // Dims ::= DimsLoop
2680
pushOnIntStack(this.dimensions);
2681    this.dimensions = 0;
2682}
2683protected void consumeDimWithOrWithOutExpr() {
2684    // DimWithOrWithOutExpr ::= '[' ']'
2685
pushOnExpressionStack(null);
2686    
2687    if(this.currentElement != null && this.currentToken == TokenNameLBRACE) {
2688        this.ignoreNextOpeningBrace = true;
2689        this.currentElement.bracketBalance++;
2690    }
2691}
2692protected void consumeDimWithOrWithOutExprs() {
2693    // DimWithOrWithOutExprs ::= DimWithOrWithOutExprs DimWithOrWithOutExpr
2694
concatExpressionLists();
2695}
2696protected void consumeEmptyAnnotationTypeMemberDeclarationsopt() {
2697    // AnnotationTypeMemberDeclarationsopt ::= $empty
2698
pushOnAstLengthStack(0);
2699}
2700protected void consumeEmptyArgumentListopt() {
2701    // ArgumentListopt ::= $empty
2702
pushOnExpressionStackLengthStack(0);
2703}
2704protected void consumeEmptyArguments() {
2705    // Argumentsopt ::= $empty
2706
final FieldDeclaration fieldDeclaration = (FieldDeclaration) this.astStack[this.astPtr];
2707    pushOnIntStack(fieldDeclaration.sourceEnd);
2708    pushOnExpressionStackLengthStack(0);
2709}
2710protected void consumeEmptyArrayInitializer() {
2711    // ArrayInitializer ::= '{' ,opt '}'
2712
arrayInitializer(0);
2713}
2714protected void consumeEmptyArrayInitializeropt() {
2715    // ArrayInitializeropt ::= $empty
2716
pushOnExpressionStackLengthStack(0);
2717}
2718protected void consumeEmptyBlockStatementsopt() {
2719    // BlockStatementsopt ::= $empty
2720
pushOnAstLengthStack(0);
2721}
2722protected void consumeEmptyCatchesopt() {
2723    // Catchesopt ::= $empty
2724
pushOnAstLengthStack(0);
2725}
2726protected void consumeEmptyClassBodyDeclarationsopt() {
2727    // ClassBodyDeclarationsopt ::= $empty
2728
pushOnAstLengthStack(0);
2729}
2730protected void consumeEmptyMethodHeaderDefaultValue() {
2731    // DefaultValueopt ::= $empty
2732
AbstractMethodDeclaration method = (AbstractMethodDeclaration)this.astStack[this.astPtr];
2733    if(method.isAnnotationMethod()) { //'method' can be a MethodDeclaration when recovery is started
2734
pushOnExpressionStackLengthStack(0);
2735    }
2736    this.recordStringLiterals = true;
2737}
2738protected void consumeEmptyDimsopt() {
2739    // Dimsopt ::= $empty
2740
pushOnIntStack(0);
2741}
2742protected void consumeEmptyEnumDeclarations() {
2743    // EnumBodyDeclarationsopt ::= $empty
2744
pushOnAstLengthStack(0);
2745}
2746protected void consumeEmptyExpression() {
2747    // Expressionopt ::= $empty
2748
pushOnExpressionStackLengthStack(0);
2749}
2750protected void consumeEmptyForInitopt() {
2751    // ForInitopt ::= $empty
2752
pushOnAstLengthStack(0);
2753}
2754protected void consumeEmptyForUpdateopt() {
2755    // ForUpdateopt ::= $empty
2756
pushOnExpressionStackLengthStack(0);
2757}
2758protected void consumeEmptyInterfaceMemberDeclarationsopt() {
2759    // InterfaceMemberDeclarationsopt ::= $empty
2760
pushOnAstLengthStack(0);
2761}
2762protected void consumeEmptyInternalCompilationUnit() {
2763    // InternalCompilationUnit ::= $empty
2764
// nothing to do by default
2765
if (this.compilationUnit.isPackageInfo()) {
2766        this.compilationUnit.types = new TypeDeclaration[1];
2767        // create a fake interface declaration
2768
TypeDeclaration declaration = new TypeDeclaration(compilationUnit.compilationResult);
2769        declaration.name = TypeConstants.PACKAGE_INFO_NAME;
2770        declaration.modifiers = ClassFileConstants.AccDefault | ClassFileConstants.AccInterface;
2771        this.compilationUnit.types[0] = declaration;
2772        declaration.javadoc = this.compilationUnit.javadoc;
2773    }
2774}
2775protected void consumeEmptyMemberValuePairsopt() {
2776    // MemberValuePairsopt ::= $empty
2777
pushOnAstLengthStack(0);
2778}
2779protected void consumeEmptyMemberValueArrayInitializer() {
2780    // MemberValueArrayInitializer ::= '{' ',' '}'
2781
// MemberValueArrayInitializer ::= '{' '}'
2782
arrayInitializer(0);
2783}
2784protected void consumeEmptyStatement() {
2785    // EmptyStatement ::= ';'
2786
char[] source = this.scanner.source;
2787    if (source[this.endStatementPosition] == ';') {
2788        pushOnAstStack(new EmptyStatement(this.endStatementPosition, this.endStatementPosition));
2789    } else {
2790        if(source.length > 5) {
2791            int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
2792            int pos = this.endStatementPosition - 4;
2793            while (source[pos] == 'u') {
2794                pos--;
2795            }
2796            if (source[pos] == '\\' &&
2797                    !((c1 = ScannerHelper.getNumericValue(source[this.endStatementPosition - 3])) > 15
2798                        || c1 < 0
2799                        || (c2 = ScannerHelper.getNumericValue(source[this.endStatementPosition - 2])) > 15
2800                        || c2 < 0
2801                        || (c3 = ScannerHelper.getNumericValue(source[this.endStatementPosition - 1])) > 15
2802                        || c3 < 0
2803                        || (c4 = ScannerHelper.getNumericValue(source[this.endStatementPosition])) > 15
2804                        || c4 < 0) &&
2805                    ((char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4)) == ';'){
2806                // we have a Unicode for the ';' (/u003B)
2807
pushOnAstStack(new EmptyStatement(pos, this.endStatementPosition));
2808                return;
2809            }
2810        }
2811        pushOnAstStack(new EmptyStatement(this.endStatementPosition, this.endStatementPosition));
2812    }
2813}
2814protected void consumeEmptySwitchBlock() {
2815    // SwitchBlock ::= '{' '}'
2816
pushOnAstLengthStack(0);
2817}
2818protected void consumeEmptyTypeDeclaration() {
2819    // ClassMemberDeclaration ::= ';'
2820
// InterfaceMemberDeclaration ::= ';'
2821
// TypeDeclaration ::= ';'
2822
pushOnAstLengthStack(0);
2823    if(!this.statementRecoveryActivated) problemReporter().superfluousSemicolon(this.endPosition+1, this.endStatementPosition);
2824    flushCommentsDefinedPriorTo(this.endStatementPosition);
2825}
2826protected void consumeEnhancedForStatementHeaderInit(boolean hasModifiers) {
2827    TypeReference type;
2828
2829    char[] identifierName = this.identifierStack[this.identifierPtr];
2830    long namePosition = this.identifierPositionStack[this.identifierPtr];
2831    
2832    LocalDeclaration localDeclaration = createLocalDeclaration(identifierName, (int) (namePosition >>> 32), (int) namePosition);
2833    localDeclaration.declarationSourceEnd = localDeclaration.declarationEnd;
2834    
2835    int extraDims = this.intStack[this.intPtr--];
2836    this.identifierPtr--;
2837    this.identifierLengthPtr--;
2838    // remove fake modifiers/modifiers start
2839
int declarationSourceStart = 0;
2840    int modifiersValue = 0;
2841    if (hasModifiers) {
2842        declarationSourceStart = this.intStack[this.intPtr--];
2843        modifiersValue = this.intStack[this.intPtr--];
2844    } else {
2845        this.intPtr-=2;
2846    }
2847
2848    type = getTypeReference(this.intStack[this.intPtr--] + extraDims); // type dimension
2849

2850    // consume annotations
2851
int length;
2852    if ((length = this.expressionLengthStack[this.expressionLengthPtr--])!= 0) {
2853        System.arraycopy(
2854            this.expressionStack,
2855            (this.expressionPtr -= length) + 1,
2856            localDeclaration.annotations = new Annotation[length],
2857            0,
2858            length);
2859    }
2860    if (hasModifiers) {
2861        localDeclaration.declarationSourceStart = declarationSourceStart;
2862        localDeclaration.modifiers = modifiersValue;
2863    } else {
2864        localDeclaration.declarationSourceStart = type.sourceStart;
2865    }
2866    localDeclaration.type = type;
2867
2868    ForeachStatement iteratorForStatement =
2869        new ForeachStatement(
2870            localDeclaration,
2871            this.intStack[this.intPtr--]);
2872    pushOnAstStack(iteratorForStatement);
2873    
2874    iteratorForStatement.sourceEnd = localDeclaration.declarationSourceEnd;
2875}
2876protected void consumeEnhancedForStatementHeader(){
2877    // EnhancedForStatementHeader ::= EnhancedForStatementHeaderInit ':' Expression ')'
2878
final ForeachStatement statement = (ForeachStatement) this.astStack[this.astPtr];
2879    //updates are on the expression stack
2880
this.expressionLengthPtr--;
2881    final Expression collection = this.expressionStack[this.expressionPtr--];
2882    statement.collection = collection;
2883    statement.sourceEnd = this.rParenPos;
2884    
2885    if(!this.statementRecoveryActivated &&
2886            options.sourceLevel < ClassFileConstants.JDK1_5 &&
2887            this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
2888        this.problemReporter().invalidUsageOfForeachStatements(statement.elementVariable, collection);
2889    }
2890}
2891protected void consumeEnhancedForStatement() {
2892    // EnhancedForStatement ::= EnhancedForStatementHeader Statement
2893
// EnhancedForStatementNoShortIf ::= EnhancedForStatementHeader StatementNoShortIf
2894

2895    //statements
2896
this.astLengthPtr--;
2897    Statement statement = (Statement) this.astStack[this.astPtr--];
2898
2899    // foreach statement is on the ast stack
2900
ForeachStatement foreachStatement = (ForeachStatement) this.astStack[this.astPtr];
2901    foreachStatement.action = statement;
2902    // remember useful empty statement
2903
if (statement instanceof EmptyStatement) statement.bits |= ASTNode.IsUsefulEmptyStatement;
2904    
2905    foreachStatement.sourceEnd = this.endStatementPosition;
2906}
2907protected void consumeEnterAnonymousClassBody() {
2908    // EnterAnonymousClassBody ::= $empty
2909
TypeReference typeReference = getTypeReference(0);
2910
2911    TypeDeclaration anonymousType = new TypeDeclaration(this.compilationUnit.compilationResult);
2912    anonymousType.name = CharOperation.NO_CHAR;
2913    anonymousType.bits |= (ASTNode.IsAnonymousType|ASTNode.IsLocalType);
2914    QualifiedAllocationExpression alloc = new QualifiedAllocationExpression(anonymousType);
2915    markEnclosingMemberWithLocalType();
2916    pushOnAstStack(anonymousType);
2917
2918    alloc.sourceEnd = this.rParenPos; //the position has been stored explicitly
2919
int argumentLength;
2920    if ((argumentLength = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2921        this.expressionPtr -= argumentLength;
2922        System.arraycopy(
2923            this.expressionStack,
2924            this.expressionPtr + 1,
2925            alloc.arguments = new Expression[argumentLength],
2926            0,
2927            argumentLength);
2928    }
2929    alloc.type = typeReference;
2930
2931    anonymousType.sourceEnd = alloc.sourceEnd;
2932    //position at the type while it impacts the anonymous declaration
2933
anonymousType.sourceStart = anonymousType.declarationSourceStart = alloc.type.sourceStart;
2934    alloc.sourceStart = this.intStack[this.intPtr--];
2935    pushOnExpressionStack(alloc);
2936
2937    anonymousType.bodyStart = this.scanner.currentPosition;
2938    this.listLength = 0; // will be updated when reading super-interfaces
2939

2940    // flush the comments related to the anonymous
2941
this.scanner.commentPtr = -1;
2942    
2943    // recovery
2944
if (this.currentElement != null){
2945        this.lastCheckPoint = anonymousType.bodyStart;
2946        this.currentElement = this.currentElement.add(anonymousType, 0);
2947        this.currentToken = 0; // opening brace already taken into account
2948
this.lastIgnoredToken = -1;
2949    }
2950}
2951protected void consumeEnterCompilationUnit() {
2952    // EnterCompilationUnit ::= $empty
2953
// do nothing by default
2954
}
2955protected void consumeEnterMemberValue() {
2956    // EnterMemberValue ::= $empty
2957
// do nothing by default
2958
}
2959protected void consumeEnterMemberValueArrayInitializer() {
2960    // EnterMemberValueArrayInitializer ::= $empty
2961
if(this.currentElement != null) {
2962        this.ignoreNextOpeningBrace = true;
2963        this.currentElement.bracketBalance++;
2964    }
2965}
2966protected void consumeEnterVariable() {
2967    // EnterVariable ::= $empty
2968
// do nothing by default
2969

2970    char[] identifierName = this.identifierStack[this.identifierPtr];
2971    long namePosition = this.identifierPositionStack[this.identifierPtr];
2972    int extendedDimension = this.intStack[this.intPtr--];
2973    AbstractVariableDeclaration declaration;
2974    // create the ast node
2975
boolean isLocalDeclaration = this.nestedMethod[this.nestedType] != 0;
2976    if (isLocalDeclaration) {
2977        // create the local variable declarations
2978
declaration =
2979            this.createLocalDeclaration(identifierName, (int) (namePosition >>> 32), (int) namePosition);
2980    } else {
2981        // create the field declaration
2982
declaration =
2983            this.createFieldDeclaration(identifierName, (int) (namePosition >>> 32), (int) namePosition);
2984    }
2985    
2986    this.identifierPtr--;
2987    this.identifierLengthPtr--;
2988    TypeReference type;
2989    int variableIndex = this.variablesCounter[this.nestedType];
2990    int typeDim = 0;
2991    if (variableIndex == 0) {
2992        // first variable of the declaration (FieldDeclaration or LocalDeclaration)
2993
if (isLocalDeclaration) {
2994            declaration.declarationSourceStart = this.intStack[this.intPtr--];
2995            declaration.modifiers = this.intStack[this.intPtr--];
2996            // consume annotations
2997
int length;
2998            if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2999                System.arraycopy(
3000                    this.expressionStack,
3001                    (this.expressionPtr -= length) + 1,
3002                    declaration.annotations = new Annotation[length],
3003                    0,
3004                    length);
3005            }
3006            type = getTypeReference(typeDim = this.intStack[this.intPtr--]); // type dimension
3007
if (declaration.declarationSourceStart == -1) {
3008                // this is true if there is no modifiers for the local variable declaration
3009
declaration.declarationSourceStart = type.sourceStart;
3010            }
3011            pushOnAstStack(type);
3012        } else {
3013            type = getTypeReference(typeDim = this.intStack[this.intPtr--]); // type dimension
3014
pushOnAstStack(type);
3015            declaration.declarationSourceStart = this.intStack[this.intPtr--];
3016            declaration.modifiers = this.intStack[this.intPtr--];
3017            // consume annotations
3018
int length;
3019            if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3020                System.arraycopy(
3021                    this.expressionStack,
3022                    (this.expressionPtr -= length) + 1,
3023                    declaration.annotations = new Annotation[length],
3024                    0,
3025                    length);
3026            }
3027            // Store javadoc only on first declaration as it is the same for all ones
3028
FieldDeclaration fieldDeclaration = (FieldDeclaration) declaration;
3029            fieldDeclaration.javadoc = this.javadoc;
3030            this.javadoc = null;
3031        }
3032    } else {
3033        type = (TypeReference) this.astStack[this.astPtr - variableIndex];
3034        typeDim = type.dimensions();
3035        AbstractVariableDeclaration previousVariable =
3036            (AbstractVariableDeclaration) this.astStack[this.astPtr];
3037        declaration.declarationSourceStart = previousVariable.declarationSourceStart;
3038        declaration.modifiers = previousVariable.modifiers;
3039        final Annotation[] annotations = previousVariable.annotations;
3040        if (annotations != null) {
3041            final int annotationsLength = annotations.length;
3042            System.arraycopy(annotations, 0, declaration.annotations = new Annotation[annotationsLength], 0, annotationsLength);
3043        }
3044    }
3045
3046    if (extendedDimension == 0) {
3047        declaration.type = type;
3048    } else {
3049        int dimension = typeDim + extendedDimension;
3050        declaration.type = this.copyDims(type, dimension);
3051    }
3052    this.variablesCounter[this.nestedType]++;
3053    pushOnAstStack(declaration);
3054    // recovery
3055
if (this.currentElement != null) {
3056        if (!(this.currentElement instanceof RecoveredType)
3057            && (this.currentToken == TokenNameDOT
3058                //|| declaration.modifiers != 0
3059
|| (Util.getLineNumber(declaration.type.sourceStart, this.scanner.lineEnds, 0, this.scanner.linePtr)
3060                        != Util.getLineNumber((int) (namePosition >>> 32), this.scanner.lineEnds, 0, this.scanner.linePtr)))){
3061            this.lastCheckPoint = (int) (namePosition >>> 32);
3062            this.restartRecovery = true;
3063            return;
3064        }
3065        if (isLocalDeclaration){
3066            LocalDeclaration localDecl = (LocalDeclaration) this.astStack[this.astPtr];
3067            this.lastCheckPoint = localDecl.sourceEnd + 1;
3068            this.currentElement = this.currentElement.add(localDecl, 0);
3069        } else {
3070            FieldDeclaration fieldDecl = (FieldDeclaration) this.astStack[this.astPtr];
3071            this.lastCheckPoint = fieldDecl.sourceEnd + 1;
3072            this.currentElement = this.currentElement.add(fieldDecl, 0);
3073        }
3074        this.lastIgnoredToken = -1;
3075    }
3076}
3077protected void consumeEnumBodyNoConstants() {
3078    // nothing to do
3079
// The 0 on the astLengthStack has been pushed by EnumBodyDeclarationsopt
3080
}
3081protected void consumeEnumBodyWithConstants() {
3082    // merge the constants values with the class body
3083
concatNodeLists();
3084}
3085protected void consumeEnumConstantHeaderName() {
3086    if (this.currentElement != null) {
3087        if (!(this.currentElement instanceof RecoveredType
3088                    || (this.currentElement instanceof RecoveredField && ((RecoveredField)currentElement).fieldDeclaration.type == null))
3089                || (this.lastIgnoredToken == TokenNameDOT)) {
3090            this.lastCheckPoint = this.scanner.startPosition;
3091            this.restartRecovery = true;
3092            return;
3093        }
3094    }
3095   long namePosition = this.identifierPositionStack[this.identifierPtr];
3096   char[] constantName = this.identifierStack[this.identifierPtr];
3097   final int sourceEnd = (int) namePosition;
3098   FieldDeclaration enumConstant = createFieldDeclaration(constantName, (int) (namePosition >>> 32), sourceEnd);
3099   this.identifierPtr--;
3100   this.identifierLengthPtr--;
3101   enumConstant.modifiersSourceStart = this.intStack[this.intPtr--];
3102   enumConstant.modifiers = this.intStack[this.intPtr--];
3103   enumConstant.declarationSourceStart = enumConstant.modifiersSourceStart;
3104
3105    // Store secondary info
3106
if ((enumConstant.bits & ASTNode.IsMemberType) == 0 && (enumConstant.bits & ASTNode.IsLocalType) == 0) {
3107        if (this.compilationUnit != null && !CharOperation.equals(enumConstant.name, this.compilationUnit.getMainTypeName())) {
3108            enumConstant.bits |= ASTNode.IsSecondaryType;
3109        }
3110    }
3111
3112    // consume annotations
3113
int length;
3114   if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3115      System.arraycopy(
3116         this.expressionStack,
3117         (this.expressionPtr -= length) + 1,
3118         enumConstant.annotations = new Annotation[length],
3119         0,
3120         length);
3121   }
3122   pushOnAstStack(enumConstant);
3123    if (this.currentElement != null){
3124        this.lastCheckPoint = enumConstant.sourceEnd + 1;
3125        this.currentElement = this.currentElement.add(enumConstant, 0);
3126    }
3127    // javadoc
3128
enumConstant.javadoc = this.javadoc;
3129    this.javadoc = null;
3130}
3131protected void consumeEnumConstantHeader() {
3132   FieldDeclaration enumConstant = (FieldDeclaration) this.astStack[this.astPtr];
3133   boolean foundOpeningBrace = this.currentToken == TokenNameLBRACE;
3134   if (foundOpeningBrace){
3135      // qualified allocation expression
3136
TypeDeclaration anonymousType = new TypeDeclaration(this.compilationUnit.compilationResult);
3137      anonymousType.name = CharOperation.NO_CHAR;
3138      anonymousType.bits |= (ASTNode.IsAnonymousType|ASTNode.IsLocalType);
3139      final int start = this.scanner.startPosition;
3140      anonymousType.declarationSourceStart = start;
3141      anonymousType.sourceStart = start;
3142      anonymousType.sourceEnd = start; // closing parenthesis
3143
anonymousType.modifiers = 0;
3144      anonymousType.bodyStart = this.scanner.currentPosition;
3145      markEnclosingMemberWithLocalType();
3146      pushOnAstStack(anonymousType);
3147      QualifiedAllocationExpression allocationExpression = new QualifiedAllocationExpression(anonymousType);
3148      allocationExpression.enumConstant = enumConstant;
3149      
3150      // fill arguments if needed
3151
int length;
3152      if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3153         this.expressionPtr -= length;
3154         System.arraycopy(
3155               this.expressionStack,
3156               this.expressionPtr + 1,
3157               allocationExpression.arguments = new Expression[length],
3158               0,
3159               length);
3160      }
3161      enumConstant.initialization = allocationExpression;
3162   } else {
3163      AllocationExpression allocationExpression = new AllocationExpression();
3164      allocationExpression.enumConstant = enumConstant;
3165      // fill arguments if needed
3166
int length;
3167      if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3168         this.expressionPtr -= length;
3169         System.arraycopy(
3170               this.expressionStack,
3171               this.expressionPtr + 1,
3172               allocationExpression.arguments = new Expression[length],
3173               0,
3174               length);
3175      }
3176      enumConstant.initialization = allocationExpression;
3177   }
3178   
3179   // recovery
3180
if (this.currentElement != null) {
3181      if(foundOpeningBrace) {
3182        TypeDeclaration anonymousType = (TypeDeclaration) this.astStack[this.astPtr];
3183        this.currentElement = this.currentElement.add(anonymousType, 0);
3184        this.lastCheckPoint = anonymousType.bodyStart;
3185        this.lastIgnoredToken = -1;
3186        this.currentToken = 0; // opening brace already taken into account
3187
} else {
3188          if(this.currentToken == TokenNameSEMICOLON) {
3189            RecoveredType currentType = this.currentRecoveryType();
3190            if(currentType != null) {
3191                currentType.insideEnumConstantPart = false;
3192            }
3193          }
3194          this.lastCheckPoint = this.scanner.startPosition; // force to restart at this exact position
3195
this.lastIgnoredToken = -1;
3196          this.restartRecovery = true;
3197      }
3198   }
3199}
3200protected void consumeEnumConstantNoClassBody() {
3201    // set declarationEnd and declarationSourceEnd
3202
int endOfEnumConstant = intStack[intPtr--];
3203    final FieldDeclaration fieldDeclaration = (FieldDeclaration) this.astStack[this.astPtr];
3204    fieldDeclaration.declarationEnd = endOfEnumConstant;
3205    fieldDeclaration.declarationSourceEnd = endOfEnumConstant;
3206}
3207protected void consumeEnumConstants() {
3208    concatNodeLists();
3209}
3210protected void consumeEnumConstantWithClassBody() {
3211   dispatchDeclarationInto(this.astLengthStack[this.astLengthPtr--]);
3212   TypeDeclaration anonymousType = (TypeDeclaration) this.astStack[this.astPtr--]; // pop type
3213
this.astLengthPtr--;
3214   anonymousType.bodyEnd = this.endPosition;
3215   anonymousType.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
3216   final FieldDeclaration fieldDeclaration = ((FieldDeclaration) this.astStack[this.astPtr]);
3217   fieldDeclaration.declarationEnd = this.endStatementPosition;
3218   fieldDeclaration.declarationSourceEnd = anonymousType.declarationSourceEnd;
3219   intPtr --; // remove end position of the arguments
3220
}
3221protected void consumeEnumDeclaration() {
3222    // EnumDeclaration ::= EnumHeader ClassHeaderImplementsopt EnumBody
3223
int length;
3224    if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
3225        //there are length declarations
3226
//dispatch according to the type of the declarations
3227
dispatchDeclarationIntoEnumDeclaration(length);
3228    }
3229
3230    TypeDeclaration enumDeclaration = (TypeDeclaration) this.astStack[this.astPtr];
3231
3232    // mark initializers with local type mark if needed
3233
markInitializersWithLocalType(enumDeclaration);
3234
3235    //convert constructor that do not have the type's name into methods
3236
boolean hasConstructor = enumDeclaration.checkConstructors(this);
3237    
3238    //add the default constructor when needed
3239
if (!hasConstructor) {
3240        boolean insideFieldInitializer = false;
3241        if (this.diet) {
3242            for (int i = this.nestedType; i > 0; i--){
3243                if (this.variablesCounter[i] > 0) {
3244                    insideFieldInitializer = true;
3245                    break;
3246                }
3247            }
3248        }
3249        enumDeclaration.createDefaultConstructor(!this.diet || insideFieldInitializer, true);
3250    }
3251
3252    //always add <clinit> (will be remove at code gen time if empty)
3253
if (this.scanner.containsAssertKeyword) {
3254        enumDeclaration.bits |= ASTNode.ContainsAssertion;
3255    }
3256    enumDeclaration.addClinit();
3257    enumDeclaration.bodyEnd = this.endStatementPosition;
3258    if (length == 0 && !containsComment(enumDeclaration.bodyStart, enumDeclaration.bodyEnd)) {
3259        enumDeclaration.bits |= ASTNode.UndocumentedEmptyBlock;
3260    }
3261
3262    enumDeclaration.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
3263}
3264protected void consumeEnumDeclarations() {
3265    // Do nothing by default
3266
}
3267protected void consumeEnumHeader() {
3268    TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
3269    if (this.currentToken == TokenNameLBRACE) {
3270        typeDecl.bodyStart = this.scanner.currentPosition;
3271    }
3272
3273    if (this.currentElement != null) {
3274        this.restartRecovery = true; // used to avoid branching back into the regular automaton
3275
}
3276    
3277    // flush the comments related to the enum header
3278
this.scanner.commentPtr = -1;
3279}
3280protected void consumeEnumHeaderName() {
3281    // EnumHeaderName ::= Modifiersopt 'enum' Identifier
3282
TypeDeclaration enumDeclaration = new TypeDeclaration(this.compilationUnit.compilationResult);
3283    if (this.nestedMethod[this.nestedType] == 0) {
3284        if (this.nestedType != 0) {
3285            enumDeclaration.bits |= ASTNode.IsMemberType;
3286        }
3287    } else {
3288        // Record that the block has a declaration for local types
3289
// markEnclosingMemberWithLocalType();
3290
blockReal();
3291    }
3292    //highlight the name of the type
3293
long pos = this.identifierPositionStack[this.identifierPtr];
3294    enumDeclaration.sourceEnd = (int) pos;
3295    enumDeclaration.sourceStart = (int) (pos >>> 32);
3296    enumDeclaration.name = this.identifierStack[this.identifierPtr--];
3297    this.identifierLengthPtr--;
3298
3299    //compute the declaration source too
3300
// 'class' and 'interface' push two int positions: the beginning of the class token and its end.
3301
// we want to keep the beginning position but get rid of the end position
3302
// it is only used for the ClassLiteralAccess positions.
3303
enumDeclaration.declarationSourceStart = this.intStack[this.intPtr--];
3304    this.intPtr--; // remove the end position of the class token
3305

3306    enumDeclaration.modifiersSourceStart = this.intStack[this.intPtr--];
3307    enumDeclaration.modifiers = this.intStack[this.intPtr--] | ClassFileConstants.AccEnum;
3308    if (enumDeclaration.modifiersSourceStart >= 0) {
3309        enumDeclaration.declarationSourceStart = enumDeclaration.modifiersSourceStart;
3310    }
3311    // consume annotations
3312
int length;
3313    if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3314        System.arraycopy(
3315            this.expressionStack,
3316            (this.expressionPtr -= length) + 1,
3317            enumDeclaration.annotations = new Annotation[length],
3318            0,
3319            length);
3320    }
3321// if (this.currentToken == TokenNameLBRACE) {
3322
// enumDeclaration.bodyStart = this.scanner.currentPosition;
3323
// }
3324
enumDeclaration.bodyStart = enumDeclaration.sourceEnd + 1;
3325    pushOnAstStack(enumDeclaration);
3326
3327    this.listLength = 0; // will be updated when reading super-interfaces
3328

3329    if(!this.statementRecoveryActivated &&
3330            options.sourceLevel < ClassFileConstants.JDK1_5 &&
3331            this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
3332        //TODO this code will be never run while 'enum' is an identifier in 1.3 scanner
3333
this.problemReporter().invalidUsageOfEnumDeclarations(enumDeclaration);
3334    }
3335    
3336    // recovery
3337
if (this.currentElement != null){
3338        this.lastCheckPoint = enumDeclaration.bodyStart;
3339        this.currentElement = this.currentElement.add(enumDeclaration, 0);
3340        this.lastIgnoredToken = -1;
3341    }
3342    // javadoc
3343
enumDeclaration.javadoc = this.javadoc;
3344    this.javadoc = null;
3345}
3346protected void consumeEqualityExpression(int op) {
3347    // EqualityExpression ::= EqualityExpression '==' RelationalExpression
3348
// EqualityExpression ::= EqualityExpression '!=' RelationalExpression
3349

3350    //optimize the push/pop
3351

3352    this.expressionPtr--;
3353    this.expressionLengthPtr--;
3354    this.expressionStack[this.expressionPtr] =
3355        new EqualExpression(
3356            this.expressionStack[this.expressionPtr],
3357            this.expressionStack[this.expressionPtr + 1],
3358            op);
3359}
3360/*
3361 * @param op
3362 */

3363protected void consumeEqualityExpressionWithName(int op) {
3364    // EqualityExpression ::= Name '==' RelationalExpression
3365
// EqualityExpression ::= Name '!=' RelationalExpression
3366
pushOnExpressionStack(getUnspecifiedReferenceOptimized());
3367    this.expressionPtr--;
3368    this.expressionLengthPtr--;
3369    this.expressionStack[this.expressionPtr] =
3370        new EqualExpression(
3371            this.expressionStack[this.expressionPtr + 1],
3372            this.expressionStack[this.expressionPtr],
3373            op);
3374}
3375protected void consumeExitMemberValue() {
3376    // ExitMemberValue ::= $empty
3377
// do nothing by default
3378
}
3379protected void consumeExitTryBlock() {
3380    //ExitTryBlock ::= $empty
3381
if(this.currentElement != null) {
3382        this.restartRecovery = true;
3383    }
3384}
3385protected void consumeExitVariableWithInitialization() {
3386    // ExitVariableWithInitialization ::= $empty
3387
// do nothing by default
3388
this.expressionLengthPtr--;
3389    AbstractVariableDeclaration variableDecl = (AbstractVariableDeclaration) this.astStack[this.astPtr];
3390    variableDecl.initialization = this.expressionStack[this.expressionPtr--];
3391    // we need to update the declarationSourceEnd of the local variable declaration to the
3392
// source end position of the initialization expression
3393
variableDecl.declarationSourceEnd = variableDecl.initialization.sourceEnd;
3394    variableDecl.declarationEnd = variableDecl.initialization.sourceEnd;
3395    
3396    this.recoveryExitFromVariable();
3397}
3398protected void consumeExitVariableWithoutInitialization() {
3399    // ExitVariableWithoutInitialization ::= $empty
3400
// do nothing by default
3401

3402    AbstractVariableDeclaration variableDecl = (AbstractVariableDeclaration) this.astStack[this.astPtr];
3403    variableDecl.declarationSourceEnd = variableDecl.declarationEnd;
3404    if(this.currentElement != null && this.currentElement instanceof RecoveredField) {
3405        if(this.endStatementPosition > variableDecl.sourceEnd) {
3406            this.currentElement.updateSourceEndIfNecessary(this.endStatementPosition);
3407        }
3408    }
3409    this.recoveryExitFromVariable();
3410}
3411protected void consumeExplicitConstructorInvocation(int flag, int recFlag) {
3412
3413    /* flag allows to distinguish 3 cases :
3414    (0) :
3415    ExplicitConstructorInvocation ::= 'this' '(' ArgumentListopt ')' ';'
3416    ExplicitConstructorInvocation ::= 'super' '(' ArgumentListopt ')' ';'
3417    (1) :
3418    ExplicitConstructorInvocation ::= Primary '.' 'super' '(' ArgumentListopt ')' ';'
3419    ExplicitConstructorInvocation ::= Primary '.' 'this' '(' ArgumentListopt ')' ';'
3420    (2) :
3421    ExplicitConstructorInvocation ::= Name '.' 'super' '(' ArgumentListopt ')' ';'
3422    ExplicitConstructorInvocation ::= Name '.' 'this' '(' ArgumentListopt ')' ';'
3423    */

3424    int startPosition = this.intStack[this.intPtr--];
3425    ExplicitConstructorCall ecc = new ExplicitConstructorCall(recFlag);
3426    int length;
3427    if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3428        this.expressionPtr -= length;
3429        System.arraycopy(this.expressionStack, this.expressionPtr + 1, ecc.arguments = new Expression[length], 0, length);
3430    }
3431    switch (flag) {
3432        case 0 :
3433            ecc.sourceStart = startPosition;
3434            break;
3435        case 1 :
3436            this.expressionLengthPtr--;
3437            ecc.sourceStart = (ecc.qualification = this.expressionStack[this.expressionPtr--]).sourceStart;
3438            break;
3439        case 2 :
3440            ecc.sourceStart = (ecc.qualification = getUnspecifiedReferenceOptimized()).sourceStart;
3441            break;
3442    }
3443    pushOnAstStack(ecc);
3444    ecc.sourceEnd = this.endStatementPosition;
3445}
3446protected void consumeExplicitConstructorInvocationWithTypeArguments(int flag, int recFlag) {
3447
3448    /* flag allows to distinguish 3 cases :
3449    (0) :
3450    ExplicitConstructorInvocation ::= TypeArguments 'this' '(' ArgumentListopt ')' ';'
3451    ExplicitConstructorInvocation ::= TypeArguments 'super' '(' ArgumentListopt ')' ';'
3452    (1) :
3453    ExplicitConstructorInvocation ::= Primary '.' TypeArguments 'super' '(' ArgumentListopt ')' ';'
3454    ExplicitConstructorInvocation ::= Primary '.' TypeArguments 'this' '(' ArgumentListopt ')' ';'
3455    (2) :
3456    ExplicitConstructorInvocation ::= Name '.' TypeArguments 'super' '(' ArgumentListopt ')' ';'
3457    ExplicitConstructorInvocation ::= Name '.' TypeArguments 'this' '(' ArgumentListopt ')' ';'
3458    */

3459    int startPosition = this.intStack[this.intPtr--];
3460    ExplicitConstructorCall ecc = new ExplicitConstructorCall(recFlag);
3461    int length;
3462    if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3463        this.expressionPtr -= length;
3464        System.arraycopy(this.expressionStack, this.expressionPtr + 1, ecc.arguments = new Expression[length], 0, length);
3465    }
3466    length = this.genericsLengthStack[this.genericsLengthPtr--];
3467    this.genericsPtr -= length;
3468    System.arraycopy(this.genericsStack, this.genericsPtr + 1, ecc.typeArguments = new TypeReference[length], 0, length);
3469    ecc.typeArgumentsSourceStart = this.intStack[intPtr--];
3470
3471    switch (flag) {
3472        case 0 :
3473            ecc.sourceStart = startPosition;
3474            break;
3475        case 1 :
3476            this.expressionLengthPtr--;
3477            ecc.sourceStart = (ecc.qualification = this.expressionStack[this.expressionPtr--]).sourceStart;
3478            break;
3479        case 2 :
3480            ecc.sourceStart = (ecc.qualification = getUnspecifiedReferenceOptimized()).sourceStart;
3481            break;
3482    }
3483    
3484    pushOnAstStack(ecc);
3485    ecc.sourceEnd = this.endStatementPosition;
3486}
3487protected void consumeExpressionStatement() {
3488    // ExpressionStatement ::= StatementExpression ';'
3489
this.expressionLengthPtr--;
3490    Expression expression = this.expressionStack[this.expressionPtr--];
3491    expression.statementEnd = this.endStatementPosition;
3492    pushOnAstStack(expression);
3493}
3494protected void consumeFieldAccess(boolean isSuperAccess) {
3495    // FieldAccess ::= Primary '.' 'Identifier'
3496
// FieldAccess ::= 'super' '.' 'Identifier'
3497

3498    FieldReference fr =
3499        new FieldReference(
3500            this.identifierStack[this.identifierPtr],
3501            this.identifierPositionStack[this.identifierPtr--]);
3502    this.identifierLengthPtr--;
3503    if (isSuperAccess) {
3504        //considerates the fieldReference beginning at the 'super' ....
3505
fr.sourceStart = this.intStack[this.intPtr--];
3506        fr.receiver = new SuperReference(fr.sourceStart, this.endPosition);
3507        pushOnExpressionStack(fr);
3508    } else {
3509        //optimize push/pop
3510
fr.receiver = this.expressionStack[this.expressionPtr];
3511        //fieldreference begins at the receiver
3512
fr.sourceStart = fr.receiver.sourceStart;
3513        this.expressionStack[this.expressionPtr] = fr;
3514    }
3515}
3516protected void consumeFieldDeclaration() {
3517    // See consumeLocalVariableDeclarationDefaultModifier() in case of change: duplicated code
3518
// FieldDeclaration ::= Modifiersopt Type VariableDeclarators ';'
3519

3520    /*
3521    this.astStack :
3522    this.expressionStack: Expression Expression ...... Expression
3523    this.identifierStack : type identifier identifier ...... identifier
3524    this.intStack : typeDim dim dim dim
3525     ==>
3526    this.astStack : FieldDeclaration FieldDeclaration ...... FieldDeclaration
3527    this.expressionStack :
3528    this.identifierStack :
3529    this.intStack :
3530      
3531    */

3532    int variableDeclaratorsCounter = this.astLengthStack[this.astLengthPtr];
3533
3534    for (int i = variableDeclaratorsCounter - 1; i >= 0; i--) {
3535        FieldDeclaration fieldDeclaration = (FieldDeclaration) this.astStack[this.astPtr - i];
3536        fieldDeclaration.declarationSourceEnd = this.endStatementPosition;
3537        fieldDeclaration.declarationEnd = this.endStatementPosition; // semi-colon included
3538
}
3539    
3540    updateSourceDeclarationParts(variableDeclaratorsCounter);
3541    int endPos = flushCommentsDefinedPriorTo(this.endStatementPosition);
3542    if (endPos != this.endStatementPosition) {
3543        for (int i = 0; i < variableDeclaratorsCounter; i++) {
3544            FieldDeclaration fieldDeclaration = (FieldDeclaration) this.astStack[this.astPtr - i];
3545            fieldDeclaration.declarationSourceEnd = endPos;
3546        }
3547    }
3548    // update the this.astStack, this.astPtr and this.astLengthStack
3549
int startIndex = this.astPtr - this.variablesCounter[this.nestedType] + 1;
3550    System.arraycopy(
3551        this.astStack,
3552        startIndex,
3553        this.astStack,
3554        startIndex - 1,
3555        variableDeclaratorsCounter);
3556    this.astPtr--; // remove the type reference
3557
this.astLengthStack[--this.astLengthPtr] = variableDeclaratorsCounter;
3558
3559    // recovery
3560
if (this.currentElement != null) {
3561        this.lastCheckPoint = endPos + 1;
3562        if (this.currentElement.parent != null && this.currentElement instanceof RecoveredField){
3563            if (!(this.currentElement instanceof RecoveredInitializer)) {
3564                this.currentElement = this.currentElement.parent;
3565            }
3566        }
3567        this.restartRecovery = true;
3568    }
3569    this.variablesCounter[this.nestedType] = 0;
3570}
3571protected void consumeForceNoDiet() {
3572    // ForceNoDiet ::= $empty
3573
this.dietInt++;
3574}
3575protected void consumeForInit() {
3576    // ForInit ::= StatementExpressionList
3577
pushOnAstLengthStack(-1);
3578}
3579protected void consumeFormalParameter(boolean isVarArgs) {
3580    // FormalParameter ::= Type VariableDeclaratorId ==> false
3581
// FormalParameter ::= Modifiers Type VariableDeclaratorId ==> true
3582
/*
3583    this.astStack :
3584    this.identifierStack : type identifier
3585    this.intStack : dim dim
3586     ==>
3587    this.astStack : Argument
3588    this.identifierStack :
3589    this.intStack :
3590    */

3591
3592    this.identifierLengthPtr--;
3593    char[] identifierName = this.identifierStack[this.identifierPtr];
3594    long namePositions = this.identifierPositionStack[this.identifierPtr--];
3595    int extendedDimensions = this.intStack[this.intPtr--];
3596    int endOfEllipsis = 0;
3597    if (isVarArgs) {
3598        endOfEllipsis = this.intStack[this.intPtr--];
3599    }
3600    int firstDimensions = this.intStack[this.intPtr--];
3601    final int typeDimensions = firstDimensions + extendedDimensions;
3602    TypeReference type = getTypeReference(typeDimensions);
3603    if (isVarArgs) {
3604        type = copyDims(type, typeDimensions + 1);
3605        if (extendedDimensions == 0) {
3606            type.sourceEnd = endOfEllipsis;
3607        }
3608        type.bits |= ASTNode.IsVarArgs; // set isVarArgs
3609
}
3610    int modifierPositions = this.intStack[this.intPtr--];
3611    this.intPtr--;
3612    Argument arg =
3613        new Argument(
3614            identifierName,
3615            namePositions,
3616            type,
3617            this.intStack[this.intPtr + 1] & ~ClassFileConstants.AccDeprecated); // modifiers
3618
arg.declarationSourceStart = modifierPositions;
3619    // consume annotations
3620
int length;
3621    if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3622        System.arraycopy(
3623            this.expressionStack,
3624            (this.expressionPtr -= length) + 1,
3625            arg.annotations = new Annotation[length],
3626            0,
3627            length);
3628    }
3629    pushOnAstStack(arg);
3630
3631    /* if incomplete method header, this.listLength counter will not have been reset,
3632        indicating that some arguments are available on the stack */

3633    this.listLength++;
3634    
3635    if(isVarArgs) {
3636        if (!this.statementRecoveryActivated &&
3637                options.sourceLevel < ClassFileConstants.JDK1_5 &&
3638                this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
3639                this.problemReporter().invalidUsageOfVarargs(arg);
3640        } else if (!this.statementRecoveryActivated &&
3641                extendedDimensions > 0) {
3642            this.problemReporter().illegalExtendedDimensions(arg);
3643        }
3644    }
3645}
3646protected void consumeFormalParameterList() {
3647    // FormalParameterList ::= FormalParameterList ',' FormalParameter
3648
optimizedConcatNodeLists();
3649}
3650protected void consumeFormalParameterListopt() {
3651    // FormalParameterListopt ::= $empty
3652
pushOnAstLengthStack(0);
3653}
3654protected void consumeGenericType() {
3655    // nothing to do
3656
// Will be consume by a getTypeRefence call
3657
}
3658protected void consumeGenericTypeArrayType() {
3659    // nothing to do
3660
// Will be consume by a getTypeRefence call
3661
}
3662protected void consumeGenericTypeNameArrayType() {
3663    // nothing to do
3664
// Will be consume by a getTypeRefence call
3665
}
3666protected void consumeImportDeclaration() {
3667    // SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName ';'
3668
ImportReference impt = (ImportReference) this.astStack[this.astPtr];
3669    // flush annotations defined prior to import statements
3670
impt.declarationEnd = this.endStatementPosition;
3671    impt.declarationSourceEnd =
3672        this.flushCommentsDefinedPriorTo(impt.declarationSourceEnd);
3673
3674    // recovery
3675
if (this.currentElement != null) {
3676        this.lastCheckPoint = impt.declarationSourceEnd + 1;
3677        this.currentElement = this.currentElement.add(impt, 0);
3678        this.lastIgnoredToken = -1;
3679        this.restartRecovery = true;
3680        // used to avoid branching back into the regular automaton
3681
}
3682}
3683protected void consumeImportDeclarations() {
3684    // ImportDeclarations ::= ImportDeclarations ImportDeclaration
3685
optimizedConcatNodeLists();
3686}
3687protected void consumeInsideCastExpression() {
3688    // InsideCastExpression ::= $empty
3689
}
3690protected void consumeInsideCastExpressionLL1() {
3691    // InsideCastExpressionLL1 ::= $empty
3692
pushOnExpressionStack(getUnspecifiedReferenceOptimized());
3693}
3694protected void consumeInsideCastExpressionWithQualifiedGenerics() {
3695    // InsideCastExpressionWithQualifiedGenerics ::= $empty
3696
}
3697protected void consumeInstanceOfExpression() {
3698    // RelationalExpression ::= RelationalExpression 'instanceof' ReferenceType
3699
//optimize the push/pop
3700

3701    //by construction, no base type may be used in getTypeReference
3702
Expression exp;
3703    this.expressionStack[this.expressionPtr] = exp =
3704        new InstanceOfExpression(
3705            this.expressionStack[this.expressionPtr],
3706            getTypeReference(this.intStack[this.intPtr--]));
3707    if (exp.sourceEnd == 0) {
3708        //array on base type....
3709
exp.sourceEnd = this.scanner.startPosition - 1;
3710    }
3711    //the scanner is on the next token already....
3712
}
3713protected void consumeInstanceOfExpressionWithName() {
3714    // RelationalExpression_NotName ::= Name instanceof ReferenceType
3715
//optimize the push/pop
3716

3717    //by construction, no base type may be used in getTypeReference
3718
TypeReference reference = getTypeReference(this.intStack[this.intPtr--]);
3719    pushOnExpressionStack(getUnspecifiedReferenceOptimized());
3720    Expression exp;
3721    this.expressionStack[this.expressionPtr] = exp =
3722        new InstanceOfExpression(
3723            this.expressionStack[this.expressionPtr],
3724            reference);
3725    if (exp.sourceEnd == 0) {
3726        //array on base type....
3727
exp.sourceEnd = this.scanner.startPosition - 1;
3728    }
3729    //the scanner is on the next token already....
3730
}
3731protected void consumeInterfaceDeclaration() {
3732    // see consumeClassDeclaration in case of changes: duplicated code
3733
// InterfaceDeclaration ::= InterfaceHeader InterfaceBody
3734
int length;
3735    if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
3736        //there are length declarations
3737
//dispatch.....according to the type of the declarations
3738
dispatchDeclarationInto(length);
3739    }
3740
3741    TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
3742    
3743    // mark initializers with local type mark if needed
3744
markInitializersWithLocalType(typeDecl);
3745
3746    //convert constructor that do not have the type's name into methods
3747
typeDecl.checkConstructors(this);
3748    
3749    //always add <clinit> (will be remove at code gen time if empty)
3750
if (this.scanner.containsAssertKeyword) {
3751        typeDecl.bits |= ASTNode.ContainsAssertion;
3752    }
3753    typeDecl.addClinit();
3754    typeDecl.bodyEnd = this.endStatementPosition;
3755    if (length == 0 && !containsComment(typeDecl.bodyStart, typeDecl.bodyEnd)) {
3756        typeDecl.bits |= ASTNode.UndocumentedEmptyBlock;
3757    }
3758    typeDecl.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
3759}
3760protected void consumeInterfaceHeader() {
3761    // InterfaceHeader ::= InterfaceHeaderName InterfaceHeaderExtendsopt
3762

3763    TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
3764    if (this.currentToken == TokenNameLBRACE){
3765        typeDecl.bodyStart = this.scanner.currentPosition;
3766    }
3767    if (this.currentElement != null){
3768        this.restartRecovery = true; // used to avoid branching back into the regular automaton
3769
}
3770    // flush the comments related to the interface header
3771
this.scanner.commentPtr = -1;
3772}
3773protected void consumeInterfaceHeaderExtends() {
3774    // InterfaceHeaderExtends ::= 'extends' InterfaceTypeList
3775
int length = this.astLengthStack[this.astLengthPtr--];
3776    //super interfaces
3777
this.astPtr -= length;
3778    TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
3779    System.arraycopy(
3780        this.astStack,
3781        this.astPtr + 1,
3782        typeDecl.superInterfaces = new TypeReference[length],
3783        0,
3784        length);
3785    for (int i = 0, max = typeDecl.superInterfaces.length; i < max; i++) {
3786        typeDecl.superInterfaces[i].bits |= ASTNode.IsSuperType;
3787    }
3788    typeDecl.bodyStart = typeDecl.superInterfaces[length-1].sourceEnd + 1;
3789    this.listLength = 0; // reset after having read super-interfaces
3790
// recovery
3791
if (this.currentElement != null) {
3792        this.lastCheckPoint = typeDecl.bodyStart;
3793    }
3794}
3795protected void consumeInterfaceHeaderName1() {
3796    // InterfaceHeaderName ::= Modifiersopt 'interface' 'Identifier'
3797
TypeDeclaration typeDecl = new TypeDeclaration(this.compilationUnit.compilationResult);
3798
3799    if (this.nestedMethod[this.nestedType] == 0) {
3800        if (this.nestedType != 0) {
3801            typeDecl.bits |= ASTNode.IsMemberType;
3802        }
3803    } else {
3804        // Record that the block has a declaration for local types
3805
typeDecl.bits |= ASTNode.IsLocalType;
3806        markEnclosingMemberWithLocalType();
3807        blockReal();
3808    }
3809
3810    //highlight the name of the type
3811
long pos = this.identifierPositionStack[this.identifierPtr];
3812    typeDecl.sourceEnd = (int) pos;
3813    typeDecl.sourceStart = (int) (pos >>> 32);
3814    typeDecl.name = this.identifierStack[this.identifierPtr--];
3815    this.identifierLengthPtr--;
3816
3817    //compute the declaration source too
3818
// 'class' and 'interface' push two int positions: the beginning of the class token and its end.
3819
// we want to keep the beginning position but get rid of the end position
3820
// it is only used for the ClassLiteralAccess positions.
3821
typeDecl.declarationSourceStart = this.intStack[this.intPtr--];
3822    this.intPtr--; // remove the end position of the class token
3823
typeDecl.modifiersSourceStart = this.intStack[this.intPtr--];
3824    typeDecl.modifiers = this.intStack[this.intPtr--] | ClassFileConstants.AccInterface;
3825    if (typeDecl.modifiersSourceStart >= 0) {
3826        typeDecl.declarationSourceStart = typeDecl.modifiersSourceStart;
3827    }
3828
3829    // Store secondary info
3830
if ((typeDecl.bits & ASTNode.IsMemberType) == 0 && (typeDecl.bits & ASTNode.IsLocalType) == 0) {
3831        if (this.compilationUnit != null && !CharOperation.equals(typeDecl.name, this.compilationUnit.getMainTypeName())) {
3832            typeDecl.bits |= ASTNode.IsSecondaryType;
3833        }
3834    }
3835
3836    // consume annotations
3837
int length;
3838    if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3839        System.arraycopy(
3840            this.expressionStack,
3841            (this.expressionPtr -= length) + 1,
3842            typeDecl.annotations = new Annotation[length],
3843            0,
3844            length);
3845    }
3846    typeDecl.bodyStart = typeDecl.sourceEnd + 1;
3847    pushOnAstStack(typeDecl);
3848    this.listLength = 0; // will be updated when reading super-interfaces
3849
// recovery
3850
if (this.currentElement != null){ // is recovering
3851
this.lastCheckPoint = typeDecl.bodyStart;
3852        this.currentElement = this.currentElement.add(typeDecl, 0);
3853        this.lastIgnoredToken = -1;
3854    }
3855    // javadoc
3856
typeDecl.javadoc = this.javadoc;
3857    this.javadoc = null;
3858}
3859protected void consumeInterfaceMemberDeclarations() {
3860    // InterfaceMemberDeclarations ::= InterfaceMemberDeclarations InterfaceMemberDeclaration
3861
concatNodeLists();
3862}
3863protected void consumeInterfaceMemberDeclarationsopt() {
3864    // InterfaceMemberDeclarationsopt ::= NestedType InterfaceMemberDeclarations
3865
this.nestedType--;
3866}
3867protected void consumeInterfaceType() {
3868    // InterfaceType ::= ClassOrInterfaceType
3869
pushOnAstStack(getTypeReference(0));
3870    /* if incomplete type header, this.listLength counter will not have been reset,
3871        indicating that some interfaces are available on the stack */

3872    this.listLength++;
3873}
3874protected void consumeInterfaceTypeList() {
3875    // InterfaceTypeList ::= InterfaceTypeList ',' InterfaceType
3876
optimizedConcatNodeLists();
3877}
3878protected void consumeInternalCompilationUnit() {
3879    // InternalCompilationUnit ::= PackageDeclaration
3880
// InternalCompilationUnit ::= PackageDeclaration ImportDeclarations ReduceImports
3881
// InternalCompilationUnit ::= ImportDeclarations ReduceImports
3882
if (this.compilationUnit.isPackageInfo()) {
3883        this.compilationUnit.types = new TypeDeclaration[1];
3884        // create a fake interface declaration
3885
TypeDeclaration declaration = new TypeDeclaration(compilationUnit.compilationResult);
3886        declaration.name = TypeConstants.PACKAGE_INFO_NAME;
3887        declaration.modifiers = ClassFileConstants.AccDefault | ClassFileConstants.AccInterface;
3888        this.compilationUnit.types[0] = declaration;
3889        declaration.javadoc = this.compilationUnit.javadoc;
3890    }
3891}
3892protected void consumeInternalCompilationUnitWithTypes() {
3893    // InternalCompilationUnit ::= PackageDeclaration ImportDeclarations ReduceImports TypeDeclarations
3894
// InternalCompilationUnit ::= PackageDeclaration TypeDeclarations
3895
// InternalCompilationUnit ::= TypeDeclarations
3896
// InternalCompilationUnit ::= ImportDeclarations ReduceImports TypeDeclarations
3897
// consume type declarations
3898
int length;
3899    if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
3900        if (this.compilationUnit.isPackageInfo()) {
3901            this.compilationUnit.types = new TypeDeclaration[length + 1];
3902            this.astPtr -= length;
3903            System.arraycopy(this.astStack, this.astPtr + 1, this.compilationUnit.types, 1, length);
3904            // create a fake interface declaration
3905
TypeDeclaration declaration = new TypeDeclaration(compilationUnit.compilationResult);
3906            declaration.name = TypeConstants.PACKAGE_INFO_NAME;
3907            declaration.modifiers = ClassFileConstants.AccDefault | ClassFileConstants.AccInterface;
3908            this.compilationUnit.types[0] = declaration;
3909            declaration.javadoc = this.compilationUnit.javadoc;
3910        } else {
3911            this.compilationUnit.types = new TypeDeclaration[length];
3912            this.astPtr -= length;
3913            System.arraycopy(this.astStack, this.astPtr + 1, this.compilationUnit.types, 0, length);
3914        }
3915    }
3916}
3917protected void consumeInvalidAnnotationTypeDeclaration() {
3918    // BlockStatement ::= AnnotationTypeDeclaration
3919
TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
3920    if(!this.statementRecoveryActivated) problemReporter().illegalLocalTypeDeclaration(typeDecl);
3921    // remove the ast node created in interface header
3922
this.astPtr--;
3923    pushOnAstLengthStack(-1);
3924    concatNodeLists();
3925}
3926protected void consumeInvalidConstructorDeclaration() {
3927    // ConstructorDeclaration ::= ConstructorHeader ';'
3928
// now we know that the top of stack is a constructorDeclaration
3929
ConstructorDeclaration cd = (ConstructorDeclaration) this.astStack[this.astPtr];
3930
3931    cd.bodyEnd = this.endPosition; // position just before the trailing semi-colon
3932
cd.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
3933    // report the problem and continue the parsing - narrowing the problem onto the method
3934

3935    cd.modifiers |= ExtraCompilerModifiers.AccSemicolonBody; // remember semi-colon body
3936
}
3937protected void consumeInvalidConstructorDeclaration(boolean hasBody) {
3938    // InvalidConstructorDeclaration ::= ConstructorHeader ConstructorBody ==> true
3939
// InvalidConstructorDeclaration ::= ConstructorHeader ';' ==> false
3940

3941    /*
3942    this.astStack : modifiers arguments throws statements
3943    this.identifierStack : name
3944     ==>
3945    this.astStack : MethodDeclaration
3946    this.identifierStack :
3947    */

3948    if (hasBody) {
3949        // pop the position of the { (body of the method) pushed in block decl
3950
this.intPtr--;
3951    }
3952
3953    //statements
3954
if (hasBody) {
3955        this.realBlockPtr--;
3956    }
3957
3958    int length;
3959    if (hasBody && ((length = this.astLengthStack[this.astLengthPtr--]) != 0)) {
3960        this.astPtr -= length;
3961    }
3962    ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) this.astStack[this.astPtr];
3963    constructorDeclaration.bodyEnd = this.endStatementPosition;
3964    constructorDeclaration.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
3965    if (!hasBody) {
3966        constructorDeclaration.modifiers |= ExtraCompilerModifiers.AccSemicolonBody;
3967    }
3968}
3969protected void consumeInvalidInterfaceDeclaration() {
3970    // BlockStatement ::= InvalidInterfaceDeclaration
3971
//InterfaceDeclaration ::= Modifiersopt 'interface' 'Identifier' ExtendsInterfacesopt InterfaceHeader InterfaceBody
3972
TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
3973    if(!this.statementRecoveryActivated) problemReporter().illegalLocalTypeDeclaration(typeDecl);
3974    // remove the ast node created in interface header
3975
this.astPtr--;
3976    pushOnAstLengthStack(-1);
3977    concatNodeLists();
3978}
3979protected void consumeInvalidEnumDeclaration() {
3980    // BlockStatement ::= EnumDeclaration
3981
TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
3982    if(!this.statementRecoveryActivated) problemReporter().illegalLocalTypeDeclaration(typeDecl);
3983    // remove the ast node created in interface header
3984
this.astPtr--;
3985    pushOnAstLengthStack(-1);
3986    concatNodeLists();
3987}
3988protected void consumeInvalidMethodDeclaration() {
3989    // InterfaceMemberDeclaration ::= InvalidMethodDeclaration
3990

3991    /*
3992    this.astStack : modifiers arguments throws statements
3993    this.identifierStack : type name
3994    this.intStack : dim dim dim
3995     ==>
3996    this.astStack : MethodDeclaration
3997    this.identifierStack :
3998    this.intStack :
3999    */

4000
4001    // pop the position of the { (body of the method) pushed in block decl
4002
this.intPtr--;
4003    // retrieve end position of method declarator
4004

4005    //statements
4006
this.realBlockPtr--;
4007    int length;
4008    if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
4009        this.astPtr -= length;
4010    }
4011
4012    //watch for } that could be given as a unicode ! ( u007D is '}' )
4013
MethodDeclaration md = (MethodDeclaration) this.astStack[this.astPtr];
4014    md.bodyEnd = this.endPosition;
4015    md.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
4016
4017    // report the problem and continue the parsing - narrowing the problem onto the method
4018
if(!this.statementRecoveryActivated) problemReporter().abstractMethodNeedingNoBody(md);
4019}
4020protected void consumeLabel() {
4021    // Do nothing
4022
}
4023protected void consumeLeftParen() {
4024    // PushLPAREN ::= '('
4025
pushOnIntStack(this.lParenPos);
4026}
4027protected void consumeLocalVariableDeclaration() {
4028    // LocalVariableDeclaration ::= Modifiers Type VariableDeclarators ';'
4029

4030    /*
4031    this.astStack :
4032    this.expressionStack: Expression Expression ...... Expression
4033    this.identifierStack : type identifier identifier ...... identifier
4034    this.intStack : typeDim dim dim dim
4035     ==>
4036    this.astStack : FieldDeclaration FieldDeclaration ...... FieldDeclaration
4037    this.expressionStack :
4038    this.identifierStack :
4039    this.intStack :
4040      
4041    */

4042    int variableDeclaratorsCounter = this.astLengthStack[this.astLengthPtr];
4043
4044    // update the this.astStack, this.astPtr and this.astLengthStack
4045
int startIndex = this.astPtr - this.variablesCounter[this.nestedType] + 1;
4046    System.arraycopy(
4047        this.astStack,
4048        startIndex,
4049        this.astStack,
4050        startIndex - 1,
4051        variableDeclaratorsCounter);
4052    this.astPtr--; // remove the type reference
4053
this.astLengthStack[--this.astLengthPtr] = variableDeclaratorsCounter;
4054    this.variablesCounter[this.nestedType] = 0;
4055}
4056protected void consumeLocalVariableDeclarationStatement() {
4057    // LocalVariableDeclarationStatement ::= LocalVariableDeclaration ';'
4058
// see blockReal in case of change: duplicated code
4059
// increment the amount of declared variables for this block
4060
this.realBlockStack[this.realBlockPtr]++;
4061    
4062    // update source end to include the semi-colon
4063
int variableDeclaratorsCounter = this.astLengthStack[this.astLengthPtr];
4064    for (int i = variableDeclaratorsCounter - 1; i >= 0; i--) {
4065        LocalDeclaration localDeclaration = (LocalDeclaration) this.astStack[this.astPtr - i];
4066        localDeclaration.declarationSourceEnd = this.endStatementPosition;
4067        localDeclaration.declarationEnd = this.endStatementPosition; // semi-colon included
4068
}
4069
4070}
4071protected void consumeMarkerAnnotation() {
4072    // MarkerAnnotation ::= '@' Name
4073
MarkerAnnotation markerAnnotation = null;
4074    TypeReference typeReference = this.getAnnotationType();
4075    markerAnnotation = new MarkerAnnotation(typeReference, this.intStack[this.intPtr--]);
4076    markerAnnotation.declarationSourceEnd = markerAnnotation.sourceEnd;
4077    pushOnExpressionStack(markerAnnotation);
4078    if(!this.statementRecoveryActivated &&
4079            options.sourceLevel < ClassFileConstants.JDK1_5 &&
4080            this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
4081        this.problemReporter().invalidUsageOfAnnotation(markerAnnotation);
4082    }
4083    this.recordStringLiterals = true;
4084}
4085protected void consumeMemberValueArrayInitializer() {
4086    // MemberValueArrayInitializer ::= '{' MemberValues ',' '}'
4087
// MemberValueArrayInitializer ::= '{' MemberValues '}'
4088
arrayInitializer(this.expressionLengthStack[this.expressionLengthPtr--]);
4089}
4090protected void consumeMemberValueAsName() {
4091    pushOnExpressionStack(getUnspecifiedReferenceOptimized());
4092}
4093protected void consumeMemberValuePair() {
4094    // MemberValuePair ::= SimpleName '=' MemberValue
4095
char[] simpleName = this.identifierStack[this.identifierPtr];
4096    long position = this.identifierPositionStack[this.identifierPtr--];
4097    this.identifierLengthPtr--;
4098    int end = (int) position;
4099    int start = (int) (position >>> 32);
4100    Expression value = this.expressionStack[this.expressionPtr--];
4101    this.expressionLengthPtr--;
4102    MemberValuePair memberValuePair = new MemberValuePair(simpleName, start, end, value);
4103    pushOnAstStack(memberValuePair);
4104}
4105protected void consumeMemberValuePairs() {
4106    // MemberValuePairs ::= MemberValuePairs ',' MemberValuePair
4107
concatNodeLists();
4108}
4109protected void consumeMemberValues() {
4110    // MemberValues ::= MemberValues ',' MemberValue
4111
concatExpressionLists();
4112}
4113protected void consumeMethodBody() {
4114    // MethodBody ::= NestedMethod '{' BlockStatementsopt '}'
4115
this.nestedMethod[this.nestedType] --;
4116}
4117protected void consumeMethodDeclaration(boolean isNotAbstract) {
4118    // MethodDeclaration ::= MethodHeader MethodBody
4119
// AbstractMethodDeclaration ::= MethodHeader ';'
4120

4121    /*
4122    this.astStack : modifiers arguments throws statements
4123    this.identifierStack : type name
4124    this.intStack : dim dim dim
4125     ==>
4126    this.astStack : MethodDeclaration
4127    this.identifierStack :
4128    this.intStack :
4129    */

4130
4131    int length;
4132    if (isNotAbstract) {
4133        // pop the position of the { (body of the method) pushed in block decl
4134
this.intPtr--;
4135        this.intPtr--;
4136    }
4137
4138    int explicitDeclarations = 0;
4139    Statement[] statements = null;
4140    if (isNotAbstract) {
4141        //statements
4142
explicitDeclarations = this.realBlockStack[this.realBlockPtr--];
4143        if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
4144            System.arraycopy(
4145                this.astStack,
4146                (this.astPtr -= length) + 1,
4147                statements = new Statement[length],
4148                0,
4149                length);
4150        }
4151    }
4152
4153    // now we know that we have a method declaration at the top of the ast stack
4154
MethodDeclaration md = (MethodDeclaration) this.astStack[this.astPtr];
4155    md.statements = statements;
4156    md.explicitDeclarations = explicitDeclarations;
4157
4158    // cannot be done in consumeMethodHeader because we have no idea whether or not there
4159
// is a body when we reduce the method header
4160
if (!isNotAbstract) { //remember the fact that the method has a semicolon body
4161
md.modifiers |= ExtraCompilerModifiers.AccSemicolonBody;
4162    } else if (!(this.diet && this.dietInt == 0) && statements == null && !containsComment(md.bodyStart, this.endPosition)) {
4163        md.bits |= ASTNode.UndocumentedEmptyBlock;
4164    }
4165    // store the this.endPosition (position just before the '}') in case there is
4166
// a trailing comment behind the end of the method
4167
md.bodyEnd = this.endPosition;
4168    md.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
4169}
4170protected void consumeMethodHeader() {
4171    // MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims ThrowsClauseopt
4172
// AnnotationMethodHeader ::= AnnotationMethodHeaderName FormalParameterListopt MethodHeaderRightParen MethodHeaderExtendedDims AnnotationMethodHeaderDefaultValueopt
4173
// RecoveryMethodHeader ::= RecoveryMethodHeaderName FormalParameterListopt MethodHeaderRightParen MethodHeaderExtendedDims AnnotationMethodHeaderDefaultValueopt
4174
// RecoveryMethodHeader ::= RecoveryMethodHeaderName FormalParameterListopt MethodHeaderRightParen MethodHeaderExtendedDims MethodHeaderThrowsClause
4175

4176    // retrieve end position of method declarator
4177
AbstractMethodDeclaration method = (AbstractMethodDeclaration)this.astStack[this.astPtr];
4178
4179    if (this.currentToken == TokenNameLBRACE){
4180        method.bodyStart = this.scanner.currentPosition;
4181    }
4182    // recovery
4183
if (this.currentElement != null){
4184// if(method.isAnnotationMethod()) {
4185
// method.modifiers |= AccSemicolonBody;
4186
// method.declarationSourceEnd = this.scanner.currentPosition-1;
4187
// method.bodyEnd = this.scanner.currentPosition-1;
4188
// this.currentElement = this.currentElement.parent;
4189
// } else
4190
if (this.currentToken == TokenNameSEMICOLON /*&& !method.isAnnotationMethod()*/){
4191            method.modifiers |= ExtraCompilerModifiers.AccSemicolonBody;
4192            method.declarationSourceEnd = this.scanner.currentPosition-1;
4193            method.bodyEnd = this.scanner.currentPosition-1;
4194            if (this.currentElement.parseTree() == method && this.currentElement.parent != null) {
4195                this.currentElement = this.currentElement.parent;
4196            }
4197        } else if(this.currentToken == TokenNameLBRACE) {
4198            if (this.currentElement instanceof RecoveredMethod &&
4199                    ((RecoveredMethod)this.currentElement).methodDeclaration != method) {
4200                this.ignoreNextOpeningBrace = true;
4201                this.currentElement.bracketBalance++;
4202            }
4203        }
4204        this.restartRecovery = true; // used to avoid branching back into the regular automaton
4205
}
4206}
4207protected void consumeMethodHeaderDefaultValue() {
4208    // MethodHeaderDefaultValue ::= DefaultValue
4209
MethodDeclaration md = (MethodDeclaration) this.astStack[this.astPtr];
4210
4211    
4212    int length = this.expressionLengthStack[this.expressionLengthPtr--];
4213    if (length == 1) {
4214        intPtr--; // we get rid of the position of the default keyword
4215
intPtr--; // we get rid of the position of the default keyword
4216
if(md.isAnnotationMethod()) {
4217            ((AnnotationMethodDeclaration)md).defaultValue = this.expressionStack[this.expressionPtr];
4218            md.modifiers |= ClassFileConstants.AccAnnotationDefault;
4219        }
4220        this.expressionPtr--;
4221        this.recordStringLiterals = true;
4222    }
4223
4224    if(this.currentElement != null) {
4225        if(md.isAnnotationMethod()) {
4226            this.currentElement.updateSourceEndIfNecessary(((AnnotationMethodDeclaration)md).defaultValue.sourceEnd);
4227        }
4228    }
4229}
4230protected void consumeMethodHeaderExtendedDims() {
4231    // MethodHeaderExtendedDims ::= Dimsopt
4232
// now we update the returnType of the method
4233
MethodDeclaration md = (MethodDeclaration) this.astStack[this.astPtr];
4234    int extendedDims = this.intStack[this.intPtr--];
4235    if(md.isAnnotationMethod()) {
4236        ((AnnotationMethodDeclaration)md).extendedDimensions = extendedDims;
4237    }
4238    if (extendedDims != 0) {
4239        TypeReference returnType = md.returnType;
4240        md.sourceEnd = this.endPosition;
4241        int dims = returnType.dimensions() + extendedDims;
4242        md.returnType = this.copyDims(returnType, dims);
4243        if (this.currentToken == TokenNameLBRACE){
4244            md.bodyStart = this.endPosition + 1;
4245        }
4246        // recovery
4247
if (this.currentElement != null){
4248            this.lastCheckPoint = md.bodyStart;
4249        }
4250    }
4251}
4252protected void consumeMethodHeaderName(boolean isAnnotationMethod) {
4253    // MethodHeaderName ::= Modifiersopt Type 'Identifier' '('
4254
// AnnotationMethodHeaderName ::= Modifiersopt Type 'Identifier' '('
4255
// RecoveryMethodHeaderName ::= Modifiersopt Type 'Identifier' '('
4256
MethodDeclaration md = null;
4257    if(isAnnotationMethod) {
4258        md = new AnnotationMethodDeclaration(this.compilationUnit.compilationResult);
4259        this.recordStringLiterals = false;
4260    } else {
4261        md = new MethodDeclaration(this.compilationUnit.compilationResult);
4262    }
4263
4264    //name
4265
md.selector = this.identifierStack[this.identifierPtr];
4266    long selectorSource = this.identifierPositionStack[this.identifierPtr--];
4267    this.identifierLengthPtr--;
4268    //type
4269
md.returnType = getTypeReference(this.intStack[this.intPtr--]);
4270    //modifiers
4271
md.declarationSourceStart = this.intStack[this.intPtr--];
4272    md.modifiers = this.intStack[this.intPtr--];
4273    // consume annotations
4274
int length;
4275    if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
4276        System.arraycopy(
4277            this.expressionStack,
4278            (this.expressionPtr -= length) + 1,
4279            md.annotations = new Annotation[length],
4280            0,
4281            length);
4282    }
4283    // javadoc
4284
md.javadoc = this.javadoc;
4285    this.javadoc = null;
4286
4287    //highlight starts at selector start
4288
md.sourceStart = (int) (selectorSource >>> 32);
4289    pushOnAstStack(md);
4290    md.sourceEnd = this.lParenPos;
4291    md.bodyStart = this.lParenPos+1;
4292    this.listLength = 0; // initialize this.listLength before reading parameters/throws
4293

4294    // recovery
4295
if (this.currentElement != null){
4296        if (this.currentElement instanceof RecoveredType
4297            //|| md.modifiers != 0
4298
|| (Util.getLineNumber(md.returnType.sourceStart, this.scanner.lineEnds, 0, this.scanner.linePtr)
4299                    == Util.getLineNumber(md.sourceStart, this.scanner.lineEnds, 0, this.scanner.linePtr))){
4300            this.lastCheckPoint = md.bodyStart;
4301            this.currentElement = this.currentElement.add(md, 0);
4302            this.lastIgnoredToken = -1;
4303        } else {
4304            this.lastCheckPoint = md.sourceStart;
4305            this.restartRecovery = true;
4306        }
4307    }
4308}
4309protected void consumeMethodHeaderNameWithTypeParameters(boolean isAnnotationMethod) {
4310    // MethodHeaderName ::= Modifiersopt TypeParameters Type 'Identifier' '('
4311
// AnnotationMethodHeaderName ::= Modifiersopt TypeParameters Type 'Identifier' '('
4312
// RecoveryMethodHeaderName ::= Modifiersopt TypeParameters Type 'Identifier' '('
4313
MethodDeclaration md = null;
4314    if(isAnnotationMethod) {
4315        md = new AnnotationMethodDeclaration(this.compilationUnit.compilationResult);
4316        this.recordStringLiterals = false;
4317    } else {
4318        md = new MethodDeclaration(this.compilationUnit.compilationResult);
4319    }
4320
4321    //name
4322
md.selector = this.identifierStack[this.identifierPtr];
4323    long selectorSource = this.identifierPositionStack[this.identifierPtr--];
4324    this.identifierLengthPtr--;
4325    //type
4326
md.returnType = getTypeReference(this.intStack[this.intPtr--]);
4327    
4328    // consume type parameters
4329
int length = this.genericsLengthStack[this.genericsLengthPtr--];
4330    this.genericsPtr -= length;
4331    System.arraycopy(this.genericsStack, this.genericsPtr + 1, md.typeParameters = new TypeParameter[length], 0, length);
4332    
4333    //modifiers
4334
md.declarationSourceStart = this.intStack[this.intPtr--];
4335    md.modifiers = this.intStack[this.intPtr--];
4336    // consume annotations
4337
if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
4338        System.arraycopy(
4339            this.expressionStack,
4340            (this.expressionPtr -= length) + 1,
4341            md.annotations = new Annotation[length],
4342            0,
4343            length);
4344    }
4345    // javadoc
4346
md.javadoc = this.javadoc;
4347    this.javadoc = null;
4348
4349    //highlight starts at selector start
4350
md.sourceStart = (int) (selectorSource >>> 32);
4351    pushOnAstStack(md);
4352    md.sourceEnd = this.lParenPos;
4353    md.bodyStart = this.lParenPos+1;
4354    this.listLength = 0; // initialize this.listLength before reading parameters/throws
4355

4356    // recovery
4357
if (this.currentElement != null){
4358        boolean isType;
4359        if ((isType = this.currentElement instanceof RecoveredType)
4360            //|| md.modifiers != 0
4361
|| (Util.getLineNumber(md.returnType.sourceStart, this.scanner.lineEnds, 0, this.scanner.linePtr)
4362                    == Util.getLineNumber(md.sourceStart, this.scanner.lineEnds, 0, this.scanner.linePtr))){
4363            if(isType) {
4364                ((RecoveredType) this.currentElement).pendingTypeParameters = null;
4365            }
4366            this.lastCheckPoint = md.bodyStart;
4367            this.currentElement = this.currentElement.add(md, 0);
4368            this.lastIgnoredToken = -1;
4369        } else {
4370            this.lastCheckPoint = md.sourceStart;
4371            this.restartRecovery = true;
4372        }
4373    }
4374}
4375protected void consumeMethodHeaderRightParen() {
4376    // MethodHeaderParameters ::= FormalParameterListopt ')'
4377
int length = this.astLengthStack[this.astLengthPtr--];
4378    this.astPtr -= length;
4379    AbstractMethodDeclaration md = (AbstractMethodDeclaration) this.astStack[this.astPtr];
4380    md.sourceEnd = this.rParenPos;
4381    //arguments
4382
if (length != 0) {
4383        System.arraycopy(
4384            this.astStack,
4385            this.astPtr + 1,
4386            md.arguments = new Argument[length],
4387            0,
4388            length);
4389    }
4390    md.bodyStart = this.rParenPos+1;
4391    this.listLength = 0; // reset this.listLength after having read all parameters
4392
// recovery
4393
if (this.currentElement != null){
4394        this.lastCheckPoint = md.bodyStart;
4395        if (this.currentElement.parseTree() == md) return;
4396
4397        // might not have been attached yet - in some constructor scenarii
4398
if (md.isConstructor()){
4399            if ((length != 0)
4400                || (this.currentToken == TokenNameLBRACE)
4401                || (this.currentToken == TokenNamethrows)){
4402                this.currentElement = this.currentElement.add(md, 0);
4403                this.lastIgnoredToken = -1;
4404            }
4405        }
4406    }
4407}
4408protected void consumeMethodHeaderThrowsClause() {
4409    // MethodHeaderThrowsClause ::= 'throws' ClassTypeList
4410
int length = this.astLengthStack[this.astLengthPtr--];
4411    this.astPtr -= length;
4412    AbstractMethodDeclaration md = (AbstractMethodDeclaration) this.astStack[this.astPtr];
4413    System.arraycopy(
4414        this.astStack,
4415        this.astPtr + 1,
4416        md.thrownExceptions = new TypeReference[length],
4417        0,
4418        length);
4419    md.sourceEnd = md.thrownExceptions[length-1].sourceEnd;
4420    md.bodyStart = md.thrownExceptions[length-1].sourceEnd + 1;
4421    this.listLength = 0; // reset this.listLength after having read all thrown exceptions
4422
// recovery
4423
if (this.currentElement != null){
4424        this.lastCheckPoint = md.bodyStart;
4425    }
4426}
4427protected void consumeMethodInvocationName() {
4428    // MethodInvocation ::= Name '(' ArgumentListopt ')'
4429

4430    // when the name is only an identifier...we have a message send to "this" (implicit)
4431

4432    MessageSend m = newMessageSend();
4433    m.sourceEnd = this.rParenPos;
4434    m.sourceStart =
4435        (int) ((m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr]) >>> 32);
4436    m.selector = this.identifierStack[this.identifierPtr--];
4437    if (this.identifierLengthStack[this.identifierLengthPtr] == 1) {
4438        m.receiver = ThisReference.implicitThis();
4439        this.identifierLengthPtr--;
4440    } else {
4441        this.identifierLengthStack[this.identifierLengthPtr]--;
4442        m.receiver = getUnspecifiedReference();
4443        m.sourceStart = m.receiver.sourceStart;
4444    }
4445    pushOnExpressionStack(m);
4446}
4447protected void consumeMethodInvocationNameWithTypeArguments() {
4448    // MethodInvocation ::= Name '.' TypeArguments 'Identifier' '(' ArgumentListopt ')'
4449

4450    // when the name is only an identifier...we have a message send to "this" (implicit)
4451

4452    MessageSend m = newMessageSendWithTypeArguments();
4453    m.sourceEnd = this.rParenPos;
4454    m.sourceStart =
4455        (int) ((m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr]) >>> 32);
4456    m.selector = this.identifierStack[this.identifierPtr--];
4457    this.identifierLengthPtr--;
4458
4459    // handle type arguments
4460
int length = this.genericsLengthStack[this.genericsLengthPtr--];
4461    this.genericsPtr -= length;
4462    System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
4463    intPtr--;
4464    
4465    m.receiver = getUnspecifiedReference();
4466    m.sourceStart = m.receiver.sourceStart;
4467    pushOnExpressionStack(m);
4468}
4469protected void consumeMethodInvocationPrimary() {
4470    //optimize the push/pop
4471
//MethodInvocation ::= Primary '.' 'Identifier' '(' ArgumentListopt ')'
4472

4473    MessageSend m = newMessageSend();
4474    m.sourceStart =
4475        (int) ((m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr]) >>> 32);
4476    m.selector = this.identifierStack[this.identifierPtr--];
4477    this.identifierLengthPtr--;
4478    m.receiver = this.expressionStack[this.expressionPtr];
4479    m.sourceStart = m.receiver.sourceStart;
4480    m.sourceEnd = this.rParenPos;
4481    this.expressionStack[this.expressionPtr] = m;
4482}
4483protected void consumeMethodInvocationPrimaryWithTypeArguments() {
4484    //optimize the push/pop
4485
//MethodInvocation ::= Primary '.' TypeArguments 'Identifier' '(' ArgumentListopt ')'
4486

4487    MessageSend m = newMessageSendWithTypeArguments();
4488    m.sourceStart =
4489        (int) ((m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr]) >>> 32);
4490    m.selector = this.identifierStack[this.identifierPtr--];
4491    this.identifierLengthPtr--;
4492    
4493    // handle type arguments
4494
int length = this.genericsLengthStack[this.genericsLengthPtr--];
4495    this.genericsPtr -= length;
4496    System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
4497    intPtr--;
4498
4499    m.receiver = this.expressionStack[this.expressionPtr];
4500    m.sourceStart = m.receiver.sourceStart;
4501    m.sourceEnd = this.rParenPos;
4502    this.expressionStack[this.expressionPtr] = m;
4503}
4504protected void consumeMethodInvocationSuper() {
4505    // MethodInvocation ::= 'super' '.' 'Identifier' '(' ArgumentListopt ')'
4506

4507    MessageSend m = newMessageSend();
4508    m.sourceStart = this.intStack[this.intPtr--]; // start position of the super keyword
4509
m.sourceEnd = this.rParenPos;
4510    m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr];
4511    m.selector = this.identifierStack[this.identifierPtr--];
4512    this.identifierLengthPtr--;
4513    m.receiver = new SuperReference(m.sourceStart, this.endPosition);
4514    pushOnExpressionStack(m);
4515}
4516protected void consumeMethodInvocationSuperWithTypeArguments() {
4517    // MethodInvocation ::= 'super' '.' TypeArguments 'Identifier' '(' ArgumentListopt ')'
4518

4519    MessageSend m = newMessageSendWithTypeArguments();
4520    intPtr--; // start position of the typeArguments
4521
m.sourceEnd = this.rParenPos;
4522    m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr];
4523    m.selector = this.identifierStack[this.identifierPtr--];
4524    this.identifierLengthPtr--;
4525    
4526    // handle type arguments
4527
int length = this.genericsLengthStack[this.genericsLengthPtr--];
4528    this.genericsPtr -= length;
4529    System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
4530    m.sourceStart = this.intStack[this.intPtr--]; // start position of the super keyword
4531

4532    m.receiver = new SuperReference(m.sourceStart, this.endPosition);
4533    pushOnExpressionStack(m);
4534}
4535protected void consumeModifiers() {
4536    int savedModifiersSourceStart = this.modifiersSourceStart;
4537    checkComment(); // might update modifiers with AccDeprecated
4538
pushOnIntStack(this.modifiers); // modifiers
4539
if (this.modifiersSourceStart >= savedModifiersSourceStart) {
4540        this.modifiersSourceStart = savedModifiersSourceStart;
4541    }
4542    pushOnIntStack(this.modifiersSourceStart);
4543    resetModifiers();
4544}
4545protected void consumeModifiers2() {
4546    this.expressionLengthStack[this.expressionLengthPtr - 1] += this.expressionLengthStack[this.expressionLengthPtr--];
4547}
4548protected void consumeNameArrayType() {
4549    pushOnGenericsLengthStack(0); // handle type arguments
4550
pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
4551}
4552protected void consumeNestedMethod() {
4553    // NestedMethod ::= $empty
4554
jumpOverMethodBody();
4555    this.nestedMethod[this.nestedType] ++;
4556    pushOnIntStack(this.scanner.currentPosition);
4557    consumeOpenBlock();
4558}
4559protected void consumeNestedType() {
4560    // NestedType ::= $empty
4561
int length = this.nestedMethod.length;
4562    if (++this.nestedType >= length) {
4563        System.arraycopy(
4564            this.nestedMethod, 0,
4565            this.nestedMethod = new int[length + 30], 0,
4566            length);
4567        // increase the size of the variablesCounter as well. It has to be consistent with the size of the nestedMethod collection
4568
System.arraycopy(
4569            this.variablesCounter, 0,
4570            this.variablesCounter = new int[length + 30], 0,
4571            length);
4572    }
4573    this.nestedMethod[this.nestedType] = 0;
4574    this.variablesCounter[this.nestedType] = 0;
4575}
4576protected void consumeNormalAnnotation() {
4577    // NormalAnnotation ::= '@' Name '(' MemberValuePairsopt ')'
4578
NormalAnnotation normalAnnotation = null;
4579    TypeReference typeReference = this.getAnnotationType();
4580    normalAnnotation = new NormalAnnotation(typeReference, this.intStack[this.intPtr--]);
4581    int length;
4582    if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
4583        System.arraycopy(
4584            this.astStack,
4585            (this.astPtr -= length) + 1,
4586            normalAnnotation.memberValuePairs = new MemberValuePair[length],
4587            0,
4588            length);
4589    }
4590    normalAnnotation.declarationSourceEnd = this.rParenPos;
4591    pushOnExpressionStack(normalAnnotation);
4592    
4593    if(this.currentElement != null) {
4594        annotationRecoveryCheckPoint(normalAnnotation.sourceStart, normalAnnotation.declarationSourceEnd);
4595    }
4596    
4597    if(!this.statementRecoveryActivated &&
4598            options.sourceLevel < ClassFileConstants.JDK1_5 &&
4599            this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
4600        this.problemReporter().invalidUsageOfAnnotation(normalAnnotation);
4601    }
4602    this.recordStringLiterals = true;
4603}
4604protected void consumeOneDimLoop() {
4605    // OneDimLoop ::= '[' ']'
4606
this.dimensions++;
4607}
4608protected void consumeOnlySynchronized() {
4609    // OnlySynchronized ::= 'synchronized'
4610
pushOnIntStack(this.synchronizedBlockSourceStart);
4611    resetModifiers();
4612    this.expressionLengthPtr--;
4613}
4614protected void consumeOnlyTypeArguments() {
4615    if(!this.statementRecoveryActivated &&
4616            options.sourceLevel < ClassFileConstants.JDK1_5 &&
4617            this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
4618        int length = this.genericsLengthStack[this.genericsLengthPtr];
4619        this.problemReporter().invalidUsageOfTypeArguments(
4620            (TypeReference)this.genericsStack[this.genericsPtr - length + 1],
4621            (TypeReference)this.genericsStack[this.genericsPtr]);
4622    }
4623}
4624protected void consumeOnlyTypeArgumentsForCastExpression() {
4625    // OnlyTypeArgumentsForCastExpression ::= OnlyTypeArguments
4626
}
4627protected void consumeOpenBlock() {
4628    // OpenBlock ::= $empty
4629

4630    pushOnIntStack(this.scanner.startPosition);
4631    int stackLength = this.realBlockStack.length;
4632    if (++this.realBlockPtr >= stackLength) {
4633        System.arraycopy(
4634            this.realBlockStack, 0,
4635            this.realBlockStack = new int[stackLength + StackIncrement], 0,
4636            stackLength);
4637    }
4638    this.realBlockStack[this.realBlockPtr] = 0;
4639}
4640protected void consumePackageComment() {
4641    // get possible comment for syntax since 1.5
4642
if(options.sourceLevel >= ClassFileConstants.JDK1_5) {
4643        checkComment();
4644        resetModifiers();
4645    }
4646}
4647protected void consumePackageDeclaration() {
4648    // PackageDeclaration ::= 'package' Name ';'
4649
/* build an ImportRef build from the last name
4650    stored in the identifier stack. */

4651
4652    ImportReference impt = this.compilationUnit.currentPackage;
4653    this.compilationUnit.javadoc = this.javadoc;
4654    this.javadoc = null;
4655    // flush comments defined prior to import statements
4656
impt.declarationEnd = this.endStatementPosition;
4657    impt.declarationSourceEnd = this.flushCommentsDefinedPriorTo(impt.declarationSourceEnd);
4658}
4659protected void consumePackageDeclarationName() {
4660    // PackageDeclarationName ::= 'package' Name
4661
/* build an ImportRef build from the last name
4662    stored in the identifier stack. */

4663
4664    ImportReference impt;
4665    int length;
4666    char[][] tokens =
4667        new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
4668    this.identifierPtr -= length;
4669    long[] positions = new long[length];
4670    System.arraycopy(this.identifierStack, ++this.identifierPtr, tokens, 0, length);
4671    System.arraycopy(
4672        this.identifierPositionStack,
4673        this.identifierPtr--,
4674        positions,
4675        0,
4676        length);
4677    
4678    impt = new ImportReference(tokens, positions, true, ClassFileConstants.AccDefault);
4679    this.compilationUnit.currentPackage = impt;
4680
4681    if (this.currentToken == TokenNameSEMICOLON){
4682        impt.declarationSourceEnd = this.scanner.currentPosition - 1;
4683    } else {
4684        impt.declarationSourceEnd = impt.sourceEnd;
4685    }
4686    impt.declarationEnd = impt.declarationSourceEnd;
4687    //this.endPosition is just before the ;
4688
impt.declarationSourceStart = this.intStack[this.intPtr--];
4689
4690    // get possible comment source start
4691
if(this.javadoc != null) {
4692        impt.declarationSourceStart = this.javadoc.sourceStart;
4693    }
4694
4695    // recovery
4696
if (this.currentElement != null){
4697        this.lastCheckPoint = impt.declarationSourceEnd+1;
4698        this.restartRecovery = true; // used to avoid branching back into the regular automaton
4699
}
4700}
4701protected void consumePackageDeclarationNameWithModifiers() {
4702    // PackageDeclarationName ::= Modifiers 'package' Name
4703
/* build an ImportRef build from the last name
4704    stored in the identifier stack. */

4705
4706    ImportReference impt;
4707    int length;
4708    char[][] tokens =
4709        new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
4710    this.identifierPtr -= length;
4711    long[] positions = new long[length];
4712    System.arraycopy(this.identifierStack, ++this.identifierPtr, tokens, 0, length);
4713    System.arraycopy(
4714        this.identifierPositionStack,
4715        this.identifierPtr--,
4716        positions,
4717        0,
4718        length);
4719    
4720    int packageModifiersSourceStart = this.intStack[this.intPtr--]; // we don't need the modifiers start
4721
int packageModifiers = this.intStack[this.intPtr--];
4722
4723    impt = new ImportReference(tokens, positions, true, packageModifiers);
4724    this.compilationUnit.currentPackage = impt;
4725    // consume annotations
4726
if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
4727        System.arraycopy(
4728            this.expressionStack,
4729            (this.expressionPtr -= length) + 1,
4730            impt.annotations = new Annotation[length],
4731            0,
4732            length);
4733        impt.declarationSourceStart = packageModifiersSourceStart;
4734        intPtr--; // we don't need the position of the 'package keyword
4735
} else {
4736        impt.declarationSourceStart = this.intStack[this.intPtr--];
4737        // get possible comment source start
4738
if (this.javadoc != null) {
4739            impt.declarationSourceStart = this.javadoc.sourceStart;
4740        }
4741    }
4742        
4743    if (this.currentToken == TokenNameSEMICOLON){
4744        impt.declarationSourceEnd = this.scanner.currentPosition - 1;
4745    } else {
4746        impt.declarationSourceEnd = impt.sourceEnd;
4747    }
4748    impt.declarationEnd = impt.declarationSourceEnd;
4749
4750    // recovery
4751
if (this.currentElement != null){
4752        this.lastCheckPoint = impt.declarationSourceEnd+1;
4753        this.restartRecovery = true; // used to avoid branching back into the regular automaton
4754
}
4755}
4756protected void consumePostfixExpression() {
4757    // PostfixExpression ::= Name
4758
pushOnExpressionStack(getUnspecifiedReferenceOptimized());
4759}
4760protected void consumePrimaryNoNewArray() {
4761    // PrimaryNoNewArray ::= PushLPAREN Expression PushRPAREN
4762
final Expression parenthesizedExpression = this.expressionStack[this.expressionPtr];
4763    updateSourcePosition(parenthesizedExpression);
4764    int numberOfParenthesis = (parenthesizedExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
4765    parenthesizedExpression.bits &= ~ASTNode.ParenthesizedMASK;
4766    parenthesizedExpression.bits |= (numberOfParenthesis + 1) << ASTNode.ParenthesizedSHIFT;
4767}
4768protected void consumePrimaryNoNewArrayArrayType() {
4769    // PrimaryNoNewArray ::= Name Dims '.' 'class'
4770
this.intPtr--; // remove the class start position
4771

4772    pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
4773    pushOnGenericsLengthStack(0);
4774
4775    pushOnExpressionStack(
4776        new ClassLiteralAccess(this.intStack[this.intPtr--], getTypeReference(this.intStack[this.intPtr--])));
4777}
4778protected void consumePrimaryNoNewArrayName() {
4779    // PrimaryNoNewArray ::= Name '.' 'class'
4780
this.intPtr--; // remove the class start position
4781

4782    // handle type arguments
4783
pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
4784    pushOnGenericsLengthStack(0);
4785    TypeReference typeReference = getTypeReference(0);
4786    
4787    pushOnExpressionStack(
4788        new ClassLiteralAccess(this.intStack[this.intPtr--], typeReference));
4789}
4790protected void consumePrimaryNoNewArrayNameSuper() {
4791    // PrimaryNoNewArray ::= Name '.' 'super'
4792
// handle type arguments
4793
pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
4794    pushOnGenericsLengthStack(0);
4795    TypeReference typeReference = getTypeReference(0);
4796
4797    pushOnExpressionStack(
4798        new QualifiedSuperReference(
4799            typeReference,
4800            this.intStack[this.intPtr--],
4801            this.endPosition));
4802}
4803protected void consumePrimaryNoNewArrayNameThis() {
4804    // PrimaryNoNewArray ::= Name '.' 'this'
4805
// handle type arguments
4806
pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
4807    pushOnGenericsLengthStack(0); // handle type arguments
4808

4809    TypeReference typeReference = getTypeReference(0);
4810    
4811    pushOnExpressionStack(
4812        new QualifiedThisReference(
4813            typeReference,
4814            this.intStack[this.intPtr--],
4815            this.endPosition));
4816}
4817protected void consumePrimaryNoNewArrayPrimitiveArrayType() {
4818    // PrimaryNoNewArray ::= PrimitiveType Dims '.' 'class'
4819
this.intPtr--; // remove the class start position
4820
pushOnExpressionStack(
4821        new ClassLiteralAccess(this.intStack[this.intPtr--], getTypeReference(this.intStack[this.intPtr--])));
4822}
4823protected void consumePrimaryNoNewArrayPrimitiveType() {
4824    // PrimaryNoNewArray ::= PrimitiveType '.' 'class'
4825
this.intPtr--; // remove the class start position
4826
pushOnExpressionStack(
4827        new ClassLiteralAccess(this.intStack[this.intPtr--], getTypeReference(0)));
4828}
4829protected void consumePrimaryNoNewArrayThis() {
4830    // PrimaryNoNewArray ::= 'this'
4831
pushOnExpressionStack(new ThisReference(this.intStack[this.intPtr--], this.endPosition));
4832}
4833protected void consumePrimaryNoNewArrayWithName() {
4834    // PrimaryNoNewArray ::= PushLPAREN Expression PushRPAREN
4835
pushOnExpressionStack(getUnspecifiedReferenceOptimized());
4836    final Expression parenthesizedExpression = this.expressionStack[this.expressionPtr];
4837    updateSourcePosition(parenthesizedExpression);
4838    int numberOfParenthesis = (parenthesizedExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
4839    parenthesizedExpression.bits &= ~ASTNode.ParenthesizedMASK;
4840    parenthesizedExpression.bits |= (numberOfParenthesis + 1) << ASTNode.ParenthesizedSHIFT;
4841}
4842protected void consumePrimitiveArrayType() {
4843    // nothing to do
4844
// Will be consume by a getTypeRefence call
4845
}
4846protected void consumePrimitiveType() {
4847    // Type ::= PrimitiveType
4848
pushOnIntStack(0);
4849}
4850protected void consumePushLeftBrace() {
4851    pushOnIntStack(this.endPosition); // modifiers
4852
}
4853protected void consumePushRealModifiers() {
4854    checkComment(); // might update modifiers with AccDeprecated
4855
pushOnIntStack(this.modifiers); // modifiers
4856
pushOnIntStack(this.modifiersSourceStart);
4857    resetModifiers();
4858}
4859protected void consumePushModifiers() {
4860    pushOnIntStack(this.modifiers); // modifiers
4861
pushOnIntStack(this.modifiersSourceStart);
4862    resetModifiers();
4863    pushOnExpressionStackLengthStack(0);
4864}
4865protected void consumePushModifiersForHeader() {
4866    checkComment(); // might update modifiers with AccDeprecated
4867
pushOnIntStack(this.modifiers); // modifiers
4868
pushOnIntStack(this.modifiersSourceStart);
4869    resetModifiers();
4870    pushOnExpressionStackLengthStack(0);
4871}
4872protected void consumePushPosition() {
4873    // for source managment purpose
4874
// PushPosition ::= $empty
4875
pushOnIntStack(this.endPosition);
4876}
4877protected void consumeQualifiedName() {
4878    // QualifiedName ::= Name '.' SimpleName
4879
/*back from the recursive loop of QualifiedName.
4880    Updates identifier length into the length stack*/

4881
4882    this.identifierLengthStack[--this.identifierLengthPtr]++;
4883}
4884protected void consumeRecoveryMethodHeaderName() {
4885    // this method is call only inside recovery
4886
boolean isAnnotationMethod = false;
4887    if(this.currentElement instanceof RecoveredType) {
4888        isAnnotationMethod = (((RecoveredType)this.currentElement).typeDeclaration.modifiers & ClassFileConstants.AccAnnotation) != 0;
4889    } else {
4890        RecoveredType recoveredType = this.currentElement.enclosingType();
4891        if(recoveredType != null) {
4892            isAnnotationMethod = (recoveredType.typeDeclaration.modifiers & ClassFileConstants.AccAnnotation) != 0;
4893        }
4894    }
4895    this.consumeMethodHeaderName(isAnnotationMethod);
4896}
4897protected void consumeRecoveryMethodHeaderNameWithTypeParameters() {
4898    // this method is call only inside recovery
4899
boolean isAnnotationMethod = false;
4900    if(this.currentElement instanceof RecoveredType) {
4901        isAnnotationMethod = (((RecoveredType)this.currentElement).typeDeclaration.modifiers & ClassFileConstants.AccAnnotation) != 0;
4902    } else {
4903        RecoveredType recoveredType = this.currentElement.enclosingType();
4904        if(recoveredType != null) {
4905            isAnnotationMethod = (recoveredType.typeDeclaration.modifiers & ClassFileConstants.AccAnnotation) != 0;
4906        }
4907    }
4908    this.consumeMethodHeaderNameWithTypeParameters(isAnnotationMethod);
4909}
4910protected void consumeReduceImports() {
4911    // Consume imports
4912
int length;
4913    if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
4914        this.astPtr -= length;
4915        System.arraycopy(
4916            this.astStack,
4917            this.astPtr + 1,
4918            this.compilationUnit.imports = new ImportReference[length],
4919            0,
4920            length);
4921    }
4922}
4923protected void consumeReferenceType() {
4924    pushOnIntStack(0); // handle array type
4925
}
4926protected void consumeReferenceType1() {
4927    pushOnGenericsStack(getTypeReference(this.intStack[this.intPtr--]));
4928}
4929protected void consumeReferenceType2() {
4930    pushOnGenericsStack(getTypeReference(this.intStack[this.intPtr--]));
4931}
4932protected void consumeReferenceType3() {
4933    pushOnGenericsStack(getTypeReference(this.intStack[this.intPtr--]));
4934}
4935protected void consumeRestoreDiet() {
4936    // RestoreDiet ::= $empty
4937
this.dietInt--;
4938}
4939protected void consumeRightParen() {
4940    // PushRPAREN ::= ')'
4941
pushOnIntStack(this.rParenPos);
4942}
4943// This method is part of an automatic generation : do NOT edit-modify
4944
protected void consumeRule(int act) {
4945  switch ( act ) {
4946    case 30 : if (DEBUG) { System.out.println("Type ::= PrimitiveType"); } //$NON-NLS-1$
4947
consumePrimitiveType();
4948            break;
4949 
4950    case 44 : if (DEBUG) { System.out.println("ReferenceType ::= ClassOrInterfaceType"); } //$NON-NLS-1$
4951
consumeReferenceType();
4952            break;
4953 
4954    case 48 : if (DEBUG) { System.out.println("ClassOrInterface ::= Name"); } //$NON-NLS-1$
4955
consumeClassOrInterfaceName();
4956            break;
4957 
4958    case 49 : if (DEBUG) { System.out.println("ClassOrInterface ::= GenericType DOT Name"); } //$NON-NLS-1$
4959
consumeClassOrInterface();
4960            break;
4961 
4962    case 50 : if (DEBUG) { System.out.println("GenericType ::= ClassOrInterface TypeArguments"); } //$NON-NLS-1$
4963
consumeGenericType();
4964            break;
4965 
4966    case 51 : if (DEBUG) { System.out.println("ArrayTypeWithTypeArgumentsName ::= GenericType DOT Name"); } //$NON-NLS-1$
4967
consumeArrayTypeWithTypeArgumentsName();
4968            break;
4969 
4970    case 52 : if (DEBUG) { System.out.println("ArrayType ::= PrimitiveType Dims"); } //$NON-NLS-1$
4971
consumePrimitiveArrayType();
4972            break;
4973 
4974    case 53 : if (DEBUG) { System.out.println("ArrayType ::= Name Dims"); } //$NON-NLS-1$
4975
consumeNameArrayType();
4976            break;
4977 
4978    case 54 : if (DEBUG) { System.out.println("ArrayType ::= ArrayTypeWithTypeArgumentsName Dims"); } //$NON-NLS-1$
4979
consumeGenericTypeNameArrayType();
4980            break;
4981 
4982    case 55 : if (DEBUG) { System.out.println("ArrayType ::= GenericType Dims"); } //$NON-NLS-1$
4983
consumeGenericTypeArrayType();
4984            break;
4985 
4986    case 60 : if (DEBUG) { System.out.println("QualifiedName ::= Name DOT SimpleName"); } //$NON-NLS-1$
4987
consumeQualifiedName();
4988            break;
4989 
4990    case 61 : if (DEBUG) { System.out.println("CompilationUnit ::= EnterCompilationUnit..."); } //$NON-NLS-1$
4991
consumeCompilationUnit();
4992            break;
4993 
4994    case 62 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration"); } //$NON-NLS-1$
4995
consumeInternalCompilationUnit();
4996            break;
4997 
4998    case 63 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration..."); } //$NON-NLS-1$
4999
consumeInternalCompilationUnit();
5000            break;
5001 
5002    case 64 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration..."); } //$NON-NLS-1$
5003
consumeInternalCompilationUnitWithTypes();
5004            break;
5005 
5006    case 65 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration..."); } //$NON-NLS-1$
5007
consumeInternalCompilationUnitWithTypes();
5008            break;
5009 
5010    case 66 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= ImportDeclarations..."); } //$NON-NLS-1$
5011
consumeInternalCompilationUnit();
5012            break;
5013 
5014    case 67 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= TypeDeclarations"); } //$NON-NLS-1$
5015
consumeInternalCompilationUnitWithTypes();
5016            break;
5017 
5018    case 68 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= ImportDeclarations..."); } //$NON-NLS-1$
5019
consumeInternalCompilationUnitWithTypes();
5020            break;
5021 
5022    case 69 : if (DEBUG) { System.out.println("InternalCompilationUnit ::="); } //$NON-NLS-1$
5023
consumeEmptyInternalCompilationUnit();
5024            break;
5025 
5026    case 70 : if (DEBUG) { System.out.println("ReduceImports ::="); } //$NON-NLS-1$
5027
consumeReduceImports();
5028            break;
5029 
5030    case 71 : if (DEBUG) { System.out.println("EnterCompilationUnit ::="); } //$NON-NLS-1$
5031
consumeEnterCompilationUnit();
5032            break;
5033 
5034    case 87 : if (DEBUG) { System.out.println("CatchHeader ::= catch LPAREN FormalParameter RPAREN..."); } //$NON-NLS-1$
5035
consumeCatchHeader();
5036            break;
5037 
5038    case 89 : if (DEBUG) { System.out.println("ImportDeclarations ::= ImportDeclarations..."); } //$NON-NLS-1$
5039
consumeImportDeclarations();
5040            break;
5041 
5042    case 91 : if (DEBUG) { System.out.println("TypeDeclarations ::= TypeDeclarations TypeDeclaration"); } //$NON-NLS-1$
5043
consumeTypeDeclarations();
5044            break;
5045 
5046    case 92 : if (DEBUG) { System.out.println("PackageDeclaration ::= PackageDeclarationName SEMICOLON"); } //$NON-NLS-1$
5047
consumePackageDeclaration();
5048            break;
5049 
5050    case 93 : if (DEBUG) { System.out.println("PackageDeclarationName ::= Modifiers package..."); } //$NON-NLS-1$
5051
consumePackageDeclarationNameWithModifiers();
5052            break;
5053 
5054    case 94 : if (DEBUG) { System.out.println("PackageDeclarationName ::= PackageComment package Name"); } //$NON-NLS-1$
5055
consumePackageDeclarationName();
5056            break;
5057 
5058    case 95 : if (DEBUG) { System.out.println("PackageComment ::="); } //$NON-NLS-1$
5059
consumePackageComment();
5060            break;
5061 
5062    case 100 : if (DEBUG) { System.out.println("SingleTypeImportDeclaration ::=..."); } //$NON-NLS-1$
5063
consumeImportDeclaration();
5064            break;
5065 
5066    case 101 : if (DEBUG) { System.out.println("SingleTypeImportDeclarationName ::= import Name"); } //$NON-NLS-1$
5067
consumeSingleTypeImportDeclarationName();
5068            break;
5069 
5070    case 102 : if (DEBUG) { System.out.println("TypeImportOnDemandDeclaration ::=..."); } //$NON-NLS-1$
5071
consumeImportDeclaration();
5072            break;
5073 
5074    case 103 : if (DEBUG) { System.out.println("TypeImportOnDemandDeclarationName ::= import Name DOT..."); } //$NON-NLS-1$
5075
consumeTypeImportOnDemandDeclarationName();
5076            break;
5077 
5078     case 106 : if (DEBUG) { System.out.println("TypeDeclaration ::= SEMICOLON"); } //$NON-NLS-1$
5079
consumeEmptyTypeDeclaration();
5080            break;
5081 
5082    case 110 : if (DEBUG) { System.out.println("Modifiers ::= Modifiers Modifier"); } //$NON-NLS-1$
5083
consumeModifiers2();
5084            break;
5085 
5086    case 122 : if (DEBUG) { System.out.println("Modifier ::= Annotation"); } //$NON-NLS-1$
5087
consumeAnnotationAsModifier();
5088            break;
5089 
5090    case 123 : if (DEBUG) { System.out.println("ClassDeclaration ::= ClassHeader ClassBody"); } //$NON-NLS-1$
5091
consumeClassDeclaration();
5092            break;
5093 
5094    case 124 : if (DEBUG) { System.out.println("ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt..."); } //$NON-NLS-1$
5095
consumeClassHeader();
5096            break;
5097 
5098    case 125 : if (DEBUG) { System.out.println("ClassHeaderName ::= ClassHeaderName1 TypeParameters"); } //$NON-NLS-1$
5099
consumeTypeHeaderNameWithTypeParameters();
5100            break;
5101 
5102    case 127 : if (DEBUG) { System.out.println("ClassHeaderName1 ::= Modifiersopt class Identifier"); } //$NON-NLS-1$
5103
consumeClassHeaderName1();
5104            break;
5105 
5106    case 128 : if (DEBUG) { System.out.println("ClassHeaderExtends ::= extends ClassType"); } //$NON-NLS-1$
5107
consumeClassHeaderExtends();
5108            break;
5109 
5110    case 129 : if (DEBUG) { System.out.println("ClassHeaderImplements ::= implements InterfaceTypeList"); } //$NON-NLS-1$
5111
consumeClassHeaderImplements();
5112            break;
5113 
5114    case 131 : if (DEBUG) { System.out.println("InterfaceTypeList ::= InterfaceTypeList COMMA..."); } //$NON-NLS-1$
5115
consumeInterfaceTypeList();
5116            break;
5117 
5118    case 132 : if (DEBUG) { System.out.println("InterfaceType ::= ClassOrInterfaceType"); } //$NON-NLS-1$
5119
consumeInterfaceType();
5120            break;
5121 
5122    case 135 : if (DEBUG) { System.out.println("ClassBodyDeclarations ::= ClassBodyDeclarations..."); } //$NON-NLS-1$
5123
consumeClassBodyDeclarations();
5124            break;
5125 
5126    case 139 : if (DEBUG) { System.out.println("ClassBodyDeclaration ::= Diet NestedMethod Block"); } //$NON-NLS-1$
5127
consumeClassBodyDeclaration();
5128            break;
5129 
5130    case 140 : if (DEBUG) { System.out.println("Diet ::="); } //$NON-NLS-1$
5131
consumeDiet();
5132            break;
5133
5134    case 141 : if (DEBUG) { System.out.println("Initializer ::= Diet NestedMethod Block"); } //$NON-NLS-1$
5135
consumeClassBodyDeclaration();
5136            break;
5137 
5138    case 148 : if (DEBUG) { System.out.println("ClassMemberDeclaration ::= SEMICOLON"); } //$NON-NLS-1$
5139
consumeEmptyTypeDeclaration();
5140            break;
5141
5142    case 151 : if (DEBUG) { System.out.println("FieldDeclaration ::= Modifiersopt Type..."); } //$NON-NLS-1$
5143
consumeFieldDeclaration();
5144            break;
5145 
5146    case 153 : if (DEBUG) { System.out.println("VariableDeclarators ::= VariableDeclarators COMMA..."); } //$NON-NLS-1$
5147
consumeVariableDeclarators();
5148            break;
5149 
5150    case 156 : if (DEBUG) { System.out.println("EnterVariable ::="); } //$NON-NLS-1$
5151
consumeEnterVariable();
5152            break;
5153 
5154    case 157 : if (DEBUG) { System.out.println("ExitVariableWithInitialization ::="); } //$NON-NLS-1$
5155
consumeExitVariableWithInitialization();
5156            break;
5157 
5158    case 158 : if (DEBUG) { System.out.println("ExitVariableWithoutInitialization ::="); } //$NON-NLS-1$
5159
consumeExitVariableWithoutInitialization();
5160            break;
5161 
5162    case 159 : if (DEBUG) { System.out.println("ForceNoDiet ::="); } //$NON-NLS-1$
5163
consumeForceNoDiet();
5164            break;
5165 
5166    case 160 : if (DEBUG) { System.out.println("RestoreDiet ::="); } //$NON-NLS-1$
5167
consumeRestoreDiet();
5168            break;
5169 
5170    case 165 : if (DEBUG) { System.out.println("MethodDeclaration ::= MethodHeader MethodBody"); } //$NON-NLS-1$
5171
// set to true to consume a method with a body
5172
consumeMethodDeclaration(true);
5173            break;
5174 
5175    case 166 : if (DEBUG) { System.out.println("AbstractMethodDeclaration ::= MethodHeader SEMICOLON"); } //$NON-NLS-1$
5176
// set to false to consume a method without body
5177
consumeMethodDeclaration(false);
5178            break;
5179 
5180    case 167 : if (DEBUG) { System.out.println("MethodHeader ::= MethodHeaderName FormalParameterListopt"); } //$NON-NLS-1$
5181
consumeMethodHeader();
5182            break;
5183 
5184    case 168 : if (DEBUG) { System.out.println("MethodHeaderName ::= Modifiersopt TypeParameters Type..."); } //$NON-NLS-1$
5185
consumeMethodHeaderNameWithTypeParameters(false);
5186            break;
5187 
5188    case 169 : if (DEBUG) { System.out.println("MethodHeaderName ::= Modifiersopt Type Identifier LPAREN"); } //$NON-NLS-1$
5189
consumeMethodHeaderName(false);
5190            break;
5191 
5192    case 170 : if (DEBUG) { System.out.println("MethodHeaderRightParen ::= RPAREN"); } //$NON-NLS-1$
5193
consumeMethodHeaderRightParen();
5194            break;
5195 
5196    case 171 : if (DEBUG) { System.out.println("MethodHeaderExtendedDims ::= Dimsopt"); } //$NON-NLS-1$
5197
consumeMethodHeaderExtendedDims();
5198            break;
5199 
5200    case 172 : if (DEBUG) { System.out.println("MethodHeaderThrowsClause ::= throws ClassTypeList"); } //$NON-NLS-1$
5201
consumeMethodHeaderThrowsClause();
5202            break;
5203 
5204    case 173 : if (DEBUG) { System.out.println("ConstructorHeader ::= ConstructorHeaderName..."); } //$NON-NLS-1$
5205
consumeConstructorHeader();
5206            break;
5207 
5208    case 174 : if (DEBUG) { System.out.println("ConstructorHeaderName ::= Modifiersopt TypeParameters..."); } //$NON-NLS-1$
5209
consumeConstructorHeaderNameWithTypeParameters();
5210            break;
5211 
5212    case 175 : if (DEBUG) { System.out.println("ConstructorHeaderName ::= Modifiersopt Identifier LPAREN"); } //$NON-NLS-1$
5213
consumeConstructorHeaderName();
5214            break;
5215 
5216    case 177 : if (DEBUG) { System.out.println("FormalParameterList ::= FormalParameterList COMMA..."); } //$NON-NLS-1$
5217
consumeFormalParameterList();
5218            break;
5219 
5220    case 178 : if (DEBUG) { System.out.println("FormalParameter ::= Modifiersopt Type..."); } //$NON-NLS-1$
5221
consumeFormalParameter(false);
5222            break;
5223 
5224    case 179 : if (DEBUG) { System.out.println("FormalParameter ::= Modifiersopt Type ELLIPSIS..."); } //$NON-NLS-1$
5225
consumeFormalParameter(true);
5226            break;
5227 
5228    case 181 : if (DEBUG) { System.out.println("ClassTypeList ::= ClassTypeList COMMA ClassTypeElt"); } //$NON-NLS-1$
5229
consumeClassTypeList();
5230            break;
5231 
5232    case 182 : if (DEBUG) { System.out.println("ClassTypeElt ::= ClassType"); } //$NON-NLS-1$
5233
consumeClassTypeElt();
5234            break;
5235 
5236    case 183 : if (DEBUG) { System.out.println("MethodBody ::= NestedMethod LBRACE BlockStatementsopt..."); } //$NON-NLS-1$
5237
consumeMethodBody();
5238            break;
5239 
5240    case 184 : if (DEBUG) { System.out.println("NestedMethod ::="); } //$NON-NLS-1$
5241
consumeNestedMethod();
5242            break;
5243 
5244    case 185 : if (DEBUG) { System.out.println("StaticInitializer ::= StaticOnly Block"); } //$NON-NLS-1$
5245
consumeStaticInitializer();
5246            break;
5247
5248    case 186 : if (DEBUG) { System.out.println("StaticOnly ::= static"); } //$NON-NLS-1$
5249
consumeStaticOnly();
5250            break;
5251 
5252    case 187 : if (DEBUG) { System.out.println("ConstructorDeclaration ::= ConstructorHeader MethodBody"); } //$NON-NLS-1$
5253
consumeConstructorDeclaration() ;
5254            break;
5255 
5256    case 188 : if (DEBUG) { System.out.println("ConstructorDeclaration ::= ConstructorHeader SEMICOLON"); } //$NON-NLS-1$
5257
consumeInvalidConstructorDeclaration() ;
5258            break;
5259 
5260    case 189 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= this LPAREN..."); } //$NON-NLS-1$
5261
consumeExplicitConstructorInvocation(0, THIS_CALL);
5262            break;
5263 
5264    case 190 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= OnlyTypeArguments this"); } //$NON-NLS-1$
5265
consumeExplicitConstructorInvocationWithTypeArguments(0,THIS_CALL);
5266            break;
5267 
5268    case 191 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= super LPAREN..."); } //$NON-NLS-1$
5269
consumeExplicitConstructorInvocation(0,SUPER_CALL);
5270            break;
5271 
5272    case 192 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= OnlyTypeArguments..."); } //$NON-NLS-1$
5273
consumeExplicitConstructorInvocationWithTypeArguments(0,SUPER_CALL);
5274            break;
5275 
5276    case 193 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT super..."); } //$NON-NLS-1$
5277
consumeExplicitConstructorInvocation(1, SUPER_CALL);
5278            break;
5279 
5280    case 194 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT..."); } //$NON-NLS-1$
5281
consumeExplicitConstructorInvocationWithTypeArguments(1, SUPER_CALL);
5282            break;
5283 
5284    case 195 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT super LPAREN"); } //$NON-NLS-1$
5285
consumeExplicitConstructorInvocation(2, SUPER_CALL);
5286            break;
5287 
5288    case 196 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT..."); } //$NON-NLS-1$
5289
consumeExplicitConstructorInvocationWithTypeArguments(2, SUPER_CALL);
5290            break;
5291 
5292    case 197 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT this..."); } //$NON-NLS-1$
5293
consumeExplicitConstructorInvocation(1, THIS_CALL);
5294            break;
5295 
5296    case 198 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT..."); } //$NON-NLS-1$
5297
consumeExplicitConstructorInvocationWithTypeArguments(1, THIS_CALL);
5298            break;
5299 
5300    case 199 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT this LPAREN"); } //$NON-NLS-1$
5301
consumeExplicitConstructorInvocation(2, THIS_CALL);
5302            break;
5303 
5304    case 200 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT..."); } //$NON-NLS-1$
5305
consumeExplicitConstructorInvocationWithTypeArguments(2, THIS_CALL);
5306            break;
5307 
5308    case 201 : if (DEBUG) { System.out.println("InterfaceDeclaration ::= InterfaceHeader InterfaceBody"); } //$NON-NLS-1$
5309
consumeInterfaceDeclaration();
5310            break;
5311 
5312    case 202 : if (DEBUG) { System.out.println("InterfaceHeader ::= InterfaceHeaderName..."); } //$NON-NLS-1$
5313
consumeInterfaceHeader();
5314            break;
5315 
5316    case 203 : if (DEBUG) { System.out.println("InterfaceHeaderName ::= InterfaceHeaderName1..."); } //$NON-NLS-1$
5317
consumeTypeHeaderNameWithTypeParameters();
5318            break;
5319 
5320    case 205 : if (DEBUG) { System.out.println("InterfaceHeaderName1 ::= Modifiersopt interface..."); } //$NON-NLS-1$
5321
consumeInterfaceHeaderName1();
5322            break;
5323 
5324    case 206 : if (DEBUG) { System.out.println("InterfaceHeaderExtends ::= extends InterfaceTypeList"); } //$NON-NLS-1$
5325
consumeInterfaceHeaderExtends();
5326            break;
5327 
5328    case 209 : if (DEBUG) { System.out.println("InterfaceMemberDeclarations ::=..."); } //$NON-NLS-1$
5329
consumeInterfaceMemberDeclarations();
5330            break;
5331 
5332    case 210 : if (DEBUG) { System.out.println("InterfaceMemberDeclaration ::= SEMICOLON"); } //$NON-NLS-1$
5333
consumeEmptyTypeDeclaration();
5334            break;
5335 
5336    case 212 : if (DEBUG) { System.out.println("InterfaceMemberDeclaration ::= MethodHeader MethodBody"); } //$NON-NLS-1$
5337
consumeInvalidMethodDeclaration();
5338            break;
5339 
5340    case 213 : if (DEBUG) { System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader..."); } //$NON-NLS-1$
5341
consumeInvalidConstructorDeclaration(true);
5342            break;
5343 
5344    case 214 : if (DEBUG) { System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader..."); } //$NON-NLS-1$
5345
consumeInvalidConstructorDeclaration(false);
5346            break;
5347 
5348    case 222 : if (DEBUG) { System.out.println("PushLeftBrace ::="); } //$NON-NLS-1$
5349
consumePushLeftBrace();
5350            break;
5351 
5352    case 223 : if (DEBUG) { System.out.println("ArrayInitializer ::= LBRACE PushLeftBrace ,opt RBRACE"); } //$NON-NLS-1$
5353
consumeEmptyArrayInitializer();
5354            break;
5355 
5356    case 224 : if (DEBUG) { System.out.println("ArrayInitializer ::= LBRACE PushLeftBrace..."); } //$NON-NLS-1$
5357
consumeArrayInitializer();
5358            break;
5359 
5360    case 225 : if (DEBUG) { System.out.println("ArrayInitializer ::= LBRACE PushLeftBrace..."); } //$NON-NLS-1$
5361
consumeArrayInitializer();
5362            break;
5363 
5364    case 227 : if (DEBUG) { System.out.println("VariableInitializers ::= VariableInitializers COMMA..."); } //$NON-NLS-1$
5365
consumeVariableInitializers();
5366            break;
5367 
5368    case 228 : if (DEBUG) { System.out.println("Block ::= OpenBlock LBRACE BlockStatementsopt RBRACE"); } //$NON-NLS-1$
5369
consumeBlock();
5370            break;
5371 
5372    case 229 : if (DEBUG) { System.out.println("OpenBlock ::="); } //$NON-NLS-1$
5373
consumeOpenBlock() ;
5374            break;
5375 
5376    case 231 : if (DEBUG) { System.out.println("BlockStatements ::= BlockStatements BlockStatement"); } //$NON-NLS-1$
5377
consumeBlockStatements() ;
5378            break;
5379 
5380    case 235 : if (DEBUG) { System.out.println("BlockStatement ::= InterfaceDeclaration"); } //$NON-NLS-1$
5381
consumeInvalidInterfaceDeclaration();
5382            break;
5383 
5384    case 236 : if (DEBUG) { System.out.println("BlockStatement ::= AnnotationTypeDeclaration"); } //$NON-NLS-1$
5385
consumeInvalidAnnotationTypeDeclaration();
5386            break;
5387 
5388    case 237 : if (DEBUG) { System.out.println("BlockStatement ::= EnumDeclaration"); } //$NON-NLS-1$
5389
consumeInvalidEnumDeclaration();
5390            break;
5391 
5392    case 238 : if (DEBUG) { System.out.println("LocalVariableDeclarationStatement ::=..."); } //$NON-NLS-1$
5393
consumeLocalVariableDeclarationStatement();
5394            break;
5395 
5396    case 239 : if (DEBUG) { System.out.println("LocalVariableDeclaration ::= Type PushModifiers..."); } //$NON-NLS-1$
5397
consumeLocalVariableDeclaration();
5398            break;
5399 
5400    case 240 : if (DEBUG) { System.out.println("LocalVariableDeclaration ::= Modifiers Type..."); } //$NON-NLS-1$
5401
consumeLocalVariableDeclaration();
5402            break;
5403 
5404    case 241 : if (DEBUG) { System.out.println("PushModifiers ::="); } //$NON-NLS-1$
5405
consumePushModifiers();
5406            break;
5407 
5408    case 242 : if (DEBUG) { System.out.println("PushModifiersForHeader ::="); } //$NON-NLS-1$
5409
consumePushModifiersForHeader();
5410            break;
5411 
5412    case 243 : if (DEBUG) { System.out.println("PushRealModifiers ::="); } //$NON-NLS-1$
5413
consumePushRealModifiers();
5414            break;
5415 
5416    case 269 : if (DEBUG) { System.out.println("EmptyStatement ::= SEMICOLON"); } //$NON-NLS-1$
5417
consumeEmptyStatement();
5418            break;
5419 
5420    case 270 : if (DEBUG) { System.out.println("LabeledStatement ::= Label COLON Statement"); } //$NON-NLS-1$
5421
consumeStatementLabel() ;
5422            break;
5423 
5424    case 271 : if (DEBUG) { System.out.println("LabeledStatementNoShortIf ::= Label COLON..."); } //$NON-NLS-1$
5425
consumeStatementLabel() ;
5426            break;
5427 
5428    case 272 : if (DEBUG) { System.out.println("Label ::= Identifier"); } //$NON-NLS-1$
5429
consumeLabel() ;
5430            break;
5431 
5432     case 273 : if (DEBUG) { System.out.println("ExpressionStatement ::= StatementExpression SEMICOLON"); } //$NON-NLS-1$
5433
consumeExpressionStatement();
5434            break;
5435 
5436    case 282 : if (DEBUG) { System.out.println("IfThenStatement ::= if LPAREN Expression RPAREN..."); } //$NON-NLS-1$
5437
consumeStatementIfNoElse();
5438            break;
5439 
5440    case 283 : if (DEBUG) { System.out.println("IfThenElseStatement ::= if LPAREN Expression RPAREN..."); } //$NON-NLS-1$
5441
consumeStatementIfWithElse();
5442            break;
5443 
5444    case 284 : if (DEBUG) { System.out.println("IfThenElseStatementNoShortIf ::= if LPAREN Expression..."); } //$NON-NLS-1$
5445
consumeStatementIfWithElse();
5446            break;
5447 
5448    case 285 : if (DEBUG) { System.out.println("SwitchStatement ::= switch LPAREN Expression RPAREN..."); } //$NON-NLS-1$
5449
consumeStatementSwitch() ;
5450            break;
5451 
5452    case 286 : if (DEBUG) { System.out.println("SwitchBlock ::= LBRACE RBRACE"); } //$NON-NLS-1$
5453
consumeEmptySwitchBlock() ;
5454            break;
5455 
5456    case 289 : if (DEBUG) { System.out.println("SwitchBlock ::= LBRACE SwitchBlockStatements..."); } //$NON-NLS-1$
5457
consumeSwitchBlock() ;
5458            break;
5459 
5460    case 291 : if (DEBUG) { System.out.println("SwitchBlockStatements ::= SwitchBlockStatements..."); } //$NON-NLS-1$
5461
consumeSwitchBlockStatements() ;
5462            break;
5463 
5464    case 292 : if (DEBUG) { System.out.println("SwitchBlockStatement ::= SwitchLabels BlockStatements"); } //$NON-NLS-1$
5465
consumeSwitchBlockStatement() ;
5466            break;
5467 
5468    case 294 : if (DEBUG) { System.out.println("SwitchLabels ::= SwitchLabels SwitchLabel"); } //$NON-NLS-1$
5469
consumeSwitchLabels() ;
5470            break;
5471 
5472     case 295 : if (DEBUG) { System.out.println("SwitchLabel ::= case ConstantExpression COLON"); } //$NON-NLS-1$
5473
consumeCaseLabel();
5474            break;
5475 
5476     case 296 : if (DEBUG) { System.out.println("SwitchLabel ::= default COLON"); } //$NON-NLS-1$
5477
consumeDefaultLabel();
5478            break;
5479 
5480    case 297 : if (DEBUG) { System.out.println("WhileStatement ::= while LPAREN Expression RPAREN..."); } //$NON-NLS-1$
5481
consumeStatementWhile() ;
5482            break;
5483 
5484    case 298 : if (DEBUG) { System.out.println("WhileStatementNoShortIf ::= while LPAREN Expression..."); } //$NON-NLS-1$
5485
consumeStatementWhile() ;
5486            break;
5487 
5488    case 299 : if (DEBUG) { System.out.println("DoStatement ::= do Statement while LPAREN Expression..."); } //$NON-NLS-1$
5489
consumeStatementDo() ;
5490            break;
5491 
5492    case 300 : if (DEBUG) { System.out.println("ForStatement ::= for LPAREN ForInitopt SEMICOLON..."); } //$NON-NLS-1$
5493
consumeStatementFor() ;
5494            break;
5495 
5496    case 301 : if (DEBUG) { System.out.println("ForStatementNoShortIf ::= for LPAREN ForInitopt..."); } //$NON-NLS-1$
5497
consumeStatementFor() ;
5498            break;
5499 
5500    case 302 : if (DEBUG) { System.out.println("ForInit ::= StatementExpressionList"); } //$NON-NLS-1$
5501
consumeForInit() ;
5502            break;
5503 
5504    case 306 : if (DEBUG) { System.out.println("StatementExpressionList ::= StatementExpressionList..."); } //$NON-NLS-1$
5505
consumeStatementExpressionList() ;
5506            break;
5507 
5508    case 307 : if (DEBUG) { System.out.println("AssertStatement ::= assert Expression SEMICOLON"); } //$NON-NLS-1$
5509
consumeSimpleAssertStatement() ;
5510            break;
5511 
5512    case 308 : if (DEBUG) { System.out.println("AssertStatement ::= assert Expression COLON Expression"); } //$NON-NLS-1$
5513
consumeAssertStatement() ;
5514            break;
5515 
5516    case 309 : if (DEBUG) { System.out.println("BreakStatement ::= break SEMICOLON"); } //$NON-NLS-1$
5517
consumeStatementBreak() ;
5518            break;
5519 
5520    case 310 : if (DEBUG) { System.out.println("BreakStatement ::= break Identifier SEMICOLON"); } //$NON-NLS-1$
5521
consumeStatementBreakWithLabel() ;
5522            break;
5523 
5524    case 311 : if (DEBUG) { System.out.println("ContinueStatement ::= continue SEMICOLON"); } //$NON-NLS-1$
5525
consumeStatementContinue() ;
5526            break;
5527 
5528    case 312 : if (DEBUG) { System.out.println("ContinueStatement ::= continue Identifier SEMICOLON"); } //$NON-NLS-1$
5529
consumeStatementContinueWithLabel() ;
5530            break;
5531 
5532    case 313 : if (DEBUG) { System.out.println("ReturnStatement ::= return Expressionopt SEMICOLON"); } //$NON-NLS-1$
5533
consumeStatementReturn() ;
5534            break;
5535 
5536    case 314 : if (DEBUG) { System.out.println("ThrowStatement ::= throw Expression SEMICOLON"); } //$NON-NLS-1$
5537
consumeStatementThrow();
5538            break;
5539 
5540    case 315 : if (DEBUG) { System.out.println("SynchronizedStatement ::= OnlySynchronized LPAREN..."); } //$NON-NLS-1$
5541
consumeStatementSynchronized();
5542            break;
5543 
5544    case 316 : if (DEBUG) { System.out.println("OnlySynchronized ::= synchronized"); } //$NON-NLS-1$
5545
consumeOnlySynchronized();
5546            break;
5547 
5548    case 317 : if (DEBUG) { System.out.println("TryStatement ::= try TryBlock Catches"); } //$NON-NLS-1$
5549
consumeStatementTry(false);
5550            break;
5551 
5552    case 318 : if (DEBUG) { System.out.println("TryStatement ::= try TryBlock Catchesopt Finally"); } //$NON-NLS-1$
5553
consumeStatementTry(true);
5554            break;
5555 
5556    case 320 : if (DEBUG) { System.out.println("ExitTryBlock ::="); } //$NON-NLS-1$
5557
consumeExitTryBlock();
5558            break;
5559 
5560    case 322 : if (DEBUG) { System.out.println("Catches ::= Catches CatchClause"); } //$NON-NLS-1$
5561
consumeCatches();
5562            break;
5563 
5564    case 323 : if (DEBUG) { System.out.println("CatchClause ::= catch LPAREN FormalParameter RPAREN..."); } //$NON-NLS-1$
5565
consumeStatementCatch() ;
5566            break;
5567 
5568    case 325 : if (DEBUG) { System.out.println("PushLPAREN ::= LPAREN"); } //$NON-NLS-1$
5569
consumeLeftParen();
5570            break;
5571 
5572    case 326 : if (DEBUG) { System.out.println("PushRPAREN ::= RPAREN"); } //$NON-NLS-1$
5573
consumeRightParen();
5574            break;
5575 
5576    case 331 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= this"); } //$NON-NLS-1$
5577
consumePrimaryNoNewArrayThis();
5578            break;
5579 
5580    case 332 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PushLPAREN Expression_NotName..."); } //$NON-NLS-1$
5581
consumePrimaryNoNewArray();
5582            break;
5583 
5584    case 333 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PushLPAREN Name PushRPAREN"); } //$NON-NLS-1$
5585
consumePrimaryNoNewArrayWithName();
5586            break;
5587 
5588    case 336 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name DOT this"); } //$NON-NLS-1$
5589
consumePrimaryNoNewArrayNameThis();
5590            break;
5591 
5592    case 337 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name DOT super"); } //$NON-NLS-1$
5593
consumePrimaryNoNewArrayNameSuper();
5594            break;
5595 
5596    case 338 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name DOT class"); } //$NON-NLS-1$
5597
consumePrimaryNoNewArrayName();
5598            break;
5599 
5600    case 339 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name Dims DOT class"); } //$NON-NLS-1$
5601
consumePrimaryNoNewArrayArrayType();
5602            break;
5603 
5604    case 340 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PrimitiveType Dims DOT class"); } //$NON-NLS-1$
5605
consumePrimaryNoNewArrayPrimitiveArrayType();
5606            break;
5607 
5608    case 341 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PrimitiveType DOT class"); } //$NON-NLS-1$
5609
consumePrimaryNoNewArrayPrimitiveType();
5610            break;
5611 
5612    case 344 : if (DEBUG) { System.out.println("AllocationHeader ::= new ClassType LPAREN..."); } //$NON-NLS-1$
5613
consumeAllocationHeader();
5614            break;
5615 
5616    case 345 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= new..."); } //$NON-NLS-1$
5617
consumeClassInstanceCreationExpressionWithTypeArguments();
5618            break;
5619 
5620    case 346 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= new ClassType LPAREN"); } //$NON-NLS-1$
5621
consumeClassInstanceCreationExpression();
5622            break;
5623 
5624    case 347 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= Primary DOT new..."); } //$NON-NLS-1$
5625
consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() ;
5626            break;
5627 
5628    case 348 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= Primary DOT new..."); } //$NON-NLS-1$
5629
consumeClassInstanceCreationExpressionQualified() ;
5630            break;
5631 
5632    case 349 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::=..."); } //$NON-NLS-1$
5633
consumeClassInstanceCreationExpressionQualified() ;
5634            break;
5635 
5636    case 350 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::=..."); } //$NON-NLS-1$
5637
consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() ;
5638            break;
5639 
5640    case 351 : if (DEBUG) { System.out.println("ClassInstanceCreationExpressionName ::= Name DOT"); } //$NON-NLS-1$
5641
consumeClassInstanceCreationExpressionName() ;
5642            break;
5643 
5644    case 352 : if (DEBUG) { System.out.println("ClassBodyopt ::="); } //$NON-NLS-1$
5645
consumeClassBodyopt();
5646            break;
5647 
5648    case 354 : if (DEBUG) { System.out.println("EnterAnonymousClassBody ::="); } //$NON-NLS-1$
5649
consumeEnterAnonymousClassBody();
5650            break;
5651 
5652    case 356 : if (DEBUG) { System.out.println("ArgumentList ::= ArgumentList COMMA Expression"); } //$NON-NLS-1$
5653
consumeArgumentList();
5654            break;
5655 
5656    case 357 : if (DEBUG) { System.out.println("ArrayCreationHeader ::= new PrimitiveType..."); } //$NON-NLS-1$
5657
consumeArrayCreationHeader();
5658            break;
5659 
5660    case 358 : if (DEBUG) { System.out.println("ArrayCreationHeader ::= new ClassOrInterfaceType..."); } //$NON-NLS-1$
5661
consumeArrayCreationHeader();
5662            break;
5663 
5664    case 359 : if (DEBUG) { System.out.println("ArrayCreationWithoutArrayInitializer ::= new..."); } //$NON-NLS-1$
5665
consumeArrayCreationExpressionWithoutInitializer();
5666            break;
5667 
5668    case 360 : if (DEBUG) { System.out.println("ArrayCreationWithArrayInitializer ::= new PrimitiveType"); } //$NON-NLS-1$
5669
consumeArrayCreationExpressionWithInitializer();
5670            break;
5671 
5672    case 361 : if (DEBUG) { System.out.println("ArrayCreationWithoutArrayInitializer ::= new..."); } //$NON-NLS-1$
5673
consumeArrayCreationExpressionWithoutInitializer();
5674            break;
5675 
5676    case 362 : if (DEBUG) { System.out.println("ArrayCreationWithArrayInitializer ::= new..."); } //$NON-NLS-1$
5677
consumeArrayCreationExpressionWithInitializer();
5678            break;
5679 
5680    case 364 : if (DEBUG) { System.out.println("DimWithOrWithOutExprs ::= DimWithOrWithOutExprs..."); } //$NON-NLS-1$
5681
consumeDimWithOrWithOutExprs();
5682            break;
5683 
5684     case 366 : if (DEBUG) { System.out.println("DimWithOrWithOutExpr ::= LBRACKET RBRACKET"); } //$NON-NLS-1$
5685
consumeDimWithOrWithOutExpr();
5686            break;
5687 
5688     case 367 : if (DEBUG) { System.out.println("Dims ::= DimsLoop"); } //$NON-NLS-1$
5689
consumeDims();
5690            break;
5691 
5692     case 370 : if (DEBUG) { System.out.println("OneDimLoop ::= LBRACKET RBRACKET"); } //$NON-NLS-1$
5693
consumeOneDimLoop();
5694            break;
5695 
5696    case 371 : if (DEBUG) { System.out.println("FieldAccess ::= Primary DOT Identifier"); } //$NON-NLS-1$
5697
consumeFieldAccess(false);
5698            break;
5699 
5700    case 372 : if (DEBUG) { System.out.println("FieldAccess ::= super DOT Identifier"); } //$NON-NLS-1$
5701
consumeFieldAccess(true);
5702            break;
5703 
5704    case 373 : if (DEBUG) { System.out.println("MethodInvocation ::= Name LPAREN ArgumentListopt RPAREN"); } //$NON-NLS-1$
5705
consumeMethodInvocationName();
5706            break;
5707 
5708    case 374 : if (DEBUG) { System.out.println("MethodInvocation ::= Name DOT OnlyTypeArguments..."); } //$NON-NLS-1$
5709
consumeMethodInvocationNameWithTypeArguments();
5710            break;
5711 
5712    case 375 : if (DEBUG) { System.out.println("MethodInvocation ::= Primary DOT OnlyTypeArguments..."); } //$NON-NLS-1$
5713
consumeMethodInvocationPrimaryWithTypeArguments();
5714            break;
5715 
5716    case 376 : if (DEBUG) { System.out.println("MethodInvocation ::= Primary DOT Identifier LPAREN..."); } //$NON-NLS-1$
5717
consumeMethodInvocationPrimary();
5718            break;
5719 
5720    case 377 : if (DEBUG) { System.out.println("MethodInvocation ::= super DOT OnlyTypeArguments..."); } //$NON-NLS-1$
5721
consumeMethodInvocationSuperWithTypeArguments();
5722            break;
5723 
5724    case 378 : if (DEBUG) { System.out.println("MethodInvocation ::= super DOT Identifier LPAREN..."); } //$NON-NLS-1$
5725
consumeMethodInvocationSuper();
5726            break;
5727 
5728    case 379 : if (DEBUG) { System.out.println("ArrayAccess ::= Name LBRACKET Expression RBRACKET"); } //$NON-NLS-1$
5729
consumeArrayAccess(true);
5730            break;
5731 
5732    case 380 : if (DEBUG) { System.out.println("ArrayAccess ::= PrimaryNoNewArray LBRACKET Expression..."); } //$NON-NLS-1$
5733
consumeArrayAccess(false);
5734            break;
5735 
5736    case 381 : if (DEBUG) { System.out.println("ArrayAccess ::= ArrayCreationWithArrayInitializer..."); } //$NON-NLS-1$
5737
consumeArrayAccess(false);
5738            break;
5739 
5740    case 383 : if (DEBUG) { System.out.println("PostfixExpression ::= Name"); } //$NON-NLS-1$
5741
consumePostfixExpression();
5742            break;
5743 
5744    case 386 : if (DEBUG) { System.out.println("PostIncrementExpression ::= PostfixExpression PLUS_PLUS"); } //$NON-NLS-1$
5745
consumeUnaryExpression(OperatorIds.PLUS,true);
5746            break;
5747 
5748    case 387 : if (DEBUG) { System.out.println("PostDecrementExpression ::= PostfixExpression..."); } //$NON-NLS-1$
5749
consumeUnaryExpression(OperatorIds.MINUS,true);
5750            break;
5751 
5752    case 388 : if (DEBUG) { System.out.println("PushPosition ::="); } //$NON-NLS-1$
5753
consumePushPosition();
5754            break;
5755 
5756    case 391 : if (DEBUG) { System.out.println("UnaryExpression ::= PLUS PushPosition UnaryExpression"); } //$NON-NLS-1$
5757
consumeUnaryExpression(OperatorIds.PLUS);
5758            break;
5759 
5760    case 392 : if (DEBUG) { System.out.println("UnaryExpression ::= MINUS PushPosition UnaryExpression"); } //$NON-NLS-1$
5761
consumeUnaryExpression(OperatorIds.MINUS);
5762            break;
5763 
5764    case 394 : if (DEBUG) { System.out.println("PreIncrementExpression ::= PLUS_PLUS PushPosition..."); } //$NON-NLS-1$
5765
consumeUnaryExpression(OperatorIds.PLUS,false);
5766            break;
5767 
5768    case 395 : if (DEBUG) { System.out.println("PreDecrementExpression ::= MINUS_MINUS PushPosition..."); } //$NON-NLS-1$
5769
consumeUnaryExpression(OperatorIds.MINUS,false);
5770            break;
5771 
5772    case 397 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus ::= TWIDDLE PushPosition..."); } //$NON-NLS-1$
5773
consumeUnaryExpression(OperatorIds.TWIDDLE);
5774            break;
5775 
5776    case 398 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus ::= NOT PushPosition..."); } //$NON-NLS-1$
5777
consumeUnaryExpression(OperatorIds.NOT);
5778            break;
5779 
5780    case 400 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN PrimitiveType Dimsopt..."); } //$NON-NLS-1$
5781
consumeCastExpressionWithPrimitiveType();
5782            break;
5783 
5784    case 401 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name..."); } //$NON-NLS-1$
5785
consumeCastExpressionWithGenericsArray();
5786            break;
5787 
5788    case 402 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name..."); } //$NON-NLS-1$
5789
consumeCastExpressionWithQualifiedGenericsArray();
5790            break;
5791 
5792    case 403 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name PushRPAREN..."); } //$NON-NLS-1$
5793
consumeCastExpressionLL1();
5794            break;
5795 
5796    case 404 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name Dims PushRPAREN..."); } //$NON-NLS-1$
5797
consumeCastExpressionWithNameArray();
5798            break;
5799 
5800    case 405 : if (DEBUG) { System.out.println("OnlyTypeArgumentsForCastExpression ::= OnlyTypeArguments"); } //$NON-NLS-1$
5801
consumeOnlyTypeArgumentsForCastExpression();
5802            break;
5803 
5804    case 406 : if (DEBUG) { System.out.println("InsideCastExpression ::="); } //$NON-NLS-1$
5805
consumeInsideCastExpression();
5806            break;
5807 
5808    case 407 : if (DEBUG) { System.out.println("InsideCastExpressionLL1 ::="); } //$NON-NLS-1$
5809
consumeInsideCastExpressionLL1();
5810            break;
5811 
5812    case 408 : if (DEBUG) { System.out.println("InsideCastExpressionWithQualifiedGenerics ::="); } //$NON-NLS-1$
5813
consumeInsideCastExpressionWithQualifiedGenerics();
5814            break;
5815 
5816    case 410 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); } //$NON-NLS-1$
5817
consumeBinaryExpression(OperatorIds.MULTIPLY);
5818            break;
5819 
5820    case 411 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); } //$NON-NLS-1$
5821
consumeBinaryExpression(OperatorIds.DIVIDE);
5822            break;
5823 
5824    case 412 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); } //$NON-NLS-1$
5825
consumeBinaryExpression(OperatorIds.REMAINDER);
5826            break;
5827 
5828    case 414 : if (DEBUG) { System.out.println("AdditiveExpression ::= AdditiveExpression PLUS..."); } //$NON-NLS-1$
5829
consumeBinaryExpression(OperatorIds.PLUS);
5830            break;
5831 
5832    case 415 : if (DEBUG) { System.out.println("AdditiveExpression ::= AdditiveExpression MINUS..."); } //$NON-NLS-1$
5833
consumeBinaryExpression(OperatorIds.MINUS);
5834            break;
5835 
5836    case 417 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression LEFT_SHIFT..."); } //$NON-NLS-1$
5837
consumeBinaryExpression(OperatorIds.LEFT_SHIFT);
5838            break;
5839 
5840    case 418 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression RIGHT_SHIFT..."); } //$NON-NLS-1$
5841
consumeBinaryExpression(OperatorIds.RIGHT_SHIFT);
5842            break;
5843 
5844    case 419 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression UNSIGNED_RIGHT_SHIFT"); } //$NON-NLS-1$
5845
consumeBinaryExpression(OperatorIds.UNSIGNED_RIGHT_SHIFT);
5846            break;
5847 
5848    case 421 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression LESS..."); } //$NON-NLS-1$
5849
consumeBinaryExpression(OperatorIds.LESS);
5850            break;
5851 
5852    case 422 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression GREATER..."); } //$NON-NLS-1$
5853
consumeBinaryExpression(OperatorIds.GREATER);
5854            break;
5855 
5856    case 423 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression LESS_EQUAL"); } //$NON-NLS-1$
5857
consumeBinaryExpression(OperatorIds.LESS_EQUAL);
5858            break;
5859 
5860    case 424 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression..."); } //$NON-NLS-1$
5861
consumeBinaryExpression(OperatorIds.GREATER_EQUAL);
5862            break;
5863 
5864    case 426 : if (DEBUG) { System.out.println("InstanceofExpression ::= InstanceofExpression instanceof"); } //$NON-NLS-1$
5865
consumeInstanceOfExpression();
5866            break;
5867 
5868    case 428 : if (DEBUG) { System.out.println("EqualityExpression ::= EqualityExpression EQUAL_EQUAL..."); } //$NON-NLS-1$
5869
consumeEqualityExpression(OperatorIds.EQUAL_EQUAL);
5870            break;
5871 
5872    case 429 : if (DEBUG) { System.out.println("EqualityExpression ::= EqualityExpression NOT_EQUAL..."); } //$NON-NLS-1$
5873
consumeEqualityExpression(OperatorIds.NOT_EQUAL);
5874            break;
5875 
5876    case 431 : if (DEBUG) { System.out.println("AndExpression ::= AndExpression AND EqualityExpression"); } //$NON-NLS-1$
5877
consumeBinaryExpression(OperatorIds.AND);
5878            break;
5879 
5880    case 433 : if (DEBUG) { System.out.println("ExclusiveOrExpression ::= ExclusiveOrExpression XOR..."); } //$NON-NLS-1$
5881
consumeBinaryExpression(OperatorIds.XOR);
5882            break;
5883 
5884    case 435 : if (DEBUG) { System.out.println("InclusiveOrExpression ::= InclusiveOrExpression OR..."); } //$NON-NLS-1$
5885
consumeBinaryExpression(OperatorIds.OR);
5886            break;
5887 
5888    case 437 : if (DEBUG) { System.out.println("ConditionalAndExpression ::= ConditionalAndExpression..."); } //$NON-NLS-1$
5889
consumeBinaryExpression(OperatorIds.AND_AND);
5890            break;
5891 
5892    case 439 : if (DEBUG) { System.out.println("ConditionalOrExpression ::= ConditionalOrExpression..."); } //$NON-NLS-1$
5893
consumeBinaryExpression(OperatorIds.OR_OR);
5894            break;
5895 
5896    case 441 : if (DEBUG) { System.out.println("ConditionalExpression ::= ConditionalOrExpression..."); } //$NON-NLS-1$
5897
consumeConditionalExpression(OperatorIds.QUESTIONCOLON) ;
5898            break;
5899 
5900    case 444 : if (DEBUG) { System.out.println("Assignment ::= PostfixExpression AssignmentOperator..."); } //$NON-NLS-1$
5901
consumeAssignment();
5902            break;
5903 
5904    case 446 : if (DEBUG) { System.out.println("Assignment ::= InvalidArrayInitializerAssignement"); } //$NON-NLS-1$
5905
ignoreExpressionAssignment();
5906            break;
5907 
5908    case 447 : if (DEBUG) { System.out.println("AssignmentOperator ::= EQUAL"); } //$NON-NLS-1$
5909
consumeAssignmentOperator(EQUAL);
5910            break;
5911 
5912    case 448 : if (DEBUG) { System.out.println("AssignmentOperator ::= MULTIPLY_EQUAL"); } //$NON-NLS-1$
5913
consumeAssignmentOperator(MULTIPLY);
5914            break;
5915 
5916    case 449 : if (DEBUG) { System.out.println("AssignmentOperator ::= DIVIDE_EQUAL"); } //$NON-NLS-1$
5917
consumeAssignmentOperator(DIVIDE);
5918            break;
5919 
5920    case 450 : if (DEBUG) { System.out.println("AssignmentOperator ::= REMAINDER_EQUAL"); } //$NON-NLS-1$
5921
consumeAssignmentOperator(REMAINDER);
5922            break;
5923 
5924    case 451 : if (DEBUG) { System.out.println("AssignmentOperator ::= PLUS_EQUAL"); } //$NON-NLS-1$
5925
consumeAssignmentOperator(PLUS);
5926            break;
5927 
5928    case 452 : if (DEBUG) { System.out.println("AssignmentOperator ::= MINUS_EQUAL"); } //$NON-NLS-1$
5929
consumeAssignmentOperator(MINUS);
5930            break;
5931 
5932    case 453 : if (DEBUG) { System.out.println("AssignmentOperator ::= LEFT_SHIFT_EQUAL"); } //$NON-NLS-1$
5933
consumeAssignmentOperator(LEFT_SHIFT);
5934            break;
5935 
5936    case 454 : if (DEBUG) { System.out.println("AssignmentOperator ::= RIGHT_SHIFT_EQUAL"); } //$NON-NLS-1$
5937
consumeAssignmentOperator(RIGHT_SHIFT);
5938            break;
5939 
5940    case 455 : if (DEBUG) { System.out.println("AssignmentOperator ::= UNSIGNED_RIGHT_SHIFT_EQUAL"); } //$NON-NLS-1$
5941
consumeAssignmentOperator(UNSIGNED_RIGHT_SHIFT);
5942            break;
5943 
5944    case 456 : if (DEBUG) { System.out.println("AssignmentOperator ::= AND_EQUAL"); } //$NON-NLS-1$
5945
consumeAssignmentOperator(AND);
5946            break;
5947 
5948    case 457 : if (DEBUG) { System.out.println("AssignmentOperator ::= XOR_EQUAL"); } //$NON-NLS-1$
5949
consumeAssignmentOperator(XOR);
5950            break;
5951 
5952    case 458 : if (DEBUG) { System.out.println("AssignmentOperator ::= OR_EQUAL"); } //$NON-NLS-1$
5953
consumeAssignmentOperator(OR);
5954            break;
5955 
5956    case 462 : if (DEBUG) { System.out.println("Expressionopt ::="); } //$NON-NLS-1$
5957
consumeEmptyExpression();
5958            break;
5959 
5960    case 467 : if (DEBUG) { System.out.println("ClassBodyDeclarationsopt ::="); } //$NON-NLS-1$
5961
consumeEmptyClassBodyDeclarationsopt();
5962            break;
5963 
5964    case 468 : if (DEBUG) { System.out.println("ClassBodyDeclarationsopt ::= NestedType..."); } //$NON-NLS-1$
5965
consumeClassBodyDeclarationsopt();
5966            break;
5967 
5968     case 469 : if (DEBUG) { System.out.println("Modifiersopt ::="); } //$NON-NLS-1$
5969
consumeDefaultModifiers();
5970            break;
5971 
5972    case 470 : if (DEBUG) { System.out.println("Modifiersopt ::= Modifiers"); } //$NON-NLS-1$
5973
consumeModifiers();
5974            break;
5975 
5976    case 471 : if (DEBUG) { System.out.println("BlockStatementsopt ::="); } //$NON-NLS-1$
5977
consumeEmptyBlockStatementsopt();
5978            break;
5979 
5980     case 473 : if (DEBUG) { System.out.println("Dimsopt ::="); } //$NON-NLS-1$
5981
consumeEmptyDimsopt();
5982            break;
5983 
5984     case 475 : if (DEBUG) { System.out.println("ArgumentListopt ::="); } //$NON-NLS-1$
5985
consumeEmptyArgumentListopt();
5986            break;
5987 
5988    case 479 : if (DEBUG) { System.out.println("FormalParameterListopt ::="); } //$NON-NLS-1$
5989
consumeFormalParameterListopt();
5990            break;
5991 
5992     case 483 : if (DEBUG) { System.out.println("InterfaceMemberDeclarationsopt ::="); } //$NON-NLS-1$
5993
consumeEmptyInterfaceMemberDeclarationsopt();
5994            break;
5995 
5996     case 484 : if (DEBUG) { System.out.println("InterfaceMemberDeclarationsopt ::= NestedType..."); } //$NON-NLS-1$
5997
consumeInterfaceMemberDeclarationsopt();
5998            break;
5999 
6000    case 485 : if (DEBUG) { System.out.println("NestedType ::="); } //$NON-NLS-1$
6001
consumeNestedType();
6002            break;
6003
6004     case 486 : if (DEBUG) { System.out.println("ForInitopt ::="); } //$NON-NLS-1$
6005
consumeEmptyForInitopt();
6006            break;
6007 
6008     case 488 : if (DEBUG) { System.out.println("ForUpdateopt ::="); } //$NON-NLS-1$
6009
consumeEmptyForUpdateopt();
6010            break;
6011 
6012     case 492 : if (DEBUG) { System.out.println("Catchesopt ::="); } //$NON-NLS-1$
6013
consumeEmptyCatchesopt();
6014            break;
6015 
6016     case 494 : if (DEBUG) { System.out.println("EnumDeclaration ::= EnumHeader EnumBody"); } //$NON-NLS-1$
6017
consumeEnumDeclaration();
6018            break;
6019 
6020     case 495 : if (DEBUG) { System.out.println("EnumHeader ::= EnumHeaderName ClassHeaderImplementsopt"); } //$NON-NLS-1$
6021
consumeEnumHeader();
6022            break;
6023 
6024     case 496 : if (DEBUG) { System.out.println("EnumHeaderName ::= Modifiersopt enum Identifier"); } //$NON-NLS-1$
6025
consumeEnumHeaderName();
6026            break;
6027 
6028     case 497 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumBodyDeclarationsopt RBRACE"); } //$NON-NLS-1$
6029
consumeEnumBodyNoConstants();
6030            break;
6031 
6032     case 498 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE COMMA EnumBodyDeclarationsopt..."); } //$NON-NLS-1$
6033
consumeEnumBodyNoConstants();
6034            break;
6035 
6036     case 499 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumConstants COMMA..."); } //$NON-NLS-1$
6037
consumeEnumBodyWithConstants();
6038            break;
6039 
6040     case 500 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumConstants..."); } //$NON-NLS-1$
6041
consumeEnumBodyWithConstants();
6042            break;
6043 
6044    case 502 : if (DEBUG) { System.out.println("EnumConstants ::= EnumConstants COMMA EnumConstant"); } //$NON-NLS-1$
6045
consumeEnumConstants();
6046            break;
6047 
6048    case 503 : if (DEBUG) { System.out.println("EnumConstantHeaderName ::= Modifiersopt Identifier"); } //$NON-NLS-1$
6049
consumeEnumConstantHeaderName();
6050            break;
6051 
6052    case 504 : if (DEBUG) { System.out.println("EnumConstantHeader ::= EnumConstantHeaderName..."); } //$NON-NLS-1$
6053
consumeEnumConstantHeader();
6054            break;
6055 
6056    case 505 : if (DEBUG) { System.out.println("EnumConstant ::= EnumConstantHeader ForceNoDiet..."); } //$NON-NLS-1$
6057
consumeEnumConstantWithClassBody();
6058            break;
6059 
6060    case 506 : if (DEBUG) { System.out.println("EnumConstant ::= EnumConstantHeader"); } //$NON-NLS-1$
6061
consumeEnumConstantNoClassBody();
6062            break;
6063 
6064    case 507 : if (DEBUG) { System.out.println("Arguments ::= LPAREN ArgumentListopt RPAREN"); } //$NON-NLS-1$
6065
consumeArguments();
6066            break;
6067 
6068    case 508 : if (DEBUG) { System.out.println("Argumentsopt ::="); } //$NON-NLS-1$
6069
consumeEmptyArguments();
6070            break;
6071 
6072    case 510 : if (DEBUG) { System.out.println("EnumDeclarations ::= SEMICOLON ClassBodyDeclarationsopt"); } //$NON-NLS-1$
6073
consumeEnumDeclarations();
6074            break;
6075 
6076    case 511 : if (DEBUG) { System.out.println("EnumBodyDeclarationsopt ::="); } //$NON-NLS-1$
6077
consumeEmptyEnumDeclarations();
6078            break;
6079 
6080    case 513 : if (DEBUG) { System.out.println("EnhancedForStatement ::= EnhancedForStatementHeader..."); } //$NON-NLS-1$
6081
consumeEnhancedForStatement();
6082            break;
6083 
6084    case 514 : if (DEBUG) { System.out.println("EnhancedForStatementNoShortIf ::=..."); } //$NON-NLS-1$
6085
consumeEnhancedForStatement();
6086            break;
6087 
6088    case 515 : if (DEBUG) { System.out.println("EnhancedForStatementHeaderInit ::= for LPAREN Type..."); } //$NON-NLS-1$
6089
consumeEnhancedForStatementHeaderInit(false);
6090            break;
6091 
6092    case 516 : if (DEBUG) { System.out.println("EnhancedForStatementHeaderInit ::= for LPAREN Modifiers"); } //$NON-NLS-1$
6093
consumeEnhancedForStatementHeaderInit(true);
6094            break;
6095 
6096    case 517 : if (DEBUG) { System.out.println("EnhancedForStatementHeader ::=..."); } //$NON-NLS-1$
6097
consumeEnhancedForStatementHeader();
6098            break;
6099 
6100    case 518 : if (DEBUG) { System.out.println("SingleStaticImportDeclaration ::=..."); } //$NON-NLS-1$
6101
consumeImportDeclaration();
6102            break;
6103 
6104    case 519 : if (DEBUG) { System.out.println("SingleStaticImportDeclarationName ::= import static Name"); } //$NON-NLS-1$
6105
consumeSingleStaticImportDeclarationName();
6106            break;
6107 
6108    case 520 : if (DEBUG) { System.out.println("StaticImportOnDemandDeclaration ::=..."); } //$NON-NLS-1$
6109
consumeImportDeclaration();
6110            break;
6111 
6112    case 521 : if (DEBUG) { System.out.println("StaticImportOnDemandDeclarationName ::= import static..."); } //$NON-NLS-1$
6113
consumeStaticImportOnDemandDeclarationName();
6114            break;
6115 
6116    case 522 : if (DEBUG) { System.out.println("TypeArguments ::= LESS TypeArgumentList1"); } //$NON-NLS-1$
6117
consumeTypeArguments();
6118            break;
6119 
6120    case 523 : if (DEBUG) { System.out.println("OnlyTypeArguments ::= LESS TypeArgumentList1"); } //$NON-NLS-1$
6121
consumeOnlyTypeArguments();
6122            break;
6123 
6124    case 525 : if (DEBUG) { System.out.println("TypeArgumentList1 ::= TypeArgumentList COMMA..."); } //$NON-NLS-1$
6125
consumeTypeArgumentList1();
6126            break;
6127 
6128    case 527 : if (DEBUG) { System.out.println("TypeArgumentList ::= TypeArgumentList COMMA TypeArgument"); } //$NON-NLS-1$
6129
consumeTypeArgumentList();
6130            break;
6131 
6132    case 528 : if (DEBUG) { System.out.println("TypeArgument ::= ReferenceType"); } //$NON-NLS-1$
6133
consumeTypeArgument();
6134            break;
6135 
6136    case 532 : if (DEBUG) { System.out.println("ReferenceType1 ::= ReferenceType GREATER"); } //$NON-NLS-1$
6137
consumeReferenceType1();
6138            break;
6139 
6140    case 533 : if (DEBUG) { System.out.println("ReferenceType1 ::= ClassOrInterface LESS..."); } //$NON-NLS-1$
6141
consumeTypeArgumentReferenceType1();
6142            break;
6143 
6144    case 535 : if (DEBUG) { System.out.println("TypeArgumentList2 ::= TypeArgumentList COMMA..."); } //$NON-NLS-1$
6145
consumeTypeArgumentList2();
6146            break;
6147 
6148    case 538 : if (DEBUG) { System.out.println("ReferenceType2 ::= ReferenceType RIGHT_SHIFT"); } //$NON-NLS-1$
6149
consumeReferenceType2();
6150            break;
6151 
6152    case 539 : if (DEBUG) { System.out.println("ReferenceType2 ::= ClassOrInterface LESS..."); } //$NON-NLS-1$
6153
consumeTypeArgumentReferenceType2();
6154            break;
6155 
6156    case 541 : if (DEBUG) { System.out.println("TypeArgumentList3 ::= TypeArgumentList COMMA..."); } //$NON-NLS-1$
6157
consumeTypeArgumentList3();
6158            break;
6159 
6160    case 544 : if (DEBUG) { System.out.println("ReferenceType3 ::= ReferenceType UNSIGNED_RIGHT_SHIFT"); } //$NON-NLS-1$
6161
consumeReferenceType3();
6162            break;
6163 
6164    case 545 : if (DEBUG) { System.out.println("Wildcard ::= QUESTION"); } //$NON-NLS-1$
6165
consumeWildcard();
6166            break;
6167 
6168    case 546 : if (DEBUG) { System.out.println("Wildcard ::= QUESTION WildcardBounds"); } //$NON-NLS-1$
6169
consumeWildcardWithBounds();
6170            break;
6171 
6172    case 547 : if (DEBUG) { System.out.println("WildcardBounds ::= extends ReferenceType"); } //$NON-NLS-1$
6173
consumeWildcardBoundsExtends();
6174            break;
6175 
6176    case 548 : if (DEBUG) { System.out.println("WildcardBounds ::= super ReferenceType"); } //$NON-NLS-1$
6177
consumeWildcardBoundsSuper();
6178            break;
6179 
6180    case 549 : if (DEBUG) { System.out.println("Wildcard1 ::= QUESTION GREATER"); } //$NON-NLS-1$
6181
consumeWildcard1();
6182            break;
6183 
6184    case 550 : if (DEBUG) { System.out.println("Wildcard1 ::= QUESTION WildcardBounds1"); } //$NON-NLS-1$
6185
consumeWildcard1WithBounds();
6186            break;
6187 
6188    case 551 : if (DEBUG) { System.out.println("WildcardBounds1 ::= extends ReferenceType1"); } //$NON-NLS-1$
6189
consumeWildcardBounds1Extends();
6190            break;
6191 
6192    case 552 : if (DEBUG) { System.out.println("WildcardBounds1 ::= super ReferenceType1"); } //$NON-NLS-1$
6193
consumeWildcardBounds1Super();
6194            break;
6195 
6196    case 553 : if (DEBUG) { System.out.println("Wildcard2 ::= QUESTION RIGHT_SHIFT"); } //$NON-NLS-1$
6197
consumeWildcard2();
6198            break;
6199 
6200    case 554 : if (DEBUG) { System.out.println("Wildcard2 ::= QUESTION WildcardBounds2"); } //$NON-NLS-1$
6201
consumeWildcard2WithBounds();
6202            break;
6203 
6204    case 555 : if (DEBUG) { System.out.println("WildcardBounds2 ::= extends ReferenceType2"); } //$NON-NLS-1$
6205
consumeWildcardBounds2Extends();
6206            break;
6207 
6208    case 556 : if (DEBUG) { System.out.println("WildcardBounds2 ::= super ReferenceType2"); } //$NON-NLS-1$
6209
consumeWildcardBounds2Super();
6210            break;
6211 
6212    case 557 : if (DEBUG) { System.out.println("Wildcard3 ::= QUESTION UNSIGNED_RIGHT_SHIFT"); } //$NON-NLS-1$
6213
consumeWildcard3();
6214            break;
6215 
6216    case 558 : if (DEBUG) { System.out.println("Wildcard3 ::= QUESTION WildcardBounds3"); } //$NON-NLS-1$
6217
consumeWildcard3WithBounds();
6218            break;
6219 
6220    case 559 : if (DEBUG) { System.out.println("WildcardBounds3 ::= extends ReferenceType3"); } //$NON-NLS-1$
6221
consumeWildcardBounds3Extends();
6222            break;
6223 
6224    case 560 : if (DEBUG) { System.out.println("WildcardBounds3 ::= super ReferenceType3"); } //$NON-NLS-1$
6225
consumeWildcardBounds3Super();
6226            break;
6227 
6228    case 561 : if (DEBUG) { System.out.println("TypeParameterHeader ::= Identifier"); } //$NON-NLS-1$
6229
consumeTypeParameterHeader();
6230            break;
6231 
6232    case 562 : if (DEBUG) { System.out.println("TypeParameters ::= LESS TypeParameterList1"); } //$NON-NLS-1$
6233
consumeTypeParameters();
6234            break;
6235 
6236    case 564 : if (DEBUG) { System.out.println("TypeParameterList ::= TypeParameterList COMMA..."); } //$NON-NLS-1$
6237
consumeTypeParameterList();
6238            break;
6239 
6240    case 566 : if (DEBUG) { System.out.println("TypeParameter ::= TypeParameterHeader extends..."); } //$NON-NLS-1$
6241
consumeTypeParameterWithExtends();
6242            break;
6243 
6244    case 567 : if (DEBUG) { System.out.println("TypeParameter ::= TypeParameterHeader extends..."); } //$NON-NLS-1$
6245
consumeTypeParameterWithExtendsAndBounds();
6246            break;
6247 
6248    case 569 : if (DEBUG) { System.out.println("AdditionalBoundList ::= AdditionalBoundList..."); } //$NON-NLS-1$
6249
consumeAdditionalBoundList();
6250            break;
6251 
6252    case 570 : if (DEBUG) { System.out.println("AdditionalBound ::= AND ReferenceType"); } //$NON-NLS-1$
6253
consumeAdditionalBound();
6254            break;
6255 
6256    case 572 : if (DEBUG) { System.out.println("TypeParameterList1 ::= TypeParameterList COMMA..."); } //$NON-NLS-1$
6257
consumeTypeParameterList1();
6258            break;
6259 
6260    case 573 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader GREATER"); } //$NON-NLS-1$
6261
consumeTypeParameter1();
6262            break;
6263 
6264    case 574 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader extends..."); } //$NON-NLS-1$
6265
consumeTypeParameter1WithExtends();
6266            break;
6267 
6268    case 575 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader extends..."); } //$NON-NLS-1$
6269
consumeTypeParameter1WithExtendsAndBounds();
6270            break;
6271 
6272    case 577 : if (DEBUG) { System.out.println("AdditionalBoundList1 ::= AdditionalBoundList..."); } //$NON-NLS-1$
6273
consumeAdditionalBoundList1();
6274            break;
6275 
6276    case 578 : if (DEBUG) { System.out.println("AdditionalBound1 ::= AND ReferenceType1"); } //$NON-NLS-1$
6277
consumeAdditionalBound1();
6278            break;
6279 
6280    case 584 : if (DEBUG) { System.out.println("UnaryExpression_NotName ::= PLUS PushPosition..."); } //$NON-NLS-1$
6281
consumeUnaryExpression(OperatorIds.PLUS);
6282            break;
6283 
6284    case 585 : if (DEBUG) { System.out.println("UnaryExpression_NotName ::= MINUS PushPosition..."); } //$NON-NLS-1$
6285
consumeUnaryExpression(OperatorIds.MINUS);
6286            break;
6287 
6288    case 588 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus_NotName ::= TWIDDLE..."); } //$NON-NLS-1$
6289
consumeUnaryExpression(OperatorIds.TWIDDLE);
6290            break;
6291 
6292    case 589 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus_NotName ::= NOT PushPosition"); } //$NON-NLS-1$
6293
consumeUnaryExpression(OperatorIds.NOT);
6294            break;
6295 
6296    case 592 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); } //$NON-NLS-1$
6297
consumeBinaryExpression(OperatorIds.MULTIPLY);
6298            break;
6299 
6300    case 593 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name MULTIPLY..."); } //$NON-NLS-1$
6301
consumeBinaryExpressionWithName(OperatorIds.MULTIPLY);
6302            break;
6303 
6304    case 594 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); } //$NON-NLS-1$
6305
consumeBinaryExpression(OperatorIds.DIVIDE);
6306            break;
6307 
6308    case 595 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name DIVIDE..."); } //$NON-NLS-1$
6309
consumeBinaryExpressionWithName(OperatorIds.DIVIDE);
6310            break;
6311 
6312    case 596 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); } //$NON-NLS-1$
6313
consumeBinaryExpression(OperatorIds.REMAINDER);
6314            break;
6315 
6316    case 597 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name REMAINDER..."); } //$NON-NLS-1$
6317
consumeBinaryExpressionWithName(OperatorIds.REMAINDER);
6318            break;
6319 
6320    case 599 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::=..."); } //$NON-NLS-1$
6321
consumeBinaryExpression(OperatorIds.PLUS);
6322            break;
6323 
6324    case 600 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::= Name PLUS..."); } //$NON-NLS-1$
6325
consumeBinaryExpressionWithName(OperatorIds.PLUS);
6326            break;
6327 
6328    case 601 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::=..."); } //$NON-NLS-1$
6329
consumeBinaryExpression(OperatorIds.MINUS);
6330            break;
6331 
6332    case 602 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::= Name MINUS..."); } //$NON-NLS-1$
6333
consumeBinaryExpressionWithName(OperatorIds.MINUS);
6334            break;
6335 
6336    case 604 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); } //$NON-NLS-1$
6337
consumeBinaryExpression(OperatorIds.LEFT_SHIFT);
6338            break;
6339 
6340    case 605 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name LEFT_SHIFT..."); } //$NON-NLS-1$
6341
consumeBinaryExpressionWithName(OperatorIds.LEFT_SHIFT);
6342            break;
6343 
6344    case 606 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); } //$NON-NLS-1$
6345
consumeBinaryExpression(OperatorIds.RIGHT_SHIFT);
6346            break;
6347 
6348    case 607 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name RIGHT_SHIFT..."); } //$NON-NLS-1$
6349
consumeBinaryExpressionWithName(OperatorIds.RIGHT_SHIFT);
6350            break;
6351 
6352    case 608 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); } //$NON-NLS-1$
6353
consumeBinaryExpression(OperatorIds.UNSIGNED_RIGHT_SHIFT);
6354            break;
6355 
6356    case 609 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name UNSIGNED_RIGHT_SHIFT..."); } //$NON-NLS-1$
6357
consumeBinaryExpressionWithName(OperatorIds.UNSIGNED_RIGHT_SHIFT);
6358            break;
6359 
6360    case 611 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= ShiftExpression_NotName"); } //$NON-NLS-1$
6361
consumeBinaryExpression(OperatorIds.LESS);
6362            break;
6363 
6364    case 612 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name LESS..."); } //$NON-NLS-1$
6365
consumeBinaryExpressionWithName(OperatorIds.LESS);
6366            break;
6367 
6368    case 613 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= ShiftExpression_NotName"); } //$NON-NLS-1$
6369
consumeBinaryExpression(OperatorIds.GREATER);
6370            break;
6371 
6372    case 614 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name GREATER..."); } //$NON-NLS-1$
6373
consumeBinaryExpressionWithName(OperatorIds.GREATER);
6374            break;
6375 
6376    case 615 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::=..."); } //$NON-NLS-1$
6377
consumeBinaryExpression(OperatorIds.LESS_EQUAL);
6378            break;
6379 
6380    case 616 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name LESS_EQUAL..."); } //$NON-NLS-1$
6381
consumeBinaryExpressionWithName(OperatorIds.LESS_EQUAL);
6382            break;
6383 
6384    case 617 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::=..."); } //$NON-NLS-1$
6385
consumeBinaryExpression(OperatorIds.GREATER_EQUAL);
6386            break;
6387 
6388    case 618 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name GREATER_EQUAL..."); } //$NON-NLS-1$
6389
consumeBinaryExpressionWithName(OperatorIds.GREATER_EQUAL);
6390            break;
6391 
6392    case 620 : if (DEBUG) { System.out.println("InstanceofExpression_NotName ::= Name instanceof..."); } //$NON-NLS-1$
6393
consumeInstanceOfExpressionWithName();
6394            break;
6395 
6396    case 621 : if (DEBUG) { System.out.println("InstanceofExpression_NotName ::=..."); } //$NON-NLS-1$
6397
consumeInstanceOfExpression();
6398            break;
6399 
6400    case 623 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::=..."); } //$NON-NLS-1$
6401
consumeEqualityExpression(OperatorIds.EQUAL_EQUAL);
6402            break;
6403 
6404    case 624 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::= Name EQUAL_EQUAL..."); } //$NON-NLS-1$
6405
consumeEqualityExpressionWithName(OperatorIds.EQUAL_EQUAL);
6406            break;
6407 
6408    case 625 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::=..."); } //$NON-NLS-1$
6409
consumeEqualityExpression(OperatorIds.NOT_EQUAL);
6410            break;
6411 
6412    case 626 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::= Name NOT_EQUAL..."); } //$NON-NLS-1$
6413
consumeEqualityExpressionWithName(OperatorIds.NOT_EQUAL);
6414            break;
6415 
6416    case 628 : if (DEBUG) { System.out.println("AndExpression_NotName ::= AndExpression_NotName AND..."); } //$NON-NLS-1$
6417
consumeBinaryExpression(OperatorIds.AND);
6418            break;
6419 
6420    case 629 : if (DEBUG) { System.out.println("AndExpression_NotName ::= Name AND EqualityExpression"); } //$NON-NLS-1$
6421
consumeBinaryExpressionWithName(OperatorIds.AND);
6422            break;
6423 
6424    case 631 : if (DEBUG) { System.out.println("ExclusiveOrExpression_NotName ::=..."); } //$NON-NLS-1$
6425
consumeBinaryExpression(OperatorIds.XOR);
6426            break;
6427 
6428    case 632 : if (DEBUG) { System.out.println("ExclusiveOrExpression_NotName ::= Name XOR AndExpression"); } //$NON-NLS-1$
6429
consumeBinaryExpressionWithName(OperatorIds.XOR);
6430            break;
6431 
6432    case 634 : if (DEBUG) { System.out.println("InclusiveOrExpression_NotName ::=..."); } //$NON-NLS-1$
6433
consumeBinaryExpression(OperatorIds.OR);
6434            break;
6435 
6436    case 635 : if (DEBUG) { System.out.println("InclusiveOrExpression_NotName ::= Name OR..."); } //$NON-NLS-1$
6437
consumeBinaryExpressionWithName(OperatorIds.OR);
6438            break;
6439 
6440    case 637 : if (DEBUG) { System.out.println("ConditionalAndExpression_NotName ::=..."); } //$NON-NLS-1$
6441
consumeBinaryExpression(OperatorIds.AND_AND);
6442            break;
6443 
6444    case 638 : if (DEBUG) { System.out.println("ConditionalAndExpression_NotName ::= Name AND_AND..."); } //$NON-NLS-1$
6445
consumeBinaryExpressionWithName(OperatorIds.AND_AND);
6446            break;
6447 
6448    case 640 : if (DEBUG) { System.out.println("ConditionalOrExpression_NotName ::=..."); } //$NON-NLS-1$
6449
consumeBinaryExpression(OperatorIds.OR_OR);
6450            break;
6451 
6452    case 641 : if (DEBUG) { System.out.println("ConditionalOrExpression_NotName ::= Name OR_OR..."); } //$NON-NLS-1$
6453
consumeBinaryExpressionWithName(OperatorIds.OR_OR);
6454            break;
6455 
6456    case 643 : if (DEBUG) { System.out.println("ConditionalExpression_NotName ::=..."); } //$NON-NLS-1$
6457
consumeConditionalExpression(OperatorIds.QUESTIONCOLON) ;
6458            break;
6459 
6460    case 644 : if (DEBUG) { System.out.println("ConditionalExpression_NotName ::= Name QUESTION..."); } //$NON-NLS-1$
6461
consumeConditionalExpressionWithName(OperatorIds.QUESTIONCOLON) ;
6462            break;
6463 
6464    case 648 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= Modifiers AT..."); } //$NON-NLS-1$
6465
consumeAnnotationTypeDeclarationHeaderName() ;
6466            break;
6467 
6468    case 649 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= AT..."); } //$NON-NLS-1$
6469
consumeAnnotationTypeDeclarationHeaderName() ;
6470            break;
6471 
6472    case 650 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeader ::=..."); } //$NON-NLS-1$
6473
consumeAnnotationTypeDeclarationHeader() ;
6474            break;
6475 
6476    case 651 : if (DEBUG) { System.out.println("AnnotationTypeDeclaration ::=..."); } //$NON-NLS-1$
6477
consumeAnnotationTypeDeclaration() ;
6478            break;
6479 
6480    case 653 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarationsopt ::="); } //$NON-NLS-1$
6481
consumeEmptyAnnotationTypeMemberDeclarationsopt() ;
6482            break;
6483 
6484    case 654 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarationsopt ::= NestedType..."); } //$NON-NLS-1$
6485
consumeAnnotationTypeMemberDeclarationsopt() ;
6486            break;
6487 
6488    case 656 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarations ::=..."); } //$NON-NLS-1$
6489
consumeAnnotationTypeMemberDeclarations() ;
6490            break;
6491 
6492    case 657 : if (DEBUG) { System.out.println("AnnotationMethodHeaderName ::= Modifiersopt..."); } //$NON-NLS-1$
6493
consumeMethodHeaderNameWithTypeParameters(true);
6494            break;
6495 
6496    case 658 : if (DEBUG) { System.out.println("AnnotationMethodHeaderName ::= Modifiersopt Type..."); } //$NON-NLS-1$
6497
consumeMethodHeaderName(true);
6498            break;
6499 
6500    case 659 : if (DEBUG) { System.out.println("AnnotationMethodHeaderDefaultValueopt ::="); } //$NON-NLS-1$
6501
consumeEmptyMethodHeaderDefaultValue() ;
6502            break;
6503 
6504    case 660 : if (DEBUG) { System.out.println("AnnotationMethodHeaderDefaultValueopt ::= DefaultValue"); } //$NON-NLS-1$
6505
consumeMethodHeaderDefaultValue();
6506            break;
6507 
6508    case 661 : if (DEBUG) { System.out.println("AnnotationMethodHeader ::= AnnotationMethodHeaderName..."); } //$NON-NLS-1$
6509
consumeMethodHeader();
6510            break;
6511 
6512    case 662 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclaration ::=..."); } //$NON-NLS-1$
6513
consumeAnnotationTypeMemberDeclaration() ;
6514            break;
6515 
6516    case 670 : if (DEBUG) { System.out.println("AnnotationName ::= AT Name"); } //$NON-NLS-1$
6517
consumeAnnotationName() ;
6518            break;
6519 
6520    case 671 : if (DEBUG) { System.out.println("NormalAnnotation ::= AnnotationName LPAREN..."); } //$NON-NLS-1$
6521
consumeNormalAnnotation() ;
6522            break;
6523 
6524    case 672 : if (DEBUG) { System.out.println("MemberValuePairsopt ::="); } //$NON-NLS-1$
6525
consumeEmptyMemberValuePairsopt() ;
6526            break;
6527 
6528    case 675 : if (DEBUG) { System.out.println("MemberValuePairs ::= MemberValuePairs COMMA..."); } //$NON-NLS-1$
6529
consumeMemberValuePairs() ;
6530            break;
6531 
6532    case 676 : if (DEBUG) { System.out.println("MemberValuePair ::= SimpleName EQUAL EnterMemberValue..."); } //$NON-NLS-1$
6533
consumeMemberValuePair() ;
6534            break;
6535 
6536    case 677 : if (DEBUG) { System.out.println("EnterMemberValue ::="); } //$NON-NLS-1$
6537
consumeEnterMemberValue() ;
6538            break;
6539 
6540    case 678 : if (DEBUG) { System.out.println("ExitMemberValue ::="); } //$NON-NLS-1$
6541
consumeExitMemberValue() ;
6542            break;
6543 
6544    case 680 : if (DEBUG) { System.out.println("MemberValue ::= Name"); } //$NON-NLS-1$
6545
consumeMemberValueAsName() ;
6546            break;
6547 
6548    case 683 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$
6549
consumeMemberValueArrayInitializer() ;
6550            break;
6551 
6552    case 684 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$
6553
consumeMemberValueArrayInitializer() ;
6554            break;
6555 
6556    case 685 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$
6557
consumeEmptyMemberValueArrayInitializer() ;
6558            break;
6559 
6560    case 686 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::=..."); } //$NON-NLS-1$
6561
consumeEmptyMemberValueArrayInitializer() ;
6562            break;
6563 
6564    case 687 : if (DEBUG) { System.out.println("EnterMemberValueArrayInitializer ::="); } //$NON-NLS-1$
6565
consumeEnterMemberValueArrayInitializer() ;
6566            break;
6567 
6568    case 689 : if (DEBUG) { System.out.println("MemberValues ::= MemberValues COMMA MemberValue"); } //$NON-NLS-1$
6569
consumeMemberValues() ;
6570            break;
6571 
6572    case 690 : if (DEBUG) { System.out.println("MarkerAnnotation ::= AnnotationName"); } //$NON-NLS-1$
6573
consumeMarkerAnnotation() ;
6574            break;
6575 
6576    case 691 : if (DEBUG) { System.out.println("SingleMemberAnnotation ::= AnnotationName LPAREN..."); } //$NON-NLS-1$
6577
consumeSingleMemberAnnotation() ;
6578            break;
6579 
6580    case 692 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= Modifiersopt TypeParameters"); } //$NON-NLS-1$
6581
consumeRecoveryMethodHeaderNameWithTypeParameters();
6582            break;
6583 
6584    case 693 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= Modifiersopt Type..."); } //$NON-NLS-1$
6585
consumeRecoveryMethodHeaderName();
6586            break;
6587 
6588    case 694 : if (DEBUG) { System.out.println("RecoveryMethodHeader ::= RecoveryMethodHeaderName..."); } //$NON-NLS-1$
6589
consumeMethodHeader();
6590            break;
6591 
6592    case 695 : if (DEBUG) { System.out.println("RecoveryMethodHeader ::= RecoveryMethodHeaderName..."); } //$NON-NLS-1$
6593
consumeMethodHeader();
6594            break;
6595 
6596    }
6597}
6598protected void consumeSimpleAssertStatement() {
6599    // AssertStatement ::= 'assert' Expression ';'
6600
this.expressionLengthPtr--;
6601    pushOnAstStack(new AssertStatement(this.expressionStack[this.expressionPtr--], this.intStack[this.intPtr--]));
6602}
6603protected void consumeSingleMemberAnnotation() {
6604    // SingleMemberAnnotation ::= '@' Name '(' MemberValue ')'
6605
SingleMemberAnnotation singleMemberAnnotation = null;
6606    TypeReference typeReference = this.getAnnotationType();
6607    singleMemberAnnotation = new SingleMemberAnnotation(typeReference, this.intStack[this.intPtr--]);
6608    singleMemberAnnotation.memberValue = this.expressionStack[this.expressionPtr--];
6609    this.expressionLengthPtr--;
6610    singleMemberAnnotation.declarationSourceEnd = this.rParenPos;
6611    pushOnExpressionStack(singleMemberAnnotation);
6612    
6613    
6614    if(this.currentElement != null) {
6615        annotationRecoveryCheckPoint(singleMemberAnnotation.sourceStart, singleMemberAnnotation.declarationSourceEnd);
6616    }
6617    
6618    if(!this.statementRecoveryActivated &&
6619            options.sourceLevel < ClassFileConstants.JDK1_5 &&
6620            this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
6621        this.problemReporter().invalidUsageOfAnnotation(singleMemberAnnotation);
6622    }
6623    this.recordStringLiterals = true;
6624}
6625protected void consumeSingleStaticImportDeclarationName() {
6626    // SingleTypeImportDeclarationName ::= 'import' 'static' Name
6627
/* push an ImportRef build from the last name
6628    stored in the identifier stack. */

6629
6630    ImportReference impt;
6631    int length;
6632    char[][] tokens = new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
6633    this.identifierPtr -= length;
6634    long[] positions = new long[length];
6635    System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
6636    System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
6637    pushOnAstStack(impt = new ImportReference(tokens, positions, false, ClassFileConstants.AccStatic));
6638
6639    this.modifiers = ClassFileConstants.AccDefault;
6640    this.modifiersSourceStart = -1; // <-- see comment into modifiersFlag(int)
6641

6642    if (this.currentToken == TokenNameSEMICOLON){
6643        impt.declarationSourceEnd = this.scanner.currentPosition - 1;
6644    } else {
6645        impt.declarationSourceEnd = impt.sourceEnd;
6646    }
6647    impt.declarationEnd = impt.declarationSourceEnd;
6648    //this.endPosition is just before the ;
6649
impt.declarationSourceStart = this.intStack[this.intPtr--];
6650
6651    if(!this.statementRecoveryActivated &&
6652            this.options.sourceLevel < ClassFileConstants.JDK1_5 &&
6653            this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
6654        impt.modifiers = ClassFileConstants.AccDefault; // convert the static import reference to a non-static importe reference
6655
this.problemReporter().invalidUsageOfStaticImports(impt);
6656    }
6657    
6658    // recovery
6659
if (this.currentElement != null){
6660        this.lastCheckPoint = impt.declarationSourceEnd+1;
6661        this.currentElement = this.currentElement.add(impt, 0);
6662        this.lastIgnoredToken = -1;
6663        this.restartRecovery = true; // used to avoid branching back into the regular automaton
6664
}
6665}
6666protected void consumeSingleTypeImportDeclarationName() {
6667    // SingleTypeImportDeclarationName ::= 'import' Name
6668
/* push an ImportRef build from the last name
6669    stored in the identifier stack. */

6670
6671    ImportReference impt;
6672    int length;
6673    char[][] tokens = new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
6674    this.identifierPtr -= length;
6675    long[] positions = new long[length];
6676    System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
6677    System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
6678    pushOnAstStack(impt = new ImportReference(tokens, positions, false, ClassFileConstants.AccDefault));
6679
6680    if (this.currentToken == TokenNameSEMICOLON){
6681        impt.declarationSourceEnd = this.scanner.currentPosition - 1;
6682    } else {
6683        impt.declarationSourceEnd = impt.sourceEnd;
6684    }
6685    impt.declarationEnd = impt.declarationSourceEnd;
6686    //this.endPosition is just before the ;
6687
impt.declarationSourceStart = this.intStack[this.intPtr--];
6688
6689    // recovery
6690
if (this.currentElement != null){
6691        this.lastCheckPoint = impt.declarationSourceEnd+1;
6692        this.currentElement = this.currentElement.add(impt, 0);
6693        this.lastIgnoredToken = -1;
6694        this.restartRecovery = true; // used to avoid branching back into the regular automaton
6695
}
6696}
6697protected void consumeStatementBreak() {
6698    // BreakStatement ::= 'break' ';'
6699
// break pushs a position on this.intStack in case there is no label
6700

6701    pushOnAstStack(new BreakStatement(null, this.intStack[this.intPtr--], this.endStatementPosition));
6702    
6703    if (this.pendingRecoveredType != null) {
6704        // Used only in statements recovery.
6705
// This is not a real break statement but a placeholder for an existing local type.
6706
// The break statement must be replace by the local type.
6707
if (this.pendingRecoveredType.allocation == null &&
6708                this.endPosition <= this.pendingRecoveredType.declarationSourceEnd) {
6709            this.astStack[this.astPtr] = this.pendingRecoveredType;
6710            this.pendingRecoveredType = null;
6711            return;
6712        }
6713        this.pendingRecoveredType = null;
6714    }
6715}
6716protected void consumeStatementBreakWithLabel() {
6717    // BreakStatement ::= 'break' Identifier ';'
6718
// break pushs a position on this.intStack in case there is no label
6719

6720    pushOnAstStack(
6721        new BreakStatement(
6722            this.identifierStack[this.identifierPtr--],
6723            this.intStack[this.intPtr--],
6724            this.endStatementPosition));
6725    this.identifierLengthPtr--;
6726}
6727protected void consumeStatementCatch() {
6728    // CatchClause ::= 'catch' '(' FormalParameter ')' Block
6729

6730    //catch are stored directly into the Try
6731
//has they always comes two by two....
6732
//we remove one entry from the astlengthPtr.
6733
//The construction of the try statement must
6734
//then fetch the catches using 2*i and 2*i + 1
6735

6736    this.astLengthPtr--;
6737    this.listLength = 0; // reset formalParameter counter (incremented for catch variable)
6738
}
6739protected void consumeStatementContinue() {
6740    // ContinueStatement ::= 'continue' ';'
6741
// continue pushs a position on this.intStack in case there is no label
6742

6743    pushOnAstStack(
6744        new ContinueStatement(
6745            null,
6746            this.intStack[this.intPtr--],
6747            this.endStatementPosition));
6748}
6749protected void consumeStatementContinueWithLabel() {
6750    // ContinueStatement ::= 'continue' Identifier ';'
6751
// continue pushs a position on this.intStack in case there is no label
6752

6753    pushOnAstStack(
6754        new ContinueStatement(
6755            this.identifierStack[this.identifierPtr--],
6756            this.intStack[this.intPtr--],
6757            this.endStatementPosition));
6758    this.identifierLengthPtr--;
6759}
6760protected void consumeStatementDo() {
6761    // DoStatement ::= 'do' Statement 'while' '(' Expression ')' ';'
6762

6763    //the 'while' pushes a value on this.intStack that we need to remove
6764
this.intPtr--;
6765
6766    Statement statement = (Statement) this.astStack[this.astPtr];
6767    this.expressionLengthPtr--;
6768    this.astStack[this.astPtr] =
6769        new DoStatement(
6770            this.expressionStack[this.expressionPtr--],
6771            statement,
6772            this.intStack[this.intPtr--],
6773            this.endStatementPosition);
6774}
6775protected void consumeStatementExpressionList() {
6776    // StatementExpressionList ::= StatementExpressionList ',' StatementExpression
6777
concatExpressionLists();
6778}
6779protected void consumeStatementFor() {
6780    // ForStatement ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' Statement
6781
// ForStatementNoShortIf ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' StatementNoShortIf
6782

6783    int length;
6784    Expression cond = null;
6785    Statement[] inits, updates;
6786    boolean scope = true;
6787
6788    //statements
6789
this.astLengthPtr--;
6790    Statement statement = (Statement) this.astStack[this.astPtr--];
6791
6792    //updates are on the expresion stack
6793
if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) == 0) {
6794        updates = null;
6795    } else {
6796        this.expressionPtr -= length;
6797        System.arraycopy(
6798            this.expressionStack,
6799            this.expressionPtr + 1,
6800            updates = new Statement[length],
6801            0,
6802            length);
6803    }
6804
6805    if (this.expressionLengthStack[this.expressionLengthPtr--] != 0)
6806        cond = this.expressionStack[this.expressionPtr--];
6807
6808    //inits may be on two different stacks
6809
if ((length = this.astLengthStack[this.astLengthPtr--]) == 0) {
6810        inits = null;
6811        scope = false;
6812    } else {
6813        if (length == -1) { //on this.expressionStack
6814
scope = false;
6815            length = this.expressionLengthStack[this.expressionLengthPtr--];
6816            this.expressionPtr -= length;
6817            System.arraycopy(
6818                this.expressionStack,
6819                this.expressionPtr + 1,
6820                inits = new Statement[length],
6821                0,
6822                length);
6823        } else { //on this.astStack
6824
this.astPtr -= length;
6825            System.arraycopy(
6826                this.astStack,
6827                this.astPtr + 1,
6828                inits = new Statement[length],
6829                0,
6830                length);
6831        }
6832    }
6833    pushOnAstStack(
6834        new ForStatement(
6835            inits,
6836            cond,
6837            updates,
6838            statement,
6839            scope,
6840            this.intStack[this.intPtr--],
6841            this.endStatementPosition));
6842}
6843protected void consumeStatementIfNoElse() {
6844    // IfThenStatement ::= 'if' '(' Expression ')' Statement
6845

6846    //optimize the push/pop
6847
this.expressionLengthPtr--;
6848    Statement thenStatement = (Statement) this.astStack[this.astPtr];
6849    this.astStack[this.astPtr] =
6850        new IfStatement(
6851            this.expressionStack[this.expressionPtr--],
6852            thenStatement,
6853            this.intStack[this.intPtr--],
6854            this.endStatementPosition);
6855}
6856protected void consumeStatementIfWithElse() {
6857    // IfThenElseStatement ::= 'if' '(' Expression ')' StatementNoShortIf 'else' Statement
6858
// IfThenElseStatementNoShortIf ::= 'if' '(' Expression ')' StatementNoShortIf 'else' StatementNoShortIf
6859

6860    this.expressionLengthPtr--;
6861
6862    // optimized {..., Then, Else } ==> {..., If }
6863
this.astLengthPtr--;
6864
6865    //optimize the push/pop
6866
this.astStack[--this.astPtr] =
6867        new IfStatement(
6868            this.expressionStack[this.expressionPtr--],
6869            (Statement) this.astStack[this.astPtr],
6870            (Statement) this.astStack[this.astPtr + 1],
6871            this.intStack[this.intPtr--],
6872            this.endStatementPosition);
6873}
6874protected void consumeStatementLabel() {
6875    // LabeledStatement ::= 'Identifier' ':' Statement
6876
// LabeledStatementNoShortIf ::= 'Identifier' ':' StatementNoShortIf
6877

6878    //optimize push/pop
6879
Statement statement = (Statement) this.astStack[this.astPtr];
6880    this.astStack[this.astPtr] =
6881        new LabeledStatement(
6882            this.identifierStack[this.identifierPtr],
6883            statement,
6884            this.identifierPositionStack[this.identifierPtr--],
6885            this.endStatementPosition);
6886    this.identifierLengthPtr--;
6887}
6888protected void consumeStatementReturn() {
6889    // ReturnStatement ::= 'return' Expressionopt ';'
6890
// return pushs a position on this.intStack in case there is no expression
6891

6892    if (this.expressionLengthStack[this.expressionLengthPtr--] != 0) {
6893        pushOnAstStack(
6894            new ReturnStatement(
6895                this.expressionStack[this.expressionPtr--],
6896                this.intStack[this.intPtr--],
6897                this.endStatementPosition)
6898        );
6899    } else {
6900        pushOnAstStack(new ReturnStatement(null, this.intStack[this.intPtr--], this.endStatementPosition));
6901    }
6902}
6903protected void consumeStatementSwitch() {
6904    // SwitchStatement ::= 'switch' OpenBlock '(' Expression ')' SwitchBlock
6905

6906    //OpenBlock just makes the semantic action blockStart()
6907
//the block is inlined but a scope need to be created
6908
//if some declaration occurs.
6909

6910    int length;
6911    SwitchStatement switchStatement = new SwitchStatement();
6912    this.expressionLengthPtr--;
6913    switchStatement.expression = this.expressionStack[this.expressionPtr--];
6914    if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
6915        this.astPtr -= length;
6916        System.arraycopy(
6917            this.astStack,
6918            this.astPtr + 1,
6919            switchStatement.statements = new Statement[length],
6920            0,
6921            length);
6922    }
6923    switchStatement.explicitDeclarations = this.realBlockStack[this.realBlockPtr--];
6924    pushOnAstStack(switchStatement);
6925    switchStatement.blockStart = this.intStack[this.intPtr--];
6926    switchStatement.sourceStart = this.intStack[this.intPtr--];
6927    switchStatement.sourceEnd = this.endStatementPosition;
6928    if (length == 0 && !containsComment(switchStatement.blockStart, switchStatement.sourceEnd)) {
6929        switchStatement.bits |= ASTNode.UndocumentedEmptyBlock;
6930    }
6931}
6932protected void consumeStatementSynchronized() {
6933    // SynchronizedStatement ::= OnlySynchronized '(' Expression ')' Block
6934
//optimize the push/pop
6935

6936    if (this.astLengthStack[this.astLengthPtr] == 0) {
6937        this.astLengthStack[this.astLengthPtr] = 1;
6938        this.expressionLengthPtr--;
6939        this.astStack[++this.astPtr] =
6940            new SynchronizedStatement(
6941                this.expressionStack[this.expressionPtr--],
6942                null,
6943                this.intStack[this.intPtr--],
6944                this.endStatementPosition);
6945    } else {
6946        this.expressionLengthPtr--;
6947        this.astStack[this.astPtr] =
6948            new SynchronizedStatement(
6949                this.expressionStack[this.expressionPtr--],
6950                (Block) this.astStack[this.astPtr],
6951                this.intStack[this.intPtr--],
6952                this.endStatementPosition);
6953    }
6954    resetModifiers();
6955}
6956protected void consumeStatementThrow() {
6957    // ThrowStatement ::= 'throw' Expression ';'
6958
this.expressionLengthPtr--;
6959    pushOnAstStack(new ThrowStatement(this.expressionStack[this.expressionPtr--], this.intStack[this.intPtr--], this.endStatementPosition));
6960}
6961protected void consumeStatementTry(boolean withFinally) {
6962    //TryStatement ::= 'try' Block Catches
6963
//TryStatement ::= 'try' Block Catchesopt Finally
6964

6965    int length;
6966    TryStatement tryStmt = new TryStatement();
6967    //finally
6968
if (withFinally) {
6969        this.astLengthPtr--;
6970        tryStmt.finallyBlock = (Block) this.astStack[this.astPtr--];
6971    }
6972    //catches are handle by two <argument-block> [see statementCatch]
6973
if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
6974        if (length == 1) {
6975            tryStmt.catchBlocks = new Block[] {(Block) this.astStack[this.astPtr--]};
6976            tryStmt.catchArguments = new Argument[] {(Argument) this.astStack[this.astPtr--]};
6977        } else {
6978            Block[] bks = (tryStmt.catchBlocks = new Block[length]);
6979            Argument[] args = (tryStmt.catchArguments = new Argument[length]);
6980            while (length-- > 0) {
6981                bks[length] = (Block) this.astStack[this.astPtr--];
6982                args[length] = (Argument) this.astStack[this.astPtr--];
6983            }
6984        }
6985    }
6986    //try
6987
this.astLengthPtr--;
6988    tryStmt.tryBlock = (Block) this.astStack[this.astPtr--];
6989
6990    //positions
6991
tryStmt.sourceEnd = this.endStatementPosition;
6992    tryStmt.sourceStart = this.intStack[this.intPtr--];
6993    pushOnAstStack(tryStmt);
6994}
6995protected void consumeStatementWhile() {
6996    // WhileStatement ::= 'while' '(' Expression ')' Statement
6997
// WhileStatementNoShortIf ::= 'while' '(' Expression ')' StatementNoShortIf
6998

6999    this.expressionLengthPtr--;
7000    Statement statement = (Statement) this.astStack[this.astPtr];
7001    this.astStack[this.astPtr] =
7002        new WhileStatement(
7003            this.expressionStack[this.expressionPtr--],
7004            statement,
7005            this.intStack[this.intPtr--],
7006            this.endStatementPosition);
7007}
7008protected void consumeStaticImportOnDemandDeclarationName() {
7009    // TypeImportOnDemandDeclarationName ::= 'import' 'static' Name '.' '*'
7010
/* push an ImportRef build from the last name
7011    stored in the identifier stack. */

7012
7013    ImportReference impt;
7014    int length;
7015    char[][] tokens = new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
7016    this.identifierPtr -= length;
7017    long[] positions = new long[length];
7018    System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
7019    System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
7020    pushOnAstStack(impt = new ImportReference(tokens, positions, true, ClassFileConstants.AccStatic));
7021
7022    this.modifiers = ClassFileConstants.AccDefault;
7023    this.modifiersSourceStart = -1; // <-- see comment into modifiersFlag(int)
7024

7025    if (this.currentToken == TokenNameSEMICOLON){
7026        impt.declarationSourceEnd = this.scanner.currentPosition - 1;
7027    } else {
7028        impt.declarationSourceEnd = impt.sourceEnd;
7029    }
7030    impt.declarationEnd = impt.declarationSourceEnd;
7031    //this.endPosition is just before the ;
7032
impt.declarationSourceStart = this.intStack[this.intPtr--];
7033
7034    if(!this.statementRecoveryActivated &&
7035            options.sourceLevel < ClassFileConstants.JDK1_5 &&
7036            this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
7037        impt.modifiers = ClassFileConstants.AccDefault; // convert the static import reference to a non-static importe reference
7038
this.problemReporter().invalidUsageOfStaticImports(impt);
7039    }
7040    
7041    // recovery
7042
if (this.currentElement != null){
7043        this.lastCheckPoint = impt.declarationSourceEnd+1;
7044        this.currentElement = this.currentElement.add(impt, 0);
7045        this.lastIgnoredToken = -1;
7046        this.restartRecovery = true; // used to avoid branching back into the regular automaton
7047
}
7048}
7049protected void consumeStaticInitializer() {
7050    // StaticInitializer ::= StaticOnly Block
7051
//push an Initializer
7052
//optimize the push/pop
7053
Block block = (Block) this.astStack[this.astPtr];
7054    if (this.diet) block.bits &= ~ASTNode.UndocumentedEmptyBlock; // clear bit set since was diet
7055
Initializer initializer = new Initializer(block, ClassFileConstants.AccStatic);
7056    this.astStack[this.astPtr] = initializer;
7057    initializer.sourceEnd = this.endStatementPosition;
7058    initializer.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
7059    this.nestedMethod[this.nestedType] --;
7060    initializer.declarationSourceStart = this.intStack[this.intPtr--];
7061    initializer.bodyStart = this.intStack[this.intPtr--];
7062    initializer.bodyEnd = this.endPosition;
7063    // doc comment
7064
initializer.javadoc = this.javadoc;
7065    this.javadoc = null;
7066    
7067    // recovery
7068
if (this.currentElement != null){
7069        this.lastCheckPoint = initializer.declarationSourceEnd;
7070        this.currentElement = this.currentElement.add(initializer, 0);
7071        this.lastIgnoredToken = -1;
7072    }
7073}
7074protected void consumeStaticOnly() {
7075    // StaticOnly ::= 'static'
7076
int savedModifiersSourceStart = this.modifiersSourceStart;
7077    checkComment(); // might update declaration source start
7078
if (this.modifiersSourceStart >= savedModifiersSourceStart) {
7079        this.modifiersSourceStart = savedModifiersSourceStart;
7080    }
7081    pushOnIntStack(this.scanner.currentPosition);
7082    pushOnIntStack(
7083        this.modifiersSourceStart >= 0 ? this.modifiersSourceStart : this.scanner.startPosition);
7084    jumpOverMethodBody();
7085    this.nestedMethod[this.nestedType]++;
7086    resetModifiers();
7087    this.expressionLengthPtr--; // remove the 0 pushed in consumeToken() for the static modifier
7088

7089    // recovery
7090
if (this.currentElement != null){
7091        this.recoveredStaticInitializerStart = this.intStack[this.intPtr]; // remember start position only for static initializers
7092
}
7093}
7094protected void consumeSwitchBlock() {
7095    // SwitchBlock ::= '{' SwitchBlockStatements SwitchLabels '}'
7096
concatNodeLists();
7097}
7098protected void consumeSwitchBlockStatement() {
7099    // SwitchBlockStatement ::= SwitchLabels BlockStatements
7100
concatNodeLists();
7101}
7102protected void consumeSwitchBlockStatements() {
7103    // SwitchBlockStatements ::= SwitchBlockStatements SwitchBlockStatement
7104
concatNodeLists();
7105}
7106protected void consumeSwitchLabels() {
7107    // SwitchLabels ::= SwitchLabels SwitchLabel
7108
optimizedConcatNodeLists();
7109}
7110protected void consumeToken(int type) {
7111    /* remember the last consumed value */
7112    /* try to minimize the number of build values */
7113// // clear the commentPtr of the scanner in case we read something different from a modifier
7114
// switch(type) {
7115
// case TokenNameabstract :
7116
// case TokenNamestrictfp :
7117
// case TokenNamefinal :
7118
// case TokenNamenative :
7119
// case TokenNameprivate :
7120
// case TokenNameprotected :
7121
// case TokenNamepublic :
7122
// case TokenNametransient :
7123
// case TokenNamevolatile :
7124
// case TokenNamestatic :
7125
// case TokenNamesynchronized :
7126
// break;
7127
// default:
7128
// this.scanner.commentPtr = -1;
7129
// }
7130
//System.out.println(this.scanner.toStringAction(type));
7131
switch (type) {
7132        case TokenNameIdentifier :
7133            pushIdentifier();
7134            if (this.scanner.useAssertAsAnIndentifier &&
7135                    this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
7136                long positions = this.identifierPositionStack[this.identifierPtr];
7137                if(!this.statementRecoveryActivated) problemReporter().useAssertAsAnIdentifier((int) (positions >>> 32), (int) positions);
7138            }
7139            if (this.scanner.useEnumAsAnIndentifier &&
7140                    this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
7141                long positions = this.identifierPositionStack[this.identifierPtr];
7142                if(!this.statementRecoveryActivated) problemReporter().useEnumAsAnIdentifier((int) (positions >>> 32), (int) positions);
7143            }
7144            break;
7145        case TokenNameinterface :
7146            //'class' is pushing two int (positions) on the stack ==> 'interface' needs to do it too....
7147
pushOnIntStack(this.scanner.currentPosition - 1);
7148            pushOnIntStack(this.scanner.startPosition);
7149            break;
7150        case TokenNameabstract :
7151            checkAndSetModifiers(ClassFileConstants.AccAbstract);
7152            pushOnExpressionStackLengthStack(0);
7153            break;
7154        case TokenNamestrictfp :
7155            checkAndSetModifiers(ClassFileConstants.AccStrictfp);
7156            pushOnExpressionStackLengthStack(0);
7157            break;
7158        case TokenNamefinal :
7159            checkAndSetModifiers(ClassFileConstants.AccFinal);
7160            pushOnExpressionStackLengthStack(0);
7161            break;
7162        case TokenNamenative :
7163            checkAndSetModifiers(ClassFileConstants.AccNative);
7164            pushOnExpressionStackLengthStack(0);
7165            break;
7166        case TokenNameprivate :
7167            checkAndSetModifiers(ClassFileConstants.AccPrivate);
7168            pushOnExpressionStackLengthStack(0);
7169            break;
7170        case TokenNameprotected :
7171            checkAndSetModifiers(ClassFileConstants.AccProtected);
7172            pushOnExpressionStackLengthStack(0);
7173            break;
7174        case TokenNamepublic :
7175            checkAndSetModifiers(ClassFileConstants.AccPublic);
7176            pushOnExpressionStackLengthStack(0);
7177            break;
7178        case TokenNametransient :
7179            checkAndSetModifiers(ClassFileConstants.AccTransient);
7180            pushOnExpressionStackLengthStack(0);
7181            break;
7182        case TokenNamevolatile :
7183            checkAndSetModifiers(ClassFileConstants.AccVolatile);
7184            pushOnExpressionStackLengthStack(0);
7185            break;
7186        case TokenNamestatic :
7187            checkAndSetModifiers(ClassFileConstants.AccStatic);
7188            pushOnExpressionStackLengthStack(0);
7189            break;
7190        case TokenNamesynchronized :
7191            this.synchronizedBlockSourceStart = this.scanner.startPosition;
7192            checkAndSetModifiers(ClassFileConstants.AccSynchronized);
7193            pushOnExpressionStackLengthStack(0);
7194            break;
7195            //==============================
7196
case TokenNamevoid :
7197            pushIdentifier(-T_void);
7198            pushOnIntStack(this.scanner.currentPosition - 1);
7199            pushOnIntStack(this.scanner.startPosition);
7200            break;
7201            //push a default dimension while void is not part of the primitive
7202
//declaration baseType and so takes the place of a type without getting into
7203
//regular type parsing that generates a dimension on this.intStack
7204
case TokenNameboolean :
7205            pushIdentifier(-T_boolean);
7206            pushOnIntStack(this.scanner.currentPosition - 1);
7207            pushOnIntStack(this.scanner.startPosition);
7208            break;
7209        case TokenNamebyte :
7210            pushIdentifier(-T_byte);
7211            pushOnIntStack(this.scanner.currentPosition - 1);
7212            pushOnIntStack(this.scanner.startPosition);
7213            break;
7214        case TokenNamechar :
7215            pushIdentifier(-T_char);
7216            pushOnIntStack(this.scanner.currentPosition - 1);
7217            pushOnIntStack(this.scanner.startPosition);
7218            break;
7219        case TokenNamedouble :
7220            pushIdentifier(-T_double);
7221            pushOnIntStack(this.scanner.currentPosition - 1);
7222            pushOnIntStack(this.scanner.startPosition);
7223            break;
7224        case TokenNamefloat :
7225            pushIdentifier(-T_float);
7226            pushOnIntStack(this.scanner.currentPosition - 1);
7227            pushOnIntStack(this.scanner.startPosition);
7228            break;
7229        case TokenNameint :
7230            pushIdentifier(-T_int);
7231            pushOnIntStack(this.scanner.currentPosition - 1);
7232            pushOnIntStack(this.scanner.startPosition);
7233            break;
7234        case TokenNamelong :
7235            pushIdentifier(-T_long);
7236            pushOnIntStack(this.scanner.currentPosition - 1);
7237            pushOnIntStack(this.scanner.startPosition);
7238            break;
7239        case TokenNameshort :
7240            pushIdentifier(-T_short);
7241            pushOnIntStack(this.scanner.currentPosition - 1);
7242            pushOnIntStack(this.scanner.startPosition);
7243            break;
7244            //==============================
7245
case TokenNameIntegerLiteral :
7246            pushOnExpressionStack(
7247                new IntLiteral(
7248                    this.scanner.getCurrentTokenSource(),
7249                    this.scanner.startPosition,
7250                    this.scanner.currentPosition - 1));
7251            break;
7252        case TokenNameLongLiteral :
7253            pushOnExpressionStack(
7254                new LongLiteral(
7255                    this.scanner.getCurrentTokenSource(),
7256                    this.scanner.startPosition,
7257                    this.scanner.currentPosition - 1));
7258            break;
7259        case TokenNameFloatingPointLiteral :
7260            pushOnExpressionStack(
7261                new FloatLiteral(
7262                    this.scanner.getCurrentTokenSource(),
7263                    this.scanner.startPosition,
7264                    this.scanner.currentPosition - 1));
7265            break;
7266        case TokenNameDoubleLiteral :
7267            pushOnExpressionStack(
7268                new DoubleLiteral(
7269                    this.scanner.getCurrentTokenSource(),
7270                    this.scanner.startPosition,
7271                    this.scanner.currentPosition - 1));
7272            break;
7273        case TokenNameCharacterLiteral :
7274            pushOnExpressionStack(
7275                new CharLiteral(
7276                    this.scanner.getCurrentTokenSource(),
7277                    this.scanner.startPosition,
7278                    this.scanner.currentPosition - 1));
7279            break;
7280        case TokenNameStringLiteral :
7281            StringLiteral stringLiteral;
7282            if (this.recordStringLiterals && this.checkExternalizeStrings && !this.statementRecoveryActivated) {
7283                stringLiteral = this.createStringLiteral(
7284                    this.scanner.getCurrentTokenSourceString(),
7285                    this.scanner.startPosition,
7286                    this.scanner.currentPosition - 1,
7287                    Util.getLineNumber(this.scanner.startPosition, this.scanner.lineEnds, 0, this.scanner.linePtr));
7288                this.compilationUnit.recordStringLiteral(stringLiteral);
7289            } else {
7290                stringLiteral = this.createStringLiteral(
7291                    this.scanner.getCurrentTokenSourceString(),
7292                    this.scanner.startPosition,
7293                    this.scanner.currentPosition - 1,
7294                    0);
7295            }
7296            pushOnExpressionStack(stringLiteral);
7297            break;
7298        case TokenNamefalse :
7299            pushOnExpressionStack(
7300                new FalseLiteral(this.scanner.startPosition, this.scanner.currentPosition - 1));
7301            break;
7302        case TokenNametrue :
7303            pushOnExpressionStack(
7304                new TrueLiteral(this.scanner.startPosition, this.scanner.currentPosition - 1));
7305            break;
7306        case TokenNamenull :
7307            pushOnExpressionStack(
7308                new NullLiteral(this.scanner.startPosition, this.scanner.currentPosition - 1));
7309            break;
7310            //============================
7311
case TokenNamesuper :
7312        case TokenNamethis :
7313            this.endPosition = this.scanner.currentPosition - 1;
7314            pushOnIntStack(this.scanner.startPosition);
7315            break;
7316        case TokenNameassert :
7317        case TokenNameimport :
7318        case TokenNamepackage :
7319        case TokenNamethrow :
7320        case TokenNamedo :
7321        case TokenNameif :
7322        case TokenNamefor :
7323        case TokenNameswitch :
7324        case TokenNametry :
7325        case TokenNamewhile :
7326        case TokenNamebreak :
7327        case TokenNamecontinue :
7328        case TokenNamereturn :
7329        case TokenNamecase :
7330            pushOnIntStack(this.scanner.startPosition);
7331            break;
7332        case TokenNamenew :
7333            // https://bugs.eclipse.org/bugs/show_bug.cgi?id=40954
7334
resetModifiers();
7335            pushOnIntStack(this.scanner.startPosition);
7336            break;
7337        case TokenNameclass :
7338            pushOnIntStack(this.scanner.currentPosition - 1);
7339            pushOnIntStack(this.scanner.startPosition);
7340            break;
7341        case TokenNameenum :
7342            pushOnIntStack(this.scanner.currentPosition - 1);
7343            pushOnIntStack(this.scanner.startPosition);
7344            break;
7345        case TokenNamedefault :
7346            pushOnIntStack(this.scanner.startPosition);
7347            pushOnIntStack(this.scanner.currentPosition - 1);
7348            break;
7349            //let extra semantic action decide when to push
7350
case TokenNameRBRACKET :
7351            this.endPosition = this.scanner.startPosition;
7352            this.endStatementPosition = this.scanner.currentPosition - 1;
7353            break;
7354        case TokenNameLBRACE :
7355            this.endStatementPosition = this.scanner.currentPosition - 1;
7356        case TokenNamePLUS :
7357        case TokenNameMINUS :
7358        case TokenNameNOT :
7359        case TokenNameTWIDDLE :
7360            this.endPosition = this.scanner.startPosition;
7361            break;
7362        case TokenNamePLUS_PLUS :
7363        case TokenNameMINUS_MINUS :
7364            this.endPosition = this.scanner.startPosition;
7365            this.endStatementPosition = this.scanner.currentPosition - 1;
7366            break;
7367        case TokenNameRBRACE:
7368        case TokenNameSEMICOLON :
7369            this.endStatementPosition = this.scanner.currentPosition - 1;
7370            this.endPosition = this.scanner.startPosition - 1;
7371            //the item is not part of the potential futur expression/statement
7372
break;
7373        case TokenNameRPAREN :
7374            // in order to handle ( expression) ////// (cast)expression///// foo(x)
7375
this.rParenPos = this.scanner.currentPosition - 1; // position of the end of right parenthesis (in case of unicode \u0029) lex00101
7376
break;
7377        case TokenNameLPAREN :
7378            this.lParenPos = this.scanner.startPosition;
7379            break;
7380        case TokenNameAT :
7381            pushOnIntStack(this.scanner.startPosition);
7382            break;
7383        case TokenNameQUESTION :
7384            pushOnIntStack(this.scanner.startPosition);
7385            pushOnIntStack(this.scanner.currentPosition - 1);
7386            break;
7387        case TokenNameLESS :
7388            pushOnIntStack(this.scanner.startPosition);
7389            break;
7390        case TokenNameELLIPSIS :
7391            pushOnIntStack(this.scanner.currentPosition - 1);
7392            break;
7393            // case TokenNameCOMMA :
7394
// case TokenNameCOLON :
7395
// case TokenNameEQUAL :
7396
// case TokenNameLBRACKET :
7397
// case TokenNameDOT :
7398
// case TokenNameERROR :
7399
// case TokenNameEOF :
7400
// case TokenNamecase :
7401
// case TokenNamecatch :
7402
// case TokenNameelse :
7403
// case TokenNameextends :
7404
// case TokenNamefinally :
7405
// case TokenNameimplements :
7406
// case TokenNamethrows :
7407
// case TokenNameinstanceof :
7408
// case TokenNameEQUAL_EQUAL :
7409
// case TokenNameLESS_EQUAL :
7410
// case TokenNameGREATER_EQUAL :
7411
// case TokenNameNOT_EQUAL :
7412
// case TokenNameLEFT_SHIFT :
7413
// case TokenNameRIGHT_SHIFT :
7414
// case TokenNameUNSIGNED_RIGHT_SHIFT :
7415
// case TokenNamePLUS_EQUAL :
7416
// case TokenNameMINUS_EQUAL :
7417
// case TokenNameMULTIPLY_EQUAL :
7418
// case TokenNameDIVIDE_EQUAL :
7419
// case TokenNameAND_EQUAL :
7420
// case TokenNameOR_EQUAL :
7421
// case TokenNameXOR_EQUAL :
7422
// case TokenNameREMAINDER_EQUAL :
7423
// case TokenNameLEFT_SHIFT_EQUAL :
7424
// case TokenNameRIGHT_SHIFT_EQUAL :
7425
// case TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL :
7426
// case TokenNameOR_OR :
7427
// case TokenNameAND_AND :
7428
// case TokenNameREMAINDER :
7429
// case TokenNameXOR :
7430
// case TokenNameAND :
7431
// case TokenNameMULTIPLY :
7432
// case TokenNameOR :
7433
// case TokenNameDIVIDE :
7434
// case TokenNameGREATER :
7435
}
7436}
7437protected void consumeTypeArgument() {
7438    pushOnGenericsStack(getTypeReference(this.intStack[this.intPtr--]));
7439}
7440protected void consumeTypeArgumentList() {
7441    concatGenericsLists();
7442}
7443protected void consumeTypeArgumentList1() {
7444    concatGenericsLists();
7445}
7446protected void consumeTypeArgumentList2() {
7447    concatGenericsLists();
7448}
7449protected void consumeTypeArgumentList3() {
7450    concatGenericsLists();
7451}
7452protected void consumeTypeArgumentReferenceType1() {
7453    concatGenericsLists();
7454    pushOnGenericsStack(getTypeReference(0));
7455    intPtr--;
7456}
7457protected void consumeTypeArgumentReferenceType2() {
7458    concatGenericsLists();
7459    pushOnGenericsStack(getTypeReference(0));
7460    intPtr--;
7461}
7462protected void consumeTypeArguments() {
7463    concatGenericsLists();
7464    intPtr--;
7465
7466    if(!this.statementRecoveryActivated &&
7467            options.sourceLevel < ClassFileConstants.JDK1_5 &&
7468            this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
7469        int length = this.genericsLengthStack[this.genericsLengthPtr];
7470        this.problemReporter().invalidUsageOfTypeArguments(
7471            (TypeReference)this.genericsStack[this.genericsPtr - length + 1],
7472            (TypeReference)this.genericsStack[this.genericsPtr]);
7473    }
7474}
7475protected void consumeTypeDeclarations() {
7476    // TypeDeclarations ::= TypeDeclarations TypeDeclaration
7477
concatNodeLists();
7478}
7479protected void consumeTypeImportOnDemandDeclarationName() {
7480    // TypeImportOnDemandDeclarationName ::= 'import' Name '.' '*'
7481
/* push an ImportRef build from the last name
7482    stored in the identifier stack. */

7483
7484    ImportReference impt;
7485    int length;
7486    char[][] tokens = new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
7487    this.identifierPtr -= length;
7488    long[] positions = new long[length];
7489    System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
7490    System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
7491    pushOnAstStack(impt = new ImportReference(tokens, positions, true, ClassFileConstants.AccDefault));
7492
7493    if (this.currentToken == TokenNameSEMICOLON){
7494        impt.declarationSourceEnd = this.scanner.currentPosition - 1;
7495    } else {
7496        impt.declarationSourceEnd = impt.sourceEnd;
7497    }
7498    impt.declarationEnd = impt.declarationSourceEnd;
7499    //this.endPosition is just before the ;
7500
impt.declarationSourceStart = this.intStack[this.intPtr--];
7501
7502    // recovery
7503
if (this.currentElement != null){
7504        this.lastCheckPoint = impt.declarationSourceEnd+1;
7505        this.currentElement = this.currentElement.add(impt, 0);
7506        this.lastIgnoredToken = -1;
7507        this.restartRecovery = true; // used to avoid branching back into the regular automaton
7508
}
7509}
7510protected void consumeTypeParameterHeader() {
7511    //TypeParameterHeader ::= Identifier
7512
TypeParameter typeParameter = new TypeParameter();
7513    long pos = this.identifierPositionStack[this.identifierPtr];
7514    final int end = (int) pos;
7515    typeParameter.declarationSourceEnd = end;
7516    typeParameter.sourceEnd = end;
7517    final int start = (int) (pos >>> 32);
7518    typeParameter.declarationSourceStart = start;
7519    typeParameter.sourceStart = start;
7520    typeParameter.name = this.identifierStack[this.identifierPtr--];
7521    this.identifierLengthPtr--;
7522    pushOnGenericsStack(typeParameter);
7523    
7524    this.listTypeParameterLength++;
7525}
7526protected void consumeTypeParameter1() {
7527    // nothing to do
7528
}
7529protected void consumeTypeParameter1WithExtends() {
7530    //TypeParameter1 ::= TypeParameterHeader 'extends' ReferenceType1
7531
TypeReference superType = (TypeReference) this.genericsStack[this.genericsPtr--];
7532    this.genericsLengthPtr--;
7533    TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
7534    typeParameter.declarationSourceEnd = superType.sourceEnd;
7535    typeParameter.type = superType;
7536    superType.bits |= ASTNode.IsSuperType;
7537    this.genericsStack[this.genericsPtr] = typeParameter;
7538}
7539protected void consumeTypeParameter1WithExtendsAndBounds() {
7540    //TypeParameter1 ::= TypeParameterHeader 'extends' ReferenceType AdditionalBoundList1
7541
int additionalBoundsLength = this.genericsLengthStack[this.genericsLengthPtr--];
7542    TypeReference[] bounds = new TypeReference[additionalBoundsLength];
7543    this.genericsPtr -= additionalBoundsLength;
7544    System.arraycopy(this.genericsStack, this.genericsPtr + 1, bounds, 0, additionalBoundsLength);
7545    TypeReference superType = getTypeReference(this.intStack[this.intPtr--]);
7546    TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
7547    typeParameter.declarationSourceEnd = bounds[additionalBoundsLength - 1].sourceEnd;
7548    typeParameter.type = superType;
7549    superType.bits |= ASTNode.IsSuperType;
7550    typeParameter.bounds = bounds;
7551    for (int i = 0, max = bounds.length; i < max; i++) {
7552        bounds[i].bits |= ASTNode.IsSuperType;
7553    }
7554}
7555protected void consumeTypeParameterList() {
7556    //TypeParameterList ::= TypeParameterList ',' TypeParameter
7557
concatGenericsLists();
7558}
7559protected void consumeTypeParameterList1() {
7560    //TypeParameterList1 ::= TypeParameterList ',' TypeParameter1
7561
concatGenericsLists();
7562}
7563protected void consumeTypeParameters() {
7564    int startPos = this.intStack[this.intPtr--];
7565    
7566    if(this.currentElement != null) {
7567        if(this.currentElement instanceof RecoveredType) {
7568            RecoveredType recoveredType =(RecoveredType) this.currentElement;
7569            int length = this.genericsLengthStack[this.genericsLengthPtr];
7570            TypeParameter[] typeParameters = new TypeParameter[length];
7571            System.arraycopy(this.genericsStack, genericsPtr - length + 1, typeParameters, 0, length);
7572            
7573            recoveredType.add(typeParameters, startPos);
7574        }
7575    }
7576    
7577    
7578    if(!this.statementRecoveryActivated &&
7579            options.sourceLevel < ClassFileConstants.JDK1_5&&
7580            this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
7581        int length = this.genericsLengthStack[this.genericsLengthPtr];
7582        this.problemReporter().invalidUsageOfTypeParameters(
7583            (TypeParameter) this.genericsStack[genericsPtr - length + 1],
7584            (TypeParameter) this.genericsStack[genericsPtr]);
7585    }
7586}
7587protected void consumeTypeParameterWithExtends() {
7588    //TypeParameter ::= TypeParameterHeader 'extends' ReferenceType
7589
TypeReference superType = getTypeReference(this.intStack[this.intPtr--]);
7590    TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
7591    typeParameter.declarationSourceEnd = superType.sourceEnd;
7592    typeParameter.type = superType;
7593    superType.bits |= ASTNode.IsSuperType;
7594}
7595protected void consumeTypeParameterWithExtendsAndBounds() {
7596    //TypeParameter ::= TypeParameterHeader 'extends' ReferenceType AdditionalBoundList
7597
int additionalBoundsLength = this.genericsLengthStack[this.genericsLengthPtr--];
7598    TypeReference[] bounds = new TypeReference[additionalBoundsLength];
7599    this.genericsPtr -= additionalBoundsLength;
7600    System.arraycopy(this.genericsStack, this.genericsPtr + 1, bounds, 0, additionalBoundsLength);
7601    TypeReference superType = getTypeReference(this.intStack[this.intPtr--]);
7602    TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
7603    typeParameter.type = superType;
7604    superType.bits |= ASTNode.IsSuperType;
7605    typeParameter.bounds = bounds;
7606    typeParameter.declarationSourceEnd = bounds[additionalBoundsLength - 1].sourceEnd;
7607    for (int i = 0, max = bounds.length; i < max; i++) {
7608        bounds[i].bits |= ASTNode.IsSuperType;
7609    }
7610}
7611protected void consumeUnaryExpression(int op) {
7612    // UnaryExpression ::= '+' PushPosition UnaryExpression
7613
// UnaryExpression ::= '-' PushPosition UnaryExpression
7614
// UnaryExpressionNotPlusMinus ::= '~' PushPosition UnaryExpression
7615
// UnaryExpressionNotPlusMinus ::= '!' PushPosition UnaryExpression
7616

7617    //optimize the push/pop
7618

7619    //handle manually the -2147483648 while it is not a real
7620
//computation of an - and 2147483648 (notice that 2147483648
7621
//is Integer.MAX_VALUE+1.....)
7622
//Same for -9223372036854775808L ............
7623

7624    //this.intStack have the position of the operator
7625

7626    Expression r, exp = this.expressionStack[this.expressionPtr];
7627    if (op == MINUS) {
7628        if ((exp instanceof IntLiteral) && (((IntLiteral) exp).mayRepresentMIN_VALUE())) {
7629            r = this.expressionStack[this.expressionPtr] = new IntLiteralMinValue();
7630        } else {
7631            if ((exp instanceof LongLiteral) && (((LongLiteral) exp).mayRepresentMIN_VALUE())) {
7632                r = this.expressionStack[this.expressionPtr] = new LongLiteralMinValue();
7633            } else {
7634                r = this.expressionStack[this.expressionPtr] = new UnaryExpression(exp, op);
7635            }
7636        }
7637    } else {
7638        r = this.expressionStack[this.expressionPtr] = new UnaryExpression(exp, op);
7639    }
7640    r.sourceStart = this.intStack[this.intPtr--];
7641    r.sourceEnd = exp.sourceEnd;
7642}
7643protected void consumeUnaryExpression(int op, boolean post) {
7644    // PreIncrementExpression ::= '++' PushPosition UnaryExpression
7645
// PreDecrementExpression ::= '--' PushPosition UnaryExpression
7646

7647    // ++ and -- operators
7648
//optimize the push/pop
7649

7650    //this.intStack has the position of the operator when prefix
7651

7652    Expression leftHandSide = this.expressionStack[this.expressionPtr];
7653    if (leftHandSide instanceof Reference) {
7654        // ++foo()++ is unvalid
7655
if (post) {
7656            this.expressionStack[this.expressionPtr] =
7657                new PostfixExpression(
7658                    leftHandSide,
7659                    IntLiteral.One,
7660                    op,
7661                    this.endStatementPosition);
7662        } else {
7663            this.expressionStack[this.expressionPtr] =
7664                new PrefixExpression(
7665                    leftHandSide,
7666                    IntLiteral.One,
7667                    op,
7668                    this.intStack[this.intPtr--]);
7669        }
7670    } else {
7671        //the ++ or the -- is NOT taken into account if code gen proceeds
7672
if (!post) {
7673            this.intPtr--;
7674        }
7675        if(!this.statementRecoveryActivated) problemReporter().invalidUnaryExpression(leftHandSide);
7676    }
7677}
7678protected void consumeVariableDeclarators() {
7679    // VariableDeclarators ::= VariableDeclarators ',' VariableDeclarator
7680
optimizedConcatNodeLists();
7681}
7682protected void consumeVariableInitializers() {
7683    // VariableInitializers ::= VariableInitializers ',' VariableInitializer
7684
concatExpressionLists();
7685}
7686protected void consumeWildcard() {
7687    final Wildcard wildcard = new Wildcard(Wildcard.UNBOUND);
7688    wildcard.sourceEnd = this.intStack[this.intPtr--];
7689    wildcard.sourceStart = this.intStack[this.intPtr--];
7690    pushOnGenericsStack(wildcard);
7691}
7692protected void consumeWildcard1() {
7693    final Wildcard wildcard = new Wildcard(Wildcard.UNBOUND);
7694    wildcard.sourceEnd = this.intStack[this.intPtr--];
7695    wildcard.sourceStart = this.intStack[this.intPtr--];
7696    pushOnGenericsStack(wildcard);
7697}
7698protected void consumeWildcard1WithBounds() {
7699    // Nothing to do
7700
// The wildcard is created by the consumeWildcardBounds1Extends or by consumeWildcardBounds1Super
7701
}
7702protected void consumeWildcard2() {
7703    final Wildcard wildcard = new Wildcard(Wildcard.UNBOUND);
7704    wildcard.sourceEnd = this.intStack[this.intPtr--];
7705    wildcard.sourceStart = this.intStack[this.intPtr--];
7706    pushOnGenericsStack(wildcard);
7707}
7708protected void consumeWildcard2WithBounds() {
7709    // Nothing to do
7710
// The wildcard is created by the consumeWildcardBounds2Extends or by consumeWildcardBounds2Super
7711
}
7712protected void consumeWildcard3() {
7713    final Wildcard wildcard = new Wildcard(Wildcard.UNBOUND);
7714    wildcard.sourceEnd = this.intStack[this.intPtr--];
7715    wildcard.sourceStart = this.intStack[this.intPtr--];
7716    pushOnGenericsStack(wildcard);
7717}
7718protected void consumeWildcard3WithBounds() {
7719    // Nothing to do
7720
// The wildcard is created by the consumeWildcardBounds3Extends or by consumeWildcardBounds3Super
7721
}
7722protected void consumeWildcardBounds1Extends() {
7723    Wildcard wildcard = new Wildcard(Wildcard.EXTENDS);
7724    wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
7725    wildcard.sourceEnd = wildcard.bound.sourceEnd;
7726    this.intPtr--; // remove end position of the '?'
7727
wildcard.sourceStart = this.intStack[this.intPtr--];
7728    this.genericsStack[this.genericsPtr] = wildcard;
7729}
7730protected void consumeWildcardBounds1Super() {
7731    Wildcard wildcard = new Wildcard(Wildcard.SUPER);
7732    wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
7733    this.intPtr--; // remove the starting position of the super keyword
7734
wildcard.sourceEnd = wildcard.bound.sourceEnd;
7735    this.intPtr--; // remove end position of the '?'
7736
wildcard.sourceStart = this.intStack[this.intPtr--];
7737    this.genericsStack[this.genericsPtr] = wildcard;
7738}
7739protected void consumeWildcardBounds2Extends() {
7740    Wildcard wildcard = new Wildcard(Wildcard.EXTENDS);
7741    wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
7742    wildcard.sourceEnd = wildcard.bound.sourceEnd;
7743    this.intPtr--; // remove end position of the '?'
7744
wildcard.sourceStart = this.intStack[this.intPtr--];
7745    this.genericsStack[this.genericsPtr] = wildcard;
7746}
7747protected void consumeWildcardBounds2Super() {
7748    Wildcard wildcard = new Wildcard(Wildcard.SUPER);
7749    wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
7750    this.intPtr--; // remove the starting position of the super keyword
7751
wildcard.sourceEnd = wildcard.bound.sourceEnd;
7752    this.intPtr--; // remove end position of the '?'
7753
wildcard.sourceStart = this.intStack[this.intPtr--];
7754    this.genericsStack[this.genericsPtr] = wildcard;
7755}
7756protected void consumeWildcardBounds3Extends() {
7757    Wildcard wildcard = new Wildcard(Wildcard.EXTENDS);
7758    wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
7759    wildcard.sourceEnd = wildcard.bound.sourceEnd;
7760    this.intPtr--; // remove end position of the '?'
7761
wildcard.sourceStart = this.intStack[this.intPtr--];
7762    this.genericsStack[this.genericsPtr] = wildcard;
7763}
7764protected void consumeWildcardBounds3Super() {
7765    Wildcard wildcard = new Wildcard(Wildcard.SUPER);
7766    wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
7767    this.intPtr--; // remove the starting position of the super keyword
7768
wildcard.sourceEnd = wildcard.bound.sourceEnd;
7769    this.intPtr--; // remove end position of the '?'
7770
wildcard.sourceStart = this.intStack[this.intPtr--];
7771    this.genericsStack[this.genericsPtr] = wildcard;
7772}
7773protected void consumeWildcardBoundsExtends() {
7774    Wildcard wildcard = new Wildcard(Wildcard.EXTENDS);
7775    wildcard.bound = getTypeReference(this.intStack[this.intPtr--]);
7776    wildcard.sourceEnd = wildcard.bound.sourceEnd;
7777    this.intPtr--; // remove end position of the '?'
7778
wildcard.sourceStart = this.intStack[this.intPtr--];
7779    pushOnGenericsStack(wildcard);
7780}
7781protected void consumeWildcardBoundsSuper() {
7782    Wildcard wildcard = new Wildcard(Wildcard.SUPER);
7783    wildcard.bound = getTypeReference(this.intStack[this.intPtr--]);
7784    this.intPtr--; // remove the starting position of the super keyword
7785
wildcard.sourceEnd = wildcard.bound.sourceEnd;
7786    this.intPtr--; // remove end position of the '?'
7787
wildcard.sourceStart = this.intStack[this.intPtr--];
7788    pushOnGenericsStack(wildcard);
7789}
7790protected void consumeWildcardWithBounds() {
7791    // Nothing to do
7792
// The wildcard is created by the consumeWildcardBoundsExtends or by consumeWildcardBoundsSuper
7793
}
7794/**
7795 * Given the current comment stack, answer whether some comment is available in a certain exclusive range
7796 *
7797 * @param sourceStart int
7798 * @param sourceEnd int
7799 * @return boolean
7800 */

7801public boolean containsComment(int sourceStart, int sourceEnd) {
7802    int iComment = this.scanner.commentPtr;
7803    for (; iComment >= 0; iComment--) {
7804        int commentStart = this.scanner.commentStarts[iComment];
7805        // ignore comments before start
7806
if (commentStart < sourceStart) continue;
7807        // ignore comments after end
7808
if (commentStart > sourceEnd) continue;
7809        return true;
7810    }
7811    return false;
7812}
7813public MethodDeclaration convertToMethodDeclaration(ConstructorDeclaration c, CompilationResult compilationResult) {
7814    MethodDeclaration m = new MethodDeclaration(compilationResult);
7815    m.typeParameters = c.typeParameters;
7816    m.sourceStart = c.sourceStart;
7817    m.sourceEnd = c.sourceEnd;
7818    m.bodyStart = c.bodyStart;
7819    m.bodyEnd = c.bodyEnd;
7820    m.declarationSourceEnd = c.declarationSourceEnd;
7821    m.declarationSourceStart = c.declarationSourceStart;
7822    m.selector = c.selector;
7823    m.statements = c.statements;
7824    m.modifiers = c.modifiers;
7825    m.annotations = c.annotations;
7826    m.arguments = c.arguments;
7827    m.thrownExceptions = c.thrownExceptions;
7828    m.explicitDeclarations = c.explicitDeclarations;
7829    m.returnType = null;
7830    m.javadoc = c.javadoc;
7831    return m;
7832}
7833protected TypeReference copyDims(TypeReference typeRef, int dim) {
7834    return typeRef.copyDims(dim);
7835}
7836protected FieldDeclaration createFieldDeclaration(char[] fieldDeclarationName, int sourceStart, int sourceEnd) {
7837    return new FieldDeclaration(fieldDeclarationName, sourceStart, sourceEnd);
7838}
7839protected JavadocParser createJavadocParser() {
7840    return new JavadocParser(this);
7841}
7842protected LocalDeclaration createLocalDeclaration(char[] localDeclarationName, int sourceStart, int sourceEnd) {
7843    return new LocalDeclaration(localDeclarationName, sourceStart, sourceEnd);
7844}
7845protected StringLiteral createStringLiteral(char[] token, int start, int end, int lineNumber) {
7846    return new StringLiteral(token, start, end, lineNumber);
7847}
7848protected RecoveredType currentRecoveryType() {
7849    if(this.currentElement != null) {
7850        if(this.currentElement instanceof RecoveredType) {
7851            return (RecoveredType) this.currentElement;
7852        } else {
7853            return this.currentElement.enclosingType();
7854        }
7855    }
7856    return null;
7857}
7858public CompilationUnitDeclaration dietParse(ICompilationUnit sourceUnit, CompilationResult compilationResult) {
7859
7860    CompilationUnitDeclaration parsedUnit;
7861    boolean old = this.diet;
7862    try {
7863        this.diet = true;
7864        parsedUnit = parse(sourceUnit, compilationResult);
7865    } finally {
7866        this.diet = old;
7867    }
7868    return parsedUnit;
7869}
7870protected void dispatchDeclarationInto(int length) {
7871    /* they are length on this.astStack that should go into
7872       methods fields constructors lists of the typeDecl
7873
7874       Return if there is a constructor declaration in the methods declaration */

7875       
7876    
7877    // Looks for the size of each array .
7878

7879    if (length == 0)
7880        return;
7881    int[] flag = new int[length + 1]; //plus one -- see <HERE>
7882
int size1 = 0, size2 = 0, size3 = 0;
7883    boolean hasAbstractMethods = false;
7884    for (int i = length - 1; i >= 0; i--) {
7885        ASTNode astNode = this.astStack[this.astPtr--];
7886        if (astNode instanceof AbstractMethodDeclaration) {
7887            //methods and constructors have been regrouped into one single list
7888
flag[i] = 2;
7889            size2++;
7890            if (((AbstractMethodDeclaration) astNode).isAbstract()) {
7891                hasAbstractMethods = true;
7892            }
7893        } else if (astNode instanceof TypeDeclaration) {
7894            flag[i] = 3;
7895            size3++;
7896        } else {
7897            //field
7898
flag[i] = 1;
7899            size1++;
7900        }
7901    }
7902
7903    //arrays creation
7904
TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
7905    if (size1 != 0) {
7906        typeDecl.fields = new FieldDeclaration[size1];
7907    }
7908    if (size2 != 0) {
7909        typeDecl.methods = new AbstractMethodDeclaration[size2];
7910        if (hasAbstractMethods) typeDecl.bits |= ASTNode.HasAbstractMethods;
7911    }
7912    if (size3 != 0) {
7913        typeDecl.memberTypes = new TypeDeclaration[size3];
7914    }
7915
7916    //arrays fill up
7917
size1 = size2 = size3 = 0;
7918    int flagI = flag[0], start = 0;
7919    int length2;
7920    for (int end = 0; end <= length; end++) //<HERE> the plus one allows to
7921
{
7922        if (flagI != flag[end]) //treat the last element as a ended flag.....
7923
{ //array copy
7924
switch (flagI) {
7925                case 1 :
7926                    size1 += (length2 = end - start);
7927                    System.arraycopy(
7928                        this.astStack,
7929                        this.astPtr + start + 1,
7930                        typeDecl.fields,
7931                        size1 - length2,
7932                        length2);
7933                    break;
7934                case 2 :
7935                    size2 += (length2 = end - start);
7936                    System.arraycopy(
7937                        this.astStack,
7938                        this.astPtr + start + 1,
7939                        typeDecl.methods,
7940                        size2 - length2,
7941                        length2);
7942                    break;
7943                case 3 :
7944                    size3 += (length2 = end - start);
7945                    System.arraycopy(
7946                        this.astStack,
7947                        this.astPtr + start + 1,
7948                        typeDecl.memberTypes,
7949                        size3 - length2,
7950                        length2);
7951                    break;
7952            }
7953            flagI = flag[start = end];
7954        }
7955    }
7956
7957    if (typeDecl.memberTypes != null) {
7958        for (int i = typeDecl.memberTypes.length - 1; i >= 0; i--) {
7959            typeDecl.memberTypes[i].enclosingType = typeDecl;
7960        }
7961    }
7962}
7963protected void dispatchDeclarationIntoEnumDeclaration(int length) {
7964    
7965    if (length == 0)
7966      return;
7967   int[] flag = new int[length + 1]; //plus one -- see <HERE>
7968
int size1 = 0, size2 = 0, size3 = 0;
7969   TypeDeclaration enumDeclaration = (TypeDeclaration) this.astStack[this.astPtr - length];
7970   boolean hasAbstractMethods = false;
7971   for (int i = length - 1; i >= 0; i--) {
7972      ASTNode astNode = this.astStack[this.astPtr--];
7973      if (astNode instanceof AbstractMethodDeclaration) {
7974         //methods and constructors have been regrouped into one single list
7975
flag[i] = 2;
7976         size2++;
7977        if (((AbstractMethodDeclaration) astNode).isAbstract()) {
7978            hasAbstractMethods = true;
7979        }
7980      } else if (astNode instanceof TypeDeclaration) {
7981         flag[i] = 3;
7982         size3++;
7983      } else if (astNode instanceof FieldDeclaration) {
7984         flag[i] = 1;
7985         size1++;
7986// if(astNode instanceof EnumConstant) {
7987
// EnumConstant constant = (EnumConstant) astNode;
7988
// ((AllocationExpression)constant.initialization).type = new SingleTypeReference(enumDeclaration.name,
7989
// (((long) enumDeclaration.sourceStart) << 32) + enumDeclaration.sourceEnd);
7990
// }
7991
}
7992   }
7993 
7994   //arrays creation
7995
if (size1 != 0) {
7996      enumDeclaration.fields = new FieldDeclaration[size1];
7997   }
7998   if (size2 != 0) {
7999      enumDeclaration.methods = new AbstractMethodDeclaration[size2];
8000      if (hasAbstractMethods) enumDeclaration.bits |= ASTNode.HasAbstractMethods;
8001   }
8002   if (size3 != 0) {
8003      enumDeclaration.memberTypes = new TypeDeclaration[size3];
8004   }
8005 
8006   //arrays fill up
8007
size1 = size2 = size3 = 0;
8008   int flagI = flag[0], start = 0;
8009   int length2;
8010   for (int end = 0; end <= length; end++) //<HERE> the plus one allows to
8011
{
8012      if (flagI != flag[end]) //treat the last element as a ended flag.....
8013
{ //array copy
8014
switch (flagI) {
8015            case 1 :
8016               size1 += (length2 = end - start);
8017               System.arraycopy(
8018                  this.astStack,
8019                  this.astPtr + start + 1,
8020                  enumDeclaration.fields,
8021                  size1 - length2,
8022                  length2);
8023               break;
8024            case 2 :
8025               size2 += (length2 = end - start);
8026               System.arraycopy(
8027                  this.astStack,
8028                  this.astPtr + start + 1,
8029                  enumDeclaration.methods,
8030                  size2 - length2,
8031                  length2);
8032               break;
8033            case 3 :
8034               size3 += (length2 = end - start);
8035               System.arraycopy(
8036                  this.astStack,
8037                  this.astPtr + start + 1,
8038                  enumDeclaration.memberTypes,
8039                  size3 - length2,
8040                  length2);
8041               break;
8042         }
8043         flagI = flag[start = end];
8044      }
8045   }
8046 
8047   if (enumDeclaration.memberTypes != null) {
8048      for (int i = enumDeclaration.memberTypes.length - 1; i >= 0; i--) {
8049         enumDeclaration.memberTypes[i].enclosingType = enumDeclaration;
8050      }
8051   }}
8052protected CompilationUnitDeclaration endParse(int act) {
8053
8054    this.lastAct = act;
8055
8056    if(this.statementRecoveryActivated) {
8057        RecoveredElement recoveredElement = this.buildInitialRecoveryState();
8058        recoveredElement.topElement().updateParseTree();
8059        if(this.hasError) this.resetStacks();
8060    } else if (this.currentElement != null){
8061        if (VERBOSE_RECOVERY){
8062            System.out.print(Messages.parser_syntaxRecovery);
8063            System.out.println("--------------------------"); //$NON-NLS-1$
8064
System.out.println(this.compilationUnit);
8065            System.out.println("----------------------------------"); //$NON-NLS-1$
8066
}
8067        this.currentElement.topElement().updateParseTree();
8068    } else {
8069        if (this.diet & VERBOSE_RECOVERY){
8070            System.out.print(Messages.parser_regularParse);
8071            System.out.println("--------------------------"); //$NON-NLS-1$
8072
System.out.println(this.compilationUnit);
8073            System.out.println("----------------------------------"); //$NON-NLS-1$
8074
}
8075    }
8076    persistLineSeparatorPositions();
8077    for (int i = 0; i < this.scanner.foundTaskCount; i++){
8078        if(!this.statementRecoveryActivated) problemReporter().task(
8079            new String JavaDoc(this.scanner.foundTaskTags[i]),
8080            new String JavaDoc(this.scanner.foundTaskMessages[i]),
8081            this.scanner.foundTaskPriorities[i] == null ? null : new String JavaDoc(this.scanner.foundTaskPriorities[i]),
8082            this.scanner.foundTaskPositions[i][0],
8083            this.scanner.foundTaskPositions[i][1]);
8084    }
8085    return this.compilationUnit;
8086}
8087/*
8088 * Flush comments defined prior to a given positions.
8089 *
8090 * Note: comments are stacked in syntactical order
8091 *
8092 * Either answer given <position>, or the end position of a comment line
8093 * immediately following the <position> (same line)
8094 *
8095 * e.g.
8096 * void foo(){
8097 * } // end of method foo
8098 */

8099 
8100public int flushCommentsDefinedPriorTo(int position) {
8101
8102    int lastCommentIndex = this.scanner.commentPtr;
8103    if (lastCommentIndex < 0) return position; // no comment
8104

8105    // compute the index of the first obsolete comment
8106
int index = lastCommentIndex;
8107    int validCount = 0;
8108    while (index >= 0){
8109        int commentEnd = this.scanner.commentStops[index];
8110        if (commentEnd < 0) commentEnd = -commentEnd; // negative end position for non-javadoc comments
8111
if (commentEnd <= position){
8112            break;
8113        }
8114        index--;
8115        validCount++;
8116    }
8117    // if the source at <position> is immediately followed by a line comment, then
8118
// flush this comment and shift <position> to the comment end.
8119
if (validCount > 0){
8120        int immediateCommentEnd = -this.scanner.commentStops[index+1]; //non-javadoc comment end positions are negative
8121
if (immediateCommentEnd > 0){ // only tolerating non-javadoc comments
8122
// is there any line break until the end of the immediate comment ? (thus only tolerating line comment)
8123
immediateCommentEnd--; // comment end in one char too far
8124
if (Util.getLineNumber(position, this.scanner.lineEnds, 0, this.scanner.linePtr)
8125                    == Util.getLineNumber(immediateCommentEnd, this.scanner.lineEnds, 0, this.scanner.linePtr)){
8126                position = immediateCommentEnd;
8127                validCount--; // flush this comment
8128
index++;
8129            }
8130        }
8131    }
8132
8133    if (index < 0) return position; // no obsolete comment
8134

8135    switch (validCount) {
8136        case 0:
8137            // do nothing
8138
break;
8139        // move valid comment infos, overriding obsolete comment infos
8140
case 2:
8141            this.scanner.commentStarts[0] = this.scanner.commentStarts[index+1];
8142            this.scanner.commentStops[0] = this.scanner.commentStops[index+1];
8143            this.scanner.commentTagStarts[0] = this.scanner.commentTagStarts[index+1];
8144            this.scanner.commentStarts[1] = this.scanner.commentStarts[index+2];
8145            this.scanner.commentStops[1] = this.scanner.commentStops[index+2];
8146            this.scanner.commentTagStarts[1] = this.scanner.commentTagStarts[index+2];
8147            break;
8148        case 1:
8149            this.scanner.commentStarts[0] = this.scanner.commentStarts[index+1];
8150            this.scanner.commentStops[0] = this.scanner.commentStops[index+1];
8151            this.scanner.commentTagStarts[0] = this.scanner.commentTagStarts[index+1];
8152            break;
8153        default:
8154            System.arraycopy(this.scanner.commentStarts, index + 1, this.scanner.commentStarts, 0, validCount);
8155            System.arraycopy(this.scanner.commentStops, index + 1, this.scanner.commentStops, 0, validCount);
8156            System.arraycopy(this.scanner.commentTagStarts, index + 1, this.scanner.commentTagStarts, 0, validCount);
8157    }
8158    this.scanner.commentPtr = validCount - 1;
8159    return position;
8160}
8161protected TypeReference getAnnotationType() {
8162    int length = this.identifierLengthStack[this.identifierLengthPtr--];
8163    if (length == 1) {
8164        return new SingleTypeReference(
8165                this.identifierStack[this.identifierPtr],
8166                this.identifierPositionStack[this.identifierPtr--]);
8167    } else {
8168        char[][] tokens = new char[length][];
8169        this.identifierPtr -= length;
8170        long[] positions = new long[length];
8171        System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
8172        System.arraycopy(
8173            this.identifierPositionStack,
8174            this.identifierPtr + 1,
8175            positions,
8176            0,
8177            length);
8178        return new QualifiedTypeReference(tokens, positions);
8179    }
8180}
8181public int getFirstToken() {
8182    // the first token is a virtual token that
8183
// allows the parser to parse several goals
8184
// even if they aren't LALR(1)....
8185
// Goal ::= '++' CompilationUnit
8186
// Goal ::= '--' MethodBody
8187
// Goal ::= '==' ConstructorBody
8188
// -- Initializer
8189
// Goal ::= '>>' StaticInitializer
8190
// Goal ::= '>>' Block
8191
// -- error recovery
8192
// Goal ::= '>>>' Headers
8193
// Goal ::= '*' BlockStatements
8194
// Goal ::= '*' MethodPushModifiersHeader
8195
// -- JDOM
8196
// Goal ::= '&&' FieldDeclaration
8197
// Goal ::= '||' ImportDeclaration
8198
// Goal ::= '?' PackageDeclaration
8199
// Goal ::= '+' TypeDeclaration
8200
// Goal ::= '/' GenericMethodDeclaration
8201
// Goal ::= '&' ClassBodyDeclaration
8202
// -- code snippet
8203
// Goal ::= '%' Expression
8204
// -- completion parser
8205
// Goal ::= '!' ConstructorBlockStatementsopt
8206
// Goal ::= '~' BlockStatementsopt
8207

8208    return this.firstToken;
8209}
8210/*
8211 * Answer back an array of sourceStart/sourceEnd positions of the available JavaDoc comments.
8212 * The array is a flattened structure: 2*n entries with consecutives start and end positions.
8213 *
8214 * If no JavaDoc is available, then null is answered instead of an empty array.
8215 *
8216 * e.g. { 10, 20, 25, 45 } --> javadoc1 from 10 to 20, javadoc2 from 25 to 45
8217 */

8218public int[] getJavaDocPositions() {
8219
8220    int javadocCount = 0;
8221    for (int i = 0, max = this.scanner.commentPtr; i <= max; i++){
8222        // javadoc only (non javadoc comment have negative end positions.)
8223
if (this.scanner.commentStops[i] > 0){
8224            javadocCount++;
8225        }
8226    }
8227    if (javadocCount == 0) return null;
8228
8229    int[] positions = new int[2*javadocCount];
8230    int index = 0;
8231    for (int i = 0, max = this.scanner.commentPtr; i <= max; i++){
8232        // javadoc only (non javadoc comment have negative end positions.)
8233
if (this.scanner.commentStops[i] > 0){
8234            positions[index++] = this.scanner.commentStarts[i];
8235            positions[index++] = this.scanner.commentStops[i]-1; //stop is one over
8236
}
8237    }
8238    return positions;
8239}
8240    public void getMethodBodies(CompilationUnitDeclaration unit) {
8241        //fill the methods bodies in order for the code to be generated
8242

8243        if (unit == null) return;
8244        
8245        if (unit.ignoreMethodBodies) {
8246            unit.ignoreFurtherInvestigation = true;
8247            return;
8248            // if initial diet parse did not work, no need to dig into method bodies.
8249
}
8250
8251        if ((unit.bits & ASTNode.HasAllMethodBodies) != 0)
8252            return; //work already done ...
8253

8254        // save existing values to restore them at the end of the parsing process
8255
// see bug 47079 for more details
8256
int[] oldLineEnds = this.scanner.lineEnds;
8257        int oldLinePtr = this.scanner.linePtr;
8258
8259        //real parse of the method....
8260
CompilationResult compilationResult = unit.compilationResult;
8261        char[] contents = compilationResult.compilationUnit.getContents();
8262        this.scanner.setSource(contents, compilationResult);
8263        
8264        if (this.javadocParser != null && this.javadocParser.checkDocComment) {
8265            this.javadocParser.scanner.setSource(contents);
8266        }
8267        if (unit.types != null) {
8268            for (int i = unit.types.length; --i >= 0;)
8269                unit.types[i].parseMethod(this, unit);
8270        }
8271        
8272        // tag unit has having read bodies
8273
unit.bits |= ASTNode.HasAllMethodBodies;
8274
8275        // this is done to prevent any side effects on the compilation unit result
8276
// line separator positions array.
8277
this.scanner.lineEnds = oldLineEnds;
8278        this.scanner.linePtr = oldLinePtr;
8279    }
8280protected char getNextCharacter(char[] comment, int[] index) {
8281    char nextCharacter = comment[index[0]++];
8282    switch(nextCharacter) {
8283        case '\\' :
8284            int c1, c2, c3, c4;
8285            index[0]++;
8286            while (comment[index[0]] == 'u') index[0]++;
8287            if (!(((c1 = ScannerHelper.getNumericValue(comment[index[0]++])) > 15
8288                || c1 < 0)
8289                || ((c2 = ScannerHelper.getNumericValue(comment[index[0]++])) > 15 || c2 < 0)
8290                || ((c3 = ScannerHelper.getNumericValue(comment[index[0]++])) > 15 || c3 < 0)
8291                || ((c4 = ScannerHelper.getNumericValue(comment[index[0]++])) > 15 || c4 < 0))) {
8292                    nextCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
8293            }
8294            break;
8295    }
8296    return nextCharacter;
8297}
8298protected Expression getTypeReference(Expression exp) {
8299    
8300    exp.bits &= ~ASTNode.RestrictiveFlagMASK;
8301    exp.bits |= Binding.TYPE;
8302    return exp;
8303}
8304protected TypeReference getTypeReference(int dim) {
8305    /* build a Reference on a variable that may be qualified or not
8306     This variable is a type reference and dim will be its dimensions*/

8307
8308    TypeReference ref;
8309    int length = this.identifierLengthStack[this.identifierLengthPtr--];
8310    if (length < 0) { //flag for precompiled type reference on base types
8311
ref = TypeReference.baseTypeReference(-length, dim);
8312        ref.sourceStart = this.intStack[this.intPtr--];
8313        if (dim == 0) {
8314            ref.sourceEnd = this.intStack[this.intPtr--];
8315        } else {
8316            this.intPtr--;
8317            ref.sourceEnd = this.endPosition;
8318        }
8319    } else {
8320        int numberOfIdentifiers = this.genericsIdentifiersLengthStack[this.genericsIdentifiersLengthPtr--];
8321        if (length != numberOfIdentifiers || this.genericsLengthStack[this.genericsLengthPtr] != 0) {
8322            // generic type
8323
ref = getTypeReferenceForGenericType(dim, length, numberOfIdentifiers);
8324        } else if (length == 1) {
8325            // single variable reference
8326
this.genericsLengthPtr--; // pop the 0
8327
if (dim == 0) {
8328                ref =
8329                    new SingleTypeReference(
8330                        this.identifierStack[this.identifierPtr],
8331                        this.identifierPositionStack[this.identifierPtr--]);
8332            } else {
8333                ref =
8334                    new ArrayTypeReference(
8335                        this.identifierStack[this.identifierPtr],
8336                        dim,
8337                        this.identifierPositionStack[this.identifierPtr--]);
8338                ref.sourceEnd = this.endPosition;
8339            }
8340        } else {
8341            this.genericsLengthPtr--;
8342            //Qualified variable reference
8343
char[][] tokens = new char[length][];
8344            this.identifierPtr -= length;
8345            long[] positions = new long[length];
8346            System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
8347            System.arraycopy(
8348                this.identifierPositionStack,
8349                this.identifierPtr + 1,
8350                positions,
8351                0,
8352                length);
8353            if (dim == 0) {
8354                ref = new QualifiedTypeReference(tokens, positions);
8355            } else {
8356                ref = new ArrayQualifiedTypeReference(tokens, dim, positions);
8357                ref.sourceEnd = this.endPosition;
8358            }
8359        }
8360    }
8361    return ref;
8362}
8363protected TypeReference getTypeReferenceForGenericType(int dim, int identifierLength, int numberOfIdentifiers) {
8364    if (identifierLength == 1 && numberOfIdentifiers == 1) {
8365        int currentTypeArgumentsLength = this.genericsLengthStack[this.genericsLengthPtr--];
8366        TypeReference[] typeArguments = new TypeReference[currentTypeArgumentsLength];
8367        this.genericsPtr -= currentTypeArgumentsLength;
8368        System.arraycopy(this.genericsStack, this.genericsPtr + 1, typeArguments, 0, currentTypeArgumentsLength);
8369        ParameterizedSingleTypeReference parameterizedSingleTypeReference = new ParameterizedSingleTypeReference(this.identifierStack[this.identifierPtr], typeArguments, dim, this.identifierPositionStack[this.identifierPtr--]);
8370        if (dim != 0) {
8371            parameterizedSingleTypeReference.sourceEnd = this.endStatementPosition;
8372        }
8373        return parameterizedSingleTypeReference;
8374    } else {
8375        TypeReference[][] typeArguments = new TypeReference[numberOfIdentifiers][];
8376        char[][] tokens = new char[numberOfIdentifiers][];
8377        long[] positions = new long[numberOfIdentifiers];
8378        int index = numberOfIdentifiers;
8379        int currentIdentifiersLength = identifierLength;
8380        while (index > 0) {
8381            int currentTypeArgumentsLength = this.genericsLengthStack[this.genericsLengthPtr--];
8382            if (currentTypeArgumentsLength != 0) {
8383                this.genericsPtr -= currentTypeArgumentsLength;
8384                System.arraycopy(this.genericsStack, this.genericsPtr + 1, typeArguments[index - 1] = new TypeReference[currentTypeArgumentsLength], 0, currentTypeArgumentsLength);
8385            }
8386            switch(currentIdentifiersLength) {
8387                case 1 :
8388                    // we are in a case A<B>.C<D> or A<B>.C<D>
8389
tokens[index - 1] = this.identifierStack[this.identifierPtr];
8390                    positions[index - 1] = this.identifierPositionStack[this.identifierPtr--];
8391                    break;
8392                default:
8393                    // we are in a case A.B.C<B>.C<D> or A.B.C<B>...
8394
this.identifierPtr -= currentIdentifiersLength;
8395                    System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, index - currentIdentifiersLength, currentIdentifiersLength);
8396                    System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, index - currentIdentifiersLength, currentIdentifiersLength);
8397            }
8398            index -= currentIdentifiersLength;
8399            if (index > 0) {
8400                currentIdentifiersLength = this.identifierLengthStack[this.identifierLengthPtr--];
8401            }
8402        }
8403        ParameterizedQualifiedTypeReference parameterizedQualifiedTypeReference = new ParameterizedQualifiedTypeReference(tokens, typeArguments, dim, positions);
8404        if (dim != 0) {
8405            parameterizedQualifiedTypeReference.sourceEnd = this.endStatementPosition;
8406        }
8407        return parameterizedQualifiedTypeReference;
8408    }
8409}
8410protected NameReference getUnspecifiedReference() {
8411    /* build a (unspecified) NameReference which may be qualified*/
8412
8413    int length;
8414    NameReference ref;
8415    if ((length = this.identifierLengthStack[this.identifierLengthPtr--]) == 1)
8416        // single variable reference
8417
ref =
8418            new SingleNameReference(
8419                this.identifierStack[this.identifierPtr],
8420                this.identifierPositionStack[this.identifierPtr--]);
8421    else
8422        //Qualified variable reference
8423
{
8424        char[][] tokens = new char[length][];
8425        this.identifierPtr -= length;
8426        System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
8427        long[] positions = new long[length];
8428        System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
8429        ref =
8430            new QualifiedNameReference(tokens,
8431                positions,
8432                (int) (this.identifierPositionStack[this.identifierPtr + 1] >> 32), // sourceStart
8433
(int) this.identifierPositionStack[this.identifierPtr + length]); // sourceEnd
8434
}
8435    return ref;
8436}
8437protected NameReference getUnspecifiedReferenceOptimized() {
8438    /* build a (unspecified) NameReference which may be qualified
8439    The optimization occurs for qualified reference while we are
8440    certain in this case the last item of the qualified name is
8441    a field access. This optimization is IMPORTANT while it results
8442    that when a NameReference is build, the type checker should always
8443    look for that it is not a type reference */

8444
8445    int length;
8446    NameReference ref;
8447    if ((length = this.identifierLengthStack[this.identifierLengthPtr--]) == 1) {
8448        // single variable reference
8449
ref =
8450            new SingleNameReference(
8451                this.identifierStack[this.identifierPtr],
8452                this.identifierPositionStack[this.identifierPtr--]);
8453        ref.bits &= ~ASTNode.RestrictiveFlagMASK;
8454        ref.bits |= Binding.LOCAL | Binding.FIELD;
8455        return ref;
8456    }
8457
8458    //Qualified-variable-reference
8459
//In fact it is variable-reference DOT field-ref , but it would result in a type
8460
//conflict tha can be only reduce by making a superclass (or inetrface ) between
8461
//nameReference and FiledReference or putting FieldReference under NameReference
8462
//or else..........This optimisation is not really relevant so just leave as it is
8463

8464    char[][] tokens = new char[length][];
8465    this.identifierPtr -= length;
8466    System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
8467    long[] positions = new long[length];
8468    System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
8469    ref = new QualifiedNameReference(
8470            tokens,
8471            positions,
8472            (int) (this.identifierPositionStack[this.identifierPtr + 1] >> 32), // sourceStart
8473
(int) this.identifierPositionStack[this.identifierPtr + length]); // sourceEnd
8474
ref.bits &= ~ASTNode.RestrictiveFlagMASK;
8475    ref.bits |= Binding.LOCAL | Binding.FIELD;
8476    return ref;
8477}
8478public void goForBlockStatementsopt() {
8479    //tells the scanner to go for block statements opt parsing
8480

8481    this.firstToken = TokenNameTWIDDLE;
8482    this.scanner.recordLineSeparator = false;
8483}
8484public void goForBlockStatementsOrCatchHeader() {
8485    //tells the scanner to go for block statements or method headers parsing
8486

8487    this.firstToken = TokenNameMULTIPLY;
8488    this.scanner.recordLineSeparator = false;
8489}
8490public void goForClassBodyDeclarations() {
8491    //tells the scanner to go for any body declarations parsing
8492

8493    this.firstToken = TokenNameAND;
8494    this.scanner.recordLineSeparator = true;
8495}
8496public void goForCompilationUnit(){
8497    //tells the scanner to go for compilation unit parsing
8498

8499    this.firstToken = TokenNamePLUS_PLUS ;
8500    this.scanner.foundTaskCount = 0;
8501    this.scanner.recordLineSeparator = true;
8502}
8503public void goForExpression() {
8504    //tells the scanner to go for an expression parsing
8505

8506    this.firstToken = TokenNameREMAINDER;
8507    this.scanner.recordLineSeparator = true; // recovery goals must record line separators
8508
}
8509public void goForFieldDeclaration(){
8510    //tells the scanner to go for field declaration parsing
8511

8512    this.firstToken = TokenNameAND_AND ;
8513    this.scanner.recordLineSeparator = true;
8514}
8515public void goForGenericMethodDeclaration(){
8516    //tells the scanner to go for generic method declarations parsing
8517

8518    this.firstToken = TokenNameDIVIDE;
8519    this.scanner.recordLineSeparator = true;
8520}
8521public void goForHeaders(){
8522    //tells the scanner to go for headers only parsing
8523
RecoveredType currentType = this.currentRecoveryType();
8524    if(currentType != null && currentType.insideEnumConstantPart) {
8525        this.firstToken = TokenNameNOT;
8526    } else {
8527        this.firstToken = TokenNameUNSIGNED_RIGHT_SHIFT;
8528    }
8529    this.scanner.recordLineSeparator = true; // recovery goals must record line separators
8530
}
8531public void goForImportDeclaration(){
8532    //tells the scanner to go for import declaration parsing
8533

8534    this.firstToken = TokenNameOR_OR ;
8535    this.scanner.recordLineSeparator = true;
8536}
8537public void goForInitializer(){
8538    //tells the scanner to go for initializer parsing
8539

8540    this.firstToken = TokenNameRIGHT_SHIFT ;
8541    this.scanner.recordLineSeparator = false;
8542}
8543public void goForMemberValue() {
8544    //tells the scanner to go for a member value parsing
8545

8546    this.firstToken = TokenNameOR_OR;
8547    this.scanner.recordLineSeparator = true; // recovery goals must record line separators
8548
}
8549public void goForMethodBody(){
8550    //tells the scanner to go for method body parsing
8551

8552    this.firstToken = TokenNameMINUS_MINUS ;
8553    this.scanner.recordLineSeparator = false;
8554}
8555public void goForPackageDeclaration() {
8556    //tells the scanner to go for package declaration parsing
8557

8558    this.firstToken = TokenNameQUESTION;
8559    this.scanner.recordLineSeparator = true;
8560}
8561public void goForTypeDeclaration() {
8562    //tells the scanner to go for type (interface or class) declaration parsing
8563

8564    this.firstToken = TokenNamePLUS;
8565    this.scanner.recordLineSeparator = true;
8566}
8567protected void ignoreExpressionAssignment() {
8568    // Assignment ::= InvalidArrayInitializerAssignement
8569
// encoded operator would be: this.intStack[this.intPtr]
8570
this.intPtr--;
8571    ArrayInitializer arrayInitializer = (ArrayInitializer) this.expressionStack[this.expressionPtr--];
8572    this.expressionLengthPtr -- ;
8573    // report a syntax error and abort parsing
8574
if(!this.statementRecoveryActivated) problemReporter().arrayConstantsOnlyInArrayInitializers(arrayInitializer.sourceStart, arrayInitializer.sourceEnd);
8575}
8576public void initialize() {
8577    this.initialize(false);
8578}
8579public void initialize(boolean initializeNLS) {
8580    //positionning the parser for a new compilation unit
8581
//avoiding stack reallocation and all that....
8582
this.astPtr = -1;
8583    this.astLengthPtr = -1;
8584    this.expressionPtr = -1;
8585    this.expressionLengthPtr = -1;
8586    this.identifierPtr = -1;
8587    this.identifierLengthPtr = -1;
8588    this.intPtr = -1;
8589    this.nestedMethod[this.nestedType = 0] = 0; // need to reset for further reuse
8590
this.variablesCounter[this.nestedType] = 0;
8591    this.dimensions = 0 ;
8592    this.realBlockPtr = -1;
8593    this.compilationUnit = null;
8594    this.referenceContext = null;
8595    this.endStatementPosition = 0;
8596
8597    //remove objects from stack too, while the same parser/compiler couple is
8598
//re-used between two compilations ....
8599

8600    int astLength = this.astStack.length;
8601    if (this.noAstNodes.length < astLength){
8602        this.noAstNodes = new ASTNode[astLength];
8603        //System.out.println("Resized AST stacks : "+ astLength);
8604

8605    }
8606    System.arraycopy(this.noAstNodes, 0, this.astStack, 0, astLength);
8607
8608    int expressionLength = this.expressionStack.length;
8609    if (this.noExpressions.length < expressionLength){
8610        this.noExpressions = new Expression[expressionLength];
8611        //System.out.println("Resized EXPR stacks : "+ expressionLength);
8612
}
8613    System.arraycopy(this.noExpressions, 0, this.expressionStack, 0, expressionLength);
8614
8615    // reset this.scanner state
8616
this.scanner.commentPtr = -1;
8617    this.scanner.foundTaskCount = 0;
8618    this.scanner.eofPosition = Integer.MAX_VALUE;
8619    this.recordStringLiterals = true;
8620    final boolean checkNLS = this.options.getSeverity(CompilerOptions.NonExternalizedString) != ProblemSeverities.Ignore;
8621    this.checkExternalizeStrings = checkNLS;
8622    this.scanner.checkNonExternalizedStringLiterals = initializeNLS && checkNLS;
8623
8624    resetModifiers();
8625
8626    // recovery
8627
this.lastCheckPoint = -1;
8628    this.currentElement = null;
8629    this.restartRecovery = false;
8630    this.hasReportedError = false;
8631    this.recoveredStaticInitializerStart = 0;
8632    this.lastIgnoredToken = -1;
8633    this.lastErrorEndPosition = -1;
8634    this.lastErrorEndPositionBeforeRecovery = -1;
8635    this.lastJavadocEnd = -1;
8636    this.listLength = 0;
8637    this.listTypeParameterLength = 0;
8638    
8639    this.rBraceStart = 0;
8640    this.rBraceEnd = 0;
8641    this.rBraceSuccessorStart = 0;
8642
8643    this.genericsIdentifiersLengthPtr = -1;
8644    this.genericsLengthPtr = -1;
8645    this.genericsPtr = -1;
8646}
8647public void initializeScanner(){
8648    this.scanner = new Scanner(
8649        false /*comment*/,
8650        false /*whitespace*/,
8651        false, /* will be set in initialize(boolean) */
8652        this.options.sourceLevel /*sourceLevel*/,
8653        this.options.complianceLevel /*complianceLevel*/,
8654        this.options.taskTags/*taskTags*/,
8655        this.options.taskPriorites/*taskPriorities*/,
8656        this.options.isTaskCaseSensitive/*taskCaseSensitive*/);
8657}
8658public void jumpOverMethodBody() {
8659    //on diet parsing.....do not buffer method statements
8660

8661    //the scanner.diet is reinitialized to false
8662
//automatically by the scanner once it has jumped over
8663
//the statements
8664

8665    if (this.diet && (this.dietInt == 0))
8666        this.scanner.diet = true;
8667}
8668private void jumpOverType(){
8669    if (this.recoveredTypes != null && this.nextTypeStart > -1 && this.nextTypeStart < this.scanner.currentPosition) {
8670        
8671        if (DEBUG_AUTOMATON) {
8672            System.out.println("Jump -"); //$NON-NLS-1$
8673
}
8674        
8675        TypeDeclaration typeDeclaration = this.recoveredTypes[this.recoveredTypePtr];
8676        boolean isAnonymous = typeDeclaration.allocation != null;
8677        
8678        int end = this.scanner.eofPosition;
8679        this.scanner.resetTo(typeDeclaration.declarationSourceEnd + 1, end - 1);
8680        if(!isAnonymous) {
8681            ((RecoveryScanner)this.scanner).setPendingTokens(new int[]{TokenNameSEMICOLON, TokenNamebreak});
8682        } else {
8683            ((RecoveryScanner)this.scanner).setPendingTokens(new int[]{TokenNameIdentifier, TokenNameEQUAL, TokenNameIdentifier});
8684        }
8685        
8686        this.pendingRecoveredType = typeDeclaration;
8687        
8688        try {
8689            this.currentToken = this.scanner.getNextToken();
8690        } catch(InvalidInputException e){
8691            // it's impossible because we added pending tokens before
8692
}
8693        
8694        if(++this.recoveredTypePtr < this.recoveredTypes.length) {
8695            TypeDeclaration nextTypeDeclaration = this.recoveredTypes[this.recoveredTypePtr];
8696            this.nextTypeStart =
8697                nextTypeDeclaration.allocation == null
8698                    ? nextTypeDeclaration.declarationSourceStart
8699                            : nextTypeDeclaration.allocation.sourceStart;
8700        } else {
8701            this.nextTypeStart = Integer.MAX_VALUE;
8702        }
8703    }
8704}
8705protected void markEnclosingMemberWithLocalType() {
8706    if (this.currentElement != null) return; // this is already done in the recovery code
8707
for (int i = this.astPtr; i >= 0; i--) {
8708        ASTNode node = this.astStack[i];
8709        if (node instanceof AbstractMethodDeclaration
8710                || node instanceof FieldDeclaration
8711                || (node instanceof TypeDeclaration // mark type for now: all initializers will be marked when added to this type
8712
// and enclosing type must not be closed (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=147485)
8713
&& ((TypeDeclaration) node).declarationSourceEnd == 0)) {
8714            node.bits |= ASTNode.HasLocalType;
8715            return;
8716        }
8717    }
8718    // default to reference context (case of parse method body)
8719
if (this.referenceContext instanceof AbstractMethodDeclaration
8720            || this.referenceContext instanceof TypeDeclaration) {
8721        ((ASTNode)this.referenceContext).bits |= ASTNode.HasLocalType;
8722    }
8723}
8724protected void markInitializersWithLocalType(TypeDeclaration type) {
8725    if (type.fields == null || (type.bits & ASTNode.HasLocalType) == 0) return;
8726    for (int i = 0, length = type.fields.length; i < length; i++) {
8727        FieldDeclaration field = type.fields[i];
8728        if (field instanceof Initializer) {
8729            field.bits |= ASTNode.HasLocalType;
8730        }
8731    }
8732}
8733
8734/*
8735 * Move checkpoint location (current implementation is moving it by one token)
8736 *
8737 * Answers true if successfully moved checkpoint (in other words, it did not attempt to move it
8738 * beyond end of file).
8739 */

8740protected boolean moveRecoveryCheckpoint() {
8741
8742    int pos = this.lastCheckPoint;
8743    /* reset this.scanner, and move checkpoint by one token */
8744    this.scanner.startPosition = pos;
8745    this.scanner.currentPosition = pos;
8746    this.scanner.diet = false; // quit jumping over method bodies
8747

8748    /* if about to restart, then no need to shift token */
8749    if (this.restartRecovery){
8750        this.lastIgnoredToken = -1;
8751        this.scanner.insideRecovery = true;
8752        return true;
8753    }
8754    
8755    /* protect against shifting on an invalid token */
8756    this.lastIgnoredToken = this.nextIgnoredToken;
8757    this.nextIgnoredToken = -1;
8758    do {
8759        try {
8760            this.nextIgnoredToken = this.scanner.getNextToken();
8761            if(this.scanner.currentPosition == this.scanner.startPosition){
8762                this.scanner.currentPosition++; // on fake completion identifier
8763
this.nextIgnoredToken = -1;
8764            }
8765            
8766        } catch(InvalidInputException e){
8767            pos = this.scanner.currentPosition;
8768        }
8769    } while (this.nextIgnoredToken < 0);
8770    
8771    if (this.nextIgnoredToken == TokenNameEOF) { // no more recovery after this point
8772
if (this.currentToken == TokenNameEOF) { // already tried one iteration on EOF
8773
return false;
8774        }
8775    }
8776    this.lastCheckPoint = this.scanner.currentPosition;
8777    
8778    /* reset this.scanner again to previous checkpoint location*/
8779    this.scanner.startPosition = pos;
8780    this.scanner.currentPosition = pos;
8781    this.scanner.commentPtr = -1;
8782    this.scanner.foundTaskCount = 0;
8783    return true;
8784
8785/*
8786    The following implementation moves the checkpoint location by one line:
8787     
8788    int pos = this.lastCheckPoint;
8789    // reset this.scanner, and move checkpoint by one token
8790    this.scanner.startPosition = pos;
8791    this.scanner.currentPosition = pos;
8792    this.scanner.diet = false; // quit jumping over method bodies
8793    
8794    // if about to restart, then no need to shift token
8795    if (this.restartRecovery){
8796        this.lastIgnoredToken = -1;
8797        return true;
8798    }
8799    
8800    // protect against shifting on an invalid token
8801    this.lastIgnoredToken = this.nextIgnoredToken;
8802    this.nextIgnoredToken = -1;
8803    
8804    boolean wasTokenizingWhiteSpace = this.scanner.tokenizeWhiteSpace;
8805    this.scanner.tokenizeWhiteSpace = true;
8806    checkpointMove:
8807        do {
8808            try {
8809                this.nextIgnoredToken = this.scanner.getNextToken();
8810                switch(this.nextIgnoredToken){
8811                    case Scanner.TokenNameWHITESPACE :
8812                        if(this.scanner.getLineNumber(this.scanner.startPosition)
8813                            == this.scanner.getLineNumber(this.scanner.currentPosition)){
8814                            this.nextIgnoredToken = -1;
8815                            }
8816                        break;
8817                    case TokenNameSEMICOLON :
8818                    case TokenNameLBRACE :
8819                    case TokenNameRBRACE :
8820                        break;
8821                    case TokenNameIdentifier :
8822                        if(this.scanner.currentPosition == this.scanner.startPosition){
8823                            this.scanner.currentPosition++; // on fake completion identifier
8824                        }
8825                    default:
8826                        this.nextIgnoredToken = -1;
8827                        break;
8828                    case TokenNameEOF :
8829                        break checkpointMove;
8830                }
8831            } catch(InvalidInputException e){
8832                pos = this.scanner.currentPosition;
8833            }
8834        } while (this.nextIgnoredToken < 0);
8835    this.scanner.tokenizeWhiteSpace = wasTokenizingWhiteSpace;
8836    
8837    if (this.nextIgnoredToken == TokenNameEOF) { // no more recovery after this point
8838        if (this.currentToken == TokenNameEOF) { // already tried one iteration on EOF
8839            return false;
8840        }
8841    }
8842    this.lastCheckPoint = this.scanner.currentPosition;
8843    
8844    // reset this.scanner again to previous checkpoint location
8845    this.scanner.startPosition = pos;
8846    this.scanner.currentPosition = pos;
8847    this.scanner.commentPtr = -1;
8848
8849    return true;
8850*/

8851}
8852protected MessageSend newMessageSend() {
8853    // '(' ArgumentListopt ')'
8854
// the arguments are on the expression stack
8855

8856    MessageSend m = new MessageSend();
8857    int length;
8858    if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
8859        this.expressionPtr -= length;
8860        System.arraycopy(
8861            this.expressionStack,
8862            this.expressionPtr + 1,
8863            m.arguments = new Expression[length],
8864            0,
8865            length);
8866    }
8867    return m;
8868}
8869protected MessageSend newMessageSendWithTypeArguments() {
8870    MessageSend m = new MessageSend();
8871    int length;
8872    if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
8873        this.expressionPtr -= length;
8874        System.arraycopy(
8875            this.expressionStack,
8876            this.expressionPtr + 1,
8877            m.arguments = new Expression[length],
8878            0,
8879            length);
8880    }
8881    return m;
8882}
8883protected void optimizedConcatNodeLists() {
8884    /*back from a recursive loop. Virtualy group the
8885    astNode into an array using this.astLengthStack*/

8886
8887    /*
8888     * This is a case where you have two sublists into the this.astStack that you want
8889     * to merge in one list. There is no action required on the this.astStack. The only
8890     * thing you need to do is merge the two lengths specified on the astStackLength.
8891     * The top two length are for example:
8892     * ... p n
8893     * and you want to result in a list like:
8894     * ... n+p
8895     * This means that the p could be equals to 0 in case there is no astNode pushed
8896     * on the this.astStack.
8897     * Look at the InterfaceMemberDeclarations for an example.
8898     * This case optimizes the fact that p == 1.
8899     */

8900
8901    this.astLengthStack[--this.astLengthPtr]++;
8902}
8903/*main loop of the automat
8904When a rule is reduced, the method consumeRule(int) is called with the number
8905of the consumed rule. When a terminal is consumed, the method consumeToken(int) is
8906called in order to remember (when needed) the consumed token */

8907// (int)asr[asi(act)]
8908
// name[symbol_index[currentKind]]
8909
protected void parse() {
8910    if (DEBUG) System.out.println("-- ENTER INSIDE PARSE METHOD --"); //$NON-NLS-1$
8911

8912    if (DEBUG_AUTOMATON) {
8913        System.out.println("- Start --------------------------------"); //$NON-NLS-1$
8914
}
8915    
8916    boolean isDietParse = this.diet;
8917    int oldFirstToken = getFirstToken();
8918    this.hasError = false;
8919    
8920    this.hasReportedError = false;
8921    int act = START_STATE;
8922    this.stateStackTop = -1;
8923    this.currentToken = getFirstToken();
8924    ProcessTerminals : for (;;) {
8925        int stackLength = this.stack.length;
8926        if (++this.stateStackTop >= stackLength) {
8927            System.arraycopy(
8928                this.stack, 0,
8929                this.stack = new int[stackLength + StackIncrement], 0,
8930                stackLength);
8931        }
8932        this.stack[this.stateStackTop] = act;
8933
8934        act = tAction(act, this.currentToken);
8935        if (act == ERROR_ACTION || this.restartRecovery) {
8936            
8937            if (DEBUG_AUTOMATON) {
8938                if (this.restartRecovery) {
8939                    System.out.println("Restart - "); //$NON-NLS-1$
8940
} else {
8941                    System.out.println("Error - "); //$NON-NLS-1$
8942
}
8943            }
8944            
8945            int errorPos = this.scanner.currentPosition;
8946            if (!this.hasReportedError) {
8947                this.hasError = true;
8948            }
8949            if (resumeOnSyntaxError()) {
8950                if (act == ERROR_ACTION) this.lastErrorEndPosition = errorPos;
8951                act = START_STATE;
8952                this.stateStackTop = -1;
8953                this.currentToken = getFirstToken();
8954                continue ProcessTerminals;
8955            }
8956            act = ERROR_ACTION;
8957            break ProcessTerminals;
8958        }
8959        if (act <= NUM_RULES) {
8960            this.stateStackTop--;
8961            
8962            if (DEBUG_AUTOMATON) {
8963                System.out.print("Reduce - "); //$NON-NLS-1$
8964
}
8965            
8966        } else if (act > ERROR_ACTION) { /* shift-reduce */
8967            consumeToken(this.currentToken);
8968            if (this.currentElement != null) this.recoveryTokenCheck();
8969            try {
8970                this.currentToken = this.scanner.getNextToken();
8971            } catch(InvalidInputException e){
8972                if (!this.hasReportedError){
8973                    this.problemReporter().scannerError(this, e.getMessage());
8974                    this.hasReportedError = true;
8975                }
8976                this.lastCheckPoint = this.scanner.currentPosition;
8977                this.restartRecovery = true;
8978            }
8979            if(this.statementRecoveryActivated) {
8980                this.jumpOverType();
8981            }
8982            act -= ERROR_ACTION;
8983            
8984            if (DEBUG_AUTOMATON) {
8985                System.out.print("Shift/Reduce - (" + name[terminal_index[this.currentToken]]+") "); //$NON-NLS-1$ //$NON-NLS-2$
8986
}
8987            
8988        } else {
8989            if (act < ACCEPT_ACTION) { /* shift */
8990                consumeToken(this.currentToken);
8991                if (this.currentElement != null) this.recoveryTokenCheck();
8992                try{
8993                    this.currentToken = this.scanner.getNextToken();
8994                } catch(InvalidInputException e){
8995                    if (!this.hasReportedError){
8996                        this.problemReporter().scannerError(this, e.getMessage());
8997                        this.hasReportedError = true;
8998                    }
8999                    this.lastCheckPoint = this.scanner.currentPosition;
9000                    this.restartRecovery = true;
9001                }
9002                if(this.statementRecoveryActivated) {
9003                    this.jumpOverType();
9004                }
9005                if (DEBUG_AUTOMATON) {
9006                    System.out.println("Shift - (" + name[terminal_index[this.currentToken]]+")"); //$NON-NLS-1$ //$NON-NLS-2$
9007
}
9008                continue ProcessTerminals;
9009            }
9010            break ProcessTerminals;
9011        }
9012            
9013        // ProcessNonTerminals :
9014
do { /* reduce */
9015            
9016            if (DEBUG_AUTOMATON) {
9017                System.out.println(name[non_terminal_index[lhs[act]]]);
9018            }
9019            
9020            consumeRule(act);
9021            this.stateStackTop -= (rhs[act] - 1);
9022            act = ntAction(this.stack[this.stateStackTop], lhs[act]);
9023            
9024            if (DEBUG_AUTOMATON && act <= NUM_RULES) {
9025                System.out.print(" - "); //$NON-NLS-1$
9026
}
9027            
9028        } while (act <= NUM_RULES);
9029        
9030        if (DEBUG_AUTOMATON) {
9031            System.out.println("----------------------------------------"); //$NON-NLS-1$
9032
}
9033    }
9034    
9035    if (DEBUG_AUTOMATON) {
9036        System.out.println("- End ----------------------------------"); //$NON-NLS-1$
9037
}
9038    
9039    endParse(act);
9040    // record all nls tags in the corresponding compilation unit
9041
final NLSTag[] tags = this.scanner.getNLSTags();
9042    if (tags != null) {
9043        this.compilationUnit.nlsTags = tags;
9044    }
9045    
9046    this.scanner.checkNonExternalizedStringLiterals = false;
9047    if (this.reportSyntaxErrorIsRequired && this.hasError && !this.statementRecoveryActivated) {
9048        if(!this.options.performStatementsRecovery) {
9049            reportSyntaxErrors(isDietParse, oldFirstToken);
9050        } else {
9051            RecoveryScannerData data = this.referenceContext.compilationResult().recoveryScannerData;
9052            
9053            if(this.recoveryScanner == null) {
9054                this.recoveryScanner = new RecoveryScanner(this.scanner, data);
9055            } else {
9056                this.recoveryScanner.setData(data);
9057            }
9058            
9059            this.recoveryScanner.setSource(scanner.source);
9060            this.recoveryScanner.lineEnds = this.scanner.lineEnds;
9061            this.recoveryScanner.linePtr = this.scanner.linePtr;
9062            
9063            reportSyntaxErrors(isDietParse, oldFirstToken);
9064            
9065            if(data == null) {
9066                this.referenceContext.compilationResult().recoveryScannerData =
9067                    this.recoveryScanner.getData();
9068            }
9069            
9070            if (this.methodRecoveryActivated && this.options.performStatementsRecovery) {
9071                this.methodRecoveryActivated = false;
9072                this.recoverStatements();
9073                this.methodRecoveryActivated = true;
9074
9075                this.lastAct = ERROR_ACTION;
9076            }
9077        }
9078    }
9079    
9080    if (DEBUG) System.out.println("-- EXIT FROM PARSE METHOD --"); //$NON-NLS-1$
9081
}
9082public void parse(ConstructorDeclaration cd, CompilationUnitDeclaration unit) {
9083    parse(cd, unit, false);
9084}
9085public void parse(ConstructorDeclaration cd, CompilationUnitDeclaration unit, boolean recordLineSeparator) {
9086    //only parse the method body of cd
9087
//fill out its statements
9088

9089    //convert bugs into parse error
9090

9091    boolean oldMethodRecoveryActivated = this.methodRecoveryActivated;
9092    if(this.options.performMethodsFullRecovery) {
9093        this.methodRecoveryActivated = true;
9094    }
9095    
9096    initialize();
9097    goForBlockStatementsopt();
9098    if (recordLineSeparator) {
9099        this.scanner.recordLineSeparator = true;
9100    }
9101    this.nestedMethod[this.nestedType]++;
9102    pushOnRealBlockStack(0);
9103    
9104    this.referenceContext = cd;
9105    this.compilationUnit = unit;
9106
9107    this.scanner.resetTo(cd.bodyStart, cd.bodyEnd);
9108    try {
9109        parse();
9110    } catch (AbortCompilation ex) {
9111        this.lastAct = ERROR_ACTION;
9112    } finally {
9113        this.nestedMethod[this.nestedType]--;
9114        if(this.options.performStatementsRecovery) {
9115            this.methodRecoveryActivated = oldMethodRecoveryActivated;
9116        }
9117    }
9118
9119    checkNonNLSAfterBodyEnd(cd.declarationSourceEnd);
9120    
9121    if (this.lastAct == ERROR_ACTION) {
9122        initialize();
9123        return;
9124    }
9125
9126    //statements
9127
cd.explicitDeclarations = this.realBlockStack[this.realBlockPtr--];
9128    int length;
9129    if (astLengthPtr > -1 && (length = this.astLengthStack[this.astLengthPtr--]) != 0) {
9130        this.astPtr -= length;
9131        if (this.astStack[this.astPtr + 1] instanceof ExplicitConstructorCall)
9132            //avoid a isSomeThing that would only be used here BUT what is faster between two alternatives ?
9133
{
9134            System.arraycopy(
9135                this.astStack,
9136                this.astPtr + 2,
9137                cd.statements = new Statement[length - 1],
9138                0,
9139                length - 1);
9140            cd.constructorCall = (ExplicitConstructorCall) this.astStack[this.astPtr + 1];
9141        } else { //need to add explicitly the super();
9142
System.arraycopy(
9143                this.astStack,
9144                this.astPtr + 1,
9145                cd.statements = new Statement[length],
9146                0,
9147                length);
9148            cd.constructorCall = SuperReference.implicitSuperConstructorCall();
9149        }
9150    } else {
9151        cd.constructorCall = SuperReference.implicitSuperConstructorCall();
9152        if (!containsComment(cd.bodyStart, cd.bodyEnd)) {
9153            cd.bits |= ASTNode.UndocumentedEmptyBlock;
9154        }
9155    }
9156
9157    if (cd.constructorCall.sourceEnd == 0) {
9158        cd.constructorCall.sourceEnd = cd.sourceEnd;
9159        cd.constructorCall.sourceStart = cd.sourceStart;
9160    }
9161}
9162// A P I
9163

9164public void parse(
9165    FieldDeclaration field,
9166    TypeDeclaration type,
9167    CompilationUnitDeclaration unit,
9168    char[] initializationSource) {
9169    //only parse the initializationSource of the given field
9170

9171    //convert bugs into parse error
9172

9173    initialize();
9174    goForExpression();
9175    this.nestedMethod[this.nestedType]++;
9176
9177    this.referenceContext = type;
9178    this.compilationUnit = unit;
9179
9180    this.scanner.setSource(initializationSource);
9181    this.scanner.resetTo(0, initializationSource.length-1);
9182    try {
9183        parse();
9184    } catch (AbortCompilation ex) {
9185        this.lastAct = ERROR_ACTION;
9186    } finally {
9187        this.nestedMethod[this.nestedType]--;
9188    }
9189
9190    if (this.lastAct == ERROR_ACTION) {
9191        return;
9192    }
9193
9194    field.initialization = this.expressionStack[this.expressionPtr];
9195    
9196    // mark field with local type if one was found during parsing
9197
if ((type.bits & ASTNode.HasLocalType) != 0) {
9198        field.bits |= ASTNode.HasLocalType;
9199    }
9200}
9201// A P I
9202

9203public CompilationUnitDeclaration parse(
9204    ICompilationUnit sourceUnit,
9205    CompilationResult compilationResult) {
9206    // parses a compilation unit and manages error handling (even bugs....)
9207

9208    return parse(sourceUnit, compilationResult, -1, -1/*parse without reseting the scanner*/);
9209}
9210// A P I
9211

9212public CompilationUnitDeclaration parse(
9213    ICompilationUnit sourceUnit,
9214    CompilationResult compilationResult,
9215    int start,
9216    int end) {
9217    // parses a compilation unit and manages error handling (even bugs....)
9218

9219    CompilationUnitDeclaration unit;
9220    try {
9221        /* automaton initialization */
9222        initialize(true);
9223        goForCompilationUnit();
9224
9225        /* unit creation */
9226        this.referenceContext =
9227            this.compilationUnit =
9228                new CompilationUnitDeclaration(
9229                    this.problemReporter,
9230                    compilationResult,
9231                    0);
9232
9233        /* scanners initialization */
9234        char[] contents;
9235        try {
9236            contents = sourceUnit.getContents();
9237        } catch(AbortCompilationUnit abortException) {
9238            this.problemReporter().cannotReadSource(this.compilationUnit, abortException, this.options.verbose);
9239            contents = CharOperation.NO_CHAR; // pretend empty from thereon
9240
}
9241        this.scanner.setSource(contents);
9242        this.compilationUnit.sourceEnd = this.scanner.source.length - 1;
9243        if (end != -1) this.scanner.resetTo(start, end);
9244        if (this.javadocParser != null && this.javadocParser.checkDocComment) {
9245            this.javadocParser.scanner.setSource(contents);
9246            if (end != -1) {
9247                this.javadocParser.scanner.resetTo(start, end);
9248            }
9249        }
9250        /* run automaton */
9251        parse();
9252    } finally {
9253        unit = this.compilationUnit;
9254        this.compilationUnit = null; // reset parser
9255
// tag unit has having read bodies
9256
if (!this.diet) unit.bits |= ASTNode.HasAllMethodBodies;
9257    }
9258    return unit;
9259}
9260// A P I
9261

9262public void parse(
9263    Initializer initializer,
9264    TypeDeclaration type,
9265    CompilationUnitDeclaration unit) {
9266    //only parse the method body of md
9267
//fill out method statements
9268

9269    //convert bugs into parse error
9270

9271    boolean oldMethodRecoveryActivated = this.methodRecoveryActivated;
9272    if(this.options.performMethodsFullRecovery) {
9273        this.methodRecoveryActivated = true;
9274    }
9275    
9276    initialize();
9277    goForBlockStatementsopt();
9278    this.nestedMethod[this.nestedType]++;
9279    pushOnRealBlockStack(0);
9280    
9281    this.referenceContext = type;
9282    this.compilationUnit = unit;
9283
9284    this.scanner.resetTo(initializer.bodyStart, initializer.bodyEnd); // just on the beginning {
9285
try {
9286        parse();
9287    } catch (AbortCompilation ex) {
9288        this.lastAct = ERROR_ACTION;
9289    } finally {
9290        this.nestedMethod[this.nestedType]--;
9291        if(this.options.performStatementsRecovery) {
9292            this.methodRecoveryActivated = oldMethodRecoveryActivated;
9293        }
9294    }
9295
9296    checkNonNLSAfterBodyEnd(initializer.declarationSourceEnd);
9297    
9298    if (this.lastAct == ERROR_ACTION) {
9299        return;
9300    }
9301    
9302    //refill statements
9303
initializer.block.explicitDeclarations = this.realBlockStack[this.realBlockPtr--];
9304    int length;
9305    if (astLengthPtr > -1 && (length = this.astLengthStack[this.astLengthPtr--]) > 0) {
9306        System.arraycopy(this.astStack, (this.astPtr -= length) + 1, initializer.block.statements = new Statement[length], 0, length);
9307    } else {
9308        // check whether this block at least contains some comment in it
9309
if (!containsComment(initializer.block.sourceStart, initializer.block.sourceEnd)) {
9310            initializer.block.bits |= ASTNode.UndocumentedEmptyBlock;
9311        }
9312    }
9313    
9314    // mark initializer with local type if one was found during parsing
9315
if ((type.bits & ASTNode.HasLocalType) != 0) {
9316        initializer.bits |= ASTNode.HasLocalType;
9317    }
9318}
9319// A P I
9320
public void parse(MethodDeclaration md, CompilationUnitDeclaration unit) {
9321    //only parse the method body of md
9322
//fill out method statements
9323

9324    //convert bugs into parse error
9325

9326    if (md.isAbstract())
9327        return;
9328    if (md.isNative())
9329        return;
9330    if ((md.modifiers & ExtraCompilerModifiers.AccSemicolonBody) != 0)
9331        return;
9332
9333    boolean oldMethodRecoveryActivated = this.methodRecoveryActivated;
9334    if(this.options.performMethodsFullRecovery) {
9335        this.methodRecoveryActivated = true;
9336        this.rParenPos = md.sourceEnd;
9337    }
9338    initialize();
9339    goForBlockStatementsopt();
9340    this.nestedMethod[this.nestedType]++;
9341    pushOnRealBlockStack(0);
9342
9343    this.referenceContext = md;
9344    this.compilationUnit = unit;
9345
9346    this.scanner.resetTo(md.bodyStart, md.bodyEnd);
9347    // reset the scanner to parser from { down to }
9348
try {
9349        parse();
9350    } catch (AbortCompilation ex) {
9351        this.lastAct = ERROR_ACTION;
9352    } finally {
9353        this.nestedMethod[this.nestedType]--;
9354        if(this.options.performStatementsRecovery) {
9355            this.methodRecoveryActivated = oldMethodRecoveryActivated;
9356        }
9357    }
9358
9359    checkNonNLSAfterBodyEnd(md.declarationSourceEnd);
9360    
9361    if (this.lastAct == ERROR_ACTION) {
9362        return;
9363    }
9364
9365    //refill statements
9366
md.explicitDeclarations = this.realBlockStack[this.realBlockPtr--];
9367    int length;
9368    if (astLengthPtr > -1 && (length = this.astLengthStack[this.astLengthPtr--]) != 0) {
9369        System.arraycopy(
9370            this.astStack,
9371            (this.astPtr -= length) + 1,
9372            md.statements = new Statement[length],
9373            0,
9374            length);
9375    } else {
9376        if (!containsComment(md.bodyStart, md.bodyEnd)) {
9377            md.bits |= ASTNode.UndocumentedEmptyBlock;
9378        }
9379    }
9380}
9381public ASTNode[] parseClassBodyDeclarations(char[] source, int offset, int length, CompilationUnitDeclaration unit) {
9382    /* automaton initialization */
9383    initialize();
9384    goForClassBodyDeclarations();
9385    /* scanner initialization */
9386    this.scanner.setSource(source);
9387    this.scanner.resetTo(offset, offset + length - 1);
9388    if (this.javadocParser != null && this.javadocParser.checkDocComment) {
9389        this.javadocParser.scanner.setSource(source);
9390        this.javadocParser.scanner.resetTo(offset, offset + length - 1);
9391    }
9392
9393    /* type declaration should be parsed as member type declaration */
9394    this.nestedType = 1;
9395
9396    /* unit creation */
9397    this.referenceContext = unit;
9398    this.compilationUnit = unit;
9399
9400    /* run automaton */
9401    try {
9402        parse();
9403    } catch (AbortCompilation ex) {
9404        this.lastAct = ERROR_ACTION;
9405    }
9406
9407    if (this.lastAct == ERROR_ACTION) {
9408        return null;
9409    }
9410    int astLength;
9411    if (astLengthPtr > -1 && (astLength = this.astLengthStack[this.astLengthPtr--]) != 0) {
9412        ASTNode[] result = new ASTNode[astLength];
9413        this.astPtr -= astLength;
9414        System.arraycopy(this.astStack, this.astPtr + 1, result, 0, astLength);
9415        return result;
9416    }
9417    return null;
9418}
9419public Expression parseExpression(char[] source, int offset, int length, CompilationUnitDeclaration unit) {
9420
9421    initialize();
9422    goForExpression();
9423    this.nestedMethod[this.nestedType]++;
9424
9425    this.referenceContext = unit;
9426    this.compilationUnit = unit;
9427
9428    this.scanner.setSource(source);
9429    this.scanner.resetTo(offset, offset + length - 1);
9430    try {
9431        parse();
9432    } catch (AbortCompilation ex) {
9433        this.lastAct = ERROR_ACTION;
9434    } finally {
9435        this.nestedMethod[this.nestedType]--;
9436    }
9437
9438    if (this.lastAct == ERROR_ACTION) {
9439        return null;
9440    }
9441
9442    return this.expressionStack[this.expressionPtr];
9443}
9444public Expression parseMemberValue(char[] source, int offset, int length, CompilationUnitDeclaration unit) {
9445
9446    initialize();
9447    goForMemberValue();
9448    this.nestedMethod[this.nestedType]++;
9449
9450    this.referenceContext = unit;
9451    this.compilationUnit = unit;
9452
9453    this.scanner.setSource(source);
9454    this.scanner.resetTo(offset, offset + length - 1);
9455    try {
9456        parse();
9457    } catch (AbortCompilation ex) {
9458        this.lastAct = ERROR_ACTION;
9459    } finally {
9460        this.nestedMethod[this.nestedType]--;
9461    }
9462
9463    if (this.lastAct == ERROR_ACTION) {
9464        return null;
9465    }
9466
9467    return this.expressionStack[this.expressionPtr];
9468}
9469public void parseStatements(ReferenceContext rc, int start, int end, TypeDeclaration[] types, CompilationUnitDeclaration unit) {
9470    boolean oldStatementRecoveryEnabled = this.statementRecoveryActivated;
9471    this.statementRecoveryActivated = true;
9472    
9473    initialize();
9474    
9475    goForBlockStatementsopt();
9476    this.nestedMethod[this.nestedType]++;
9477    pushOnRealBlockStack(0);
9478    
9479    pushOnAstLengthStack(0);
9480
9481    this.referenceContext = rc;
9482    this.compilationUnit = unit;
9483    
9484    this.pendingRecoveredType = null;
9485    
9486    if(types != null && types.length > 0) {
9487        this.recoveredTypes = types;
9488        this.recoveredTypePtr = 0;
9489        this.nextTypeStart =
9490            this.recoveredTypes[0].allocation == null
9491                ? this.recoveredTypes[0].declarationSourceStart
9492                        : this.recoveredTypes[0].allocation.sourceStart;
9493    } else {
9494        this.recoveredTypes = null;
9495        this.recoveredTypePtr = -1;
9496        this.nextTypeStart = -1;
9497    }
9498    
9499    this.scanner.resetTo(start, end);
9500    // reset the scanner to parser from { down to }
9501

9502    this.lastCheckPoint = this.scanner.initialPosition;
9503    
9504    
9505    this.stateStackTop = -1;
9506        
9507    try {
9508        parse();
9509    } catch (AbortCompilation ex) {
9510        this.lastAct = ERROR_ACTION;
9511    } finally {
9512        this.nestedMethod[this.nestedType]--;
9513        this.recoveredTypes = null;
9514        this.statementRecoveryActivated = oldStatementRecoveryEnabled;
9515    }
9516
9517    checkNonNLSAfterBodyEnd(end);
9518}
9519public void persistLineSeparatorPositions() {
9520    if (this.scanner.recordLineSeparator) {
9521        this.compilationUnit.compilationResult.lineSeparatorPositions = this.scanner.getLineEnds();
9522    }
9523}
9524/*
9525 * Prepares the state of the parser to go for BlockStatements.
9526 */

9527protected void prepareForBlockStatements() {
9528    this.nestedMethod[this.nestedType = 0] = 1;
9529    this.variablesCounter[this.nestedType] = 0;
9530    this.realBlockStack[this.realBlockPtr = 1] = 0;
9531}
9532/**
9533 * Returns this parser's problem reporter initialized with its reference context.
9534 * Also it is assumed that a problem is going to be reported, so initializes
9535 * the compilation result's line positions.
9536 *
9537 * @return ProblemReporter
9538 */

9539public ProblemReporter problemReporter(){
9540    if (this.scanner.recordLineSeparator) {
9541        this.compilationUnit.compilationResult.lineSeparatorPositions = this.scanner.getLineEnds();
9542    }
9543    this.problemReporter.referenceContext = this.referenceContext;
9544    return this.problemReporter;
9545}
9546protected void pushIdentifier() {
9547    /*push the consumeToken on the identifier stack.
9548    Increase the total number of identifier in the stack.
9549    identifierPtr points on the next top */

9550
9551    int stackLength = this.identifierStack.length;
9552    if (++this.identifierPtr >= stackLength) {
9553        System.arraycopy(
9554            this.identifierStack, 0,
9555            this.identifierStack = new char[stackLength + 20][], 0,
9556            stackLength);
9557        System.arraycopy(
9558            this.identifierPositionStack, 0,
9559            this.identifierPositionStack = new long[stackLength + 20], 0,
9560            stackLength);
9561    }
9562    this.identifierStack[this.identifierPtr] = this.scanner.getCurrentIdentifierSource();
9563    this.identifierPositionStack[this.identifierPtr] =
9564        (((long) this.scanner.startPosition) << 32) + (this.scanner.currentPosition - 1);
9565
9566    stackLength = this.identifierLengthStack.length;
9567    if (++this.identifierLengthPtr >= stackLength) {
9568        System.arraycopy(
9569            this.identifierLengthStack, 0,
9570            this.identifierLengthStack = new int[stackLength + 10], 0,
9571            stackLength);
9572    }
9573    this.identifierLengthStack[this.identifierLengthPtr] = 1;
9574}
9575protected void pushIdentifier(int flag) {
9576    /*push a special flag on the stack :
9577    -zero stands for optional Name
9578    -negative number for direct ref to base types.
9579    identifierLengthPtr points on the top */

9580
9581    int stackLength = this.identifierLengthStack.length;
9582    if (++this.identifierLengthPtr >= stackLength) {
9583        System.arraycopy(
9584            this.identifierLengthStack, 0,
9585            this.identifierLengthStack = new int[stackLength + 10], 0,
9586            stackLength);
9587    }
9588    this.identifierLengthStack[this.identifierLengthPtr] = flag;
9589}
9590protected void pushOnAstLengthStack(int pos) {
9591
9592    int stackLength = this.astLengthStack.length;
9593    if (++this.astLengthPtr >= stackLength) {
9594        System.arraycopy(
9595            this.astLengthStack, 0,
9596            this.astLengthStack = new int[stackLength + StackIncrement], 0,
9597            stackLength);
9598    }
9599    this.astLengthStack[this.astLengthPtr] = pos;
9600}
9601protected void pushOnAstStack(ASTNode node) {
9602    /*add a new obj on top of the ast stack
9603    astPtr points on the top*/

9604
9605    int stackLength = this.astStack.length;
9606    if (++this.astPtr >= stackLength) {
9607        System.arraycopy(
9608            this.astStack, 0,
9609            this.astStack = new ASTNode[stackLength + AstStackIncrement], 0,
9610            stackLength);
9611        this.astPtr = stackLength;
9612    }
9613    this.astStack[this.astPtr] = node;
9614
9615    stackLength = this.astLengthStack.length;
9616    if (++this.astLengthPtr >= stackLength) {
9617        System.arraycopy(
9618            this.astLengthStack, 0,
9619            this.astLengthStack = new int[stackLength + AstStackIncrement], 0,
9620            stackLength);
9621    }
9622    this.astLengthStack[this.astLengthPtr] = 1;
9623}
9624protected void pushOnExpressionStack(Expression expr) {
9625
9626    int stackLength = this.expressionStack.length;
9627    if (++this.expressionPtr >= stackLength) {
9628        System.arraycopy(
9629            this.expressionStack, 0,
9630            this.expressionStack = new Expression[stackLength + ExpressionStackIncrement], 0,
9631            stackLength);
9632    }
9633    this.expressionStack[this.expressionPtr] = expr;
9634
9635    stackLength = this.expressionLengthStack.length;
9636    if (++this.expressionLengthPtr >= stackLength) {
9637        System.arraycopy(
9638            this.expressionLengthStack, 0,
9639            this.expressionLengthStack = new int[stackLength + ExpressionStackIncrement], 0,
9640            stackLength);
9641    }
9642    this.expressionLengthStack[this.expressionLengthPtr] = 1;
9643}
9644protected void pushOnExpressionStackLengthStack(int pos) {
9645
9646    int stackLength = this.expressionLengthStack.length;
9647    if (++this.expressionLengthPtr >= stackLength) {
9648        System.arraycopy(
9649            this.expressionLengthStack, 0,
9650            this.expressionLengthStack = new int[stackLength + StackIncrement], 0,
9651            stackLength);
9652    }
9653    this.expressionLengthStack[this.expressionLengthPtr] = pos;
9654}
9655protected void pushOnGenericsStack(ASTNode node) {
9656    /*add a new obj on top of the generics stack
9657    genericsPtr points on the top*/

9658
9659    int stackLength = this.genericsStack.length;
9660    if (++this.genericsPtr >= stackLength) {
9661        System.arraycopy(
9662            this.genericsStack, 0,
9663            this.genericsStack = new ASTNode[stackLength + GenericsStackIncrement], 0,
9664            stackLength);
9665    }
9666    this.genericsStack[this.genericsPtr] = node;
9667
9668    stackLength = this.genericsLengthStack.length;
9669    if (++this.genericsLengthPtr >= stackLength) {
9670        System.arraycopy(
9671            this.genericsLengthStack, 0,
9672            this.genericsLengthStack = new int[stackLength + GenericsStackIncrement], 0,
9673            stackLength);
9674    }
9675    this.genericsLengthStack[this.genericsLengthPtr] = 1;
9676}
9677protected void pushOnGenericsIdentifiersLengthStack(int pos) {
9678    int stackLength = this.genericsIdentifiersLengthStack.length;
9679    if (++this.genericsIdentifiersLengthPtr >= stackLength) {
9680        System.arraycopy(
9681            this.genericsIdentifiersLengthStack, 0,
9682            this.genericsIdentifiersLengthStack = new int[stackLength + GenericsStackIncrement], 0,
9683            stackLength);
9684    }
9685    this.genericsIdentifiersLengthStack[this.genericsIdentifiersLengthPtr] = pos;
9686}
9687protected void pushOnGenericsLengthStack(int pos) {
9688    int stackLength = this.genericsLengthStack.length;
9689    if (++this.genericsLengthPtr >= stackLength) {
9690        System.arraycopy(
9691            this.genericsLengthStack, 0,
9692            this.genericsLengthStack = new int[stackLength + GenericsStackIncrement], 0,
9693            stackLength);
9694    }
9695    this.genericsLengthStack[this.genericsLengthPtr] = pos;
9696}
9697protected void pushOnIntStack(int pos) {
9698
9699    int stackLength = this.intStack.length;
9700    if (++this.intPtr >= stackLength) {
9701        System.arraycopy(
9702            this.intStack, 0,
9703            this.intStack = new int[stackLength + StackIncrement], 0,
9704            stackLength);
9705    }
9706    this.intStack[this.intPtr] = pos;
9707}
9708protected void pushOnRealBlockStack(int i){
9709    
9710    int stackLength = this.realBlockStack.length;
9711    if (++this.realBlockPtr >= stackLength) {
9712        System.arraycopy(
9713            this.realBlockStack, 0,
9714            this.realBlockStack = new int[stackLength + StackIncrement], 0,
9715            stackLength);
9716    }
9717    this.realBlockStack[this.realBlockPtr] = i;
9718}
9719protected void recoverStatements() {
9720    class MethodVisitor extends ASTVisitor {
9721        public ASTVisitor typeVisitor;
9722        
9723        TypeDeclaration enclosingType; // used only for initializer
9724

9725        TypeDeclaration[] types = new TypeDeclaration[0];
9726        int typePtr = -1;
9727        public boolean visit(ConstructorDeclaration constructorDeclaration, ClassScope scope) {
9728            typePtr = -1;
9729            return true;
9730        }
9731        public boolean visit(Initializer initializer, MethodScope scope) {
9732            typePtr = -1;
9733            return true;
9734        }
9735        public boolean visit(MethodDeclaration methodDeclaration,ClassScope scope) {
9736            typePtr = -1;
9737            return true;
9738        }
9739        public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
9740            return this.visit(typeDeclaration);
9741        }
9742        public boolean visit(TypeDeclaration typeDeclaration, ClassScope scope) {
9743            return this.visit(typeDeclaration);
9744        }
9745        private boolean visit(TypeDeclaration typeDeclaration) {
9746            if(this.types.length <= ++this.typePtr) {
9747                int length = this.typePtr;
9748                System.arraycopy(this.types, 0, this.types = new TypeDeclaration[length * 2 + 1], 0, length);
9749            }
9750            this.types[this.typePtr] = typeDeclaration;
9751            return false;
9752        }
9753        public void endVisit(ConstructorDeclaration constructorDeclaration, ClassScope scope) {
9754            this.endVisitMethod(constructorDeclaration, scope);
9755        }
9756        public void endVisit(MethodDeclaration methodDeclaration, ClassScope scope) {
9757            this.endVisitMethod(methodDeclaration, scope);
9758        }
9759        private void endVisitMethod(AbstractMethodDeclaration methodDeclaration, ClassScope scope) {
9760            TypeDeclaration[] foundTypes = null;
9761            int length = 0;
9762            if(this.typePtr > -1) {
9763                length = this.typePtr + 1;
9764                foundTypes = new TypeDeclaration[length];
9765                System.arraycopy(this.types, 0, foundTypes, 0, length);
9766            }
9767            ReferenceContext oldContext = Parser.this.referenceContext;
9768            Parser.this.recoveryScanner.resetTo(methodDeclaration.bodyStart, methodDeclaration.bodyEnd);
9769            Scanner oldScanner = Parser.this.scanner;
9770            Parser.this.scanner = Parser.this.recoveryScanner;
9771            Parser.this.parseStatements(
9772                    methodDeclaration,
9773                    methodDeclaration.bodyStart,
9774                    methodDeclaration.bodyEnd,
9775                    foundTypes,
9776                    compilationUnit);
9777            Parser.this.scanner = oldScanner;
9778            Parser.this.referenceContext = oldContext;
9779            
9780            for (int i = 0; i < length; i++) {
9781                foundTypes[i].traverse(typeVisitor, scope);
9782            }
9783        }
9784        public void endVisit(Initializer initializer, MethodScope scope) {
9785            TypeDeclaration[] foundTypes = null;
9786            int length = 0;
9787            if(this.typePtr > -1) {
9788                length = this.typePtr + 1;
9789                foundTypes = new TypeDeclaration[length];
9790                System.arraycopy(this.types, 0, foundTypes, 0, length);
9791            }
9792            ReferenceContext oldContext = Parser.this.referenceContext;
9793            Parser.this.recoveryScanner.resetTo(initializer.bodyStart, initializer.bodyEnd);
9794            Scanner oldScanner = Parser.this.scanner;
9795            Parser.this.scanner = Parser.this.recoveryScanner;
9796            Parser.this.parseStatements(
9797                    this.enclosingType,
9798                    initializer.bodyStart,
9799                    initializer.bodyEnd,
9800                    foundTypes,
9801                    compilationUnit);
9802            Parser.this.scanner = oldScanner;
9803            Parser.this.referenceContext = oldContext;
9804            
9805            for (int i = 0; i < length; i++) {
9806                foundTypes[i].traverse(typeVisitor, scope);
9807            }
9808        }
9809    }
9810    class TypeVisitor extends ASTVisitor {
9811        public MethodVisitor methodVisitor;
9812        
9813        TypeDeclaration[] types = new TypeDeclaration[0];
9814        int typePtr = -1;
9815        
9816        public void endVisit(TypeDeclaration typeDeclaration, BlockScope scope) {
9817            endVisitType();
9818        }
9819        public void endVisit(TypeDeclaration typeDeclaration, ClassScope scope) {
9820            endVisitType();
9821        }
9822        private void endVisitType() {
9823            this.typePtr--;
9824        }
9825        public boolean visit(TypeDeclaration typeDeclaration, BlockScope scope) {
9826            return this.visit(typeDeclaration);
9827        }
9828        public boolean visit(TypeDeclaration typeDeclaration, ClassScope scope) {
9829            return this.visit(typeDeclaration);
9830        }
9831        private boolean visit(TypeDeclaration typeDeclaration) {
9832            if(this.types.length <= ++this.typePtr) {
9833                int length = this.typePtr;
9834                System.arraycopy(this.types, 0, this.types = new TypeDeclaration[length * 2 + 1], 0, length);
9835            }
9836            this.types[this.typePtr] = typeDeclaration;
9837            return true;
9838        }
9839        public boolean visit(ConstructorDeclaration constructorDeclaration, ClassScope scope) {
9840            if(constructorDeclaration.isDefaultConstructor()) return false;
9841            
9842            constructorDeclaration.traverse(methodVisitor, scope);
9843            return false;
9844        }
9845        public boolean visit(Initializer initializer, MethodScope scope) {
9846            methodVisitor.enclosingType = this.types[typePtr];
9847            initializer.traverse(methodVisitor, scope);
9848            return false;
9849        }
9850        public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
9851            methodDeclaration.traverse(methodVisitor, scope);
9852            return false;
9853        }
9854    }
9855    
9856    MethodVisitor methodVisitor = new MethodVisitor();
9857    TypeVisitor typeVisitor = new TypeVisitor();
9858    methodVisitor.typeVisitor = typeVisitor;
9859    typeVisitor.methodVisitor = methodVisitor;
9860    
9861    if(this.referenceContext instanceof AbstractMethodDeclaration) {
9862        ((AbstractMethodDeclaration)this.referenceContext).traverse(methodVisitor, (ClassScope)null);
9863    } else if(this.referenceContext instanceof TypeDeclaration) {
9864        TypeDeclaration typeContext = (TypeDeclaration)this.referenceContext;
9865        
9866        int length = typeContext.fields.length;
9867        for (int i = 0; i < length; i++) {
9868            final FieldDeclaration fieldDeclaration = typeContext.fields[i];
9869            switch(fieldDeclaration.getKind()) {
9870                case AbstractVariableDeclaration.INITIALIZER:
9871                    methodVisitor.enclosingType = typeContext;
9872                    ((Initializer) fieldDeclaration).traverse(methodVisitor, (MethodScope)null);
9873                    break;
9874            }
9875        }
9876    }
9877}
9878
9879public void recoveryExitFromVariable() {
9880    if(this.currentElement != null && this.currentElement.parent != null) {
9881        if(this.currentElement instanceof RecoveredLocalVariable) {
9882            
9883            int end = ((RecoveredLocalVariable)this.currentElement).localDeclaration.sourceEnd;
9884            this.currentElement.updateSourceEndIfNecessary(end);
9885            this.currentElement = this.currentElement.parent;
9886        } else if(this.currentElement instanceof RecoveredField
9887            && !(this.currentElement instanceof RecoveredInitializer)) {
9888                
9889            int end = ((RecoveredField)this.currentElement).fieldDeclaration.sourceEnd;
9890            this.currentElement.updateSourceEndIfNecessary(end);
9891            this.currentElement = this.currentElement.parent;
9892        }
9893    }
9894}
9895/* Token check performed on every token shift once having entered
9896 * recovery mode.
9897 */

9898public void recoveryTokenCheck() {
9899    switch (this.currentToken) {
9900        case TokenNameLBRACE :
9901            RecoveredElement newElement = null;
9902            if(!this.ignoreNextOpeningBrace) {
9903                newElement = this.currentElement.updateOnOpeningBrace(this.scanner.startPosition - 1, this.scanner.currentPosition - 1);
9904            }
9905            this.lastCheckPoint = this.scanner.currentPosition;
9906            if (newElement != null){ // null means nothing happened
9907
this.restartRecovery = true; // opening brace detected
9908
this.currentElement = newElement;
9909            }
9910            break;
9911        
9912        case TokenNameRBRACE :
9913            this.rBraceStart = this.scanner.startPosition - 1;
9914            this.rBraceEnd = this.scanner.currentPosition - 1;
9915            this.endPosition = this.flushCommentsDefinedPriorTo(this.rBraceEnd);
9916            newElement =
9917                this.currentElement.updateOnClosingBrace(this.scanner.startPosition, this.rBraceEnd);
9918                this.lastCheckPoint = this.scanner.currentPosition;
9919            if (newElement != this.currentElement){
9920                this.currentElement = newElement;
9921// if (newElement instanceof RecoveredField && this.dietInt <= 0) {
9922
// if (((RecoveredField)newElement).fieldDeclaration.type == null) { // enum constant
9923
// this.isInsideEnumConstantPart = true; // restore status
9924
// }
9925
// }
9926
}
9927            break;
9928        case TokenNameSEMICOLON :
9929            this.endStatementPosition = this.scanner.currentPosition - 1;
9930            this.endPosition = this.scanner.startPosition - 1;
9931            RecoveredType currentType = this.currentRecoveryType();
9932            if(currentType != null) {
9933                currentType.insideEnumConstantPart = false;
9934            }
9935            // fall through
9936
default : {
9937            if (this.rBraceEnd > this.rBraceSuccessorStart && this.scanner.currentPosition != this.scanner.startPosition){
9938                this.rBraceSuccessorStart = this.scanner.startPosition;
9939            }
9940            break;
9941        }
9942    }
9943    this.ignoreNextOpeningBrace = false;
9944}
9945// A P I
9946
protected void reportSyntaxErrors(boolean isDietParse, int oldFirstToken) {
9947    if(this.referenceContext instanceof MethodDeclaration) {
9948        MethodDeclaration methodDeclaration = (MethodDeclaration) this.referenceContext;
9949        if((methodDeclaration.bits & ASTNode.ErrorInSignature) != 0){
9950            return;
9951        }
9952    }
9953    this.compilationUnit.compilationResult.lineSeparatorPositions = this.scanner.getLineEnds();
9954    this.scanner.recordLineSeparator = false;
9955    
9956    int start = this.scanner.initialPosition;
9957    int end = this.scanner.eofPosition == Integer.MAX_VALUE ? this.scanner.eofPosition : this.scanner.eofPosition - 1;
9958    if(isDietParse) {
9959        TypeDeclaration[] types = this.compilationUnit.types;
9960        int[][] intervalToSkip = org.eclipse.jdt.internal.compiler.parser.diagnose.RangeUtil.computeDietRange(types);
9961        DiagnoseParser diagnoseParser = new DiagnoseParser(this, oldFirstToken, start, end, intervalToSkip[0], intervalToSkip[1], intervalToSkip[2], this.options);
9962        diagnoseParser.diagnoseParse(false);
9963        
9964        reportSyntaxErrorsForSkippedMethod(types);
9965        this.scanner.resetTo(start, end);
9966    } else {
9967        DiagnoseParser diagnoseParser = new DiagnoseParser(this, oldFirstToken, start, end, this.options);
9968        diagnoseParser.diagnoseParse(this.options.performStatementsRecovery);
9969    }
9970}
9971private void reportSyntaxErrorsForSkippedMethod(TypeDeclaration[] types){
9972    if(types != null) {
9973        for (int i = 0; i < types.length; i++) {
9974            TypeDeclaration[] memberTypes = types[i].memberTypes;
9975            if(memberTypes != null) {
9976                reportSyntaxErrorsForSkippedMethod(memberTypes);
9977            }
9978            
9979            AbstractMethodDeclaration[] methods = types[i].methods;
9980            if(methods != null) {
9981                for (int j = 0; j < methods.length; j++) {
9982                    AbstractMethodDeclaration method = methods[j];
9983                    if((method.bits & ASTNode.ErrorInSignature) != 0) {
9984                        if(method.isAnnotationMethod()) {
9985                            DiagnoseParser diagnoseParser = new DiagnoseParser(this, TokenNameQUESTION, method.declarationSourceStart, method.declarationSourceEnd, this.options);
9986                            diagnoseParser.diagnoseParse(this.options.performStatementsRecovery);
9987                        } else {
9988                            DiagnoseParser diagnoseParser = new DiagnoseParser(this, TokenNameDIVIDE, method.declarationSourceStart, method.declarationSourceEnd, this.options);
9989                            diagnoseParser.diagnoseParse(this.options.performStatementsRecovery);
9990                        }
9991                        
9992                    }
9993                }
9994            }
9995            
9996            FieldDeclaration[] fields = types[i].fields;
9997            if (fields != null) {
9998                int length = fields.length;
9999                for (int j = 0; j < length; j++) {
0000                    if (fields[j] instanceof Initializer) {
0001                        Initializer initializer = (Initializer)fields[j];
0002                        if((initializer.bits & ASTNode.ErrorInSignature) != 0){
0003                            DiagnoseParser diagnoseParser = new DiagnoseParser(this, TokenNameRIGHT_SHIFT, initializer.declarationSourceStart, initializer.declarationSourceEnd, this.options);
0004                            diagnoseParser.diagnoseParse(this.options.performStatementsRecovery);
0005                        }
0006                    }
0007                }
0008            }
0009        }
0010    }
0011}
0012protected void resetModifiers() {
0013    this.modifiers = ClassFileConstants.AccDefault;
0014    this.modifiersSourceStart = -1; // <-- see comment into modifiersFlag(int)
0015
this.scanner.commentPtr = -1;
0016}
0017/*
0018 * Reset context so as to resume to regular parse loop
0019 */

0020protected void resetStacks() {
0021
0022    this.astPtr = -1;
0023    this.astLengthPtr = -1;
0024    this.expressionPtr = -1;
0025    this.expressionLengthPtr = -1;
0026    this.identifierPtr = -1;
0027    this.identifierLengthPtr = -1;
0028    this.intPtr = -1;
0029    this.nestedMethod[this.nestedType = 0] = 0; // need to reset for further reuse
0030
this.variablesCounter[this.nestedType] = 0;
0031    this.dimensions = 0 ;
0032    this.realBlockStack[this.realBlockPtr = 0] = 0;
0033    this.recoveredStaticInitializerStart = 0;
0034    this.listLength = 0;
0035    this.listTypeParameterLength = 0;
0036    
0037    this.genericsIdentifiersLengthPtr = -1;
0038    this.genericsLengthPtr = -1;
0039    this.genericsPtr = -1;
0040}
0041/*
0042 * Reset context so as to resume to regular parse loop
0043 * If unable to reset for resuming, answers false.
0044 *
0045 * Move checkpoint location, reset internal stacks and
0046 * decide which grammar goal is activated.
0047 */

0048protected boolean resumeAfterRecovery() {
0049    if(!this.methodRecoveryActivated && !this.statementRecoveryActivated) {
0050        
0051        // reset internal stacks
0052
this.resetStacks();
0053        this.resetModifiers();
0054        
0055        /* attempt to move checkpoint location */
0056        if (!this.moveRecoveryCheckpoint()) {
0057            return false;
0058        }
0059    
0060        // only look for headers
0061
if (this.referenceContext instanceof CompilationUnitDeclaration){
0062            goForHeaders();
0063            this.diet = true; // passed this point, will not consider method bodies
0064
return true;
0065        }
0066        
0067        // does not know how to restart
0068
return false;
0069    } else if(!this.statementRecoveryActivated) {
0070        
0071        // reset internal stacks
0072
this.resetStacks();
0073        this.resetModifiers();
0074        
0075        /* attempt to move checkpoint location */
0076        if (!this.moveRecoveryCheckpoint()) {
0077            return false;
0078        }
0079        
0080        // only look for headers
0081
goForHeaders();
0082        return true;
0083    } else {
0084        return false;
0085    }
0086}
0087protected boolean resumeOnSyntaxError() {
0088    this.checkExternalizeStrings = false;
0089    this.scanner.checkNonExternalizedStringLiterals = false;
0090    /* request recovery initialization */
0091    if (this.currentElement == null){
0092        // Reset javadoc before restart parsing after recovery
0093
this.javadoc = null;
0094
0095        // do not investigate deeper in statement recovery
0096
if (this.statementRecoveryActivated) return false;
0097        
0098        // build some recovered elements
0099
this.currentElement = buildInitialRecoveryState();
0100    }
0101    /* do not investigate deeper in recovery when no recovered element */
0102    if (this.currentElement == null) return false;
0103    
0104    /* manual forced recovery restart - after headers */
0105    if (this.restartRecovery){
0106        this.restartRecovery = false;
0107    }
0108    /* update recovery state with current error state of the parser */
0109    this.updateRecoveryState();
0110    
0111    /* attempt to reset state in order to resume to parse loop */
0112    return this.resumeAfterRecovery();
0113}
0114public void setMethodsFullRecovery(boolean enabled) {
0115    this.options.performMethodsFullRecovery = enabled;
0116}
0117public void setStatementsRecovery(boolean enabled) {
0118    if(enabled) this.options.performMethodsFullRecovery = true;
0119    this.options.performStatementsRecovery = enabled;
0120}
0121public String JavaDoc toString() {
0122
0123
0124    String JavaDoc s = "lastCheckpoint : int = " + String.valueOf(this.lastCheckPoint) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
0125
s = s + "identifierStack : char["+(this.identifierPtr + 1)+"][] = {"; //$NON-NLS-1$ //$NON-NLS-2$
0126
for (int i = 0; i <= this.identifierPtr; i++) {
0127        s = s + "\"" + String.valueOf(this.identifierStack[i]) + "\","; //$NON-NLS-1$ //$NON-NLS-2$
0128
}
0129    s = s + "}\n"; //$NON-NLS-1$
0130

0131    s = s + "identifierLengthStack : int["+(this.identifierLengthPtr + 1)+"] = {"; //$NON-NLS-1$ //$NON-NLS-2$
0132
for (int i = 0; i <= this.identifierLengthPtr; i++) {
0133        s = s + this.identifierLengthStack[i] + ","; //$NON-NLS-1$
0134
}
0135    s = s + "}\n"; //$NON-NLS-1$
0136

0137    s = s + "astLengthStack : int["+(this.astLengthPtr + 1)+"] = {"; //$NON-NLS-1$ //$NON-NLS-2$
0138
for (int i = 0; i <= this.astLengthPtr; i++) {
0139        s = s + this.astLengthStack[i] + ","; //$NON-NLS-1$
0140
}
0141    s = s + "}\n"; //$NON-NLS-1$
0142
s = s + "astPtr : int = " + String.valueOf(this.astPtr) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
0143

0144    s = s + "intStack : int["+(this.intPtr + 1)+"] = {"; //$NON-NLS-1$ //$NON-NLS-2$
0145
for (int i = 0; i <= this.intPtr; i++) {
0146        s = s + this.intStack[i] + ","; //$NON-NLS-1$
0147
}
0148    s = s + "}\n"; //$NON-NLS-1$
0149

0150    s = s + "expressionLengthStack : int["+(this.expressionLengthPtr + 1)+"] = {"; //$NON-NLS-1$ //$NON-NLS-2$
0151
for (int i = 0; i <= this.expressionLengthPtr; i++) {
0152        s = s + this.expressionLengthStack[i] + ","; //$NON-NLS-1$
0153
}
0154    s = s + "}\n"; //$NON-NLS-1$
0155

0156    s = s + "expressionPtr : int = " + String.valueOf(this.expressionPtr) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
0157

0158    s = s + "genericsIdentifiersLengthStack : int["+(this.genericsIdentifiersLengthPtr + 1)+"] = {"; //$NON-NLS-1$ //$NON-NLS-2$
0159
for (int i = 0; i <= this.genericsIdentifiersLengthPtr; i++) {
0160        s = s + this.genericsIdentifiersLengthStack[i] + ","; //$NON-NLS-1$
0161
}
0162    s = s + "}\n"; //$NON-NLS-1$
0163

0164    s = s + "genericsLengthStack : int["+(this.genericsLengthPtr + 1)+"] = {"; //$NON-NLS-1$ //$NON-NLS-2$
0165
for (int i = 0; i <= this.genericsLengthPtr; i++) {
0166        s = s + this.genericsLengthStack[i] + ","; //$NON-NLS-1$
0167
}
0168    s = s + "}\n"; //$NON-NLS-1$
0169

0170    s = s + "genericsPtr : int = " + String.valueOf(this.genericsPtr) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
0171

0172    s = s + "\n\n\n----------------Scanner--------------\n" + this.scanner.toString(); //$NON-NLS-1$
0173
return s;
0174
0175}
0176/*
0177 * Update recovery state based on current parser/scanner state
0178 */

0179protected void updateRecoveryState() {
0180
0181    /* expose parser state to recovery state */
0182    this.currentElement.updateFromParserState();
0183
0184    /* check and update recovered state based on current token,
0185        this action is also performed when shifting token after recovery
0186        got activated once.
0187    */

0188    this.recoveryTokenCheck();
0189}
0190protected void updateSourceDeclarationParts(int variableDeclaratorsCounter) {
0191    //fields is a definition of fields that are grouped together like in
0192
//public int[] a, b[], c
0193
//which results into 3 fields.
0194

0195    FieldDeclaration field;
0196    int endTypeDeclarationPosition =
0197        -1 + this.astStack[this.astPtr - variableDeclaratorsCounter + 1].sourceStart;
0198    for (int i = 0; i < variableDeclaratorsCounter - 1; i++) {
0199        //last one is special(see below)
0200
field = (FieldDeclaration) this.astStack[this.astPtr - i - 1];
0201        field.endPart1Position = endTypeDeclarationPosition;
0202        field.endPart2Position = -1 + this.astStack[this.astPtr - i].sourceStart;
0203    }
0204    //last one
0205
(field = (FieldDeclaration) this.astStack[this.astPtr]).endPart1Position =
0206        endTypeDeclarationPosition;
0207    field.endPart2Position = field.declarationSourceEnd;
0208
0209}
0210protected void updateSourcePosition(Expression exp) {
0211    //update the source Position of the expression
0212

0213    //this.intStack : int int
0214
//-->
0215
//this.intStack :
0216

0217    exp.sourceEnd = this.intStack[this.intPtr--];
0218    exp.sourceStart = this.intStack[this.intPtr--];
0219}
0220}
0221
Popular Tags