added -J option to preserve unmodified files in preexisting jarfile
[org.ibex.tool.git] / src / org / eclipse / jdt / internal / compiler / parser / Parser.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-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;
16 import java.util.Collections;
17 import java.util.Iterator;
18 import java.util.List;
19 import java.util.Locale;
20 import java.util.MissingResourceException;
21 import java.util.ResourceBundle;
22
23 import org.eclipse.jdt.core.compiler.CharOperation;
24 import org.eclipse.jdt.core.compiler.InvalidInputException;
25 import org.eclipse.jdt.internal.compiler.CompilationResult;
26 import org.eclipse.jdt.internal.compiler.ast.*;
27 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
28 import org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
29 import org.eclipse.jdt.internal.compiler.env.IGenericType;
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.Binding;
33 import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers;
34 import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
35 import org.eclipse.jdt.internal.compiler.parser.diagnose.DiagnoseParser;
36 import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
37 import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
38 import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
39 import org.eclipse.jdt.internal.compiler.util.Util;
40
41 public class Parser implements  ParserBasicInformation, TerminalTokens, CompilerModifiers, OperatorIds, TypeIds {
42         protected static final int THIS_CALL = ExplicitConstructorCall.This;
43         protected static final int SUPER_CALL = ExplicitConstructorCall.Super;
44
45         public static char asb[] = null;
46         public static char asr[] = null;
47         //ast stack
48         protected final static int AstStackIncrement = 100;
49         public static char base_action[] = null;
50         public static final int BracketKinds = 3;
51     
52         public static short check_table[] = null;
53         public static final int CurlyBracket = 2;
54         // TODO remove once testing is done
55         private static final boolean DEBUG = false;
56         private static final String EOF_TOKEN = "$eof" ; //$NON-NLS-1$
57         private static final String ERROR_TOKEN = "$error" ; //$NON-NLS-1$
58         //expression stack
59         protected final static int ExpressionStackIncrement = 100;
60
61         protected final static int GenericsStackIncrement = 10;
62     
63         private final static String FILEPREFIX = "parser"; //$NON-NLS-1$
64     public static char in_symb[] = null;
65         private static final String INVALID_CHARACTER = "Invalid Character" ; //$NON-NLS-1$
66         public static char lhs[] =  null;
67
68         public static String name[] = null;
69         public static char nasb[] = null;
70         public static char nasr[] = null;
71         public static char non_terminal_index[] = null;
72         private final static String READABLE_NAMES_FILE = "readableNames"; //$NON-NLS-1$
73         private final static String READABLE_NAMES_FILE_NAME =
74                 "org.eclipse.jdt.internal.compiler.parser." + READABLE_NAMES_FILE; //$NON-NLS-1$
75         public static String readableName[] = null;
76         
77         public static byte rhs[] = null;
78         
79         public static long rules_compliance[] =  null;
80         
81         public static final int RoundBracket = 0;
82     
83     public static byte scope_la[] = null;
84     public static char scope_lhs[] = null;
85         
86         public static char scope_prefix[] = null;
87     public static char scope_rhs[] = null;
88     public static char scope_state[] = null;
89
90     public static char scope_state_set[] = null;
91     public static char scope_suffix[] = null;
92         public static final int SquareBracket = 1;
93                 
94         //internal data for the automat 
95         protected final static int StackIncrement = 255;
96         
97         public static char term_action[] = null;
98         public static byte term_check[] = null;
99
100         public static char terminal_index[] = null;
101
102         private static final String UNEXPECTED_EOF = "Unexpected End Of File" ; //$NON-NLS-1$
103         public static boolean VERBOSE_RECOVERY = false;
104
105
106
107         protected int astLengthPtr;
108         protected int[] astLengthStack;
109         protected int astPtr;
110         protected ASTNode[] astStack = new ASTNode[AstStackIncrement];
111         public CompilationUnitDeclaration compilationUnit; /*the result from parse()*/
112         protected RecoveredElement currentElement;
113         public int currentToken;
114         protected boolean diet = false; //tells the scanner to jump over some parts of the code/expressions like method bodies
115         protected int dietInt = 0; // if > 0 force the none-diet-parsing mode (even if diet if requested) [field parsing with anonymous inner classes...]
116         protected int endPosition; //accurate only when used ! (the start position is pushed into intStack while the end the current one)
117         protected int endStatementPosition;
118         protected int expressionLengthPtr;
119         protected int[] expressionLengthStack;
120         protected int expressionPtr;
121         protected Expression[] expressionStack = new Expression[ExpressionStackIncrement];
122         public int firstToken ; // handle for multiple parsing goals
123
124         // generics management
125         protected int genericsIdentifiersLengthPtr;
126         protected int[] genericsIdentifiersLengthStack = new int[GenericsStackIncrement];
127         protected int genericsLengthPtr;
128         protected int[] genericsLengthStack = new int[GenericsStackIncrement];
129         protected int genericsPtr;
130         protected ASTNode[] genericsStack = new ASTNode[GenericsStackIncrement];
131         
132         protected boolean hasError;
133         protected boolean hasReportedError;
134
135         //identifiers stacks 
136         protected int identifierLengthPtr;
137         protected int[] identifierLengthStack;
138         protected long[] identifierPositionStack;
139         protected int identifierPtr;
140         protected char[][] identifierStack;
141         
142         protected boolean ignoreNextOpeningBrace;
143         //positions , dimensions , .... (int stacks)
144         protected int intPtr;
145         protected int[] intStack;
146         public int lastAct ; //handle for multiple parsing goals
147
148         //error recovery management
149         protected int lastCheckPoint;
150         protected int lastErrorEndPosition;
151         protected int lastErrorEndPositionBeforeRecovery = -1;
152         protected int lastIgnoredToken, nextIgnoredToken;
153         protected int listLength; // for recovering some incomplete list (interfaces, throws or parameters)
154         protected int listTypeParameterLength; // for recovering some incomplete list (type parameters)
155         protected int lParenPos,rParenPos; //accurate only when used !
156         protected int modifiers;
157         protected int modifiersSourceStart;
158         protected int[] nestedMethod; //the ptr is nestedType
159         protected int nestedType, dimensions;
160         ASTNode [] noAstNodes = new ASTNode[AstStackIncrement];
161         Expression [] noExpressions = new Expression[ExpressionStackIncrement];
162         //modifiers dimensions nestedType etc.......
163         protected boolean optimizeStringLiterals =true;
164         protected CompilerOptions options;
165         protected ProblemReporter problemReporter;
166         protected int rBraceStart, rBraceEnd, rBraceSuccessorStart; //accurate only when used !
167         protected int realBlockPtr;
168         protected int[] realBlockStack;
169         protected int recoveredStaticInitializerStart;
170         public ReferenceContext referenceContext;
171         public boolean reportOnlyOneSyntaxError = false;
172         public boolean reportSyntaxErrorIsRequired = true;
173         protected boolean restartRecovery;
174         //scanner token 
175         public Scanner scanner;
176         protected int[] stack = new int[StackIncrement];
177         protected int stateStackTop;
178         protected int synchronizedBlockSourceStart;
179         protected int[] variablesCounter;
180
181         // javadoc
182         public Javadoc javadoc;
183         public JavadocParser javadocParser;
184         // used for recovery
185         protected int lastJavadocEnd;
186
187         static {
188                 try{
189                         initTables();
190                 } catch(java.io.IOException ex){
191                         throw new ExceptionInInitializerError(ex.getMessage());
192                 }
193         }
194 public static int asi(int state) {
195
196         return asb[original_state(state)]; 
197 }
198 public final static short base_check(int i) {
199         return check_table[i - (NUM_RULES + 1)];
200 }
201 private final static void buildFile(String filename, List listToDump) throws java.io.IOException {
202         BufferedWriter writer = new BufferedWriter(new FileWriter(filename));
203         for (Iterator iterator = listToDump.iterator(); iterator.hasNext(); ) {
204                 writer.write(String.valueOf(iterator.next()));
205         }
206         writer.flush();
207         writer.close();
208         System.out.println(filename + " creation complete"); //$NON-NLS-1$
209 }
210 private final static String[] buildFileForName(String filename, String contents) throws java.io.IOException {
211         String[] result = new String[contents.length()];
212         result[0] = null;
213         int resultCount = 1;
214         
215         StringBuffer buffer = new StringBuffer();
216         
217         int start = contents.indexOf("name[]"); //$NON-NLS-1$
218         start = contents.indexOf('\"', start); 
219         int end = contents.indexOf("};", start); //$NON-NLS-1$
220         
221         contents = contents.substring(start, end);
222         
223         boolean addLineSeparator = false;
224         int tokenStart = -1;
225         StringBuffer currentToken = new StringBuffer();
226         for (int i = 0; i < contents.length(); i++) {
227                 char c = contents.charAt(i);
228                 if(c == '\"') {
229                         if(tokenStart == -1) {
230                                 tokenStart = i + 1;     
231                         } else {
232                                 if(addLineSeparator) {
233                                         buffer.append('\n');
234                                         result[resultCount++] = currentToken.toString();
235                                         currentToken = new StringBuffer();
236                                 }
237                                 String token = contents.substring(tokenStart, i);
238                                 if(token.equals(ERROR_TOKEN)){
239                                         token = INVALID_CHARACTER;
240                                 } else if(token.equals(EOF_TOKEN)) {
241                                         token = UNEXPECTED_EOF;
242                                 }
243                                 buffer.append(token);
244                                 currentToken.append(token);
245                                 addLineSeparator = true;
246                                 tokenStart = -1;
247                         }
248                 }
249                 if(tokenStart == -1 && c == '+'){
250                         addLineSeparator = false;
251                 }
252         }
253         if(currentToken.length() > 0) {
254                 result[resultCount++] = currentToken.toString();
255         }
256         
257         buildFileForTable(filename, buffer.toString().toCharArray());
258         
259         System.arraycopy(result, 0, result = new String[resultCount], 0, resultCount);
260         return result;
261 }
262 private static void buildFileForReadableName(
263         String file,
264         char[] newLhs,
265         char[] newNonTerminalIndex,
266         String[] newName,
267         String[] tokens) throws java.io.IOException {
268
269         ArrayList entries = new ArrayList();
270         
271         boolean[] alreadyAdded = new boolean[newName.length];
272         
273         for (int i = 0; i < tokens.length; i = i + 3) {
274                 if("1".equals(tokens[i])) { //$NON-NLS-1$
275                         int index = newNonTerminalIndex[newLhs[Integer.parseInt(tokens[i + 1])]];
276                         StringBuffer buffer = new StringBuffer();
277                         if(!alreadyAdded[index]) {
278                                 alreadyAdded[index] = true;
279                                 buffer.append(newName[index]);
280                                 buffer.append('=');
281                                 buffer.append(tokens[i+2].trim());
282                                 buffer.append('\n');
283                                 entries.add(String.valueOf(buffer));
284                         }
285                 }
286         }
287         int i = 1;
288         while(!INVALID_CHARACTER.equals(newName[i])) i++;
289         i++;
290         for (; i < alreadyAdded.length; i++) {
291                 if(!alreadyAdded[i]) {
292                         System.out.println(newName[i] + " has no readable name"); //$NON-NLS-1$
293                 }
294         }
295         Collections.sort(entries);
296         buildFile(file, entries);
297 }
298 private static void buildFileForCompliance(
299                 String file,
300                 int length,
301                 String[] tokens) throws java.io.IOException {
302
303                 byte[] result = new byte[length * 8];
304                 
305                 for (int i = 0; i < tokens.length; i = i + 3) {
306                         if("2".equals(tokens[i])) { //$NON-NLS-1$
307                                 int index = Integer.parseInt(tokens[i + 1]);
308                                 String token = tokens[i + 2].trim();
309                                 long compliance = 0;
310                                 if("1.4".equals(token)) { //$NON-NLS-1$
311                                         compliance = ClassFileConstants.JDK1_4;
312                                 } else if("1.5".equals(token)) { //$NON-NLS-1$
313                                         compliance = ClassFileConstants.JDK1_5;
314                                 } else if("recovery".equals(token)) { //$NON-NLS-1$
315                                         compliance = ClassFileConstants.JDK_DEFERRED;
316                                 }
317                                 
318                                 int j = index * 8;
319                                 result[j] =     (byte)(compliance >>> 56);
320                                 result[j + 1] = (byte)(compliance >>> 48);
321                                 result[j + 2] = (byte)(compliance >>> 40);
322                                 result[j + 3] = (byte)(compliance >>> 32);
323                                 result[j + 4] = (byte)(compliance >>> 24);
324                                 result[j + 5] = (byte)(compliance >>> 16);
325                                 result[j + 6] = (byte)(compliance >>> 8);
326                                 result[j + 7] = (byte)(compliance);
327                         }
328                 }
329
330                 buildFileForTable(file, result); //$NON-NLS-1$
331         }
332 private final static void buildFileForTable(String filename, byte[] bytes) throws java.io.IOException {
333         java.io.FileOutputStream stream = new java.io.FileOutputStream(filename);
334         stream.write(bytes);
335         stream.close();
336         System.out.println(filename + " creation complete"); //$NON-NLS-1$
337 }
338 private final static void buildFileForTable(String filename, char[] chars) throws java.io.IOException {
339
340         byte[] bytes = new byte[chars.length * 2];
341         for (int i = 0; i < chars.length; i++) {
342                 bytes[2 * i] = (byte) (chars[i] >>> 8);
343                 bytes[2 * i + 1] = (byte) (chars[i] & 0xFF);
344         }
345
346         java.io.FileOutputStream stream = new java.io.FileOutputStream(filename);
347         stream.write(bytes);
348         stream.close();
349         System.out.println(filename + " creation complete"); //$NON-NLS-1$
350 }
351 private final static byte[] buildFileOfByteFor(String filename, String tag, String[] tokens) throws java.io.IOException {
352
353         //transform the String tokens into chars before dumping then into file
354
355         int i = 0;
356         //read upto the tag
357         while (!tokens[i++].equals(tag)){/*empty*/}
358         //read upto the }
359         
360         byte[] bytes = new byte[tokens.length]; //can't be bigger
361         int ic = 0;
362         String token;
363         while (!(token = tokens[i++]).equals("}")) { //$NON-NLS-1$
364                 int c = Integer.parseInt(token);
365                 bytes[ic++] = (byte) c;
366         }
367
368         //resize
369         System.arraycopy(bytes, 0, bytes = new byte[ic], 0, ic);
370
371         buildFileForTable(filename, bytes);
372         return bytes;
373 }
374 private final static char[] buildFileOfIntFor(String filename, String tag, String[] tokens) throws java.io.IOException {
375
376         //transform the String tokens into chars before dumping then into file
377
378         int i = 0;
379         //read upto the tag
380         while (!tokens[i++].equals(tag)){/*empty*/}
381         //read upto the }
382         
383         char[] chars = new char[tokens.length]; //can't be bigger
384         int ic = 0;
385         String token;
386         while (!(token = tokens[i++]).equals("}")) { //$NON-NLS-1$
387                 int c = Integer.parseInt(token);
388                 chars[ic++] = (char) c;
389         }
390
391         //resize
392         System.arraycopy(chars, 0, chars = new char[ic], 0, ic);
393
394         buildFileForTable(filename, chars);
395         return chars;
396 }
397 private final static void buildFileOfShortFor(String filename, String tag, String[] tokens) throws java.io.IOException {
398
399         //transform the String tokens into chars before dumping then into file
400
401         int i = 0;
402         //read upto the tag
403         while (!tokens[i++].equals(tag)){/*empty*/}
404         //read upto the }
405         
406         char[] chars = new char[tokens.length]; //can't be bigger
407         int ic = 0;
408         String token;
409         while (!(token = tokens[i++]).equals("}")) { //$NON-NLS-1$
410                 int c = Integer.parseInt(token);
411                 chars[ic++] = (char) (c + 32768);
412         }
413
414         //resize
415         System.arraycopy(chars, 0, chars = new char[ic], 0, ic);
416
417         buildFileForTable(filename, chars);
418 }
419 public final static void buildFilesFromLPG(String dataFilename, String dataFilename2)   throws java.io.IOException {
420
421         //RUN THIS METHOD TO GENERATE PARSER*.RSC FILES
422
423         //build from the lpg javadcl.java files that represents the parser tables
424         //lhs check_table asb asr symbol_index
425
426         //[org.eclipse.jdt.internal.compiler.parser.Parser.buildFilesFromLPG("d:/leapfrog/grammar/javadcl.java")]
427         char[] contents = new char[] {};
428         try {
429                 contents = Util.getFileCharContent(new File(dataFilename), null);
430         } catch (IOException ex) {
431                 System.out.println(Util.bind("parser.incorrectPath")); //$NON-NLS-1$
432                 return;
433         }
434         java.util.StringTokenizer st = 
435                 new java.util.StringTokenizer(new String(contents), " \t\n\r[]={,;");  //$NON-NLS-1$
436         String[] tokens = new String[st.countTokens()];
437         int j = 0;
438         while (st.hasMoreTokens()) {
439                 tokens[j++] = st.nextToken();
440         }
441         final String prefix = FILEPREFIX;
442         int i = 0;
443         
444         char[] newLhs = buildFileOfIntFor(prefix + (++i) + ".rsc", "lhs", tokens); //$NON-NLS-1$ //$NON-NLS-2$
445         buildFileOfShortFor(prefix + (++i) + ".rsc", "check_table", tokens); //$NON-NLS-2$ //$NON-NLS-1$
446         buildFileOfIntFor(prefix + (++i) + ".rsc", "asb", tokens); //$NON-NLS-2$ //$NON-NLS-1$
447         buildFileOfIntFor(prefix + (++i) + ".rsc", "asr", tokens); //$NON-NLS-2$ //$NON-NLS-1$
448         buildFileOfIntFor(prefix + (++i) + ".rsc", "nasb", tokens); //$NON-NLS-2$ //$NON-NLS-1$
449         buildFileOfIntFor(prefix + (++i) + ".rsc", "nasr", tokens); //$NON-NLS-2$ //$NON-NLS-1$
450         buildFileOfIntFor(prefix + (++i) + ".rsc", "terminal_index", tokens); //$NON-NLS-2$ //$NON-NLS-1$
451         char[] newNonTerminalIndex = buildFileOfIntFor(prefix + (++i) + ".rsc", "non_terminal_index", tokens); //$NON-NLS-1$ //$NON-NLS-2$
452         buildFileOfIntFor(prefix + (++i) + ".rsc", "term_action", tokens); //$NON-NLS-2$ //$NON-NLS-1$
453         
454         buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_prefix", tokens); //$NON-NLS-2$ //$NON-NLS-1$
455         buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_suffix", tokens); //$NON-NLS-2$ //$NON-NLS-1$
456         buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_lhs", tokens); //$NON-NLS-2$ //$NON-NLS-1$
457         buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_state_set", tokens); //$NON-NLS-2$ //$NON-NLS-1$
458         buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_rhs", tokens); //$NON-NLS-2$ //$NON-NLS-1$
459         buildFileOfIntFor(prefix + (++i) + ".rsc", "scope_state", tokens); //$NON-NLS-2$ //$NON-NLS-1$
460         buildFileOfIntFor(prefix + (++i) + ".rsc", "in_symb", tokens); //$NON-NLS-2$ //$NON-NLS-1$
461         
462         byte[] newRhs = buildFileOfByteFor(prefix + (++i) + ".rsc", "rhs", tokens); //$NON-NLS-2$ //$NON-NLS-1$
463         buildFileOfByteFor(prefix + (++i) + ".rsc", "term_check", tokens); //$NON-NLS-2$ //$NON-NLS-1$
464         buildFileOfByteFor(prefix + (++i) + ".rsc", "scope_la", tokens); //$NON-NLS-2$ //$NON-NLS-1$
465         
466         String[] newName = buildFileForName(prefix + (++i) + ".rsc", new String(contents)); //$NON-NLS-1$
467         
468         contents = new char[] {};
469         try {
470                 contents = Util.getFileCharContent(new File(dataFilename2), null);
471         } catch (IOException ex) {
472                 System.out.println(Util.bind("parser.incorrectPath")); //$NON-NLS-1$
473                 return;
474         }
475         st = new java.util.StringTokenizer(new String(contents), "\t\n\r=#");  //$NON-NLS-1$
476         tokens = new String[st.countTokens()];
477         j = 0;
478         while (st.hasMoreTokens()) {
479                 tokens[j++] = st.nextToken();
480         }
481         
482         buildFileForCompliance(prefix + (++i) + ".rsc", newRhs.length, tokens);//$NON-NLS-1$
483         buildFileForReadableName(READABLE_NAMES_FILE+".properties", newLhs, newNonTerminalIndex, newName, tokens);//$NON-NLS-1$
484         
485         System.out.println(Util.bind("parser.moveFiles")); //$NON-NLS-1$
486 }
487 public static int in_symbol(int state) {
488         return in_symb[original_state(state)];
489 }
490 public final static void initTables() throws java.io.IOException {
491
492         final String prefix = FILEPREFIX;
493         int i = 0;
494         lhs = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
495         char[] chars = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
496         check_table = new short[chars.length];
497         for (int c = chars.length; c-- > 0;) {
498                 check_table[c] = (short) (chars[c] - 32768);
499         }
500         asb = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
501         asr = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
502         nasb = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
503         nasr = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
504         terminal_index = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
505         non_terminal_index = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
506         term_action = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
507         
508         scope_prefix = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
509         scope_suffix = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
510         scope_lhs = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
511         scope_state_set = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
512         scope_rhs = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
513         scope_state = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
514         in_symb = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
515         
516         rhs = readByteTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
517         term_check = readByteTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
518         scope_la = readByteTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
519         
520         name = readNameTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
521         
522         rules_compliance = readLongTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$
523         
524         readableName = readReadableNameTable(READABLE_NAMES_FILE_NAME);
525         
526         base_action = lhs;
527 }
528 public static int nasi(int state) {
529         return nasb[original_state(state)];
530 }
531 public static int ntAction(int state, int sym) {
532         return base_action[state + sym];
533 }
534 protected static int original_state(int state) {
535         return -base_check(state);
536 }
537 protected static byte[] readByteTable(String filename) throws java.io.IOException {
538
539         //files are located at Parser.class directory
540
541         InputStream stream = Parser.class.getResourceAsStream(filename);
542         if (stream == null) {
543                 throw new java.io.IOException(Util.bind("parser.missingFile",filename)); //$NON-NLS-1$
544         }
545         byte[] bytes = null;
546         try {
547                 stream = new BufferedInputStream(stream);
548                 bytes = Util.getInputStreamAsByteArray(stream, -1);
549         } finally {
550                 try {
551                         stream.close();
552                 } catch (IOException e) {
553                         // ignore
554                 }
555         }
556         return bytes;
557 }
558         
559 protected static String[] readNameTable(String filename) throws java.io.IOException {
560         char[] contents = readTable(filename);
561         char[][] nameAsChar = CharOperation.splitOn('\n', contents);
562
563         String[] result = new String[nameAsChar.length + 1];
564         result[0] = null;
565         for (int i = 0; i < nameAsChar.length; i++) {
566                 result[i + 1] = new String(nameAsChar[i]);
567         }
568         
569         return result;
570 }
571 protected static String[] readReadableNameTable(String filename) {
572         String[] result = new String[name.length];
573
574         ResourceBundle bundle;
575         try {
576                 bundle = ResourceBundle.getBundle(filename, Locale.getDefault());
577         } catch(MissingResourceException e) {
578                 System.out.println("Missing resource : " + filename.replace('.', '/') + ".properties for locale " + Locale.getDefault()); //$NON-NLS-1$//$NON-NLS-2$
579                 throw e;
580         }
581         for (int i = 0; i < NT_OFFSET + 1; i++) {
582                 result[i] = name[i];
583         }
584         for (int i = NT_OFFSET; i < name.length; i++) {
585                 try {
586                         String n = bundle.getString(name[i]);
587                         if(n != null && n.length() > 0) {
588                                 result[i] = n;
589                         } else {
590                                 result[i] = name[i];
591                         }
592                 } catch(MissingResourceException e) {
593                         result[i] = name[i];
594                 }
595         }
596         return result;
597 }
598 protected static char[] readTable(String filename) throws java.io.IOException {
599
600         //files are located at Parser.class directory
601
602         InputStream stream = Parser.class.getResourceAsStream(filename);
603         if (stream == null) {
604                 throw new java.io.IOException(Util.bind("parser.missingFile",filename)); //$NON-NLS-1$
605         }
606         byte[] bytes = null;
607         try {
608                 stream = new BufferedInputStream(stream);
609                 bytes = Util.getInputStreamAsByteArray(stream, -1);
610         } finally {
611                 try {
612                         stream.close();
613                 } catch (IOException e) {
614                         // ignore
615                 }
616         }
617
618         //minimal integrity check (even size expected)
619         int length = bytes.length;
620         if (length % 2 != 0)
621                 throw new java.io.IOException(Util.bind("parser.corruptedFile",filename)); //$NON-NLS-1$
622
623         // convert bytes into chars
624         char[] chars = new char[length / 2];
625         int i = 0;
626         int charIndex = 0;
627
628         while (true) {
629                 chars[charIndex++] = (char) (((bytes[i++] & 0xFF) << 8) + (bytes[i++] & 0xFF));
630                 if (i == length)
631                         break;
632         }
633         return chars;
634 }
635 protected static long[] readLongTable(String filename) throws java.io.IOException {
636
637         //files are located at Parser.class directory
638
639         InputStream stream = Parser.class.getResourceAsStream(filename);
640         if (stream == null) {
641                 throw new java.io.IOException(Util.bind("parser.missingFile",filename)); //$NON-NLS-1$
642         }
643         byte[] bytes = null;
644         try {
645                 stream = new BufferedInputStream(stream);
646                 bytes = Util.getInputStreamAsByteArray(stream, -1);
647         } finally {
648                 try {
649                         stream.close();
650                 } catch (IOException e) {
651                         // ignore
652                 }
653         }
654
655         //minimal integrity check (even size expected)
656         int length = bytes.length;
657         if (length % 8 != 0)
658                 throw new java.io.IOException(Util.bind("parser.corruptedFile",filename)); //$NON-NLS-1$
659
660         // convert bytes into longs
661         long[] longs = new long[length / 8];
662         int i = 0;
663         int longIndex = 0;
664
665         while (true) {
666                 longs[longIndex++] = 
667                   (((long) (bytes[i++] & 0xFF)) << 56)
668                 + (((long) (bytes[i++] & 0xFF)) << 48)
669                 + (((long) (bytes[i++] & 0xFF)) << 40)
670                 + (((long) (bytes[i++] & 0xFF)) << 32)
671                 + (((long) (bytes[i++] & 0xFF)) << 24)
672                 + (((long) (bytes[i++] & 0xFF)) << 16)
673                 + (((long) (bytes[i++] & 0xFF)) << 8)
674                 + (bytes[i++] & 0xFF);
675                 
676                 if (i == length)
677                         break;
678         }
679         return longs;
680 }
681 public static int tAction(int state, int sym) {
682         return term_action[term_check[base_action[state]+sym] == sym ? base_action[state] + sym : base_action[state]];
683 }
684
685 public Parser(ProblemReporter problemReporter, boolean optimizeStringLiterals) {
686                 
687         this.problemReporter = problemReporter;
688         this.options = problemReporter.options;
689         this.optimizeStringLiterals = optimizeStringLiterals;
690         this.initializeScanner();
691         this.astLengthStack = new int[50];
692         this.expressionLengthStack = new int[30];
693         this.intStack = new int[50];
694         this.identifierStack = new char[30][];
695         this.identifierLengthStack = new int[30];
696         this.nestedMethod = new int[30];
697         this.realBlockStack = new int[30];
698         this.identifierPositionStack = new long[30];
699         this.variablesCounter = new int[30];
700         
701         // javadoc support
702         this.javadocParser = new JavadocParser(this);   
703 }
704 public void arrayInitializer(int length) {
705         //length is the size of the array Initializer
706         //expressionPtr points on the last elt of the arrayInitializer, 
707         // in other words, it has not been decremented yet.
708
709         ArrayInitializer ai = new ArrayInitializer();
710         if (length != 0) {
711                 this.expressionPtr -= length;
712                 System.arraycopy(this.expressionStack, this.expressionPtr + 1, ai.expressions = new Expression[length], 0, length);
713         }
714         pushOnExpressionStack(ai);
715         //positionning
716         ai.sourceEnd = this.endStatementPosition;
717         ai.sourceStart = this.intStack[this.intPtr--];
718 }
719 protected void blockReal() {
720         // See consumeLocalVariableDeclarationStatement in case of change: duplicated code
721         // increment the amount of declared variables for this block
722         this.realBlockStack[this.realBlockPtr]++;
723 }
724 /*
725  * Build initial recovery state.
726  * Recovery state is inferred from the current state of the parser (reduced node stack).
727  */
728 public RecoveredElement buildInitialRecoveryState(){
729
730         /* initialize recovery by retrieving available reduced nodes 
731          * also rebuild bracket balance 
732          */
733         this.lastCheckPoint = 0;
734         this.lastErrorEndPositionBeforeRecovery = this.scanner.currentPosition;
735
736         RecoveredElement element = null;
737         if (this.referenceContext instanceof CompilationUnitDeclaration){
738                 element = new RecoveredUnit(this.compilationUnit, 0, this);
739                 
740                 /* ignore current stack state, since restarting from the beginnning 
741                    since could not trust simple brace count */
742                 if (true){ // experimenting restart recovery from scratch
743                         this.compilationUnit.currentPackage = null;
744                         this.compilationUnit.imports = null;
745                         this.compilationUnit.types = null;
746                         this.currentToken = 0;
747                         this.listLength = 0;
748                         this.listTypeParameterLength = 0;
749                         this.endPosition = 0;
750                         this.endStatementPosition = 0;
751                         return element;
752                 }
753                 if (this.compilationUnit.currentPackage != null){
754                         this.lastCheckPoint = this.compilationUnit.currentPackage.declarationSourceEnd+1;
755                 }
756                 if (this.compilationUnit.imports != null){
757                         this.lastCheckPoint = this.compilationUnit.imports[this.compilationUnit.imports.length -1].declarationSourceEnd+1;              
758                 }
759         } else {
760                 if (this.referenceContext instanceof AbstractMethodDeclaration){
761                         element = new RecoveredMethod((AbstractMethodDeclaration) this.referenceContext, null, 0, this);
762                         this.lastCheckPoint = ((AbstractMethodDeclaration) this.referenceContext).bodyStart;
763                 } else {
764                         /* Initializer bodies are parsed in the context of the type declaration, we must thus search it inside */
765                         if (this.referenceContext instanceof TypeDeclaration){
766                                 TypeDeclaration type = (TypeDeclaration) this.referenceContext;
767                                 for (int i = 0; i < type.fields.length; i++){
768                                         FieldDeclaration field = type.fields[i];                                        
769                                         if (field != null
770                                                 && field.getKind() == AbstractVariableDeclaration.INITIALIZER
771                                                 && field.declarationSourceStart <= this.scanner.initialPosition
772                                                 && this.scanner.initialPosition <= field.declarationSourceEnd
773                                                 && this.scanner.eofPosition <= field.declarationSourceEnd+1){
774                                                 element = new RecoveredInitializer(field, null, 1, this);
775                                                 this.lastCheckPoint = field.declarationSourceStart;                                     
776                                                 break;
777                                         }
778                                 }
779                         } 
780                 }
781         }
782
783         if (element == null) return element;
784         
785         for(int i = 0; i <= this.astPtr; i++){
786                 ASTNode node = this.astStack[i];
787                 if (node instanceof AbstractMethodDeclaration){
788                         AbstractMethodDeclaration method = (AbstractMethodDeclaration) node;
789                         if (method.declarationSourceEnd == 0){
790                                 element = element.add(method, 0);
791                                 this.lastCheckPoint = method.bodyStart;
792                         } else {
793                                 element = element.add(method, 0);
794                                 this.lastCheckPoint = method.declarationSourceEnd + 1;
795                         }
796                         continue;
797                 }
798                 if (node instanceof Initializer){
799                         Initializer initializer = (Initializer) node;
800                         if (initializer.declarationSourceEnd == 0){
801                                 element = element.add(initializer, 1);
802                                 this.lastCheckPoint = initializer.sourceStart;                          
803                         } else {
804                                 element = element.add(initializer, 0);
805                                 this.lastCheckPoint = initializer.declarationSourceEnd + 1;
806                         }
807                         continue;
808                 }               
809                 if (node instanceof FieldDeclaration){
810                         FieldDeclaration field = (FieldDeclaration) node;
811                         if (field.declarationSourceEnd == 0){
812                                 element = element.add(field, 0);
813                                 if (field.initialization == null){
814                                         this.lastCheckPoint = field.sourceEnd + 1;
815                                 } else {
816                                         this.lastCheckPoint = field.initialization.sourceEnd + 1;
817                                 }
818                         } else {
819                                 element = element.add(field, 0);
820                                 this.lastCheckPoint = field.declarationSourceEnd + 1;
821                         }
822                         continue;
823                 }
824                 if (node instanceof TypeDeclaration){
825                         TypeDeclaration type = (TypeDeclaration) node;
826                         if (type.declarationSourceEnd == 0){
827                                 element = element.add(type, 0); 
828                                 this.lastCheckPoint = type.bodyStart;
829                         } else {
830                                 element = element.add(type, 0);                         
831                                 this.lastCheckPoint = type.declarationSourceEnd + 1;
832                         }
833                         continue;
834                 }
835                 if (node instanceof ImportReference){
836                         ImportReference importRef = (ImportReference) node;
837                         element = element.add(importRef, 0);
838                         this.lastCheckPoint = importRef.declarationSourceEnd + 1;
839                 }
840         }
841         return element;
842 }
843
844 protected void checkAndSetModifiers(int flag){
845         /*modify the current modifiers buffer.
846         When the startPosition of the modifiers is 0
847         it means that the modifier being parsed is the first
848         of a list of several modifiers. The startPosition
849         is zeroed when a copy of modifiers-buffer is push
850         onto the this.astStack. */
851
852         if ((this.modifiers & flag) != 0){ // duplicate modifier
853                 this.modifiers |= AccAlternateModifierProblem;
854         }
855         this.modifiers |= flag;
856                         
857         if (this.modifiersSourceStart < 0) this.modifiersSourceStart = this.scanner.startPosition;
858 }
859 public void checkComment() {
860
861         // discard obsolete comments while inside methods or fields initializer (see bug 74369)
862         if (!(this.diet && this.dietInt==0) && this.scanner.commentPtr >= 0) {
863                 flushCommentsDefinedPriorTo(this.endStatementPosition);
864         }
865         
866         int lastComment = this.scanner.commentPtr;
867         
868         if (this.modifiersSourceStart >= 0) {
869                 // eliminate comments located after modifierSourceStart if positionned
870                 while (lastComment >= 0 && this.scanner.commentStarts[lastComment] > this.modifiersSourceStart) lastComment--;
871         }
872         if (lastComment >= 0) {
873                 // consider all remaining leading comments to be part of current declaration
874                 this.modifiersSourceStart = this.scanner.commentStarts[0]; 
875         
876                 // check deprecation in last comment if javadoc (can be followed by non-javadoc comments which are simply ignored)      
877                 while (lastComment >= 0 && this.scanner.commentStops[lastComment] < 0) lastComment--; // non javadoc comment have negative end positions
878                 if (lastComment >= 0 && this.javadocParser != null) {
879                         int commentEnd = this.scanner.commentStops[lastComment] - 1; //stop is one over,
880                         // do not report problem before last parsed comment while recovering code...
881                         this.javadocParser.reportProblems = this.currentElement == null || commentEnd > this.lastJavadocEnd;
882                         if (this.javadocParser.checkDeprecation(this.scanner.commentStarts[lastComment], commentEnd)) {
883                                 checkAndSetModifiers(AccDeprecated);
884                         }
885                         this.javadoc = this.javadocParser.docComment;   // null if check javadoc is not activated
886                         if (currentElement == null) this.lastJavadocEnd = commentEnd;
887                 }
888         }
889 }
890 protected void checkNonExternalizedStringLiteral() {
891         if (this.scanner.wasNonExternalizedStringLiteral) {
892                 StringLiteral[] literals = this.scanner.nonNLSStrings;
893                 // could not reproduce, but this is the only NPE
894                 // added preventive null check see PR 9035
895                 if (literals != null) {
896                         for (int i = 0, max = literals.length; i < max; i++) {
897                                 problemReporter().nonExternalizedStringLiteral(literals[i]);
898                         }
899                 }
900                 this.scanner.wasNonExternalizedStringLiteral = false;
901         }
902 }
903 protected void checkNonNLSAfterBodyEnd(int declarationEnd){
904         if(this.scanner.currentPosition - 1 <= declarationEnd) {
905                 this.scanner.eofPosition = declarationEnd < Integer.MAX_VALUE ? declarationEnd + 1 : declarationEnd;
906                 try {
907                         while(this.scanner.getNextToken() != TokenNameEOF){/*empty*/}
908                         checkNonExternalizedStringLiteral();
909                 } catch (InvalidInputException e) {
910                         // Nothing to do
911                 }
912         }
913 }
914 protected void classInstanceCreation(boolean hasClassBody) {
915         // ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt
916
917         // ClassBodyopt produces a null item on the astStak if it produces NO class body
918         // An empty class body produces a 0 on the length stack.....
919
920         AllocationExpression alloc;
921         int length;
922         if (((length = this.astLengthStack[this.astLengthPtr--]) == 1)
923                 && (this.astStack[this.astPtr] == null)) {
924                 //NO ClassBody
925                 this.astPtr--;
926                 if (hasClassBody) {
927                         alloc = new QualifiedAllocationExpression();
928                 } else {
929                         alloc = new AllocationExpression();
930                 }
931                 alloc.sourceEnd = this.endPosition; //the position has been stored explicitly
932
933                 if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
934                         this.expressionPtr -= length;
935                         System.arraycopy(
936                                 this.expressionStack, 
937                                 this.expressionPtr + 1, 
938                                 alloc.arguments = new Expression[length], 
939                                 0, 
940                                 length); 
941                 }
942                 alloc.type = getTypeReference(0);
943                 
944                 //the default constructor with the correct number of argument
945                 //will be created and added by the TC (see createsInternalConstructorWithBinding)
946                 alloc.sourceStart = this.intStack[this.intPtr--];
947                 pushOnExpressionStack(alloc);
948         } else {
949                 dispatchDeclarationInto(length);
950                 TypeDeclaration anonymousTypeDeclaration = (TypeDeclaration)this.astStack[this.astPtr];
951                 anonymousTypeDeclaration.declarationSourceEnd = this.endStatementPosition;
952                 anonymousTypeDeclaration.bodyEnd = this.endStatementPosition;
953                 if (anonymousTypeDeclaration.allocation != null) {
954                         anonymousTypeDeclaration.allocation.sourceEnd = this.endStatementPosition;
955                 }
956                 if (length == 0 && !containsComment(anonymousTypeDeclaration.bodyStart, anonymousTypeDeclaration.bodyEnd)) {
957                         anonymousTypeDeclaration.bits |= ASTNode.UndocumentedEmptyBlockMASK;
958                 }
959                 this.astPtr--;
960                 this.astLengthPtr--;
961
962                 // mark initializers with local type mark if needed
963                 markInitializersWithLocalType(anonymousTypeDeclaration);
964         }
965 }
966 protected void concatExpressionLists() {
967         this.expressionLengthStack[--this.expressionLengthPtr]++;
968 }
969 protected void concatGenericsLists() {
970         this.genericsLengthStack[this.genericsLengthPtr - 1] += this.genericsLengthStack[this.genericsLengthPtr--];
971 }
972 protected void concatNodeLists() {
973         /*
974          * This is a case where you have two sublists into the this.astStack that you want
975          * to merge in one list. There is no action required on the this.astStack. The only
976          * thing you need to do is merge the two lengths specified on the astStackLength.
977          * The top two length are for example:
978          * ... p   n
979          * and you want to result in a list like:
980          * ... n+p 
981          * This means that the p could be equals to 0 in case there is no astNode pushed
982          * on the this.astStack.
983          * Look at the InterfaceMemberDeclarations for an example.
984          */
985
986         this.astLengthStack[this.astLengthPtr - 1] += this.astLengthStack[this.astLengthPtr--];
987 }
988 protected void consumeAdditionalBound() {
989         pushOnGenericsStack(getTypeReference(this.intStack[this.intPtr--]));
990 }
991 protected void consumeAdditionalBound1() {
992         // nothing to be done.
993         // The reference type1 is consumed by consumeReferenceType1 method.
994 }
995 protected void consumeAdditionalBoundList() {
996         concatGenericsLists();
997 }
998 protected void consumeAdditionalBoundList1() {
999         concatGenericsLists();
1000 }
1001 protected void consumeAllocationHeader() {
1002         // ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt
1003
1004         // ClassBodyopt produces a null item on the astStak if it produces NO class body
1005         // An empty class body produces a 0 on the length stack.....
1006
1007         if (this.currentElement == null){
1008                 return; // should never occur, this consumeRule is only used in recovery mode
1009         }
1010         if (this.currentToken == TokenNameLBRACE){
1011                 // beginning of an anonymous type
1012                 TypeDeclaration anonymousType = new TypeDeclaration(this.compilationUnit.compilationResult);
1013                 anonymousType.name = TypeDeclaration.ANONYMOUS_EMPTY_NAME;
1014                 anonymousType.bits |= ASTNode.AnonymousAndLocalMask;
1015                 anonymousType.sourceStart = this.intStack[this.intPtr--];
1016                 anonymousType.sourceEnd = this.rParenPos; // closing parenthesis
1017                 QualifiedAllocationExpression alloc = new QualifiedAllocationExpression(anonymousType);
1018                 alloc.type = getTypeReference(0);
1019                 alloc.sourceStart = anonymousType.sourceStart;
1020                 alloc.sourceEnd = anonymousType.sourceEnd ;
1021                 this.lastCheckPoint = anonymousType.bodyStart = this.scanner.currentPosition;
1022                 this.currentElement = this.currentElement.add(anonymousType, 0);
1023                 this.lastIgnoredToken = -1;
1024                 this.currentToken = 0; // opening brace already taken into account
1025                 return;
1026         }
1027         this.lastCheckPoint = this.scanner.startPosition; // force to restart at this exact position
1028         this.restartRecovery = true; // request to restart from here on
1029 }
1030 protected void consumeAnnotationAsModifier() {
1031         // nothing to do
1032 }
1033 protected void consumeAnnotationName() {
1034         // nothing to do
1035 }
1036 protected void consumeAnnotationTypeDeclaration() {
1037         int length;
1038         if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
1039                 //there are length declarations
1040                 //dispatch according to the type of the declarations
1041                 dispatchDeclarationInto(length);
1042         }
1043
1044         TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
1045         
1046         // mark initializers with local type mark if needed
1047         markInitializersWithLocalType(typeDecl);
1048
1049         //convert constructor that do not have the type's name into methods
1050         typeDecl.checkConstructors(this);
1051         
1052         //always add <clinit> (will be remove at code gen time if empty)
1053         if (this.scanner.containsAssertKeyword) {
1054                 typeDecl.bits |= ASTNode.AddAssertionMASK;
1055         }
1056         typeDecl.addClinit();
1057         typeDecl.bodyEnd = this.endStatementPosition;
1058         if (length == 0 && !containsComment(typeDecl.bodyStart, typeDecl.bodyEnd)) {
1059                 typeDecl.bits |= ASTNode.UndocumentedEmptyBlockMASK;
1060         }
1061         typeDecl.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition); 
1062 }
1063 protected void consumeAnnotationTypeDeclarationHeader() {
1064         if (this.currentElement != null) {
1065                 this.restartRecovery = true; // used to avoid branching back into the regular automaton         
1066         }
1067 }
1068 protected void consumeAnnotationTypeDeclarationHeaderName() {
1069         // consumeAnnotationTypeDeclarationHeader ::= Modifiers '@' PushModifiers interface Identifier
1070         // consumeAnnotationTypeDeclarationHeader ::= '@' PushModifiers interface Identifier
1071         TypeDeclaration annotationTypeDeclaration = new TypeDeclaration(this.compilationUnit.compilationResult);
1072         if (this.nestedMethod[this.nestedType] == 0) {
1073                 if (this.nestedType != 0) {
1074                         annotationTypeDeclaration.bits |= ASTNode.IsMemberTypeMASK;
1075                 }
1076         } else {
1077                 // Record that the block has a declaration for local types
1078                 annotationTypeDeclaration.bits |= ASTNode.IsLocalTypeMASK;
1079                 markEnclosingMemberWithLocalType();
1080                 blockReal();
1081         }
1082
1083         //highlight the name of the type
1084         long pos = this.identifierPositionStack[this.identifierPtr];
1085         annotationTypeDeclaration.sourceEnd = (int) pos;
1086         annotationTypeDeclaration.sourceStart = (int) (pos >>> 32);
1087         annotationTypeDeclaration.name = this.identifierStack[this.identifierPtr--];
1088         this.identifierLengthPtr--;
1089
1090         //compute the declaration source too
1091         // 'interface' push two int positions: the beginning of the class token and its end.
1092         // we want to keep the beginning position but get rid of the end position
1093         // it is only used for the ClassLiteralAccess positions.
1094         this.intPtr--; // remove the start position of the interface token
1095         this.intPtr--; // remove the end position of the interface token
1096
1097         annotationTypeDeclaration.modifiersSourceStart = this.intStack[this.intPtr--];
1098         annotationTypeDeclaration.modifiers = this.intStack[this.intPtr--] | AccAnnotation | AccInterface;
1099         if (annotationTypeDeclaration.modifiersSourceStart >= 0) {
1100                 annotationTypeDeclaration.declarationSourceStart = annotationTypeDeclaration.modifiersSourceStart;
1101                 this.intPtr--; // remove the position of the '@' token as we have modifiers
1102         } else {
1103                 int atPosition = this.intStack[this.intPtr--];
1104                 // remove the position of the '@' token as we don't have modifiers
1105                 annotationTypeDeclaration.declarationSourceStart = atPosition;
1106         }
1107         // consume annotations
1108         int length;
1109         if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
1110                 System.arraycopy(
1111                         this.expressionStack, 
1112                         (this.expressionPtr -= length) + 1, 
1113                         annotationTypeDeclaration.annotations = new Annotation[length], 
1114                         0, 
1115                         length); 
1116         }
1117         annotationTypeDeclaration.bodyStart = annotationTypeDeclaration.sourceEnd + 1;
1118
1119         // javadoc
1120         annotationTypeDeclaration.javadoc = this.javadoc;
1121         this.javadoc = null;    
1122         pushOnAstStack(annotationTypeDeclaration);
1123         if(options.sourceLevel < ClassFileConstants.JDK1_5 &&
1124                         this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
1125                 this.problemReporter().invalidUsageOfAnnotationDeclarations(annotationTypeDeclaration);
1126         }       
1127         
1128         // recovery
1129         if (this.currentElement != null){ 
1130                 this.lastCheckPoint = annotationTypeDeclaration.bodyStart;
1131                 this.currentElement = this.currentElement.add(annotationTypeDeclaration, 0);
1132                 this.lastIgnoredToken = -1;
1133         }
1134 }
1135 protected void consumeAnnotationTypeMemberDeclaration() {
1136         // AnnotationTypeMemberDeclaration ::= AnnotationTypeMemberDeclarationHeader AnnotationTypeMemberHeaderExtendedDims DefaultValueopt ';'
1137         AnnotationMethodDeclaration annotationTypeMemberDeclaration = (AnnotationMethodDeclaration) this.astStack[this.astPtr];
1138         annotationTypeMemberDeclaration.modifiers |= AccSemicolonBody;
1139         // store the this.endPosition (position just before the '}') in case there is
1140         // a trailing comment behind the end of the method
1141         int declarationEndPosition = flushCommentsDefinedPriorTo(this.endStatementPosition);
1142         annotationTypeMemberDeclaration.bodyStart = this.endStatementPosition;
1143         annotationTypeMemberDeclaration.bodyEnd = declarationEndPosition;
1144         annotationTypeMemberDeclaration.declarationSourceEnd = declarationEndPosition;
1145 }
1146 protected void consumeAnnotationTypeMemberDeclarations() {
1147         // AnnotationTypeMemberDeclarations ::= AnnotationTypeMemberDeclarations AnnotationTypeMemberDeclaration
1148         concatNodeLists();
1149 }
1150 protected void consumeArgumentList() {
1151         // ArgumentList ::= ArgumentList ',' Expression
1152         concatExpressionLists();
1153 }
1154 protected void consumeArguments() {
1155         // Arguments ::= '(' ArgumentListopt ')' 
1156         // nothing to do, the expression stack is already updated
1157 }
1158 protected void consumeArrayAccess(boolean unspecifiedReference) {
1159         // ArrayAccess ::= Name '[' Expression ']' ==> true
1160         // ArrayAccess ::= PrimaryNoNewArray '[' Expression ']' ==> false
1161
1162
1163         //optimize push/pop
1164         Expression exp;
1165         if (unspecifiedReference) {
1166                 exp = 
1167                         this.expressionStack[this.expressionPtr] = 
1168                                 new ArrayReference(
1169                                         getUnspecifiedReferenceOptimized(),
1170                                         this.expressionStack[this.expressionPtr]);
1171         } else {
1172                 this.expressionPtr--;
1173                 this.expressionLengthPtr--;
1174                 exp = 
1175                         this.expressionStack[this.expressionPtr] = 
1176                                 new ArrayReference(
1177                                         this.expressionStack[this.expressionPtr],
1178                                         this.expressionStack[this.expressionPtr + 1]);
1179         }
1180         exp.sourceEnd = this.endPosition;
1181 }
1182 protected void consumeArrayCreationExpressionWithInitializer() {
1183         // ArrayCreationWithArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializer
1184         // ArrayCreationWithArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializer
1185
1186         int length;
1187         ArrayAllocationExpression aae = new ArrayAllocationExpression();
1188         this.expressionLengthPtr -- ;
1189         aae.initializer = (ArrayInitializer) this.expressionStack[this.expressionPtr--];
1190                 
1191         aae.type = getTypeReference(0);
1192         length = (this.expressionLengthStack[this.expressionLengthPtr--]);
1193         this.expressionPtr -= length ;
1194         System.arraycopy(
1195                 this.expressionStack,
1196                 this.expressionPtr+1,
1197                 aae.dimensions = new Expression[length],
1198                 0,
1199                 length);
1200         aae.sourceStart = this.intStack[this.intPtr--];
1201         if (aae.initializer == null) {
1202                 aae.sourceEnd = this.endPosition;
1203         } else {
1204                 aae.sourceEnd = aae.initializer.sourceEnd ;
1205         }
1206         pushOnExpressionStack(aae);
1207 }
1208 protected void consumeArrayCreationExpressionWithoutInitializer() {
1209         // ArrayCreationWithoutArrayInitializer ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs
1210         // ArrayCreationWithoutArrayInitializer ::= 'new' PrimitiveType DimWithOrWithOutExprs
1211
1212         int length;
1213         ArrayAllocationExpression aae = new ArrayAllocationExpression();
1214         aae.type = getTypeReference(0);
1215         length = (this.expressionLengthStack[this.expressionLengthPtr--]);
1216         this.expressionPtr -= length ;
1217         System.arraycopy(
1218                 this.expressionStack,
1219                 this.expressionPtr+1,
1220                 aae.dimensions = new Expression[length],
1221                 0,
1222                 length);
1223         aae.sourceStart = this.intStack[this.intPtr--];
1224         if (aae.initializer == null) {
1225                 aae.sourceEnd = this.endPosition;
1226         } else {
1227                 aae.sourceEnd = aae.initializer.sourceEnd ;
1228         }
1229         pushOnExpressionStack(aae);
1230 }
1231 protected void consumeArrayCreationHeader() {
1232         // nothing to do
1233 }
1234 protected void consumeArrayInitializer() {
1235         // ArrayInitializer ::= '{' VariableInitializers '}'
1236         // ArrayInitializer ::= '{' VariableInitializers , '}'
1237
1238         arrayInitializer(this.expressionLengthStack[this.expressionLengthPtr--]);
1239 }
1240 protected void consumeArrayTypeWithTypeArgumentsName() {
1241         this.intStack[this.intPtr] += this.identifierLengthStack[this.identifierLengthPtr];
1242 }
1243 protected void consumeAssertStatement() {
1244         // AssertStatement ::= 'assert' Expression ':' Expression ';'
1245         this.expressionLengthPtr-=2;
1246         pushOnAstStack(new AssertStatement(this.expressionStack[this.expressionPtr--], this.expressionStack[this.expressionPtr--], this.intStack[this.intPtr--]));
1247 }
1248 protected void consumeAssignment() {
1249         // Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression
1250         //optimize the push/pop
1251
1252         int op = this.intStack[this.intPtr--] ; //<--the encoded operator
1253         
1254         this.expressionPtr -- ; this.expressionLengthPtr -- ;
1255         this.expressionStack[this.expressionPtr] =
1256                 (op != EQUAL ) ?
1257                         new CompoundAssignment(
1258                                 this.expressionStack[this.expressionPtr] ,
1259                                 this.expressionStack[this.expressionPtr+1], 
1260                                 op,
1261                                 this.scanner.startPosition - 1) :
1262                         new Assignment(
1263                                 this.expressionStack[this.expressionPtr] ,
1264                                 this.expressionStack[this.expressionPtr+1],
1265                                 this.scanner.startPosition - 1);
1266 }
1267 protected void consumeAssignmentOperator(int pos) {
1268         // AssignmentOperator ::= '='
1269         // AssignmentOperator ::= '*='
1270         // AssignmentOperator ::= '/='
1271         // AssignmentOperator ::= '%='
1272         // AssignmentOperator ::= '+='
1273         // AssignmentOperator ::= '-='
1274         // AssignmentOperator ::= '<<='
1275         // AssignmentOperator ::= '>>='
1276         // AssignmentOperator ::= '>>>='
1277         // AssignmentOperator ::= '&='
1278         // AssignmentOperator ::= '^='
1279         // AssignmentOperator ::= '|='
1280
1281         pushOnIntStack(pos);
1282 }
1283 protected void consumeBinaryExpression(int op) {
1284         // MultiplicativeExpression ::= MultiplicativeExpression '*' UnaryExpression
1285         // MultiplicativeExpression ::= MultiplicativeExpression '/' UnaryExpression
1286         // MultiplicativeExpression ::= MultiplicativeExpression '%' UnaryExpression
1287         // AdditiveExpression ::= AdditiveExpression '+' MultiplicativeExpression
1288         // AdditiveExpression ::= AdditiveExpression '-' MultiplicativeExpression
1289         // ShiftExpression ::= ShiftExpression '<<'  AdditiveExpression
1290         // ShiftExpression ::= ShiftExpression '>>'  AdditiveExpression
1291         // ShiftExpression ::= ShiftExpression '>>>' AdditiveExpression
1292         // RelationalExpression ::= RelationalExpression '<'  ShiftExpression
1293         // RelationalExpression ::= RelationalExpression '>'  ShiftExpression
1294         // RelationalExpression ::= RelationalExpression '<=' ShiftExpression
1295         // RelationalExpression ::= RelationalExpression '>=' ShiftExpression
1296         // AndExpression ::= AndExpression '&' EqualityExpression
1297         // ExclusiveOrExpression ::= ExclusiveOrExpression '^' AndExpression
1298         // InclusiveOrExpression ::= InclusiveOrExpression '|' ExclusiveOrExpression
1299         // ConditionalAndExpression ::= ConditionalAndExpression '&&' InclusiveOrExpression
1300         // ConditionalOrExpression ::= ConditionalOrExpression '||' ConditionalAndExpression
1301
1302         //optimize the push/pop
1303
1304         this.expressionPtr--;
1305         this.expressionLengthPtr--;
1306         Expression expr1 = this.expressionStack[this.expressionPtr];
1307         Expression expr2 = this.expressionStack[this.expressionPtr + 1];
1308         switch(op) {
1309                 case OR_OR :
1310                         this.expressionStack[this.expressionPtr] = 
1311                                 new OR_OR_Expression(
1312                                         expr1, 
1313                                         expr2, 
1314                                         op); 
1315                         break;
1316                 case AND_AND :
1317                         this.expressionStack[this.expressionPtr] = 
1318                                 new AND_AND_Expression(
1319                                         expr1, 
1320                                         expr2, 
1321                                         op);
1322                         break;
1323                 case PLUS :
1324                         // look for "string1" + "string2"
1325                         if (this.optimizeStringLiterals) {
1326                                 if (expr1 instanceof StringLiteral) {
1327                                         if (expr2 instanceof CharLiteral) { // string+char
1328                                                 this.expressionStack[this.expressionPtr] = 
1329                                                         ((StringLiteral) expr1).extendWith((CharLiteral) expr2); 
1330                                         } else if (expr2 instanceof StringLiteral) { //string+string
1331                                                 this.expressionStack[this.expressionPtr] = 
1332                                                         ((StringLiteral) expr1).extendWith((StringLiteral) expr2); 
1333                                         } else {
1334                                                 this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
1335                                         }
1336                                 } else {
1337                                         this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
1338                                 }
1339                         } else if (expr1 instanceof StringLiteral) {
1340                                 if (expr2 instanceof StringLiteral) {
1341                                         // string + string
1342                                         this.expressionStack[this.expressionPtr] = 
1343                                                 ((StringLiteral) expr1).extendsWith((StringLiteral) expr2); 
1344                                 } else {
1345                                         this.expressionStack[this.expressionPtr] = 
1346                                                 new BinaryExpression(
1347                                                         expr1, 
1348                                                         expr2, 
1349                                                         op);
1350                                 }
1351                         } else {
1352                                 this.expressionStack[this.expressionPtr] = 
1353                                         new BinaryExpression(
1354                                                 expr1, 
1355                                                 expr2, 
1356                                                 op);
1357                         }
1358                         break;
1359                 case LESS :
1360                         this.intPtr--;
1361                         this.expressionStack[this.expressionPtr] = 
1362                                 new BinaryExpression(
1363                                         expr1, 
1364                                         expr2, 
1365                                         op);
1366                         break;
1367                 default :
1368                         this.expressionStack[this.expressionPtr] = 
1369                                 new BinaryExpression(
1370                                         expr1, 
1371                                         expr2, 
1372                                         op);            
1373         }
1374 }
1375 /**
1376  * @param op binary operator
1377  */
1378 protected void consumeBinaryExpressionWithName(int op) {
1379         pushOnExpressionStack(getUnspecifiedReferenceOptimized());
1380         this.expressionPtr--;
1381         this.expressionLengthPtr--;
1382         /*
1383         if (op == OR_OR) {
1384                 this.expressionStack[this.expressionPtr] = 
1385                         new OR_OR_Expression(
1386                                 this.expressionStack[this.expressionPtr + 1], 
1387                                 this.expressionStack[this.expressionPtr], 
1388                                 op); 
1389         } else {
1390                 if (op == AND_AND) {
1391                         this.expressionStack[this.expressionPtr] = 
1392                                 new AND_AND_Expression(
1393                                         this.expressionStack[this.expressionPtr + 1], 
1394                                         this.expressionStack[this.expressionPtr], 
1395                                         op);
1396                 } else {
1397                         // look for "string1" + "string2"
1398                         if ((op == PLUS) && this.optimizeStringLiterals) {
1399                                 Expression expr1, expr2;
1400                                 expr1 = this.expressionStack[this.expressionPtr + 1];
1401                                 expr2 = this.expressionStack[this.expressionPtr];
1402                                 if (expr1 instanceof StringLiteral) {
1403                                         if (expr2 instanceof CharLiteral) { // string+char
1404                                                 this.expressionStack[this.expressionPtr] = 
1405                                                         ((StringLiteral) expr1).extendWith((CharLiteral) expr2); 
1406                                         } else if (expr2 instanceof StringLiteral) { //string+string
1407                                                 this.expressionStack[this.expressionPtr] = 
1408                                                         ((StringLiteral) expr1).extendWith((StringLiteral) expr2); 
1409                                         } else {
1410                                                 this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
1411                                         }
1412                                 } else {
1413                                         this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
1414                                 }
1415                         } else {
1416                                 this.expressionStack[this.expressionPtr] = 
1417                                         new BinaryExpression(
1418                                                 this.expressionStack[this.expressionPtr + 1], 
1419                                                 this.expressionStack[this.expressionPtr], 
1420                                                 op);
1421                         }
1422                 }
1423         }
1424         */
1425         Expression expr1 = this.expressionStack[this.expressionPtr + 1];
1426         Expression expr2 = this.expressionStack[this.expressionPtr];
1427         switch(op) {
1428                 case OR_OR :
1429                         this.expressionStack[this.expressionPtr] = 
1430                                 new OR_OR_Expression(
1431                                         expr1, 
1432                                         expr2, 
1433                                         op); 
1434                         break;
1435                 case AND_AND :
1436                         this.expressionStack[this.expressionPtr] = 
1437                                 new AND_AND_Expression(
1438                                         expr1, 
1439                                         expr2, 
1440                                         op);
1441                         break;
1442                 case PLUS :
1443                         // look for "string1" + "string2"
1444                         if (this.optimizeStringLiterals) {
1445                                 if (expr1 instanceof StringLiteral) {
1446                                         if (expr2 instanceof CharLiteral) { // string+char
1447                                                 this.expressionStack[this.expressionPtr] = 
1448                                                         ((StringLiteral) expr1).extendWith((CharLiteral) expr2); 
1449                                         } else if (expr2 instanceof StringLiteral) { //string+string
1450                                                 this.expressionStack[this.expressionPtr] = 
1451                                                         ((StringLiteral) expr1).extendWith((StringLiteral) expr2); 
1452                                         } else {
1453                                                 this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
1454                                         }
1455                                 } else {
1456                                         this.expressionStack[this.expressionPtr] = new BinaryExpression(expr1, expr2, PLUS);
1457                                 }
1458                         } else if (expr1 instanceof StringLiteral) {
1459                                 if (expr2 instanceof StringLiteral) {
1460                                         // string + string
1461                                         this.expressionStack[this.expressionPtr] = 
1462                                                 ((StringLiteral) expr1).extendsWith((StringLiteral) expr2); 
1463                                 } else {
1464                                         this.expressionStack[this.expressionPtr] = 
1465                                                 new BinaryExpression(
1466                                                         expr1, 
1467                                                         expr2, 
1468                                                         op);
1469                                 }
1470                         } else {
1471                                 this.expressionStack[this.expressionPtr] = 
1472                                         new BinaryExpression(
1473                                                 expr1, 
1474                                                 expr2, 
1475                                                 op);
1476                         }
1477                         break;
1478                 case LESS :
1479                         this.intPtr--;
1480                         this.expressionStack[this.expressionPtr] = 
1481                                 new BinaryExpression(
1482                                         expr1, 
1483                                         expr2, 
1484                                         op);
1485                         break;
1486                 default :
1487                         this.expressionStack[this.expressionPtr] = 
1488                                 new BinaryExpression(
1489                                         expr1, 
1490                                         expr2, 
1491                                         op);            
1492         }
1493 }
1494 protected void consumeBlock() {
1495         // Block ::= OpenBlock '{' BlockStatementsopt '}'
1496         // simpler action for empty blocks
1497
1498         int statementsLength = this.astLengthStack[this.astLengthPtr--];
1499         Block block;
1500         if (statementsLength == 0) { // empty block 
1501                 block = new Block(0);
1502                 block.sourceStart = this.intStack[this.intPtr--];
1503                 block.sourceEnd = this.endStatementPosition;
1504                 // check whether this block at least contains some comment in it
1505                 if (!containsComment(block.sourceStart, block.sourceEnd)) {
1506                         block.bits |= ASTNode.UndocumentedEmptyBlockMASK;
1507                 }
1508                 this.realBlockPtr--; // still need to pop the block variable counter
1509         } else {
1510                 block = new Block(this.realBlockStack[this.realBlockPtr--]);
1511                 this.astPtr -= statementsLength;
1512                 System.arraycopy(
1513                         this.astStack, 
1514                         this.astPtr + 1, 
1515                         block.statements = new Statement[statementsLength], 
1516                         0, 
1517                         statementsLength); 
1518                 block.sourceStart = this.intStack[this.intPtr--];
1519                 block.sourceEnd = this.endStatementPosition;
1520         }
1521         pushOnAstStack(block);
1522 }
1523 protected void consumeBlockStatements() {
1524         // BlockStatements ::= BlockStatements BlockStatement
1525         concatNodeLists();
1526 }
1527 protected void consumeCaseLabel() {
1528         // SwitchLabel ::= 'case' ConstantExpression ':'
1529         this.expressionLengthPtr--;
1530         Expression expression = this.expressionStack[this.expressionPtr--];
1531         pushOnAstStack(new CaseStatement(expression, expression.sourceEnd, this.intStack[this.intPtr--]));
1532 }
1533 protected void consumeCastExpressionLL1() {
1534         //CastExpression ::= '(' Expression ')' InsideCastExpressionLL1 UnaryExpressionNotPlusMinus
1535         // Expression is used in order to make the grammar LL1
1536
1537         //optimize push/pop
1538
1539         Expression cast,exp;
1540         this.expressionPtr--;
1541         this.expressionStack[this.expressionPtr] = 
1542                 cast = new CastExpression(
1543                         exp=this.expressionStack[this.expressionPtr+1] ,
1544                         getTypeReference(this.expressionStack[this.expressionPtr]));
1545         this.expressionLengthPtr -- ;
1546         updateSourcePosition(cast);
1547         cast.sourceEnd=exp.sourceEnd;
1548 }
1549 protected void consumeCastExpressionWithGenericsArray() {
1550         // CastExpression ::= PushLPAREN Name TypeArguments Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
1551
1552         Expression exp, cast, castType;
1553         int end = this.intStack[this.intPtr--];
1554
1555         int dim = this.intStack[this.intPtr--];
1556         pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
1557         
1558         this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType = getTypeReference(dim));
1559         intPtr--;
1560         castType.sourceEnd = end - 1;
1561         castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
1562         cast.sourceEnd = exp.sourceEnd;
1563 }
1564 protected void consumeCastExpressionWithNameArray() {
1565         // CastExpression ::= PushLPAREN Name Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
1566
1567         Expression exp, cast, castType;
1568         int end = this.intStack[this.intPtr--];
1569         
1570         // handle type arguments
1571         pushOnGenericsLengthStack(0);
1572         pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
1573         
1574         this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType = getTypeReference(this.intStack[this.intPtr--]));
1575         castType.sourceEnd = end - 1;
1576         castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
1577         cast.sourceEnd = exp.sourceEnd;
1578 }
1579 protected void consumeCastExpressionWithPrimitiveType() {
1580         // CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN InsideCastExpression UnaryExpression
1581
1582         //this.intStack : posOfLeftParen dim posOfRightParen
1583
1584         //optimize the push/pop
1585
1586         Expression exp, cast, castType;
1587         int end = this.intStack[this.intPtr--];
1588         this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType = getTypeReference(this.intStack[this.intPtr--]));
1589         castType.sourceEnd = end - 1;
1590         castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
1591         cast.sourceEnd = exp.sourceEnd;
1592 }
1593 protected ParameterizedQualifiedTypeReference computeQualifiedGenericsFromRightSide(TypeReference rightSide, int dim) {
1594         int nameSize = this.identifierLengthStack[this.identifierLengthPtr];
1595         int tokensSize = nameSize;
1596         if (rightSide instanceof ParameterizedSingleTypeReference) {
1597                 tokensSize ++;
1598         } else if (rightSide instanceof SingleTypeReference) {
1599                 tokensSize ++;
1600         } else if (rightSide instanceof ParameterizedQualifiedTypeReference) {
1601                 tokensSize += ((QualifiedTypeReference) rightSide).tokens.length;
1602         } else if (rightSide instanceof QualifiedTypeReference) {
1603                 tokensSize += ((QualifiedTypeReference) rightSide).tokens.length;
1604         }
1605         TypeReference[][] typeArguments = new TypeReference[tokensSize][];
1606         char[][] tokens = new char[tokensSize][];
1607         long[] positions = new long[tokensSize];
1608         if (rightSide instanceof ParameterizedSingleTypeReference) {
1609                 ParameterizedSingleTypeReference singleParameterizedTypeReference = (ParameterizedSingleTypeReference) rightSide;
1610                 tokens[nameSize] = singleParameterizedTypeReference.token;
1611                 positions[nameSize] = (((long) singleParameterizedTypeReference.sourceStart) << 32) + singleParameterizedTypeReference.sourceEnd;
1612                 typeArguments[nameSize] = singleParameterizedTypeReference.typeArguments;
1613         } else if (rightSide instanceof SingleTypeReference) {
1614                 SingleTypeReference singleTypeReference = (SingleTypeReference) rightSide;
1615                 tokens[nameSize] = singleTypeReference.token;
1616                 positions[nameSize] = (((long) singleTypeReference.sourceStart) << 32) + singleTypeReference.sourceEnd;
1617         } else if (rightSide instanceof ParameterizedQualifiedTypeReference) {
1618                 ParameterizedQualifiedTypeReference parameterizedTypeReference = (ParameterizedQualifiedTypeReference) rightSide;
1619                 TypeReference[][] rightSideTypeArguments = parameterizedTypeReference.typeArguments;
1620                 System.arraycopy(rightSideTypeArguments, 0, typeArguments, nameSize, rightSideTypeArguments.length);
1621                 char[][] rightSideTokens = parameterizedTypeReference.tokens;
1622                 System.arraycopy(rightSideTokens, 0, tokens, nameSize, rightSideTokens.length);
1623                 long[] rightSidePositions = parameterizedTypeReference.sourcePositions;
1624                 System.arraycopy(rightSidePositions, 0, positions, nameSize, rightSidePositions.length);
1625         } else if (rightSide instanceof QualifiedTypeReference) {
1626                 QualifiedTypeReference qualifiedTypeReference = (QualifiedTypeReference) rightSide;
1627                 char[][] rightSideTokens = qualifiedTypeReference.tokens;
1628                 System.arraycopy(rightSideTokens, 0, tokens, nameSize, rightSideTokens.length);
1629                 long[] rightSidePositions = qualifiedTypeReference.sourcePositions;
1630                 System.arraycopy(rightSidePositions, 0, positions, nameSize, rightSidePositions.length);
1631         }
1632
1633         int currentTypeArgumentsLength = this.genericsLengthStack[this.genericsLengthPtr--];
1634         TypeReference[] currentTypeArguments = new TypeReference[currentTypeArgumentsLength];
1635         this.genericsPtr -= currentTypeArgumentsLength;
1636         System.arraycopy(this.genericsStack, this.genericsPtr + 1, currentTypeArguments, 0, currentTypeArgumentsLength);
1637         
1638         if (nameSize == 1) {
1639                 tokens[0] = this.identifierStack[this.identifierPtr];
1640                 positions[0] = this.identifierPositionStack[this.identifierPtr--];
1641                 typeArguments[0] = currentTypeArguments;
1642         } else {
1643                 this.identifierPtr -= nameSize;
1644                 System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, nameSize);
1645                 System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, nameSize);
1646                 typeArguments[nameSize - 1] = currentTypeArguments;
1647         }
1648         this.identifierLengthPtr--;
1649         return new ParameterizedQualifiedTypeReference(tokens, typeArguments, dim, positions);
1650 }
1651 protected void consumeCastExpressionWithQualifiedGenericsArray() {
1652         // CastExpression ::= PushLPAREN Name OnlyTypeArguments '.' ClassOrInterfaceType Dims PushRPAREN InsideCastExpression UnaryExpressionNotPlusMinus
1653         Expression exp, cast, castType;
1654         int end = this.intStack[this.intPtr--];
1655
1656         int dim = this.intStack[this.intPtr--];
1657         TypeReference rightSide = getTypeReference(0);
1658         
1659         ParameterizedQualifiedTypeReference qualifiedParameterizedTypeReference = computeQualifiedGenericsFromRightSide(rightSide, dim);
1660         intPtr--;
1661         this.expressionStack[this.expressionPtr] = cast = new CastExpression(exp = this.expressionStack[this.expressionPtr], castType = qualifiedParameterizedTypeReference);
1662         castType.sourceEnd = end - 1;
1663         castType.sourceStart = (cast.sourceStart = this.intStack[this.intPtr--]) + 1;
1664         cast.sourceEnd = exp.sourceEnd;
1665 }
1666 protected void consumeCatches() {
1667         // Catches ::= Catches CatchClause
1668         optimizedConcatNodeLists();
1669 }
1670 protected void consumeCatchHeader() {
1671         // CatchDeclaration ::= 'catch' '(' FormalParameter ')' '{'
1672
1673         if (this.currentElement == null){
1674                 return; // should never occur, this consumeRule is only used in recovery mode
1675         }
1676         // current element should be a block due to the presence of the opening brace
1677         if (!(this.currentElement instanceof RecoveredBlock)){
1678                 if(!(this.currentElement instanceof RecoveredMethod)) {
1679                         return;
1680                 }
1681                 RecoveredMethod rMethod = (RecoveredMethod) this.currentElement;
1682                 if(!(rMethod.methodBody == null && rMethod.bracketBalance > 0)) {
1683                         return;
1684                 }
1685         }
1686         
1687         Argument arg = (Argument)this.astStack[this.astPtr--];
1688         // convert argument to local variable
1689         LocalDeclaration localDeclaration = new LocalDeclaration(arg.name, arg.sourceStart, arg.sourceEnd);
1690         localDeclaration.type = arg.type;
1691         localDeclaration.declarationSourceStart = arg.declarationSourceStart;
1692         localDeclaration.declarationSourceEnd = arg.declarationSourceEnd;
1693         
1694         this.currentElement = this.currentElement.add(localDeclaration, 0);
1695         this.lastCheckPoint = this.scanner.startPosition; // force to restart at this exact position
1696         this.restartRecovery = true; // request to restart from here on
1697         this.lastIgnoredToken = -1;
1698 }
1699 protected void consumeClassBodyDeclaration() {
1700         // ClassBodyDeclaration ::= Diet Block
1701         //push an Initializer
1702         //optimize the push/pop
1703         this.nestedMethod[this.nestedType]--;
1704         Block block = (Block) this.astStack[this.astPtr];
1705         if (this.diet) block.bits &= ~ASTNode.UndocumentedEmptyBlockMASK; // clear bit since was diet
1706         Initializer initializer = new Initializer(block, 0);
1707         this.intPtr--; // pop sourcestart left on the stack by consumeNestedMethod.
1708         initializer.bodyStart = this.intStack[this.intPtr--];
1709         this.realBlockPtr--; // pop the block variable counter left on the stack by consumeNestedMethod
1710         int javadocCommentStart = this.intStack[this.intPtr--];
1711         if (javadocCommentStart != -1) {
1712                 initializer.declarationSourceStart = javadocCommentStart;
1713                 initializer.javadoc = this.javadoc;
1714                 this.javadoc = null;
1715         }
1716         this.astStack[this.astPtr] = initializer;
1717         initializer.bodyEnd = this.endPosition;
1718         initializer.sourceEnd = this.endStatementPosition;
1719         initializer.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
1720 }
1721 protected void consumeClassBodyDeclarations() {
1722         // ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration
1723         concatNodeLists();
1724 }
1725 protected void consumeClassBodyDeclarationsopt() {
1726         // ClassBodyDeclarationsopt ::= NestedType ClassBodyDeclarations
1727         this.nestedType-- ;
1728 }
1729 protected void consumeClassBodyopt() {
1730         // ClassBodyopt ::= $empty
1731         pushOnAstStack(null);
1732         this.endPosition = this.rParenPos;
1733 }
1734 protected void consumeClassDeclaration() {
1735         // ClassDeclaration ::= ClassHeader ClassBody
1736
1737         int length;
1738         if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
1739                 //there are length declarations
1740                 //dispatch according to the type of the declarations
1741                 dispatchDeclarationInto(length);
1742         }
1743
1744         TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
1745
1746         // mark initializers with local type mark if needed
1747         markInitializersWithLocalType(typeDecl);
1748
1749         //convert constructor that do not have the type's name into methods
1750         boolean hasConstructor = typeDecl.checkConstructors(this);
1751         
1752         //add the default constructor when needed (interface don't have it)
1753         if (!hasConstructor) {
1754                 switch(typeDecl.kind()) {
1755                         case IGenericType.CLASS_DECL :
1756                         case IGenericType.ENUM_DECL :
1757                                 boolean insideFieldInitializer = false;
1758                                 if (this.diet) {
1759                                         for (int i = this.nestedType; i > 0; i--){
1760                                                 if (this.variablesCounter[i] > 0) {
1761                                                         insideFieldInitializer = true;
1762                                                         break;
1763                                                 }
1764                                         }
1765                                 }
1766                                 typeDecl.createDefaultConstructor(!this.diet || insideFieldInitializer, true);
1767                 }
1768         }
1769         //always add <clinit> (will be remove at code gen time if empty)
1770         if (this.scanner.containsAssertKeyword) {
1771                 typeDecl.bits |= ASTNode.AddAssertionMASK;
1772         }
1773         typeDecl.addClinit();
1774         typeDecl.bodyEnd = this.endStatementPosition;
1775         if (length == 0 && !containsComment(typeDecl.bodyStart, typeDecl.bodyEnd)) {
1776                 typeDecl.bits |= ASTNode.UndocumentedEmptyBlockMASK;
1777         }
1778
1779         typeDecl.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition); 
1780 }
1781 protected void consumeClassHeader() {
1782         // ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt ClassHeaderImplementsopt
1783
1784         TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];        
1785         if (this.currentToken == TokenNameLBRACE) { 
1786                 typeDecl.bodyStart = this.scanner.currentPosition;
1787         }
1788         if (this.currentElement != null) {
1789                 this.restartRecovery = true; // used to avoid branching back into the regular automaton         
1790         }
1791         // flush the comments related to the class header
1792         this.scanner.commentPtr = -1;
1793 }
1794 protected void consumeClassHeaderExtends() {
1795         // ClassHeaderExtends ::= 'extends' ClassType
1796         //superclass
1797         TypeReference superClass = getTypeReference(0);
1798         // There is a class declaration on the top of stack
1799         TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
1800         typeDecl.superclass = superClass;
1801         superClass.bits |= ASTNode.IsSuperType;
1802         typeDecl.bodyStart = typeDecl.superclass.sourceEnd + 1;
1803         // recovery
1804         if (this.currentElement != null){
1805                 this.lastCheckPoint = typeDecl.bodyStart;
1806         }
1807 }
1808 protected void consumeClassHeaderImplements() {
1809         // ClassHeaderImplements ::= 'implements' InterfaceTypeList
1810         int length = this.astLengthStack[this.astLengthPtr--];
1811         //super interfaces
1812         this.astPtr -= length;
1813         // There is a class declaration on the top of stack
1814         TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
1815         System.arraycopy(
1816                 this.astStack, 
1817                 this.astPtr + 1, 
1818                 typeDecl.superInterfaces = new TypeReference[length], 
1819                 0, 
1820                 length); 
1821         for (int i = 0, max = typeDecl.superInterfaces.length; i < max; i++) {
1822                 typeDecl.superInterfaces[i].bits |= ASTNode.IsSuperType;
1823         }
1824         typeDecl.bodyStart = typeDecl.superInterfaces[length-1].sourceEnd + 1;
1825         this.listLength = 0; // reset after having read super-interfaces
1826         // recovery
1827         if (this.currentElement != null) { // is recovering
1828                 this.lastCheckPoint = typeDecl.bodyStart;
1829         }
1830 }
1831 protected void consumeClassHeaderName1() {
1832         // ClassHeaderName1 ::= Modifiersopt 'class' 'Identifier'
1833         TypeDeclaration typeDecl = new TypeDeclaration(this.compilationUnit.compilationResult);
1834         if (this.nestedMethod[this.nestedType] == 0) {
1835                 if (this.nestedType != 0) {
1836                         typeDecl.bits |= ASTNode.IsMemberTypeMASK;
1837                 }
1838         } else {
1839                 // Record that the block has a declaration for local types
1840                 typeDecl.bits |= ASTNode.IsLocalTypeMASK;
1841                 markEnclosingMemberWithLocalType();
1842                 blockReal();
1843         }
1844
1845         //highlight the name of the type
1846         long pos = this.identifierPositionStack[this.identifierPtr];
1847         typeDecl.sourceEnd = (int) pos;
1848         typeDecl.sourceStart = (int) (pos >>> 32);
1849         typeDecl.name = this.identifierStack[this.identifierPtr--];
1850         this.identifierLengthPtr--;
1851
1852         //compute the declaration source too
1853         // 'class' and 'interface' push two int positions: the beginning of the class token and its end.
1854         // we want to keep the beginning position but get rid of the end position
1855         // it is only used for the ClassLiteralAccess positions.
1856         typeDecl.declarationSourceStart = this.intStack[this.intPtr--]; 
1857         this.intPtr--; // remove the end position of the class token
1858
1859         typeDecl.modifiersSourceStart = this.intStack[this.intPtr--];
1860         typeDecl.modifiers = this.intStack[this.intPtr--];
1861         if (typeDecl.modifiersSourceStart >= 0) {
1862                 typeDecl.declarationSourceStart = typeDecl.modifiersSourceStart;
1863         }
1864         // consume annotations
1865         int length;
1866         if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
1867                 System.arraycopy(
1868                         this.expressionStack, 
1869                         (this.expressionPtr -= length) + 1, 
1870                         typeDecl.annotations = new Annotation[length], 
1871                         0, 
1872                         length); 
1873         }
1874         typeDecl.bodyStart = typeDecl.sourceEnd + 1;
1875         pushOnAstStack(typeDecl);
1876
1877         this.listLength = 0; // will be updated when reading super-interfaces
1878         // recovery
1879         if (this.currentElement != null){ 
1880                 this.lastCheckPoint = typeDecl.bodyStart;
1881                 this.currentElement = this.currentElement.add(typeDecl, 0);
1882                 this.lastIgnoredToken = -1;
1883         }
1884         // javadoc
1885         typeDecl.javadoc = this.javadoc;
1886         this.javadoc = null;
1887 }
1888 protected void consumeTypeHeaderNameWithTypeParameters() {
1889         // ClassHeaderName ::= ClassHeaderName1 TypeParameters
1890         // InterfaceHeaderName ::= InterfaceHeaderName1 TypeParameters
1891         TypeDeclaration typeDecl = (TypeDeclaration)this.astStack[this.astPtr];
1892
1893         // consume type parameters
1894         int length = this.genericsLengthStack[this.genericsLengthPtr--];
1895         this.genericsPtr -= length;
1896         System.arraycopy(this.genericsStack, this.genericsPtr + 1, typeDecl.typeParameters = new TypeParameter[length], 0, length);
1897
1898         typeDecl.bodyStart = typeDecl.typeParameters[length-1].declarationSourceEnd + 1;
1899         
1900         this.listTypeParameterLength = 0;
1901         
1902         if (this.currentElement != null) { // is recovering
1903                 this.lastCheckPoint = typeDecl.bodyStart;
1904         }
1905 }
1906 protected void consumeClassInstanceCreationExpression() {
1907         // ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt
1908         classInstanceCreation(false);
1909 }
1910 protected void consumeClassInstanceCreationExpressionName() {
1911         // ClassInstanceCreationExpressionName ::= Name '.'
1912         pushOnExpressionStack(getUnspecifiedReferenceOptimized());
1913 }
1914 protected void consumeClassInstanceCreationExpressionQualified() {
1915         // ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
1916         // ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt
1917         classInstanceCreation(true);
1918
1919         this.expressionLengthPtr--;
1920         QualifiedAllocationExpression qae = 
1921                 (QualifiedAllocationExpression) this.expressionStack[this.expressionPtr--]; 
1922         qae.enclosingInstance = this.expressionStack[this.expressionPtr];
1923         this.expressionStack[this.expressionPtr] = qae;
1924         qae.sourceStart = qae.enclosingInstance.sourceStart;
1925 }
1926 protected void consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() {
1927         // ClassInstanceCreationExpression ::= Primary '.' 'new' TypeArguments SimpleName '(' ArgumentListopt ')' ClassBodyopt
1928         // ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' TypeArguments SimpleName '(' ArgumentListopt ')' ClassBodyopt
1929
1930         QualifiedAllocationExpression alloc;
1931         int length;
1932         if (((length = this.astLengthStack[this.astLengthPtr--]) == 1) && (this.astStack[this.astPtr] == null)) {
1933                 //NO ClassBody
1934                 this.astPtr--;
1935                 alloc = new QualifiedAllocationExpression();
1936                 alloc.sourceEnd = this.endPosition; //the position has been stored explicitly
1937
1938                 if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
1939                         this.expressionPtr -= length;
1940                         System.arraycopy(
1941                                 this.expressionStack, 
1942                                 this.expressionPtr + 1, 
1943                                 alloc.arguments = new Expression[length], 
1944                                 0, 
1945                                 length); 
1946                 }
1947                 alloc.type = getTypeReference(0);
1948
1949                 length = this.genericsLengthStack[this.genericsLengthPtr--];
1950                 this.genericsPtr -= length;
1951                 System.arraycopy(this.genericsStack, this.genericsPtr + 1, alloc.typeArguments = new TypeReference[length], 0, length);
1952                 intPtr--;
1953
1954                 //the default constructor with the correct number of argument
1955                 //will be created and added by the TC (see createsInternalConstructorWithBinding)
1956                 alloc.sourceStart = this.intStack[this.intPtr--];
1957                 pushOnExpressionStack(alloc);
1958         } else {
1959                 dispatchDeclarationInto(length);
1960                 TypeDeclaration anonymousTypeDeclaration = (TypeDeclaration)this.astStack[this.astPtr];
1961                 anonymousTypeDeclaration.declarationSourceEnd = this.endStatementPosition;
1962                 anonymousTypeDeclaration.bodyEnd = this.endStatementPosition;
1963                 if (length == 0 && !containsComment(anonymousTypeDeclaration.bodyStart, anonymousTypeDeclaration.bodyEnd)) {
1964                         anonymousTypeDeclaration.bits |= ASTNode.UndocumentedEmptyBlockMASK;
1965                 }
1966                 this.astPtr--;
1967                 this.astLengthPtr--;
1968
1969                 QualifiedAllocationExpression allocationExpression = anonymousTypeDeclaration.allocation;
1970                 if (allocationExpression != null) {
1971                         allocationExpression.sourceEnd = this.endStatementPosition;
1972                         // handle type arguments
1973                         length = this.genericsLengthStack[this.genericsLengthPtr--];
1974                         this.genericsPtr -= length;
1975                         System.arraycopy(this.genericsStack, this.genericsPtr + 1, allocationExpression.typeArguments = new TypeReference[length], 0, length);
1976                         allocationExpression.sourceStart = intStack[intPtr--];
1977                 }
1978                 
1979                 // mark initializers with local type mark if needed
1980                 markInitializersWithLocalType(anonymousTypeDeclaration);
1981         }
1982
1983         this.expressionLengthPtr--;
1984         QualifiedAllocationExpression qae = 
1985                 (QualifiedAllocationExpression) this.expressionStack[this.expressionPtr--]; 
1986         qae.enclosingInstance = this.expressionStack[this.expressionPtr];
1987         this.expressionStack[this.expressionPtr] = qae;
1988         qae.sourceStart = qae.enclosingInstance.sourceStart;
1989 }
1990 protected void consumeClassInstanceCreationExpressionWithTypeArguments() {
1991         // ClassInstanceCreationExpression ::= 'new' TypeArguments ClassType '(' ArgumentListopt ')' ClassBodyopt
1992         AllocationExpression alloc;
1993         int length;
1994         if (((length = this.astLengthStack[this.astLengthPtr--]) == 1)
1995                 && (this.astStack[this.astPtr] == null)) {
1996                 //NO ClassBody
1997                 this.astPtr--;
1998                 alloc = new AllocationExpression();
1999                 alloc.sourceEnd = this.endPosition; //the position has been stored explicitly
2000
2001                 if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2002                         this.expressionPtr -= length;
2003                         System.arraycopy(
2004                                 this.expressionStack, 
2005                                 this.expressionPtr + 1, 
2006                                 alloc.arguments = new Expression[length], 
2007                                 0, 
2008                                 length); 
2009                 }
2010                 alloc.type = getTypeReference(0);
2011
2012                 length = this.genericsLengthStack[this.genericsLengthPtr--];
2013                 this.genericsPtr -= length;
2014                 System.arraycopy(this.genericsStack, this.genericsPtr + 1, alloc.typeArguments = new TypeReference[length], 0, length);
2015                 intPtr--;
2016                 
2017                 //the default constructor with the correct number of argument
2018                 //will be created and added by the TC (see createsInternalConstructorWithBinding)
2019                 alloc.sourceStart = this.intStack[this.intPtr--];
2020                 pushOnExpressionStack(alloc);
2021         } else {
2022                 dispatchDeclarationInto(length);
2023                 TypeDeclaration anonymousTypeDeclaration = (TypeDeclaration)this.astStack[this.astPtr];
2024                 anonymousTypeDeclaration.declarationSourceEnd = this.endStatementPosition;
2025                 anonymousTypeDeclaration.bodyEnd = this.endStatementPosition;
2026                 if (length == 0 && !containsComment(anonymousTypeDeclaration.bodyStart, anonymousTypeDeclaration.bodyEnd)) {
2027                         anonymousTypeDeclaration.bits |= ASTNode.UndocumentedEmptyBlockMASK;
2028                 }
2029                 this.astPtr--;
2030                 this.astLengthPtr--;
2031
2032                 QualifiedAllocationExpression allocationExpression = anonymousTypeDeclaration.allocation;
2033                 if (allocationExpression != null) {
2034                         allocationExpression.sourceEnd = this.endStatementPosition;
2035                         // handle type arguments
2036                         length = this.genericsLengthStack[this.genericsLengthPtr--];
2037                         this.genericsPtr -= length;
2038                         System.arraycopy(this.genericsStack, this.genericsPtr + 1, allocationExpression.typeArguments = new TypeReference[length], 0, length);
2039                         allocationExpression.sourceStart = intStack[intPtr--];
2040                 }
2041                 
2042                 // mark initializers with local type mark if needed
2043                 markInitializersWithLocalType(anonymousTypeDeclaration);
2044         }
2045 }
2046 protected void consumeClassOrInterface() {
2047         this.genericsIdentifiersLengthStack[this.genericsIdentifiersLengthPtr] += this.identifierLengthStack[this.identifierLengthPtr];
2048         pushOnGenericsLengthStack(0); // handle type arguments
2049 }
2050 protected void consumeClassOrInterfaceName() {
2051         pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
2052         pushOnGenericsLengthStack(0); // handle type arguments
2053 }
2054 protected void consumeClassTypeElt() {
2055         // ClassTypeElt ::= ClassType
2056         pushOnAstStack(getTypeReference(0));
2057         /* if incomplete thrown exception list, this.listLength counter will not have been reset,
2058                 indicating that some items are available on the stack */
2059         this.listLength++;      
2060 }
2061 protected void consumeClassTypeList() {
2062         // ClassTypeList ::= ClassTypeList ',' ClassTypeElt
2063         optimizedConcatNodeLists();
2064 }
2065 protected void consumeCompilationUnit() {
2066         // CompilationUnit ::= EnterCompilationUnit InternalCompilationUnit
2067         // do nothing by default
2068 }
2069 protected void consumeConditionalExpression(int op) {
2070         // ConditionalExpression ::= ConditionalOrExpression '?' Expression ':' ConditionalExpression
2071         //optimize the push/pop
2072         this.intPtr -= 2;//consume position of the question mark
2073         this.expressionPtr -= 2;
2074         this.expressionLengthPtr -= 2;
2075         this.expressionStack[this.expressionPtr] =
2076                 new ConditionalExpression(
2077                         this.expressionStack[this.expressionPtr],
2078                         this.expressionStack[this.expressionPtr + 1],
2079                         this.expressionStack[this.expressionPtr + 2]);
2080 }
2081 /**
2082  * @param op
2083  */
2084 protected void consumeConditionalExpressionWithName(int op) {
2085         // ConditionalExpression ::= Name '?' Expression ':' ConditionalExpression
2086         this.intPtr -= 2;//consume position of the question mark
2087         pushOnExpressionStack(getUnspecifiedReferenceOptimized());
2088         this.expressionPtr -= 2;
2089         this.expressionLengthPtr -= 2;
2090         this.expressionStack[this.expressionPtr] =
2091                 new ConditionalExpression(
2092                         this.expressionStack[this.expressionPtr + 2],
2093                         this.expressionStack[this.expressionPtr],
2094                         this.expressionStack[this.expressionPtr + 1]);
2095 }
2096 protected void consumeConstructorBlockStatements() {
2097         // ConstructorBody ::= NestedMethod '{' ExplicitConstructorInvocation BlockStatements '}'
2098         concatNodeLists(); // explictly add the first statement into the list of statements 
2099 }
2100 protected void consumeConstructorBody() {
2101         // ConstructorBody ::= NestedMethod  '{' BlockStatementsopt '}'
2102         // ConstructorBody ::= NestedMethod  '{' ExplicitConstructorInvocation '}'
2103         this.nestedMethod[this.nestedType] --;
2104 }
2105 protected void consumeConstructorDeclaration() {
2106         // ConstructorDeclaration ::= ConstructorHeader ConstructorBody
2107
2108         /*
2109         this.astStack : MethodDeclaration statements
2110         this.identifierStack : name
2111          ==>
2112         this.astStack : MethodDeclaration
2113         this.identifierStack :
2114         */
2115
2116         //must provide a default constructor call when needed
2117
2118         int length;
2119
2120         // pop the position of the {  (body of the method) pushed in block decl
2121         this.intPtr--;
2122         this.intPtr--;
2123
2124         //statements
2125         this.realBlockPtr--;
2126         ExplicitConstructorCall constructorCall = null;
2127         Statement[] statements = null;
2128         if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
2129                 this.astPtr -= length;
2130                 if (this.astStack[this.astPtr + 1] instanceof ExplicitConstructorCall) {
2131                         //avoid a isSomeThing that would only be used here BUT what is faster between two alternatives ?
2132                         System.arraycopy(
2133                                 this.astStack, 
2134                                 this.astPtr + 2, 
2135                                 statements = new Statement[length - 1], 
2136                                 0, 
2137                                 length - 1); 
2138                         constructorCall = (ExplicitConstructorCall) this.astStack[this.astPtr + 1];
2139                 } else { //need to add explicitly the super();
2140                         System.arraycopy(
2141                                 this.astStack, 
2142                                 this.astPtr + 1, 
2143                                 statements = new Statement[length], 
2144                                 0, 
2145                                 length); 
2146                         constructorCall = SuperReference.implicitSuperConstructorCall();
2147                 }
2148         } else {
2149                 boolean insideFieldInitializer = false;
2150                 if (this.diet) {
2151                         for (int i = this.nestedType; i > 0; i--){
2152                                 if (this.variablesCounter[i] > 0) {
2153                                         insideFieldInitializer = true;
2154                                         break;
2155                                 }
2156                         }
2157                 }
2158                 
2159                 if (!this.diet || insideFieldInitializer){
2160                         // add it only in non-diet mode, if diet_bodies, then constructor call will be added elsewhere.
2161                         constructorCall = SuperReference.implicitSuperConstructorCall();
2162                 }
2163         }
2164
2165         // now we know that the top of stack is a constructorDeclaration
2166         ConstructorDeclaration cd = (ConstructorDeclaration) this.astStack[this.astPtr];
2167         cd.constructorCall = constructorCall;
2168         cd.statements = statements;
2169
2170         //highlight of the implicit call on the method name
2171         if (constructorCall != null && cd.constructorCall.sourceEnd == 0) {
2172                 cd.constructorCall.sourceEnd = cd.sourceEnd;
2173                 cd.constructorCall.sourceStart = cd.sourceStart;
2174         }
2175
2176         if (!this.diet && (statements == null && constructorCall.isImplicitSuper())) {
2177                 if (!containsComment(cd.bodyStart, this.endPosition)) {
2178                         cd.bits |= ASTNode.UndocumentedEmptyBlockMASK;
2179                 }
2180         }
2181
2182         //watch for } that could be given as a unicode ! ( u007D is '}' )
2183         // store the this.endPosition (position just before the '}') in case there is
2184         // a trailing comment behind the end of the method
2185         cd.bodyEnd = this.endPosition;
2186         cd.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition); 
2187 }
2188 protected void consumeConstructorHeader() {
2189         // ConstructorHeader ::= ConstructorHeaderName MethodHeaderParameters MethodHeaderThrowsClauseopt
2190
2191         AbstractMethodDeclaration method = (AbstractMethodDeclaration)this.astStack[this.astPtr];
2192
2193         if (this.currentToken == TokenNameLBRACE){ 
2194                 method.bodyStart = this.scanner.currentPosition;
2195         }
2196         // recovery
2197         if (this.currentElement != null){
2198                 if (this.currentToken == TokenNameSEMICOLON){ // for invalid constructors
2199                         method.modifiers |= AccSemicolonBody;                   
2200                         method.declarationSourceEnd = this.scanner.currentPosition-1;
2201                         method.bodyEnd = this.scanner.currentPosition-1;
2202                         if (this.currentElement.parseTree() == method && this.currentElement.parent != null) {
2203                                 this.currentElement = this.currentElement.parent;
2204                         }
2205                 }               
2206                 this.restartRecovery = true; // used to avoid branching back into the regular automaton
2207         }               
2208 }
2209 protected void consumeConstructorHeaderName() {
2210
2211         /* recovering - might be an empty message send */
2212         if (this.currentElement != null){
2213                 if (this.lastIgnoredToken == TokenNamenew){ // was an allocation expression
2214                         this.lastCheckPoint = this.scanner.startPosition; // force to restart at this exact position                            
2215                         this.restartRecovery = true;
2216                         return;
2217                 }
2218         }
2219         
2220         // ConstructorHeaderName ::=  Modifiersopt 'Identifier' '('
2221         ConstructorDeclaration cd = new ConstructorDeclaration(this.compilationUnit.compilationResult);
2222
2223         //name -- this is not really revelant but we do .....
2224         cd.selector = this.identifierStack[this.identifierPtr];
2225         long selectorSource = this.identifierPositionStack[this.identifierPtr--];
2226         this.identifierLengthPtr--;
2227
2228         //modifiers
2229         cd.declarationSourceStart = this.intStack[this.intPtr--];
2230         cd.modifiers = this.intStack[this.intPtr--];
2231         // consume annotations
2232         int length;
2233         if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2234                 System.arraycopy(
2235                         this.expressionStack, 
2236                         (this.expressionPtr -= length) + 1, 
2237                         cd.annotations = new Annotation[length], 
2238                         0, 
2239                         length); 
2240         }       
2241         // javadoc
2242         cd.javadoc = this.javadoc;
2243         this.javadoc = null;
2244
2245         //highlight starts at the selector starts
2246         cd.sourceStart = (int) (selectorSource >>> 32);
2247         pushOnAstStack(cd);
2248         cd.sourceEnd = this.lParenPos;
2249         cd.bodyStart = this.lParenPos+1;
2250         this.listLength = 0; // initialize this.listLength before reading parameters/throws
2251
2252         // recovery
2253         if (this.currentElement != null){
2254                 this.lastCheckPoint = cd.bodyStart;
2255                 if ((this.currentElement instanceof RecoveredType && this.lastIgnoredToken != TokenNameDOT)
2256                         || cd.modifiers != 0){
2257                         this.currentElement = this.currentElement.add(cd, 0);
2258                         this.lastIgnoredToken = -1;
2259                 }
2260         }       
2261 }
2262 protected void consumeConstructorHeaderNameWithTypeParameters() {
2263
2264         /* recovering - might be an empty message send */
2265         if (this.currentElement != null){
2266                 if (this.lastIgnoredToken == TokenNamenew){ // was an allocation expression
2267                         this.lastCheckPoint = this.scanner.startPosition; // force to restart at this exact position                            
2268                         this.restartRecovery = true;
2269                         return;
2270                 }
2271         }
2272         
2273         // ConstructorHeaderName ::=  Modifiersopt TypeParameters 'Identifier' '('
2274         ConstructorDeclaration cd = new ConstructorDeclaration(this.compilationUnit.compilationResult);
2275
2276         //name -- this is not really revelant but we do .....
2277         cd.selector = this.identifierStack[this.identifierPtr];
2278         long selectorSource = this.identifierPositionStack[this.identifierPtr--];
2279         this.identifierLengthPtr--;
2280
2281         // consume type parameters
2282         int length = this.genericsLengthStack[this.genericsLengthPtr--];
2283         this.genericsPtr -= length;
2284         System.arraycopy(this.genericsStack, this.genericsPtr + 1, cd.typeParameters = new TypeParameter[length], 0, length);
2285         
2286         //modifiers
2287         cd.declarationSourceStart = this.intStack[this.intPtr--];
2288         cd.modifiers = this.intStack[this.intPtr--];
2289         // consume annotations
2290         if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2291                 System.arraycopy(
2292                         this.expressionStack, 
2293                         (this.expressionPtr -= length) + 1, 
2294                         cd.annotations = new Annotation[length], 
2295                         0, 
2296                         length); 
2297         }
2298         // javadoc
2299         cd.javadoc = this.javadoc;
2300         this.javadoc = null;
2301
2302         //highlight starts at the selector starts
2303         cd.sourceStart = (int) (selectorSource >>> 32);
2304         pushOnAstStack(cd);
2305         cd.sourceEnd = this.lParenPos;
2306         cd.bodyStart = this.lParenPos+1;
2307         this.listLength = 0; // initialize this.listLength before reading parameters/throws
2308
2309         // recovery
2310         if (this.currentElement != null){
2311                 this.lastCheckPoint = cd.bodyStart;
2312                 if ((this.currentElement instanceof RecoveredType && this.lastIgnoredToken != TokenNameDOT)
2313                         || cd.modifiers != 0){
2314                         this.currentElement = this.currentElement.add(cd, 0);
2315                         this.lastIgnoredToken = -1;
2316                 }
2317         }       
2318 }
2319 protected void consumeDefaultLabel() {
2320         // SwitchLabel ::= 'default' ':'
2321         pushOnAstStack(new CaseStatement(null, this.intStack[this.intPtr--], this.intStack[this.intPtr--]));
2322 }
2323 protected void consumeDefaultModifiers() {
2324         checkComment(); // might update modifiers with AccDeprecated
2325         pushOnIntStack(this.modifiers); // modifiers
2326         pushOnIntStack(
2327                 this.modifiersSourceStart >= 0 ? this.modifiersSourceStart : this.scanner.startPosition); 
2328         resetModifiers();
2329         pushOnExpressionStackLengthStack(0); // no annotation
2330 }
2331 protected void consumeDiet() {
2332         // Diet ::= $empty
2333         checkComment();
2334         pushOnIntStack(this.modifiersSourceStart); // push the start position of a javadoc comment if there is one
2335         resetModifiers();
2336         jumpOverMethodBody();
2337 }
2338 protected void consumeDims() {
2339         // Dims ::= DimsLoop
2340         pushOnIntStack(this.dimensions);
2341         this.dimensions = 0;
2342 }
2343 protected void consumeDimWithOrWithOutExpr() {
2344         // DimWithOrWithOutExpr ::= '[' ']'
2345         pushOnExpressionStack(null);
2346         
2347         if(this.currentElement != null && this.currentToken == TokenNameLBRACE) {
2348                 this.ignoreNextOpeningBrace = true;
2349                 this.currentElement.bracketBalance++; 
2350         }
2351 }
2352 protected void consumeDimWithOrWithOutExprs() {
2353         // DimWithOrWithOutExprs ::= DimWithOrWithOutExprs DimWithOrWithOutExpr
2354         concatExpressionLists();
2355 }
2356 protected void consumeEmptyAnnotationTypeMemberDeclarationsopt() {
2357         // AnnotationTypeMemberDeclarationsopt ::= $empty
2358         pushOnAstLengthStack(0);
2359 }
2360 protected void consumeEmptyArgumentListopt() {
2361         // ArgumentListopt ::= $empty
2362         pushOnExpressionStackLengthStack(0);
2363 }
2364 protected void consumeEmptyArguments() {
2365         // Argumentsopt ::= $empty
2366         pushOnExpressionStackLengthStack(0);
2367 }
2368 protected void consumeEmptyArrayInitializer() {
2369         // ArrayInitializer ::= '{' ,opt '}'
2370         arrayInitializer(0);
2371 }
2372 protected void consumeEmptyArrayInitializeropt() {
2373         // ArrayInitializeropt ::= $empty
2374         pushOnExpressionStackLengthStack(0);
2375 }
2376 protected void consumeEmptyBlockStatementsopt() {
2377         // BlockStatementsopt ::= $empty
2378         pushOnAstLengthStack(0);
2379 }
2380 protected void consumeEmptyCatchesopt() {
2381         // Catchesopt ::= $empty
2382         pushOnAstLengthStack(0);
2383 }
2384 protected void consumeEmptyClassBodyDeclarationsopt() {
2385         // ClassBodyDeclarationsopt ::= $empty
2386         pushOnAstLengthStack(0);
2387 }
2388 protected void consumeEmptyClassMemberDeclaration() {
2389         // ClassMemberDeclaration ::= ';'
2390         pushOnAstLengthStack(0);
2391         problemReporter().superfluousSemicolon(this.endPosition+1, this.endStatementPosition);
2392         flushCommentsDefinedPriorTo(this.endStatementPosition);
2393 }
2394 protected void consumeEmptyMethodHeaderDefaultValue() {
2395         // DefaultValueopt ::= $empty
2396         AbstractMethodDeclaration method = (AbstractMethodDeclaration)this.astStack[this.astPtr];
2397         if(method.isAnnotationMethod()) { //'method' can be a MethodDeclaration when recovery is started
2398                 pushOnExpressionStackLengthStack(0);
2399         }
2400 }
2401 protected void consumeEmptyDimsopt() {
2402         // Dimsopt ::= $empty
2403         pushOnIntStack(0);
2404 }
2405 protected void consumeEmptyEnumDeclarations() {
2406         // EnumBodyDeclarationsopt ::= $empty
2407         pushOnAstLengthStack(0);
2408 }
2409 protected void consumeEmptyExpression() {
2410         // Expressionopt ::= $empty
2411         pushOnExpressionStackLengthStack(0);
2412 }
2413 protected void consumeEmptyForInitopt() {
2414         // ForInitopt ::= $empty
2415         pushOnAstLengthStack(0);
2416 }
2417 protected void consumeEmptyForUpdateopt() {
2418         // ForUpdateopt ::= $empty
2419         pushOnExpressionStackLengthStack(0);
2420 }
2421 protected void consumeEmptyInterfaceMemberDeclaration() {
2422         // InterfaceMemberDeclaration ::= ';'
2423         pushOnAstLengthStack(0);
2424 }
2425 protected void consumeEmptyInterfaceMemberDeclarationsopt() {
2426         // InterfaceMemberDeclarationsopt ::= $empty
2427         pushOnAstLengthStack(0);
2428 }
2429 protected void consumeEmptyInternalCompilationUnit() {
2430         // InternalCompilationUnit ::= $empty
2431         // nothing to do by default
2432 }
2433 protected void consumeEmptyMemberValuePairsopt() {
2434         // MemberValuePairsopt ::= $empty
2435         pushOnAstLengthStack(0);
2436 }
2437 protected void consumeEmptyMemberValueArrayInitializer() {
2438         // MemberValueArrayInitializer ::= '{' ',' '}'
2439         // MemberValueArrayInitializer ::= '{' '}'
2440         arrayInitializer(0);
2441 }
2442 protected void consumeEmptyStatement() {
2443         // EmptyStatement ::= ';'
2444         if (this.scanner.source[this.endStatementPosition] == ';') {
2445                 pushOnAstStack(new EmptyStatement(this.endStatementPosition, this.endStatementPosition));
2446         } else {
2447                 // we have a Unicode for the ';' (/u003B)
2448                 pushOnAstStack(new EmptyStatement(this.endStatementPosition - 5, this.endStatementPosition));
2449         }
2450 }
2451 protected void consumeEmptySwitchBlock() {
2452         // SwitchBlock ::= '{' '}'
2453         pushOnAstLengthStack(0);
2454 }
2455 protected void consumeEmptyTypeDeclaration() {
2456         // TypeDeclaration ::= ';' 
2457         pushOnAstLengthStack(0);
2458         problemReporter().superfluousSemicolon(this.endPosition+1, this.endStatementPosition);
2459         flushCommentsDefinedPriorTo(this.endStatementPosition);
2460 }
2461 protected void consumeEnhancedForStatementHeader(boolean hasModifiers){
2462         // EnhancedForStatementHeader ::= 'for' '(' Type PushModifiers Identifier Dimsopt ':' Expression ')'
2463         // EnhancedForStatementHeader ::= 'for' '(' Modifiers Type PushRealModifiers Identifier Dimsopt ':' Expression ')'
2464         TypeReference type;
2465
2466         char[] identifierName = this.identifierStack[this.identifierPtr];
2467         long namePosition = this.identifierPositionStack[this.identifierPtr];
2468         
2469         LocalDeclaration localDeclaration = createLocalDeclaration(identifierName, (int) (namePosition >>> 32), (int) namePosition);
2470         localDeclaration.declarationSourceEnd = localDeclaration.declarationEnd;
2471         
2472         int extraDims = this.intStack[this.intPtr--];
2473         this.identifierPtr--;
2474         this.identifierLengthPtr--;
2475         // remove fake modifiers/modifiers start
2476         int declarationSourceStart = 0;
2477         int modifiersValue  = 0;
2478         if (hasModifiers) {
2479                 declarationSourceStart = this.intStack[this.intPtr--];
2480                 modifiersValue = this.intStack[this.intPtr--];
2481         } else {
2482                 this.intPtr-=2;
2483         }
2484
2485         //updates are on the expression stack
2486         this.expressionLengthPtr--;
2487         Expression collection = this.expressionStack[this.expressionPtr--];
2488         
2489         type = getTypeReference(this.intStack[this.intPtr--] + extraDims); // type dimension
2490
2491         // consume annotations
2492         int length;
2493         if ((length = this.expressionLengthStack[this.expressionLengthPtr--])!= 0) {
2494                 System.arraycopy(
2495                         this.expressionStack, 
2496                         (this.expressionPtr -= length) + 1, 
2497                         localDeclaration.annotations = new Annotation[length], 
2498                         0, 
2499                         length); 
2500         }
2501         if (hasModifiers) {
2502                 localDeclaration.declarationSourceStart = declarationSourceStart;
2503                 localDeclaration.modifiers = modifiersValue;
2504         } else {
2505                 localDeclaration.declarationSourceStart = type.sourceStart;
2506         }
2507         localDeclaration.type = type;
2508
2509         ForeachStatement iteratorForStatement =
2510                 new ForeachStatement(
2511                         localDeclaration,
2512                         collection,
2513                         this.intStack[this.intPtr--]); 
2514         pushOnAstStack(iteratorForStatement);
2515         
2516         if(options.sourceLevel < ClassFileConstants.JDK1_5 &&
2517                         this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
2518                 this.problemReporter().invalidUsageOfForeachStatements(localDeclaration, collection);
2519         }
2520 }
2521 protected void consumeEnhancedForStatement() {
2522         // EnhancedForStatement ::= EnhancedForStatementHeader Statement
2523         // EnhancedForStatementNoShortIf ::= EnhancedForStatementHeader StatementNoShortIf
2524
2525         //statements
2526         this.astLengthPtr--;
2527         Statement statement = (Statement) this.astStack[this.astPtr--];
2528
2529         // foreach statement is on the ast stack
2530         ForeachStatement foreachStatement = (ForeachStatement) this.astStack[this.astPtr];
2531         foreachStatement.action = statement;
2532         // remember useful empty statement
2533         if (statement instanceof EmptyStatement) statement.bits |= ASTNode.IsUsefulEmptyStatementMASK;
2534         
2535         foreachStatement.sourceEnd = this.endStatementPosition;
2536 }
2537 protected void consumeEnterAnonymousClassBody() {
2538         // EnterAnonymousClassBody ::= $empty
2539         TypeReference typeReference = getTypeReference(0);
2540
2541         TypeDeclaration anonymousType = new TypeDeclaration(this.compilationUnit.compilationResult); 
2542         anonymousType.name = TypeDeclaration.ANONYMOUS_EMPTY_NAME;
2543         anonymousType.bits |= ASTNode.AnonymousAndLocalMask;
2544         QualifiedAllocationExpression alloc = new QualifiedAllocationExpression(anonymousType); 
2545         markEnclosingMemberWithLocalType();
2546         pushOnAstStack(anonymousType);
2547
2548         alloc.sourceEnd = this.rParenPos; //the position has been stored explicitly
2549         int argumentLength;
2550         if ((argumentLength = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2551                 this.expressionPtr -= argumentLength;
2552                 System.arraycopy(
2553                         this.expressionStack, 
2554                         this.expressionPtr + 1, 
2555                         alloc.arguments = new Expression[argumentLength], 
2556                         0, 
2557                         argumentLength); 
2558         }
2559         alloc.type = typeReference;
2560
2561         anonymousType.sourceEnd = alloc.sourceEnd;
2562         //position at the type while it impacts the anonymous declaration
2563         anonymousType.sourceStart = anonymousType.declarationSourceStart = alloc.type.sourceStart;
2564         alloc.sourceStart = this.intStack[this.intPtr--];
2565         pushOnExpressionStack(alloc);
2566
2567         anonymousType.bodyStart = this.scanner.currentPosition; 
2568         this.listLength = 0; // will be updated when reading super-interfaces
2569         // recovery
2570         if (this.currentElement != null){ 
2571                 this.lastCheckPoint = anonymousType.bodyStart;          
2572                 this.currentElement = this.currentElement.add(anonymousType, 0);
2573                 this.currentToken = 0; // opening brace already taken into account
2574                 this.lastIgnoredToken = -1;
2575         }       
2576 }
2577 protected void consumeEnterAnonymousClassBodySimpleName() {
2578         // EnterAnonymousClassBody ::= $empty
2579         pushOnGenericsLengthStack(0);
2580         pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
2581         TypeReference typeReference = getTypeReference(0);
2582
2583         TypeDeclaration anonymousType = new TypeDeclaration(this.compilationUnit.compilationResult); 
2584         anonymousType.name = TypeDeclaration.ANONYMOUS_EMPTY_NAME;
2585         anonymousType.bits |= ASTNode.AnonymousAndLocalMask;
2586         QualifiedAllocationExpression alloc = new QualifiedAllocationExpression(anonymousType); 
2587         markEnclosingMemberWithLocalType();
2588         pushOnAstStack(anonymousType);
2589
2590         alloc.sourceEnd = this.rParenPos; //the position has been stored explicitly
2591         int argumentLength;
2592         if ((argumentLength = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2593                 this.expressionPtr -= argumentLength;
2594                 System.arraycopy(
2595                         this.expressionStack, 
2596                         this.expressionPtr + 1, 
2597                         alloc.arguments = new Expression[argumentLength], 
2598                         0, 
2599                         argumentLength); 
2600         }
2601         alloc.type = typeReference;
2602
2603         anonymousType.sourceEnd = alloc.sourceEnd;
2604         //position at the type while it impacts the anonymous declaration
2605         anonymousType.sourceStart = anonymousType.declarationSourceStart = alloc.type.sourceStart;
2606         alloc.sourceStart = this.intStack[this.intPtr--];
2607         pushOnExpressionStack(alloc);
2608
2609         anonymousType.bodyStart = this.scanner.currentPosition; 
2610         this.listLength = 0; // will be updated when reading super-interfaces
2611         // recovery
2612         if (this.currentElement != null){ 
2613                 this.lastCheckPoint = anonymousType.bodyStart;          
2614                 this.currentElement = this.currentElement.add(anonymousType, 0);
2615                 this.currentToken = 0; // opening brace already taken into account
2616                 this.lastIgnoredToken = -1;
2617         }       
2618 }
2619 protected void consumeEnterCompilationUnit() {
2620         // EnterCompilationUnit ::= $empty
2621         // do nothing by default
2622 }
2623 protected void consumeEnterVariable() {
2624         // EnterVariable ::= $empty
2625         // do nothing by default
2626
2627         char[] identifierName = this.identifierStack[this.identifierPtr];
2628         long namePosition = this.identifierPositionStack[this.identifierPtr];
2629         int extendedDimension = this.intStack[this.intPtr--];
2630         AbstractVariableDeclaration declaration;
2631         // create the ast node
2632         boolean isLocalDeclaration = this.nestedMethod[this.nestedType] != 0; 
2633         if (isLocalDeclaration) {
2634                 // create the local variable declarations
2635                 declaration = 
2636                         this.createLocalDeclaration(identifierName, (int) (namePosition >>> 32), (int) namePosition);
2637         } else {
2638                 // create the field declaration
2639                 declaration = 
2640                         this.createFieldDeclaration(identifierName, (int) (namePosition >>> 32), (int) namePosition); 
2641         }
2642         
2643         this.identifierPtr--;
2644         this.identifierLengthPtr--;
2645         TypeReference type;
2646         int variableIndex = this.variablesCounter[this.nestedType];
2647         int typeDim = 0;
2648         if (variableIndex == 0) {
2649                 // first variable of the declaration (FieldDeclaration or LocalDeclaration)
2650                 if (isLocalDeclaration) {
2651                         declaration.declarationSourceStart = this.intStack[this.intPtr--];
2652                         declaration.modifiers = this.intStack[this.intPtr--];
2653                         // consume annotations
2654                         int length;
2655                         if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2656                                 System.arraycopy(
2657                                         this.expressionStack, 
2658                                         (this.expressionPtr -= length) + 1, 
2659                                         declaration.annotations = new Annotation[length], 
2660                                         0, 
2661                                         length); 
2662                         }       
2663                         type = getTypeReference(typeDim = this.intStack[this.intPtr--]); // type dimension
2664                         if (declaration.declarationSourceStart == -1) {
2665                                 // this is true if there is no modifiers for the local variable declaration
2666                                 declaration.declarationSourceStart = type.sourceStart;
2667                         }
2668                         pushOnAstStack(type);
2669                 } else {
2670                         type = getTypeReference(typeDim = this.intStack[this.intPtr--]); // type dimension
2671                         pushOnAstStack(type);
2672                         declaration.declarationSourceStart = this.intStack[this.intPtr--];
2673                         declaration.modifiers = this.intStack[this.intPtr--];
2674                         // consume annotations
2675                         int length;
2676                         if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2677                                 System.arraycopy(
2678                                         this.expressionStack, 
2679                                         (this.expressionPtr -= length) + 1, 
2680                                         declaration.annotations = new Annotation[length], 
2681                                         0, 
2682                                         length); 
2683                         }                       
2684                         // Store javadoc only on first declaration as it is the same for all ones
2685                         FieldDeclaration fieldDeclaration = (FieldDeclaration) declaration;
2686                         fieldDeclaration.javadoc = this.javadoc;
2687                         this.javadoc = null;
2688                 }
2689         } else {
2690                 type = (TypeReference) this.astStack[this.astPtr - variableIndex];
2691                 typeDim = type.dimensions();
2692                 AbstractVariableDeclaration previousVariable = 
2693                         (AbstractVariableDeclaration) this.astStack[this.astPtr]; 
2694                 declaration.declarationSourceStart = previousVariable.declarationSourceStart;
2695                 declaration.modifiers = previousVariable.modifiers;
2696         }
2697
2698         if (extendedDimension == 0) {
2699                 declaration.type = type;
2700         } else {
2701                 int dimension = typeDim + extendedDimension;
2702                 //on the this.identifierLengthStack there is the information about the type....
2703                 int baseType;
2704                 if ((baseType = this.identifierLengthStack[this.identifierLengthPtr + 1]) < 0) {
2705                         //it was a baseType
2706                         int typeSourceStart = type.sourceStart;
2707                         int typeSourceEnd = type.sourceEnd;
2708                         type = TypeReference.baseTypeReference(-baseType, dimension);
2709                         type.sourceStart = typeSourceStart;
2710                         type.sourceEnd = typeSourceEnd;
2711                         declaration.type = type;
2712                 } else {
2713                         declaration.type = this.copyDims(type, dimension);
2714                 }
2715         }
2716         this.variablesCounter[this.nestedType]++;
2717         pushOnAstStack(declaration);
2718         // recovery
2719         if (this.currentElement != null) {
2720                 if (!(this.currentElement instanceof RecoveredType)
2721                         && (this.currentToken == TokenNameDOT
2722                                 //|| declaration.modifiers != 0
2723                                 || (this.scanner.getLineNumber(declaration.type.sourceStart)
2724                                                 != this.scanner.getLineNumber((int) (namePosition >>> 32))))){
2725                         this.lastCheckPoint = (int) (namePosition >>> 32);
2726                         this.restartRecovery = true;
2727                         return;
2728                 }
2729                 if (isLocalDeclaration){
2730                         LocalDeclaration localDecl = (LocalDeclaration) this.astStack[this.astPtr];
2731                         this.lastCheckPoint = localDecl.sourceEnd + 1;
2732                         this.currentElement = this.currentElement.add(localDecl, 0);
2733                 } else {
2734                         FieldDeclaration fieldDecl = (FieldDeclaration) this.astStack[this.astPtr];
2735                         this.lastCheckPoint = fieldDecl.sourceEnd + 1;
2736                         this.currentElement = this.currentElement.add(fieldDecl, 0);
2737                 }
2738                 this.lastIgnoredToken = -1;
2739         }
2740 }
2741 protected void consumeEnumBodyNoConstants() {
2742         // nothing to do
2743         // The 0 on the astLengthStack has been pushed by EnumBodyDeclarationsopt
2744 }
2745 protected void consumeEnumBodyWithConstants() {
2746         // merge the constants values with the class body
2747         concatNodeLists();
2748 }
2749 protected void consumeEnumConstantHeaderName() {
2750         if (this.currentElement != null) {
2751                 if (!(this.currentElement instanceof RecoveredType
2752                                         || (this.currentElement instanceof RecoveredField && ((RecoveredField)currentElement).fieldDeclaration.type == null))
2753                                 || (this.lastIgnoredToken == TokenNameDOT)) {
2754                         this.lastCheckPoint = this.scanner.startPosition;
2755                         this.restartRecovery = true;
2756                         return;
2757                 }
2758         }
2759    long namePosition = this.identifierPositionStack[this.identifierPtr];
2760    char[] constantName = this.identifierStack[this.identifierPtr--];
2761    final int sourceEnd = (int) namePosition;
2762    FieldDeclaration enumConstant = createFieldDeclaration(constantName, (int) (namePosition >>> 32), sourceEnd);
2763    this.identifierLengthPtr--;
2764    enumConstant.modifiersSourceStart = this.intStack[this.intPtr--];
2765    enumConstant.modifiers = this.intStack[this.intPtr--];
2766    enumConstant.declarationSourceStart = enumConstant.modifiersSourceStart;
2767    // consume annotations
2768    int length;
2769    if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2770       System.arraycopy(
2771          this.expressionStack, 
2772          (this.expressionPtr -= length) + 1, 
2773          enumConstant.annotations = new Annotation[length], 
2774          0, 
2775          length); 
2776    }
2777    pushOnAstStack(enumConstant);
2778         if (this.currentElement != null){
2779                 this.lastCheckPoint = enumConstant.sourceEnd + 1;
2780                 this.currentElement = this.currentElement.add(enumConstant, 0);         
2781         }
2782         // javadoc
2783         enumConstant.javadoc = this.javadoc;
2784         this.javadoc = null;
2785 }
2786 protected void consumeEnumConstantHeader() {
2787    FieldDeclaration enumConstant = (FieldDeclaration) this.astStack[this.astPtr];
2788    boolean foundOpeningBrace = this.currentToken == TokenNameLBRACE;
2789    if (foundOpeningBrace){
2790       // qualified allocation expression
2791       TypeDeclaration anonymousType = new TypeDeclaration(this.compilationUnit.compilationResult);
2792       anonymousType.name = TypeDeclaration.ANONYMOUS_EMPTY_NAME;
2793       anonymousType.bits |= ASTNode.AnonymousAndLocalMask;
2794       final int start = this.scanner.startPosition;
2795       anonymousType.declarationSourceStart = start;
2796       anonymousType.sourceStart = start;
2797       anonymousType.sourceEnd = start; // closing parenthesis
2798       anonymousType.modifiers = 0;
2799       anonymousType.bodyStart = this.scanner.currentPosition;
2800       markEnclosingMemberWithLocalType();
2801       pushOnAstStack(anonymousType);
2802       QualifiedAllocationExpression allocationExpression = new QualifiedAllocationExpression(anonymousType);
2803       allocationExpression.enumConstant = enumConstant;
2804       
2805       // fill arguments if needed
2806       int length;
2807       if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2808          this.expressionPtr -= length;
2809          System.arraycopy(
2810                this.expressionStack, 
2811                this.expressionPtr + 1, 
2812                allocationExpression.arguments = new Expression[length], 
2813                0, 
2814                length); 
2815       }
2816       enumConstant.initialization = allocationExpression;
2817    } else {
2818       AllocationExpression allocationExpression = new AllocationExpression();
2819       allocationExpression.enumConstant = enumConstant;
2820       // fill arguments if needed
2821       int length;
2822       if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2823          this.expressionPtr -= length;
2824          System.arraycopy(
2825                this.expressionStack, 
2826                this.expressionPtr + 1, 
2827                allocationExpression.arguments = new Expression[length], 
2828                0, 
2829                length); 
2830       }
2831       enumConstant.initialization = allocationExpression;
2832    }
2833    
2834    // recovery
2835    if (this.currentElement != null) {
2836           if(foundOpeningBrace) {
2837                 TypeDeclaration anonymousType = (TypeDeclaration) this.astStack[this.astPtr];
2838                 this.currentElement = this.currentElement.add(anonymousType, 0);
2839         this.lastCheckPoint = anonymousType.bodyStart;
2840         this.lastIgnoredToken = -1;
2841         this.currentToken = 0; // opening brace already taken into account
2842           } else {
2843                   if(this.currentToken == TokenNameSEMICOLON) {
2844                         RecoveredType currentType = this.currentRecoveryType();
2845                         if(currentType != null) {
2846                                 currentType.insideEnumConstantPart = false;
2847                         }
2848                   }
2849               if (!(this.currentElement instanceof RecoveredType)
2850                     && (this.currentToken == TokenNameDOT)){
2851                  this.lastCheckPoint = enumConstant.sourceStart;
2852                  this.restartRecovery = true;
2853                  return;
2854               }
2855                   this.lastCheckPoint = this.scanner.startPosition; // force to restart at this exact position
2856               this.lastIgnoredToken = -1;
2857               this.restartRecovery = true;
2858           }
2859    }
2860 }
2861 protected void consumeEnumConstantNoClassBody() {
2862         // set declarationEnd and declarationSourceEnd
2863         final FieldDeclaration fieldDeclaration = (FieldDeclaration) this.astStack[this.astPtr];
2864         int declarationEnd = fieldDeclaration.sourceEnd;
2865         if (declarationEnd > rParenPos) {
2866                 fieldDeclaration.declarationEnd = declarationEnd;
2867                 fieldDeclaration.declarationSourceEnd = flushCommentsDefinedPriorTo(declarationEnd);
2868         } else {
2869                 fieldDeclaration.declarationEnd = rParenPos;
2870                 fieldDeclaration.declarationSourceEnd = flushCommentsDefinedPriorTo(rParenPos);
2871         }
2872 }
2873 protected void consumeEnumConstants() {
2874         concatNodeLists();
2875 }
2876 protected void consumeEnumConstantWithClassBody() {
2877    dispatchDeclarationInto(this.astLengthStack[this.astLengthPtr--]);
2878    TypeDeclaration anonymousType = (TypeDeclaration) this.astStack[this.astPtr--]; // pop type
2879    this.astLengthPtr--;
2880    anonymousType.bodyEnd = this.endPosition;
2881    anonymousType.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
2882    final FieldDeclaration fieldDeclaration = ((FieldDeclaration) this.astStack[this.astPtr]);
2883    fieldDeclaration.declarationEnd = this.endStatementPosition;
2884    fieldDeclaration.declarationSourceEnd = anonymousType.declarationSourceEnd;
2885 }
2886 protected void consumeEnumDeclaration() {
2887         // EnumDeclaration ::= EnumHeader ClassHeaderImplementsopt EnumBody
2888         int length;
2889         if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
2890                 //there are length declarations
2891                 //dispatch according to the type of the declarations
2892                 dispatchDeclarationIntoEnumDeclaration(length);
2893         }
2894
2895         TypeDeclaration enumDeclaration = (TypeDeclaration) this.astStack[this.astPtr];
2896
2897         // mark initializers with local type mark if needed
2898         markInitializersWithLocalType(enumDeclaration);
2899
2900         //convert constructor that do not have the type's name into methods
2901         boolean hasConstructor = enumDeclaration.checkConstructors(this);
2902         
2903         //add the default constructor when needed
2904         if (!hasConstructor) {
2905                 boolean insideFieldInitializer = false;
2906                 if (this.diet) {
2907                         for (int i = this.nestedType; i > 0; i--){
2908                                 if (this.variablesCounter[i] > 0) {
2909                                         insideFieldInitializer = true;
2910                                         break;
2911                                 }
2912                         }
2913                 }
2914                 enumDeclaration.createDefaultConstructor(!this.diet || insideFieldInitializer, true);
2915         }
2916
2917         //always add <clinit> (will be remove at code gen time if empty)
2918         if (this.scanner.containsAssertKeyword) {
2919                 enumDeclaration.bits |= ASTNode.AddAssertionMASK;
2920         }
2921         enumDeclaration.addClinit();
2922         enumDeclaration.bodyEnd = this.endStatementPosition;
2923         if (length == 0 && !containsComment(enumDeclaration.bodyStart, enumDeclaration.bodyEnd)) {
2924                 enumDeclaration.bits |= ASTNode.UndocumentedEmptyBlockMASK;
2925         }
2926
2927         enumDeclaration.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition); 
2928 }
2929 protected void consumeEnumDeclarations() {
2930         // Do nothing by default
2931 }
2932 protected void consumeEnumHeader() {
2933         TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];        
2934         if (this.currentToken == TokenNameLBRACE) { 
2935                 typeDecl.bodyStart = this.scanner.currentPosition;
2936         }
2937
2938         if (this.currentElement != null) {
2939                 this.restartRecovery = true; // used to avoid branching back into the regular automaton         
2940         }
2941         
2942         // flush the comments related to the enum header
2943         this.scanner.commentPtr = -1;
2944 }
2945 protected void consumeEnumHeaderName() {
2946         // EnumHeaderName ::= Modifiersopt 'enum' Identifier
2947         TypeDeclaration enumDeclaration = new TypeDeclaration(this.compilationUnit.compilationResult);
2948         if (this.nestedMethod[this.nestedType] == 0) {
2949                 if (this.nestedType != 0) {
2950                         enumDeclaration.bits |= ASTNode.IsMemberTypeMASK;
2951                 }               
2952         } else {
2953                 // Record that the block has a declaration for local types
2954 //              markEnclosingMemberWithLocalType();
2955                 blockReal();
2956         }
2957         //highlight the name of the type
2958         long pos = this.identifierPositionStack[this.identifierPtr];
2959         enumDeclaration.sourceEnd = (int) pos;
2960         enumDeclaration.sourceStart = (int) (pos >>> 32);
2961         enumDeclaration.name = this.identifierStack[this.identifierPtr--];
2962         this.identifierLengthPtr--;
2963
2964         //compute the declaration source too
2965         // 'class' and 'interface' push two int positions: the beginning of the class token and its end.
2966         // we want to keep the beginning position but get rid of the end position
2967         // it is only used for the ClassLiteralAccess positions.
2968         enumDeclaration.declarationSourceStart = this.intStack[this.intPtr--]; 
2969         this.intPtr--; // remove the end position of the class token
2970
2971         enumDeclaration.modifiersSourceStart = this.intStack[this.intPtr--];
2972         enumDeclaration.modifiers = this.intStack[this.intPtr--] | AccEnum;
2973         if (enumDeclaration.modifiersSourceStart >= 0) {
2974                 enumDeclaration.declarationSourceStart = enumDeclaration.modifiersSourceStart;
2975         }
2976         // consume annotations
2977         int length;
2978         if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
2979                 System.arraycopy(
2980                         this.expressionStack, 
2981                         (this.expressionPtr -= length) + 1, 
2982                         enumDeclaration.annotations = new Annotation[length], 
2983                         0, 
2984                         length); 
2985         }
2986 //      if (this.currentToken == TokenNameLBRACE) { 
2987 //              enumDeclaration.bodyStart = this.scanner.currentPosition;
2988 //      }
2989         enumDeclaration.bodyStart = enumDeclaration.sourceEnd + 1;
2990         pushOnAstStack(enumDeclaration);
2991
2992         this.listLength = 0; // will be updated when reading super-interfaces
2993         
2994         if(options.sourceLevel < ClassFileConstants.JDK1_5 &&
2995                         this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
2996                 //TODO this code will be never run while 'enum' is an identifier in 1.3 scanner 
2997                 this.problemReporter().invalidUsageOfEnumDeclarations(enumDeclaration);
2998         }
2999         
3000         // recovery
3001         if (this.currentElement != null){ 
3002                 this.lastCheckPoint = enumDeclaration.bodyStart;
3003                 this.currentElement = this.currentElement.add(enumDeclaration, 0);
3004                 this.lastIgnoredToken = -1;
3005         }
3006         // javadoc
3007         enumDeclaration.javadoc = this.javadoc;
3008         this.javadoc = null;
3009 }
3010 protected void consumeEqualityExpression(int op) {
3011         // EqualityExpression ::= EqualityExpression '==' RelationalExpression
3012         // EqualityExpression ::= EqualityExpression '!=' RelationalExpression
3013
3014         //optimize the push/pop
3015
3016         this.expressionPtr--;
3017         this.expressionLengthPtr--;
3018         this.expressionStack[this.expressionPtr] =
3019                 new EqualExpression(
3020                         this.expressionStack[this.expressionPtr],
3021                         this.expressionStack[this.expressionPtr + 1],
3022                         op);
3023 }
3024 /*
3025  * @param op
3026  */
3027 protected void consumeEqualityExpressionWithName(int op) {
3028         // EqualityExpression ::= Name '==' RelationalExpression
3029         // EqualityExpression ::= Name '!=' RelationalExpression
3030         pushOnExpressionStack(getUnspecifiedReferenceOptimized());
3031         this.expressionPtr--;
3032         this.expressionLengthPtr--;
3033         this.expressionStack[this.expressionPtr] =
3034                 new EqualExpression(
3035                         this.expressionStack[this.expressionPtr + 1],
3036                         this.expressionStack[this.expressionPtr],
3037                         op);
3038 }
3039 protected void consumeExitTryBlock() {
3040         //ExitTryBlock ::= $empty
3041         if(this.currentElement != null) {
3042                 this.restartRecovery = true;
3043         }
3044 }
3045 protected void consumeExitVariableWithInitialization() {
3046         // ExitVariableWithInitialization ::= $empty
3047         // do nothing by default
3048         this.expressionLengthPtr--;
3049         AbstractVariableDeclaration variableDecl = (AbstractVariableDeclaration) this.astStack[this.astPtr];
3050         variableDecl.initialization = this.expressionStack[this.expressionPtr--];
3051         // we need to update the declarationSourceEnd of the local variable declaration to the
3052         // source end position of the initialization expression
3053         variableDecl.declarationSourceEnd = variableDecl.initialization.sourceEnd;
3054         variableDecl.declarationEnd = variableDecl.initialization.sourceEnd;
3055         
3056         this.recoveryExitFromVariable();
3057 }
3058 protected void consumeExitVariableWithoutInitialization() {
3059         // ExitVariableWithoutInitialization ::= $empty
3060         // do nothing by default
3061         
3062         AbstractVariableDeclaration variableDecl = (AbstractVariableDeclaration) this.astStack[this.astPtr];
3063         variableDecl.declarationSourceEnd = variableDecl.declarationEnd;
3064         if(this.currentElement != null && this.currentElement instanceof RecoveredField) {
3065                 if(this.endStatementPosition > variableDecl.sourceEnd) {
3066                         this.currentElement.updateSourceEndIfNecessary(this.endStatementPosition);
3067                 }
3068         }
3069         this.recoveryExitFromVariable();
3070 }
3071 protected void consumeExplicitConstructorInvocation(int flag, int recFlag) {
3072
3073         /* flag allows to distinguish 3 cases :
3074         (0) :   
3075         ExplicitConstructorInvocation ::= 'this' '(' ArgumentListopt ')' ';'
3076         ExplicitConstructorInvocation ::= 'super' '(' ArgumentListopt ')' ';'
3077         (1) :
3078         ExplicitConstructorInvocation ::= Primary '.' 'super' '(' ArgumentListopt ')' ';'
3079         ExplicitConstructorInvocation ::= Primary '.' 'this' '(' ArgumentListopt ')' ';'
3080         (2) :
3081         ExplicitConstructorInvocation ::= Name '.' 'super' '(' ArgumentListopt ')' ';'
3082         ExplicitConstructorInvocation ::= Name '.' 'this' '(' ArgumentListopt ')' ';'
3083         */
3084         int startPosition = this.intStack[this.intPtr--];
3085         ExplicitConstructorCall ecc = new ExplicitConstructorCall(recFlag);
3086         int length;
3087         if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3088                 this.expressionPtr -= length;
3089                 System.arraycopy(this.expressionStack, this.expressionPtr + 1, ecc.arguments = new Expression[length], 0, length);
3090         }
3091         switch (flag) {
3092                 case 0 :
3093                         ecc.sourceStart = startPosition;
3094                         break;
3095                 case 1 :
3096                         this.expressionLengthPtr--;
3097                         ecc.sourceStart = (ecc.qualification = this.expressionStack[this.expressionPtr--]).sourceStart;
3098                         break;
3099                 case 2 :
3100                         ecc.sourceStart = (ecc.qualification = getUnspecifiedReferenceOptimized()).sourceStart;
3101                         break;
3102         }
3103         pushOnAstStack(ecc);
3104         ecc.sourceEnd = this.endPosition;
3105 }
3106 protected void consumeExplicitConstructorInvocationWithTypeArguments(int flag, int recFlag) {
3107
3108         /* flag allows to distinguish 3 cases :
3109         (0) :   
3110         ExplicitConstructorInvocation ::= TypeArguments 'this' '(' ArgumentListopt ')' ';'
3111         ExplicitConstructorInvocation ::= TypeArguments 'super' '(' ArgumentListopt ')' ';'
3112         (1) :
3113         ExplicitConstructorInvocation ::= Primary '.' TypeArguments 'super' '(' ArgumentListopt ')' ';'
3114         ExplicitConstructorInvocation ::= Primary '.' TypeArguments 'this' '(' ArgumentListopt ')' ';'
3115         (2) :
3116         ExplicitConstructorInvocation ::= Name '.' TypeArguments 'super' '(' ArgumentListopt ')' ';'
3117         ExplicitConstructorInvocation ::= Name '.' TypeArguments 'this' '(' ArgumentListopt ')' ';'
3118         */
3119         int startPosition = this.intStack[this.intPtr--];
3120         ExplicitConstructorCall ecc = new ExplicitConstructorCall(recFlag);
3121         int length;
3122         if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3123                 this.expressionPtr -= length;
3124                 System.arraycopy(this.expressionStack, this.expressionPtr + 1, ecc.arguments = new Expression[length], 0, length);
3125         }
3126         length = this.genericsLengthStack[this.genericsLengthPtr--];
3127         this.genericsPtr -= length;
3128         System.arraycopy(this.genericsStack, this.genericsPtr + 1, ecc.typeArguments = new TypeReference[length], 0, length);
3129         ecc.typeArgumentsSourceStart = this.intStack[intPtr--];
3130
3131         switch (flag) {
3132                 case 0 :
3133                         ecc.sourceStart = startPosition;
3134                         break;
3135                 case 1 :
3136                         this.expressionLengthPtr--;
3137                         ecc.sourceStart = (ecc.qualification = this.expressionStack[this.expressionPtr--]).sourceStart;
3138                         break;
3139                 case 2 :
3140                         ecc.sourceStart = (ecc.qualification = getUnspecifiedReferenceOptimized()).sourceStart;
3141                         break;
3142         }
3143         
3144         pushOnAstStack(ecc);
3145         ecc.sourceEnd = this.endPosition;
3146 }
3147 protected void consumeExpressionStatement() {
3148         // ExpressionStatement ::= StatementExpression ';'
3149         this.expressionLengthPtr--;
3150         pushOnAstStack(this.expressionStack[this.expressionPtr--]);
3151 }
3152 protected void consumeFieldAccess(boolean isSuperAccess) {
3153         // FieldAccess ::= Primary '.' 'Identifier'
3154         // FieldAccess ::= 'super' '.' 'Identifier'
3155
3156         FieldReference fr =
3157                 new FieldReference(
3158                         this.identifierStack[this.identifierPtr],
3159                         this.identifierPositionStack[this.identifierPtr--]);
3160         this.identifierLengthPtr--;
3161         if (isSuperAccess) {
3162                 //considerates the fieldReference beginning at the 'super' .... 
3163                 fr.sourceStart = this.intStack[this.intPtr--];
3164                 fr.receiver = new SuperReference(fr.sourceStart, this.endPosition);
3165                 pushOnExpressionStack(fr);
3166         } else {
3167                 //optimize push/pop
3168                 if ((fr.receiver = this.expressionStack[this.expressionPtr]).isThis()) {
3169                         //fieldreference begins at the this
3170                         fr.sourceStart = fr.receiver.sourceStart;
3171                 }
3172                 this.expressionStack[this.expressionPtr] = fr;
3173         }
3174 }
3175 protected void consumeFieldDeclaration() {
3176         // See consumeLocalVariableDeclarationDefaultModifier() in case of change: duplicated code
3177         // FieldDeclaration ::= Modifiersopt Type VariableDeclarators ';'
3178
3179         /*
3180         this.astStack : 
3181         this.expressionStack: Expression Expression ...... Expression
3182         this.identifierStack : type  identifier identifier ...... identifier
3183         this.intStack : typeDim      dim        dim               dim
3184          ==>
3185         this.astStack : FieldDeclaration FieldDeclaration ...... FieldDeclaration
3186         this.expressionStack :
3187         this.identifierStack : 
3188         this.intStack : 
3189           
3190         */
3191         int variableDeclaratorsCounter = this.astLengthStack[this.astLengthPtr];
3192
3193         for (int i = variableDeclaratorsCounter - 1; i >= 0; i--) {
3194                 FieldDeclaration fieldDeclaration = (FieldDeclaration) this.astStack[this.astPtr - i];
3195                 fieldDeclaration.declarationSourceEnd = this.endStatementPosition; 
3196                 fieldDeclaration.declarationEnd = this.endStatementPosition;    // semi-colon included
3197         }
3198         
3199         updateSourceDeclarationParts(variableDeclaratorsCounter);
3200         int endPos = flushCommentsDefinedPriorTo(this.endStatementPosition);
3201         if (endPos != this.endStatementPosition) {
3202                 for (int i = 0; i < variableDeclaratorsCounter; i++) {
3203                         FieldDeclaration fieldDeclaration = (FieldDeclaration) this.astStack[this.astPtr - i];
3204                         fieldDeclaration.declarationSourceEnd = endPos;
3205                 }
3206         }
3207         // update the this.astStack, this.astPtr and this.astLengthStack
3208         int startIndex = this.astPtr - this.variablesCounter[this.nestedType] + 1;
3209         System.arraycopy(
3210                 this.astStack, 
3211                 startIndex, 
3212                 this.astStack, 
3213                 startIndex - 1, 
3214                 variableDeclaratorsCounter); 
3215         this.astPtr--; // remove the type reference
3216         this.astLengthStack[--this.astLengthPtr] = variableDeclaratorsCounter;
3217
3218         // recovery
3219         if (this.currentElement != null) {
3220                 this.lastCheckPoint = endPos + 1;
3221                 if (this.currentElement.parent != null && this.currentElement instanceof RecoveredField){
3222                         if (!(this.currentElement instanceof RecoveredInitializer)) {
3223                                 this.currentElement = this.currentElement.parent;
3224                         }
3225                 }
3226                 this.restartRecovery = true;
3227         }
3228         this.variablesCounter[this.nestedType] = 0;
3229 }
3230 protected void consumeForceNoDiet() {
3231         // ForceNoDiet ::= $empty
3232         this.dietInt++;
3233 }
3234 protected void consumeForInit() {
3235         // ForInit ::= StatementExpressionList
3236         pushOnAstLengthStack(-1);
3237 }
3238 protected void consumeFormalParameter(boolean isVarArgs) {
3239         // FormalParameter ::= Type VariableDeclaratorId ==> false
3240         // FormalParameter ::= Modifiers Type VariableDeclaratorId ==> true
3241         /*
3242         this.astStack : 
3243         this.identifierStack : type identifier
3244         this.intStack : dim dim
3245          ==>
3246         this.astStack : Argument
3247         this.identifierStack :   
3248         this.intStack :  
3249         */
3250
3251         this.identifierLengthPtr--;
3252         char[] identifierName = this.identifierStack[this.identifierPtr];
3253         long namePositions = this.identifierPositionStack[this.identifierPtr--];
3254         int extendedDimensions = this.intStack[this.intPtr--];
3255         int endOfEllipsis = 0;
3256         if (isVarArgs) {
3257                 endOfEllipsis = this.intStack[this.intPtr--];
3258         }
3259         int firstDimensions = this.intStack[this.intPtr--];
3260         final int typeDimensions = firstDimensions + extendedDimensions;
3261         TypeReference type = getTypeReference(typeDimensions);
3262         if (isVarArgs) {
3263                 type = type.copyDims(typeDimensions + 1);
3264                 if (extendedDimensions == 0) {
3265                         type.sourceEnd = endOfEllipsis;
3266                 }
3267                 type.bits |= ASTNode.IsVarArgs; // set isVarArgs
3268         }
3269         int modifierPositions = this.intStack[this.intPtr--];
3270         this.intPtr--;
3271         Argument arg = 
3272                 new Argument(
3273                         identifierName, 
3274                         namePositions, 
3275                         type, 
3276                         this.intStack[this.intPtr + 1] & ~AccDeprecated); // modifiers
3277         arg.declarationSourceStart = modifierPositions;
3278         // consume annotations
3279         int length;
3280         if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3281                 System.arraycopy(
3282                         this.expressionStack, 
3283                         (this.expressionPtr -= length) + 1, 
3284                         arg.annotations = new Annotation[length], 
3285                         0, 
3286                         length); 
3287         }
3288         pushOnAstStack(arg);
3289
3290         /* if incomplete method header, this.listLength counter will not have been reset,
3291                 indicating that some arguments are available on the stack */
3292         this.listLength++;      
3293         
3294         if(isVarArgs) {
3295                 if (options.sourceLevel < ClassFileConstants.JDK1_5 &&
3296                                 this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
3297                                 this.problemReporter().invalidUsageOfVarargs(arg);
3298                 } else if (extendedDimensions > 0) {
3299                         this.problemReporter().illegalExtendedDimensions(arg);
3300                 }
3301         }
3302 }
3303 protected void consumeFormalParameterList() {
3304         // FormalParameterList ::= FormalParameterList ',' FormalParameter
3305         optimizedConcatNodeLists();
3306 }
3307 protected void consumeFormalParameterListopt() {
3308         // FormalParameterListopt ::= $empty
3309         pushOnAstLengthStack(0);
3310 }
3311 protected void consumeGenericType() {
3312         // nothing to do
3313         // Will be consume by a getTypeRefence call
3314 }
3315 protected void consumeGenericTypeArrayType() {
3316         // nothing to do
3317         // Will be consume by a getTypeRefence call
3318 }
3319 protected void consumeGenericTypeNameArrayType() {
3320         pushOnGenericsLengthStack(0); // handle type arguments
3321 }
3322 protected void consumeImportDeclaration() {
3323         // SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName ';'
3324         ImportReference impt = (ImportReference) this.astStack[this.astPtr];
3325         // flush annotations defined prior to import statements
3326         impt.declarationEnd = this.endStatementPosition;
3327         impt.declarationSourceEnd = 
3328                 this.flushCommentsDefinedPriorTo(impt.declarationSourceEnd); 
3329
3330         // recovery
3331         if (this.currentElement != null) {
3332                 this.lastCheckPoint = impt.declarationSourceEnd + 1;
3333                 this.currentElement = this.currentElement.add(impt, 0);
3334                 this.lastIgnoredToken = -1;
3335                 this.restartRecovery = true; 
3336                 // used to avoid branching back into the regular automaton
3337         }
3338 }
3339 protected void consumeImportDeclarations() {
3340         // ImportDeclarations ::= ImportDeclarations ImportDeclaration 
3341         optimizedConcatNodeLists();
3342 }
3343 protected void consumeInsideCastExpression() {
3344         // InsideCastExpression ::= $empty
3345 }
3346 protected void consumeInsideCastExpressionLL1() {
3347         // InsideCastExpressionLL1 ::= $empty
3348         pushOnExpressionStack(getUnspecifiedReferenceOptimized());
3349 }
3350 protected void consumeInsideCastExpressionWithQualifiedGenerics() {
3351         // InsideCastExpressionWithQualifiedGenerics ::= $empty
3352 }
3353 protected void consumeInstanceOfExpression(int op) {
3354         // RelationalExpression ::= RelationalExpression 'instanceof' ReferenceType
3355         //optimize the push/pop
3356
3357         //by construction, no base type may be used in getTypeReference
3358         Expression exp;
3359         this.expressionStack[this.expressionPtr] = exp =
3360                 new InstanceOfExpression(
3361                         this.expressionStack[this.expressionPtr],
3362                         getTypeReference(this.intStack[this.intPtr--]),
3363                         op);
3364         if (exp.sourceEnd == 0) {
3365                 //array on base type....
3366                 exp.sourceEnd = this.scanner.startPosition - 1;
3367         }
3368         //the scanner is on the next token already....
3369 }
3370 /**
3371  * @param op
3372  */
3373 protected void consumeInstanceOfExpressionWithName(int op) {
3374         // RelationalExpression_NotName ::= Name instanceof ReferenceType
3375         //optimize the push/pop
3376
3377         //by construction, no base type may be used in getTypeReference
3378         TypeReference reference = getTypeReference(this.intStack[this.intPtr--]);
3379         pushOnExpressionStack(getUnspecifiedReferenceOptimized());
3380         Expression exp;
3381         this.expressionStack[this.expressionPtr] = exp =
3382                 new InstanceOfExpression(
3383                         this.expressionStack[this.expressionPtr],
3384                         reference,
3385                         op);
3386         if (exp.sourceEnd == 0) {
3387                 //array on base type....
3388                 exp.sourceEnd = this.scanner.startPosition - 1;
3389         }
3390         //the scanner is on the next token already....
3391 }
3392 protected void consumeInterfaceDeclaration() {
3393         // see consumeClassDeclaration in case of changes: duplicated code
3394         // InterfaceDeclaration ::= InterfaceHeader InterfaceBody
3395         int length;
3396         if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
3397                 //there are length declarations
3398                 //dispatch.....according to the type of the declarations
3399                 dispatchDeclarationInto(length);
3400         }
3401
3402         TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
3403         
3404         // mark initializers with local type mark if needed
3405         markInitializersWithLocalType(typeDecl);
3406
3407         //convert constructor that do not have the type's name into methods
3408         typeDecl.checkConstructors(this);
3409         
3410         //always add <clinit> (will be remove at code gen time if empty)
3411         if (this.scanner.containsAssertKeyword) {
3412                 typeDecl.bits |= ASTNode.AddAssertionMASK;
3413         }
3414         typeDecl.addClinit();
3415         typeDecl.bodyEnd = this.endStatementPosition;
3416         if (length == 0 && !containsComment(typeDecl.bodyStart, typeDecl.bodyEnd)) {
3417                 typeDecl.bits |= ASTNode.UndocumentedEmptyBlockMASK;
3418         }
3419         typeDecl.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition); 
3420 }
3421 protected void consumeInterfaceHeader() {
3422         // InterfaceHeader ::= InterfaceHeaderName InterfaceHeaderExtendsopt
3423
3424         TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];        
3425         if (this.currentToken == TokenNameLBRACE){ 
3426                 typeDecl.bodyStart = this.scanner.currentPosition;
3427         }
3428         if (this.currentElement != null){
3429                 this.restartRecovery = true; // used to avoid branching back into the regular automaton         
3430         }
3431         // flush the comments related to the interface header
3432         this.scanner.commentPtr = -1;   
3433 }
3434 protected void consumeInterfaceHeaderExtends() {
3435         // InterfaceHeaderExtends ::= 'extends' InterfaceTypeList
3436         int length = this.astLengthStack[this.astLengthPtr--];
3437         //super interfaces
3438         this.astPtr -= length;
3439         TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
3440         System.arraycopy(
3441                 this.astStack, 
3442                 this.astPtr + 1, 
3443                 typeDecl.superInterfaces = new TypeReference[length], 
3444                 0, 
3445                 length); 
3446         for (int i = 0, max = typeDecl.superInterfaces.length; i < max; i++) {
3447                 typeDecl.superInterfaces[i].bits |= ASTNode.IsSuperType;
3448         }
3449         typeDecl.bodyStart = typeDecl.superInterfaces[length-1].sourceEnd + 1;          
3450         this.listLength = 0; // reset after having read super-interfaces                
3451         // recovery
3452         if (this.currentElement != null) { 
3453                 this.lastCheckPoint = typeDecl.bodyStart;
3454         }
3455 }
3456 protected void consumeInterfaceHeaderName1() {
3457         // InterfaceHeaderName ::= Modifiersopt 'interface' 'Identifier'
3458         TypeDeclaration typeDecl = new TypeDeclaration(this.compilationUnit.compilationResult);
3459
3460         if (this.nestedMethod[this.nestedType] == 0) {
3461                 if (this.nestedType != 0) {
3462                         typeDecl.bits |= ASTNode.IsMemberTypeMASK;
3463                 }
3464         } else {
3465                 // Record that the block has a declaration for local types
3466                 typeDecl.bits |= ASTNode.IsLocalTypeMASK;
3467                 markEnclosingMemberWithLocalType();
3468                 blockReal();
3469         }
3470
3471         //highlight the name of the type
3472         long pos = this.identifierPositionStack[this.identifierPtr];
3473         typeDecl.sourceEnd = (int) pos;
3474         typeDecl.sourceStart = (int) (pos >>> 32);
3475         typeDecl.name = this.identifierStack[this.identifierPtr--];
3476         this.identifierLengthPtr--;
3477
3478         //compute the declaration source too
3479         // 'class' and 'interface' push two int positions: the beginning of the class token and its end.
3480         // we want to keep the beginning position but get rid of the end position
3481         // it is only used for the ClassLiteralAccess positions.
3482         typeDecl.declarationSourceStart = this.intStack[this.intPtr--];
3483         this.intPtr--; // remove the end position of the class token
3484         typeDecl.modifiersSourceStart = this.intStack[this.intPtr--];
3485         typeDecl.modifiers = this.intStack[this.intPtr--] | AccInterface;
3486         if (typeDecl.modifiersSourceStart >= 0) {
3487                 typeDecl.declarationSourceStart = typeDecl.modifiersSourceStart;
3488         }
3489         // consume annotations
3490         int length;
3491         if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3492                 System.arraycopy(
3493                         this.expressionStack, 
3494                         (this.expressionPtr -= length) + 1, 
3495                         typeDecl.annotations = new Annotation[length], 
3496                         0, 
3497                         length); 
3498         }
3499         typeDecl.bodyStart = typeDecl.sourceEnd + 1;
3500         pushOnAstStack(typeDecl);
3501         this.listLength = 0; // will be updated when reading super-interfaces
3502         // recovery
3503         if (this.currentElement != null){ // is recovering
3504                 this.lastCheckPoint = typeDecl.bodyStart;
3505                 this.currentElement = this.currentElement.add(typeDecl, 0);
3506                 this.lastIgnoredToken = -1;             
3507         }
3508         // javadoc
3509         typeDecl.javadoc = this.javadoc;
3510         this.javadoc = null;
3511 }
3512 protected void consumeInterfaceMemberDeclarations() {
3513         // InterfaceMemberDeclarations ::= InterfaceMemberDeclarations InterfaceMemberDeclaration
3514         concatNodeLists();
3515 }
3516 protected void consumeInterfaceMemberDeclarationsopt() {
3517         // InterfaceMemberDeclarationsopt ::= NestedType InterfaceMemberDeclarations
3518         this.nestedType--;
3519 }
3520 protected void consumeInterfaceType() {
3521         // InterfaceType ::= ClassOrInterfaceType
3522         pushOnAstStack(getTypeReference(0));
3523         /* if incomplete type header, this.listLength counter will not have been reset,
3524                 indicating that some interfaces are available on the stack */
3525         this.listLength++;      
3526 }
3527 protected void consumeInterfaceTypeList() {
3528         // InterfaceTypeList ::= InterfaceTypeList ',' InterfaceType
3529         optimizedConcatNodeLists();
3530 }
3531 protected void consumeInternalCompilationUnit() {
3532         // InternalCompilationUnit ::= PackageDeclaration
3533         // InternalCompilationUnit ::= PackageDeclaration ImportDeclarations ReduceImports
3534         // InternalCompilationUnit ::= ImportDeclarations ReduceImports
3535 }
3536 protected void consumeInternalCompilationUnitWithTypes() {
3537         // InternalCompilationUnit ::= PackageDeclaration ImportDeclarations ReduceImports TypeDeclarations
3538         // InternalCompilationUnit ::= PackageDeclaration TypeDeclarations
3539         // InternalCompilationUnit ::= TypeDeclarations
3540         // InternalCompilationUnit ::= ImportDeclarations ReduceImports TypeDeclarations
3541         // consume type declarations
3542         int length;
3543         if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
3544                 this.astPtr -= length;
3545                 System.arraycopy(this.astStack, this.astPtr + 1, this.compilationUnit.types = new TypeDeclaration[length], 0, length);
3546         }
3547 }
3548 protected void consumeInvalidConstructorDeclaration() {
3549         // ConstructorDeclaration ::= ConstructorHeader ';'
3550         // now we know that the top of stack is a constructorDeclaration
3551         ConstructorDeclaration cd = (ConstructorDeclaration) this.astStack[this.astPtr];
3552
3553         cd.bodyEnd = this.endPosition; // position just before the trailing semi-colon
3554         cd.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition); 
3555         // report the problem and continue the parsing - narrowing the problem onto the method
3556         
3557         cd.modifiers |= AccSemicolonBody; // remember semi-colon body
3558 }
3559 protected void consumeLeftParen() {
3560         // PushLPAREN ::= '('
3561         pushOnIntStack(this.lParenPos);
3562 }
3563 protected void consumeLocalVariableDeclaration() {
3564         // LocalVariableDeclaration ::= Modifiers Type VariableDeclarators ';'
3565
3566         /*
3567         this.astStack : 
3568         this.expressionStack: Expression Expression ...... Expression
3569         this.identifierStack : type  identifier identifier ...... identifier
3570         this.intStack : typeDim      dim        dim               dim
3571          ==>
3572         this.astStack : FieldDeclaration FieldDeclaration ...... FieldDeclaration
3573         this.expressionStack :
3574         this.identifierStack : 
3575         this.intStack : 
3576           
3577         */
3578         int variableDeclaratorsCounter = this.astLengthStack[this.astLengthPtr];
3579
3580         // update the this.astStack, this.astPtr and this.astLengthStack
3581         int startIndex = this.astPtr - this.variablesCounter[this.nestedType] + 1;
3582         System.arraycopy(
3583                 this.astStack, 
3584                 startIndex, 
3585                 this.astStack, 
3586                 startIndex - 1, 
3587                 variableDeclaratorsCounter); 
3588         this.astPtr--; // remove the type reference
3589         this.astLengthStack[--this.astLengthPtr] = variableDeclaratorsCounter;
3590         this.variablesCounter[this.nestedType] = 0;
3591 }
3592 protected void consumeLocalVariableDeclarationStatement() {
3593         // LocalVariableDeclarationStatement ::= LocalVariableDeclaration ';'
3594         // see blockReal in case of change: duplicated code
3595         // increment the amount of declared variables for this block
3596         this.realBlockStack[this.realBlockPtr]++;
3597         
3598         // update source end to include the semi-colon
3599         int variableDeclaratorsCounter = this.astLengthStack[this.astLengthPtr];
3600         for (int i = variableDeclaratorsCounter - 1; i >= 0; i--) {
3601                 LocalDeclaration localDeclaration = (LocalDeclaration) this.astStack[this.astPtr - i];
3602                 localDeclaration.declarationSourceEnd = this.endStatementPosition; 
3603                 localDeclaration.declarationEnd = this.endStatementPosition;    // semi-colon included
3604         }
3605
3606 }
3607 protected void consumeMarkerAnnotation() {
3608         // MarkerAnnotation ::= '@' Name
3609         MarkerAnnotation markerAnnotation = null;
3610         int length = this.identifierLengthStack[this.identifierLengthPtr--];
3611         TypeReference typeReference;
3612         if (length == 1) {
3613                 typeReference = new SingleTypeReference(
3614                                 this.identifierStack[this.identifierPtr], 
3615                                 this.identifierPositionStack[this.identifierPtr--]);
3616         } else {
3617                 char[][] tokens = new char[length][];
3618                 this.identifierPtr -= length;
3619                 long[] positions = new long[length];
3620                 System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
3621                 System.arraycopy(
3622                         this.identifierPositionStack, 
3623                         this.identifierPtr + 1, 
3624                         positions, 
3625                         0, 
3626                         length);
3627                 typeReference = new QualifiedTypeReference(tokens, positions);
3628         }
3629         markerAnnotation = new MarkerAnnotation(typeReference, this.intStack[this.intPtr--]);
3630         int sourceStart = markerAnnotation.sourceStart;
3631         if (this.modifiersSourceStart < 0) {
3632                 this.modifiersSourceStart = sourceStart;
3633         } else if (this.modifiersSourceStart > sourceStart) {
3634                 this.modifiersSourceStart = sourceStart;
3635         }
3636         markerAnnotation.declarationSourceEnd = markerAnnotation.sourceEnd;
3637         pushOnExpressionStack(markerAnnotation);
3638         if(options.sourceLevel < ClassFileConstants.JDK1_5 &&
3639                         this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
3640                 this.problemReporter().invalidUsageOfAnnotation(markerAnnotation);
3641         }
3642 }
3643 protected void consumeMemberValueArrayInitializer() {
3644         // MemberValueArrayInitializer ::= '{' MemberValues ',' '}'
3645         // MemberValueArrayInitializer ::= '{' MemberValues '}'
3646         arrayInitializer(this.expressionLengthStack[this.expressionLengthPtr--]);
3647 }
3648 protected void consumeMemberValueAsName() {
3649         pushOnExpressionStack(getUnspecifiedReferenceOptimized());      
3650 }
3651 protected void consumeMemberValuePair() {
3652         // MemberValuePair ::= SimpleName '=' MemberValue
3653         char[] simpleName = this.identifierStack[this.identifierPtr];
3654         long position = this.identifierPositionStack[this.identifierPtr--];
3655         this.identifierLengthPtr--;
3656         int end = (int) position;
3657         int start = (int) (position >>> 32);
3658         Expression value = this.expressionStack[this.expressionPtr--];
3659         this.expressionLengthPtr--;
3660         MemberValuePair memberValuePair = new MemberValuePair(simpleName, start, end, value);
3661         pushOnAstStack(memberValuePair);
3662 }
3663 protected void consumeMemberValuePairs() {
3664         // MemberValuePairs ::= MemberValuePairs ',' MemberValuePair
3665         concatNodeLists();
3666 }
3667 protected void consumeMemberValues() {
3668         // MemberValues ::= MemberValues ',' MemberValue
3669         concatExpressionLists();
3670 }
3671 protected void consumeMethodBody() {
3672         // MethodBody ::= NestedMethod '{' BlockStatementsopt '}' 
3673         this.nestedMethod[this.nestedType] --;
3674 }
3675 protected void consumeMethodDeclaration(boolean isNotAbstract) {
3676         // MethodDeclaration ::= MethodHeader MethodBody
3677         // AbstractMethodDeclaration ::= MethodHeader ';'
3678
3679         /*
3680         this.astStack : modifiers arguments throws statements
3681         this.identifierStack : type name
3682         this.intStack : dim dim dim
3683          ==>
3684         this.astStack : MethodDeclaration
3685         this.identifierStack :
3686         this.intStack : 
3687         */
3688
3689         int length;
3690         if (isNotAbstract) {
3691                 // pop the position of the {  (body of the method) pushed in block decl
3692                 this.intPtr--;
3693                 this.intPtr--;
3694         }
3695
3696         int explicitDeclarations = 0;
3697         Statement[] statements = null;
3698         if (isNotAbstract) {
3699                 //statements
3700                 explicitDeclarations = this.realBlockStack[this.realBlockPtr--];
3701                 if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
3702                         System.arraycopy(
3703                                 this.astStack, 
3704                                 (this.astPtr -= length) + 1, 
3705                                 statements = new Statement[length], 
3706                                 0, 
3707                                 length); 
3708                 }
3709         }
3710
3711         // now we know that we have a method declaration at the top of the ast stack
3712         MethodDeclaration md = (MethodDeclaration) this.astStack[this.astPtr];
3713         md.statements = statements;
3714         md.explicitDeclarations = explicitDeclarations;
3715
3716         // cannot be done in consumeMethodHeader because we have no idea whether or not there
3717         // is a body when we reduce the method header
3718         if (!isNotAbstract) { //remember the fact that the method has a semicolon body
3719                 md.modifiers |= AccSemicolonBody;
3720         } else {
3721                 if (!this.diet && statements == null) {
3722                         if (!containsComment(md.bodyStart, this.endPosition)) {
3723                                 md.bits |= ASTNode.UndocumentedEmptyBlockMASK;
3724                         }
3725                 }
3726         }
3727         // store the this.endPosition (position just before the '}') in case there is
3728         // a trailing comment behind the end of the method
3729         md.bodyEnd = this.endPosition;
3730         md.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
3731 }
3732 protected void consumeMethodHeader() {
3733         // MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims ThrowsClauseopt
3734         // AnnotationMethodHeader ::= AnnotationMethodHeaderName FormalParameterListopt MethodHeaderRightParen MethodHeaderExtendedDims AnnotationMethodHeaderDefaultValueopt
3735         // RecoveryMethodHeader ::= RecoveryMethodHeaderName FormalParameterListopt MethodHeaderRightParen MethodHeaderExtendedDims AnnotationMethodHeaderDefaultValueopt
3736         // RecoveryMethodHeader ::= RecoveryMethodHeaderName FormalParameterListopt MethodHeaderRightParen MethodHeaderExtendedDims MethodHeaderThrowsClause
3737         
3738         // retrieve end position of method declarator
3739         AbstractMethodDeclaration method = (AbstractMethodDeclaration)this.astStack[this.astPtr];
3740
3741         if (this.currentToken == TokenNameLBRACE){ 
3742                 method.bodyStart = this.scanner.currentPosition;
3743         }
3744         // recovery
3745         if (this.currentElement != null){
3746 //              if(method.isAnnotationMethod()) {
3747 //                      method.modifiers |= AccSemicolonBody;
3748 //                      method.declarationSourceEnd = this.scanner.currentPosition-1;
3749 //                      method.bodyEnd = this.scanner.currentPosition-1;
3750 //                      this.currentElement = this.currentElement.parent;
3751 //              } else 
3752                 if (this.currentToken == TokenNameSEMICOLON /*&& !method.isAnnotationMethod()*/){
3753                         method.modifiers |= AccSemicolonBody;                   
3754                         method.declarationSourceEnd = this.scanner.currentPosition-1;
3755                         method.bodyEnd = this.scanner.currentPosition-1;
3756                         if (this.currentElement.parseTree() == method && this.currentElement.parent != null) {
3757                                 this.currentElement = this.currentElement.parent;
3758                         }
3759                 }               
3760                 this.restartRecovery = true; // used to avoid branching back into the regular automaton
3761         }               
3762 }
3763 protected void consumeMethodHeaderDefaultValue() {
3764         // MethodHeaderDefaultValue ::= DefaultValue
3765         MethodDeclaration md = (MethodDeclaration) this.astStack[this.astPtr];
3766
3767         
3768         int length = this.expressionLengthStack[this.expressionLengthPtr--];
3769         if (length == 1) {
3770                 intPtr--; // we get rid of the position of the default keyword
3771                 intPtr--; // we get rid of the position of the default keyword
3772                 if(md.isAnnotationMethod()) {
3773                         ((AnnotationMethodDeclaration)md).defaultValue = this.expressionStack[this.expressionPtr];
3774                         md.modifiers |=  AccAnnotationDefault;
3775                 }
3776                 this.expressionPtr--;
3777         }
3778
3779         if(this.currentElement != null) {
3780                 if(md.isAnnotationMethod()) {
3781                         this.currentElement.updateSourceEndIfNecessary(((AnnotationMethodDeclaration)md).defaultValue.sourceEnd);
3782                 }
3783         }
3784 }
3785 protected void consumeMethodHeaderExtendedDims() {
3786         // MethodHeaderExtendedDims ::= Dimsopt
3787         // now we update the returnType of the method
3788         MethodDeclaration md = (MethodDeclaration) this.astStack[this.astPtr];
3789         int extendedDims = this.intStack[this.intPtr--];
3790         if(md.isAnnotationMethod()) {
3791                 ((AnnotationMethodDeclaration)md).extendedDimensions = extendedDims;
3792         }
3793         if (extendedDims != 0) {
3794                 TypeReference returnType = md.returnType;
3795                 md.sourceEnd = this.endPosition;
3796                 int dims = returnType.dimensions() + extendedDims;
3797                 int baseType;
3798                 if ((baseType = this.identifierLengthStack[this.identifierLengthPtr + 1]) < 0) {
3799                         //it was a baseType
3800                         int sourceStart = returnType.sourceStart;
3801                         int sourceEnd =  returnType.sourceEnd;
3802                         returnType = TypeReference.baseTypeReference(-baseType, dims);
3803                         returnType.sourceStart = sourceStart;
3804                         returnType.sourceEnd = sourceEnd;
3805                         md.returnType = returnType;
3806                 } else {
3807                         md.returnType = this.copyDims(md.returnType, dims);
3808                 }
3809                 if (this.currentToken == TokenNameLBRACE){ 
3810                         md.bodyStart = this.endPosition + 1;
3811                 }
3812                 // recovery
3813                 if (this.currentElement != null){
3814                         this.lastCheckPoint = md.bodyStart;
3815                 }               
3816         }
3817 }
3818 protected void consumeMethodHeaderName(boolean isAnnotationMethod) {
3819         // MethodHeaderName ::= Modifiersopt Type 'Identifier' '('
3820         // AnnotationMethodHeaderName ::= Modifiersopt Type 'Identifier' '('
3821         // RecoveryMethodHeaderName ::= Modifiersopt Type 'Identifier' '('
3822         MethodDeclaration md = null;
3823         if(isAnnotationMethod) {
3824                 md = new AnnotationMethodDeclaration(this.compilationUnit.compilationResult);
3825         } else {
3826                 md = new MethodDeclaration(this.compilationUnit.compilationResult);
3827         }
3828
3829         //name
3830         md.selector = this.identifierStack[this.identifierPtr];
3831         long selectorSource = this.identifierPositionStack[this.identifierPtr--];
3832         this.identifierLengthPtr--;
3833         //type
3834         md.returnType = getTypeReference(this.intStack[this.intPtr--]);
3835         //modifiers
3836         md.declarationSourceStart = this.intStack[this.intPtr--];
3837         md.modifiers = this.intStack[this.intPtr--];
3838         // consume annotations
3839         int length;
3840         if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3841                 System.arraycopy(
3842                         this.expressionStack, 
3843                         (this.expressionPtr -= length) + 1, 
3844                         md.annotations = new Annotation[length], 
3845                         0, 
3846                         length); 
3847         }
3848         // javadoc
3849         md.javadoc = this.javadoc;
3850         this.javadoc = null;
3851
3852         //highlight starts at selector start
3853         md.sourceStart = (int) (selectorSource >>> 32);
3854         pushOnAstStack(md);
3855         md.sourceEnd = this.lParenPos;
3856         md.bodyStart = this.lParenPos+1;
3857         this.listLength = 0; // initialize this.listLength before reading parameters/throws
3858         
3859         // recovery
3860         if (this.currentElement != null){
3861                 if (this.currentElement instanceof RecoveredType 
3862                         //|| md.modifiers != 0
3863                         || (this.scanner.getLineNumber(md.returnType.sourceStart)
3864                                         == this.scanner.getLineNumber(md.sourceStart))){
3865                         this.lastCheckPoint = md.bodyStart;
3866                         this.currentElement = this.currentElement.add(md, 0);
3867                         this.lastIgnoredToken = -1;
3868                 } else {
3869                         this.lastCheckPoint = md.sourceStart;
3870                         this.restartRecovery = true;
3871                 }
3872         }               
3873 }
3874 protected void consumeMethodHeaderNameWithTypeParameters(boolean isAnnotationMethod) {
3875         // MethodHeaderName ::= Modifiersopt TypeParameters Type 'Identifier' '('
3876         // AnnotationMethodHeaderName ::= Modifiersopt TypeParameters Type 'Identifier' '('
3877         // RecoveryMethodHeaderName ::= Modifiersopt TypeParameters Type 'Identifier' '('
3878         MethodDeclaration md = null;
3879         if(isAnnotationMethod) {
3880                 md = new AnnotationMethodDeclaration(this.compilationUnit.compilationResult);
3881         } else {
3882                 md = new MethodDeclaration(this.compilationUnit.compilationResult);
3883         }
3884
3885         //name
3886         md.selector = this.identifierStack[this.identifierPtr];
3887         long selectorSource = this.identifierPositionStack[this.identifierPtr--];
3888         this.identifierLengthPtr--;
3889         //type
3890         md.returnType = getTypeReference(this.intStack[this.intPtr--]);
3891         
3892         // consume type parameters
3893         int length = this.genericsLengthStack[this.genericsLengthPtr--];
3894         this.genericsPtr -= length;
3895         System.arraycopy(this.genericsStack, this.genericsPtr + 1, md.typeParameters = new TypeParameter[length], 0, length);
3896         
3897         //modifiers
3898         md.declarationSourceStart = this.intStack[this.intPtr--];
3899         md.modifiers = this.intStack[this.intPtr--];
3900         // consume annotations
3901         if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
3902                 System.arraycopy(
3903                         this.expressionStack, 
3904                         (this.expressionPtr -= length) + 1, 
3905                         md.annotations = new Annotation[length], 
3906                         0, 
3907                         length); 
3908         }       
3909         // javadoc
3910         md.javadoc = this.javadoc;
3911         this.javadoc = null;
3912
3913         //highlight starts at selector start
3914         md.sourceStart = (int) (selectorSource >>> 32);
3915         pushOnAstStack(md);
3916         md.sourceEnd = this.lParenPos;
3917         md.bodyStart = this.lParenPos+1;
3918         this.listLength = 0; // initialize this.listLength before reading parameters/throws
3919         
3920         // recovery
3921         if (this.currentElement != null){
3922                 if (this.currentElement instanceof RecoveredType 
3923                         //|| md.modifiers != 0
3924                         || (this.scanner.getLineNumber(md.returnType.sourceStart)
3925                                         == this.scanner.getLineNumber(md.sourceStart))){
3926                         this.lastCheckPoint = md.bodyStart;
3927                         this.currentElement = this.currentElement.add(md, 0);
3928                         this.lastIgnoredToken = -1;
3929                 } else {
3930                         this.lastCheckPoint = md.sourceStart;
3931                         this.restartRecovery = true;
3932                 }
3933         }               
3934 }
3935 protected void consumeMethodHeaderRightParen() {
3936         // MethodHeaderParameters ::= FormalParameterListopt ')'
3937         int length = this.astLengthStack[this.astLengthPtr--];
3938         this.astPtr -= length;
3939         AbstractMethodDeclaration md = (AbstractMethodDeclaration) this.astStack[this.astPtr];
3940         md.sourceEnd =  this.rParenPos;
3941         //arguments
3942         if (length != 0) {
3943                 System.arraycopy(
3944                         this.astStack, 
3945                         this.astPtr + 1, 
3946                         md.arguments = new Argument[length], 
3947                         0, 
3948                         length); 
3949         }
3950         md.bodyStart = this.rParenPos+1;
3951         this.listLength = 0; // reset this.listLength after having read all parameters
3952         // recovery
3953         if (this.currentElement != null){
3954                 this.lastCheckPoint = md.bodyStart;
3955                 if (this.currentElement.parseTree() == md) return;
3956
3957                 // might not have been attached yet - in some constructor scenarii
3958                 if (md.isConstructor()){
3959                         if ((length != 0)
3960                                 || (this.currentToken == TokenNameLBRACE) 
3961                                 || (this.currentToken == TokenNamethrows)){
3962                                 this.currentElement = this.currentElement.add(md, 0);
3963                                 this.lastIgnoredToken = -1;
3964                         }       
3965                 }       
3966         }       
3967 }
3968 protected void consumeMethodHeaderThrowsClause() {
3969         // MethodHeaderThrowsClause ::= 'throws' ClassTypeList
3970         int length = this.astLengthStack[this.astLengthPtr--];
3971         this.astPtr -= length;
3972         AbstractMethodDeclaration md = (AbstractMethodDeclaration) this.astStack[this.astPtr];
3973         System.arraycopy(
3974                 this.astStack, 
3975                 this.astPtr + 1, 
3976                 md.thrownExceptions = new TypeReference[length], 
3977                 0, 
3978                 length);
3979         md.sourceEnd = md.thrownExceptions[length-1].sourceEnd;
3980         md.bodyStart = md.thrownExceptions[length-1].sourceEnd + 1;
3981         this.listLength = 0; // reset this.listLength after having read all thrown exceptions   
3982         // recovery
3983         if (this.currentElement != null){
3984                 this.lastCheckPoint = md.bodyStart;
3985         }
3986 }
3987 protected void consumeMethodInvocationName() {
3988         // MethodInvocation ::= Name '(' ArgumentListopt ')'
3989
3990         // when the name is only an identifier...we have a message send to "this" (implicit)
3991
3992         MessageSend m = newMessageSend();
3993         m.sourceEnd = this.rParenPos;
3994         m.sourceStart = 
3995                 (int) ((m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr]) >>> 32); 
3996         m.selector = this.identifierStack[this.identifierPtr--];
3997         if (this.identifierLengthStack[this.identifierLengthPtr] == 1) {
3998                 m.receiver = ThisReference.implicitThis();
3999                 this.identifierLengthPtr--;
4000         } else {
4001                 this.identifierLengthStack[this.identifierLengthPtr]--;
4002                 m.receiver = getUnspecifiedReference();
4003                 m.sourceStart = m.receiver.sourceStart;         
4004         }
4005         pushOnExpressionStack(m);
4006 }
4007 protected void consumeMethodInvocationNameWithTypeArguments() {
4008         // MethodInvocation ::= Name '.' TypeArguments 'Identifier' '(' ArgumentListopt ')'
4009
4010         // when the name is only an identifier...we have a message send to "this" (implicit)
4011
4012         MessageSend m = newMessageSendWithTypeArguments();
4013         m.sourceEnd = this.rParenPos;
4014         m.sourceStart = 
4015                 (int) ((m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr]) >>> 32); 
4016         m.selector = this.identifierStack[this.identifierPtr--];
4017         this.identifierLengthPtr--;
4018
4019         // handle type arguments
4020         int length = this.genericsLengthStack[this.genericsLengthPtr--];
4021         this.genericsPtr -= length;
4022         System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
4023         intPtr--;
4024         
4025         m.receiver = getUnspecifiedReference();
4026         m.sourceStart = m.receiver.sourceStart;         
4027         pushOnExpressionStack(m);
4028 }
4029 protected void consumeMethodInvocationPrimary() {
4030         //optimize the push/pop
4031         //MethodInvocation ::= Primary '.' 'Identifier' '(' ArgumentListopt ')'
4032
4033         MessageSend m = newMessageSend();
4034         m.sourceStart = 
4035                 (int) ((m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr]) >>> 32); 
4036         m.selector = this.identifierStack[this.identifierPtr--];
4037         this.identifierLengthPtr--;
4038         m.receiver = this.expressionStack[this.expressionPtr];
4039         m.sourceStart = m.receiver.sourceStart;
4040         m.sourceEnd = this.rParenPos;
4041         this.expressionStack[this.expressionPtr] = m;
4042 }
4043 protected void consumeMethodInvocationPrimaryWithTypeArguments() {
4044         //optimize the push/pop
4045         //MethodInvocation ::= Primary '.' TypeArguments 'Identifier' '(' ArgumentListopt ')'
4046
4047         MessageSend m = newMessageSendWithTypeArguments();
4048         m.sourceStart = 
4049                 (int) ((m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr]) >>> 32); 
4050         m.selector = this.identifierStack[this.identifierPtr--];
4051         this.identifierLengthPtr--;
4052         
4053         // handle type arguments
4054         int length = this.genericsLengthStack[this.genericsLengthPtr--];
4055         this.genericsPtr -= length;
4056         System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
4057         intPtr--;
4058
4059         m.receiver = this.expressionStack[this.expressionPtr];
4060         m.sourceStart = m.receiver.sourceStart;
4061         m.sourceEnd = this.rParenPos;
4062         this.expressionStack[this.expressionPtr] = m;
4063 }
4064 protected void consumeMethodInvocationSuper() {
4065         // MethodInvocation ::= 'super' '.' 'Identifier' '(' ArgumentListopt ')'
4066
4067         MessageSend m = newMessageSend();
4068         m.sourceStart = this.intStack[this.intPtr--];
4069         m.sourceEnd = this.rParenPos;
4070         m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr];
4071         m.selector = this.identifierStack[this.identifierPtr--];
4072         this.identifierLengthPtr--;
4073         m.receiver = new SuperReference(m.sourceStart, this.endPosition);
4074         pushOnExpressionStack(m);
4075 }
4076 protected void consumeMethodInvocationSuperWithTypeArguments() {
4077         // MethodInvocation ::= 'super' '.' TypeArguments 'Identifier' '(' ArgumentListopt ')'
4078
4079         MessageSend m = newMessageSendWithTypeArguments();
4080         m.sourceStart = this.intStack[this.intPtr--];
4081         m.sourceEnd = this.rParenPos;
4082         m.nameSourcePosition = this.identifierPositionStack[this.identifierPtr];
4083         m.selector = this.identifierStack[this.identifierPtr--];
4084         this.identifierLengthPtr--;
4085         
4086         // handle type arguments
4087         int length = this.genericsLengthStack[this.genericsLengthPtr--];
4088         this.genericsPtr -= length;
4089         System.arraycopy(this.genericsStack, this.genericsPtr + 1, m.typeArguments = new TypeReference[length], 0, length);
4090         intPtr--;
4091
4092         m.receiver = new SuperReference(m.sourceStart, this.endPosition);
4093         pushOnExpressionStack(m);
4094 }
4095 protected void consumeModifiers() {
4096         int savedModifiersSourceStart = this.modifiersSourceStart;      
4097         checkComment(); // might update modifiers with AccDeprecated
4098         pushOnIntStack(this.modifiers); // modifiers
4099         if (this.modifiersSourceStart >= savedModifiersSourceStart) {
4100                 this.modifiersSourceStart = savedModifiersSourceStart;
4101         }
4102         pushOnIntStack(this.modifiersSourceStart);
4103         resetModifiers();
4104 }
4105 protected void consumeModifiers2() {
4106         this.expressionLengthStack[this.expressionLengthPtr - 1] += this.expressionLengthStack[this.expressionLengthPtr--];
4107 }
4108 protected void consumeNameArrayType() {
4109         pushOnGenericsLengthStack(0); // handle type arguments
4110         pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
4111 }
4112 protected void consumeNestedMethod() {
4113         // NestedMethod ::= $empty
4114         jumpOverMethodBody();
4115         this.nestedMethod[this.nestedType] ++;
4116         pushOnIntStack(this.scanner.currentPosition);
4117         consumeOpenBlock();
4118 }
4119 protected void consumeNestedType() {
4120         // NestedType ::= $empty
4121         int length = this.nestedMethod.length;
4122         if (++this.nestedType >= length) {
4123                 System.arraycopy(
4124                         this.nestedMethod, 0,
4125                         this.nestedMethod = new int[length + 30], 0,
4126                         length);
4127                 // increase the size of the variablesCounter as well. It has to be consistent with the size of the nestedMethod collection
4128                 System.arraycopy(
4129                         this.variablesCounter, 0,
4130                         this.variablesCounter = new int[length + 30], 0,
4131                         length);
4132         }
4133         this.nestedMethod[this.nestedType] = 0;
4134         this.variablesCounter[this.nestedType] = 0;
4135 }
4136 protected void consumeNormalAnnotation() {
4137         // NormalAnnotation ::= '@' Name '(' MemberValuePairsopt ')'
4138         NormalAnnotation normalAnnotation = null;
4139         int length = this.identifierLengthStack[this.identifierLengthPtr--];
4140         TypeReference typeReference;
4141         if (length == 1) {
4142                 typeReference = new SingleTypeReference(
4143                                 this.identifierStack[this.identifierPtr], 
4144                                 this.identifierPositionStack[this.identifierPtr--]);
4145         } else {
4146                 char[][] tokens = new char[length][];
4147                 this.identifierPtr -= length;
4148                 long[] positions = new long[length];
4149                 System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
4150                 System.arraycopy(
4151                         this.identifierPositionStack, 
4152                         this.identifierPtr + 1, 
4153                         positions, 
4154                         0, 
4155                         length);
4156                 typeReference = new QualifiedTypeReference(tokens, positions);
4157         }
4158         normalAnnotation = new NormalAnnotation(typeReference, this.intStack[this.intPtr--]);
4159         if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
4160                 System.arraycopy(
4161                         this.astStack, 
4162                         (this.astPtr -= length) + 1, 
4163                         normalAnnotation.memberValuePairs = new MemberValuePair[length], 
4164                         0, 
4165                         length); 
4166         }
4167         int sourceStart = normalAnnotation.sourceStart;
4168         if (this.modifiersSourceStart < 0) {
4169                 this.modifiersSourceStart = sourceStart;
4170         } else if (this.modifiersSourceStart > sourceStart) {
4171                 this.modifiersSourceStart = sourceStart;
4172         }
4173         normalAnnotation.declarationSourceEnd = this.rParenPos;
4174         pushOnExpressionStack(normalAnnotation);
4175         if(options.sourceLevel < ClassFileConstants.JDK1_5 &&
4176                         this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
4177                 this.problemReporter().invalidUsageOfAnnotation(normalAnnotation);
4178         }
4179 }
4180 protected void consumeOneDimLoop() {
4181         // OneDimLoop ::= '[' ']'
4182         this.dimensions++;
4183 }
4184 protected void consumeOnlySynchronized() {
4185         // OnlySynchronized ::= 'synchronized'
4186         pushOnIntStack(this.synchronizedBlockSourceStart);
4187         resetModifiers();
4188         this.expressionLengthPtr--;
4189 }
4190 protected void consumeOnlyTypeArguments() {
4191         if(options.sourceLevel < ClassFileConstants.JDK1_5 &&
4192                         this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
4193                 int length = this.genericsLengthStack[this.genericsLengthPtr];
4194                 this.problemReporter().invalidUsageOfTypeArguments(
4195                         (TypeReference)this.genericsStack[this.genericsPtr - length + 1],
4196                         (TypeReference)this.genericsStack[this.genericsPtr]);
4197         }
4198 }
4199 protected void consumeOnlyTypeArgumentsForCastExpression() {
4200         // OnlyTypeArgumentsForCastExpression ::= OnlyTypeArguments
4201 }
4202 protected void consumeOpenBlock() {
4203         // OpenBlock ::= $empty
4204
4205         pushOnIntStack(this.scanner.startPosition);
4206         int stackLength = this.realBlockStack.length;
4207         if (++this.realBlockPtr >= stackLength) {
4208                 System.arraycopy(
4209                         this.realBlockStack, 0,
4210                         this.realBlockStack = new int[stackLength + StackIncrement], 0,
4211                         stackLength);
4212         }
4213         this.realBlockStack[this.realBlockPtr] = 0;
4214 }
4215 protected void consumePackageDeclaration() {
4216         // PackageDeclaration ::= 'package' Name ';'
4217         /* build an ImportRef build from the last name 
4218         stored in the identifier stack. */
4219
4220         ImportReference impt = this.compilationUnit.currentPackage;
4221         // flush comments defined prior to import statements
4222         impt.declarationEnd = this.endStatementPosition;
4223         impt.declarationSourceEnd = this.flushCommentsDefinedPriorTo(impt.declarationSourceEnd);
4224 }
4225 protected void consumePackageDeclarationName() {
4226         // PackageDeclarationName ::= 'package' Name
4227         /* build an ImportRef build from the last name 
4228         stored in the identifier stack. */
4229
4230         ImportReference impt;
4231         int length;
4232         char[][] tokens = 
4233                 new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][]; 
4234         this.identifierPtr -= length;
4235         long[] positions = new long[length];
4236         System.arraycopy(this.identifierStack, ++this.identifierPtr, tokens, 0, length);
4237         System.arraycopy(
4238                 this.identifierPositionStack, 
4239                 this.identifierPtr--, 
4240                 positions, 
4241                 0, 
4242                 length);
4243         
4244         impt = new ImportReference(tokens, positions, true, AccDefault);
4245         this.compilationUnit.currentPackage = impt; 
4246
4247         if (this.currentToken == TokenNameSEMICOLON){
4248                 impt.declarationSourceEnd = this.scanner.currentPosition - 1;
4249         } else {
4250                 impt.declarationSourceEnd = impt.sourceEnd;
4251         }
4252         impt.declarationEnd = impt.declarationSourceEnd;
4253         //this.endPosition is just before the ;
4254         impt.declarationSourceStart = this.intStack[this.intPtr--];
4255
4256         // recovery
4257         if (this.currentElement != null){
4258                 this.lastCheckPoint = impt.declarationSourceEnd+1;
4259                 this.restartRecovery = true; // used to avoid branching back into the regular automaton         
4260         }       
4261 }
4262 protected void consumePackageDeclarationNameWithModifiers() {
4263         // PackageDeclarationName ::= Modifiers 'package' Name
4264         /* build an ImportRef build from the last name 
4265         stored in the identifier stack. */
4266
4267         ImportReference impt;
4268         int length;
4269         char[][] tokens = 
4270                 new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][]; 
4271         this.identifierPtr -= length;
4272         long[] positions = new long[length];
4273         System.arraycopy(this.identifierStack, ++this.identifierPtr, tokens, 0, length);
4274         System.arraycopy(
4275                 this.identifierPositionStack, 
4276                 this.identifierPtr--, 
4277                 positions, 
4278                 0, 
4279                 length);
4280         
4281         int packageModifiersSourceStart = this.intStack[this.intPtr--]; // we don't need the modifiers start
4282         int packageModifiers = this.intStack[this.intPtr--];
4283
4284         impt = new ImportReference(tokens, positions, true, packageModifiers);
4285         this.compilationUnit.currentPackage = impt; 
4286         // consume annotations
4287         if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
4288                 System.arraycopy(
4289                         this.expressionStack, 
4290                         (this.expressionPtr -= length) + 1, 
4291                         impt.annotations = new Annotation[length], 
4292                         0, 
4293                         length);
4294                 impt.declarationSourceStart = packageModifiersSourceStart;
4295                 intPtr--; // we don't need the position of the 'package keyword
4296         } else {
4297                 impt.declarationSourceStart = this.intStack[this.intPtr--];
4298         }
4299                 
4300         if (this.currentToken == TokenNameSEMICOLON){
4301                 impt.declarationSourceEnd = this.scanner.currentPosition - 1;
4302         } else {
4303                 impt.declarationSourceEnd = impt.sourceEnd;
4304         }
4305         impt.declarationEnd = impt.declarationSourceEnd;
4306
4307         // recovery
4308         if (this.currentElement != null){
4309                 this.lastCheckPoint = impt.declarationSourceEnd+1;
4310                 this.restartRecovery = true; // used to avoid branching back into the regular automaton         
4311         }       
4312 }
4313 protected void consumePostfixExpression() {
4314         // PostfixExpression ::= Name
4315         pushOnExpressionStack(getUnspecifiedReferenceOptimized());
4316 }
4317 protected void consumePrimaryNoNewArray() {
4318         // PrimaryNoNewArray ::=  PushLPAREN Expression PushRPAREN 
4319         final Expression parenthesizedExpression = this.expressionStack[this.expressionPtr];
4320         updateSourcePosition(parenthesizedExpression);
4321         int numberOfParenthesis = (parenthesizedExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
4322         parenthesizedExpression.bits &= ~ASTNode.ParenthesizedMASK;
4323         parenthesizedExpression.bits |= (numberOfParenthesis + 1) << ASTNode.ParenthesizedSHIFT;
4324 }
4325 protected void consumePrimaryNoNewArrayArrayType() {
4326         // PrimaryNoNewArray ::= Name Dims '.' 'class'
4327         this.intPtr--; // remove the class start position
4328
4329         pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
4330         pushOnGenericsLengthStack(0);
4331
4332         pushOnExpressionStack(
4333                 new ClassLiteralAccess(this.intStack[this.intPtr--], getTypeReference(this.intStack[this.intPtr--])));
4334 }
4335 protected void consumePrimaryNoNewArrayName() {
4336         // PrimaryNoNewArray ::= Name '.' 'class'
4337         this.intPtr--; // remove the class start position
4338
4339         // handle type arguments
4340         pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
4341         pushOnGenericsLengthStack(0);
4342         TypeReference typeReference = getTypeReference(0);
4343         
4344         pushOnExpressionStack(
4345                 new ClassLiteralAccess(this.intStack[this.intPtr--], typeReference));
4346 }
4347 protected void consumePrimaryNoNewArrayNameSuper() {
4348         // PrimaryNoNewArray ::= Name '.' 'super'
4349         // handle type arguments
4350         pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
4351         pushOnGenericsLengthStack(0);
4352         TypeReference typeReference = getTypeReference(0);
4353
4354         pushOnExpressionStack(
4355                 new QualifiedSuperReference(
4356                         typeReference,
4357                         this.intStack[this.intPtr--],
4358                         this.endPosition));
4359 }
4360 protected void consumePrimaryNoNewArrayNameThis() {
4361         // PrimaryNoNewArray ::= Name '.' 'this'
4362         // handle type arguments
4363         pushOnGenericsIdentifiersLengthStack(this.identifierLengthStack[this.identifierLengthPtr]);
4364         pushOnGenericsLengthStack(0); // handle type arguments
4365
4366         TypeReference typeReference = getTypeReference(0);
4367         
4368         pushOnExpressionStack(
4369                 new QualifiedThisReference(
4370                         typeReference,
4371                         this.intStack[this.intPtr--],
4372                         this.endPosition));
4373 }
4374 protected void consumePrimaryNoNewArrayPrimitiveArrayType() {
4375         // PrimaryNoNewArray ::= PrimitiveType Dims '.' 'class'
4376         this.intPtr--; // remove the class start position
4377         pushOnExpressionStack(
4378                 new ClassLiteralAccess(this.intStack[this.intPtr--], getTypeReference(this.intStack[this.intPtr--])));
4379 }
4380 protected void consumePrimaryNoNewArrayPrimitiveType() {
4381         // PrimaryNoNewArray ::= PrimitiveType '.' 'class'
4382         this.intPtr--; // remove the class start position
4383         pushOnExpressionStack(
4384                 new ClassLiteralAccess(this.intStack[this.intPtr--], getTypeReference(0)));
4385 }
4386 protected void consumePrimaryNoNewArrayThis() {
4387         // PrimaryNoNewArray ::= 'this'
4388         pushOnExpressionStack(new ThisReference(this.intStack[this.intPtr--], this.endPosition));
4389 }
4390 protected void consumePrimaryNoNewArrayWithName() {
4391         // PrimaryNoNewArray ::=  PushLPAREN Expression PushRPAREN 
4392         pushOnExpressionStack(getUnspecifiedReferenceOptimized());
4393         final Expression parenthesizedExpression = this.expressionStack[this.expressionPtr];
4394         updateSourcePosition(parenthesizedExpression);
4395         int numberOfParenthesis = (parenthesizedExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT;
4396         parenthesizedExpression.bits &= ~ASTNode.ParenthesizedMASK;
4397         parenthesizedExpression.bits |= (numberOfParenthesis + 1) << ASTNode.ParenthesizedSHIFT;
4398 }
4399 protected void consumePrimitiveArrayType() {
4400         // nothing to do
4401         // Will be consume by a getTypeRefence call
4402 }
4403 protected void consumePrimitiveType() {
4404         // Type ::= PrimitiveType
4405         pushOnIntStack(0);
4406 }
4407 protected void consumePushLeftBrace() {
4408         pushOnIntStack(this.endPosition); // modifiers
4409 }
4410 protected void consumePushRealModifiers() {
4411         checkComment(); // might update modifiers with AccDeprecated
4412         pushOnIntStack(this.modifiers); // modifiers
4413         pushOnIntStack(this.modifiersSourceStart);
4414         resetModifiers();
4415 }
4416 protected void consumePushModifiers() {
4417         pushOnIntStack(this.modifiers); // modifiers
4418         pushOnIntStack(this.modifiersSourceStart);
4419         resetModifiers();
4420         pushOnExpressionStackLengthStack(0);
4421 }
4422 protected void consumePushModifiersForHeader() {
4423         checkComment(); // might update modifiers with AccDeprecated
4424         pushOnIntStack(this.modifiers); // modifiers
4425         pushOnIntStack(this.modifiersSourceStart);
4426         resetModifiers();
4427         pushOnExpressionStackLengthStack(0);
4428 }
4429 protected void consumePushPosition() {
4430         // for source managment purpose
4431         // PushPosition ::= $empty
4432         pushOnIntStack(this.endPosition);
4433 }
4434 protected void consumeQualifiedName() {
4435         // QualifiedName ::= Name '.' SimpleName 
4436         /*back from the recursive loop of QualifiedName.
4437         Updates identifier length into the length stack*/
4438
4439         this.identifierLengthStack[--this.identifierLengthPtr]++;
4440 }
4441 protected void consumeRecoveryMethodHeaderName() {
4442         // this method is call only inside recovery
4443         boolean isAnnotationMethod = false;
4444         if(this.currentElement instanceof RecoveredType) {
4445                 isAnnotationMethod = (((RecoveredType)this.currentElement).typeDeclaration.modifiers & AccAnnotation) != 0;
4446         } else {
4447                 RecoveredType recoveredType = this.currentElement.enclosingType();
4448                 if(recoveredType != null) {
4449                         isAnnotationMethod = (recoveredType.typeDeclaration.modifiers & AccAnnotation) != 0;
4450                 }
4451         }
4452         this.consumeMethodHeaderName(isAnnotationMethod);
4453 }
4454 protected void consumeRecoveryMethodHeaderNameWithTypeParameters() {
4455         // this method is call only inside recovery
4456         boolean isAnnotationMethod = false;
4457         if(this.currentElement instanceof RecoveredType) {
4458                 isAnnotationMethod = (((RecoveredType)this.currentElement).typeDeclaration.modifiers & AccAnnotation) != 0;
4459         } else {
4460                 RecoveredType recoveredType = this.currentElement.enclosingType();
4461                 if(recoveredType != null) {
4462                         isAnnotationMethod = (recoveredType.typeDeclaration.modifiers & AccAnnotation) != 0;
4463                 }
4464         }
4465         this.consumeMethodHeaderNameWithTypeParameters(isAnnotationMethod);
4466 }
4467 protected void consumeReduceImports() {
4468         // Consume imports
4469         int length;
4470         if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
4471                 this.astPtr -= length;
4472                 System.arraycopy(
4473                         this.astStack,
4474                         this.astPtr + 1,
4475                         this.compilationUnit.imports = new ImportReference[length],
4476                         0,
4477                         length);
4478         }
4479 }
4480 protected void consumeReferenceType() {
4481         pushOnIntStack(0); // handle array type
4482 }
4483 protected void consumeReferenceType1() {
4484         pushOnGenericsStack(getTypeReference(this.intStack[this.intPtr--]));    
4485 }
4486 protected void consumeReferenceType2() {
4487         pushOnGenericsStack(getTypeReference(this.intStack[this.intPtr--]));    
4488 }
4489 protected void consumeReferenceType3() {
4490         pushOnGenericsStack(getTypeReference(this.intStack[this.intPtr--]));    
4491 }
4492 protected void consumeRestoreDiet() {
4493         // RestoreDiet ::= $empty
4494         this.dietInt--;
4495 }
4496 protected void consumeRightParen() {
4497         // PushRPAREN ::= ')'
4498         pushOnIntStack(this.rParenPos);
4499 }
4500 // This method is part of an automatic generation : do NOT edit-modify  
4501 protected void consumeRule(int act) {
4502   switch ( act ) {
4503     case 29 : if (DEBUG) { System.out.println("Type ::= PrimitiveType"); }  //$NON-NLS-1$
4504                     consumePrimitiveType();  
4505                         break;
4506  
4507     case 43 : if (DEBUG) { System.out.println("ReferenceType ::= ClassOrInterfaceType"); }  //$NON-NLS-1$
4508                     consumeReferenceType();   
4509                         break;
4510  
4511     case 47 : if (DEBUG) { System.out.println("ClassOrInterface ::= Name"); }  //$NON-NLS-1$
4512                     consumeClassOrInterfaceName();   
4513                         break;
4514  
4515     case 48 : if (DEBUG) { System.out.println("ClassOrInterface ::= GenericType DOT Name"); }  //$NON-NLS-1$
4516                     consumeClassOrInterface();   
4517                         break;
4518  
4519     case 49 : if (DEBUG) { System.out.println("GenericType ::= ClassOrInterface TypeArguments"); }  //$NON-NLS-1$
4520                     consumeGenericType();   
4521                         break;
4522  
4523     case 50 : if (DEBUG) { System.out.println("ArrayTypeWithTypeArgumentsName ::= GenericType DOT Name"); }  //$NON-NLS-1$
4524                     consumeArrayTypeWithTypeArgumentsName();   
4525                         break;
4526  
4527     case 51 : if (DEBUG) { System.out.println("ArrayType ::= PrimitiveType Dims"); }  //$NON-NLS-1$
4528                     consumePrimitiveArrayType();   
4529                         break;
4530  
4531     case 52 : if (DEBUG) { System.out.println("ArrayType ::= Name Dims"); }  //$NON-NLS-1$
4532                     consumeNameArrayType();   
4533                         break;
4534  
4535     case 53 : if (DEBUG) { System.out.println("ArrayType ::= ArrayTypeWithTypeArgumentsName Dims"); }  //$NON-NLS-1$
4536                     consumeGenericTypeNameArrayType();   
4537                         break;
4538  
4539     case 54 : if (DEBUG) { System.out.println("ArrayType ::= GenericType Dims"); }  //$NON-NLS-1$
4540                     consumeGenericTypeArrayType();   
4541                         break;
4542  
4543     case 59 : if (DEBUG) { System.out.println("QualifiedName ::= Name DOT SimpleName"); }  //$NON-NLS-1$
4544                     consumeQualifiedName();  
4545                         break;
4546  
4547     case 60 : if (DEBUG) { System.out.println("CompilationUnit ::= EnterCompilationUnit..."); }  //$NON-NLS-1$
4548                     consumeCompilationUnit();  
4549                         break;
4550  
4551     case 61 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration"); }  //$NON-NLS-1$
4552                     consumeInternalCompilationUnit();  
4553                         break;
4554  
4555     case 62 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration..."); }  //$NON-NLS-1$
4556                     consumeInternalCompilationUnit();  
4557                         break;
4558  
4559     case 63 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration..."); }  //$NON-NLS-1$
4560                     consumeInternalCompilationUnitWithTypes();  
4561                         break;
4562  
4563     case 64 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= PackageDeclaration..."); }  //$NON-NLS-1$
4564                     consumeInternalCompilationUnitWithTypes();  
4565                         break;
4566  
4567     case 65 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= ImportDeclarations..."); }  //$NON-NLS-1$
4568                     consumeInternalCompilationUnit();  
4569                         break;
4570  
4571     case 66 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= TypeDeclarations"); }  //$NON-NLS-1$
4572                     consumeInternalCompilationUnitWithTypes();  
4573                         break;
4574  
4575     case 67 : if (DEBUG) { System.out.println("InternalCompilationUnit ::= ImportDeclarations..."); }  //$NON-NLS-1$
4576                     consumeInternalCompilationUnitWithTypes();  
4577                         break;
4578  
4579     case 68 : if (DEBUG) { System.out.println("InternalCompilationUnit ::="); }  //$NON-NLS-1$
4580                     consumeEmptyInternalCompilationUnit();  
4581                         break;
4582  
4583     case 69 : if (DEBUG) { System.out.println("ReduceImports ::="); }  //$NON-NLS-1$
4584                     consumeReduceImports();  
4585                         break;
4586  
4587     case 70 : if (DEBUG) { System.out.println("EnterCompilationUnit ::="); }  //$NON-NLS-1$
4588                     consumeEnterCompilationUnit();  
4589                         break;
4590  
4591     case 86 : if (DEBUG) { System.out.println("CatchHeader ::= catch LPAREN FormalParameter RPAREN..."); }  //$NON-NLS-1$
4592                     consumeCatchHeader();  
4593                         break;
4594  
4595     case 88 : if (DEBUG) { System.out.println("ImportDeclarations ::= ImportDeclarations..."); }  //$NON-NLS-1$
4596                     consumeImportDeclarations();  
4597                         break;
4598  
4599     case 90 : if (DEBUG) { System.out.println("TypeDeclarations ::= TypeDeclarations TypeDeclaration"); }  //$NON-NLS-1$
4600                     consumeTypeDeclarations();  
4601                         break;
4602  
4603     case 91 : if (DEBUG) { System.out.println("PackageDeclaration ::= PackageDeclarationName SEMICOLON"); }  //$NON-NLS-1$
4604                      consumePackageDeclaration();  
4605                         break;
4606  
4607     case 92 : if (DEBUG) { System.out.println("PackageDeclarationName ::= Modifiers package..."); }  //$NON-NLS-1$
4608                      consumePackageDeclarationNameWithModifiers();  
4609                         break;
4610  
4611     case 93 : if (DEBUG) { System.out.println("PackageDeclarationName ::= package Name"); }  //$NON-NLS-1$
4612                      consumePackageDeclarationName();  
4613                         break;
4614  
4615     case 98 : if (DEBUG) { System.out.println("SingleTypeImportDeclaration ::=..."); }  //$NON-NLS-1$
4616                     consumeImportDeclaration();  
4617                         break;
4618  
4619     case 99 : if (DEBUG) { System.out.println("SingleTypeImportDeclarationName ::= import Name"); }  //$NON-NLS-1$
4620                     consumeSingleTypeImportDeclarationName();  
4621                         break;
4622  
4623     case 100 : if (DEBUG) { System.out.println("TypeImportOnDemandDeclaration ::=..."); }  //$NON-NLS-1$
4624                     consumeImportDeclaration();  
4625                         break;
4626  
4627     case 101 : if (DEBUG) { System.out.println("TypeImportOnDemandDeclarationName ::= import Name DOT..."); }  //$NON-NLS-1$
4628                     consumeTypeImportOnDemandDeclarationName();  
4629                         break;
4630  
4631      case 104 : if (DEBUG) { System.out.println("TypeDeclaration ::= SEMICOLON"); }  //$NON-NLS-1$
4632                     consumeEmptyTypeDeclaration();  
4633                         break;
4634  
4635     case 108 : if (DEBUG) { System.out.println("Modifiers ::= Modifiers Modifier"); }  //$NON-NLS-1$
4636                     consumeModifiers2();  
4637                         break;
4638  
4639     case 120 : if (DEBUG) { System.out.println("Modifier ::= Annotation"); }  //$NON-NLS-1$
4640                     consumeAnnotationAsModifier();  
4641                         break;
4642  
4643     case 121 : if (DEBUG) { System.out.println("ClassDeclaration ::= ClassHeader ClassBody"); }  //$NON-NLS-1$
4644                     consumeClassDeclaration();  
4645                         break;
4646  
4647     case 122 : if (DEBUG) { System.out.println("ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt..."); }  //$NON-NLS-1$
4648                     consumeClassHeader();  
4649                         break;
4650  
4651     case 123 : if (DEBUG) { System.out.println("ClassHeaderName ::= ClassHeaderName1 TypeParameters"); }  //$NON-NLS-1$
4652                     consumeTypeHeaderNameWithTypeParameters();  
4653                         break;
4654  
4655     case 125 : if (DEBUG) { System.out.println("ClassHeaderName1 ::= Modifiersopt class Identifier"); }  //$NON-NLS-1$
4656                     consumeClassHeaderName1();  
4657                         break;
4658  
4659     case 126 : if (DEBUG) { System.out.println("ClassHeaderExtends ::= extends ClassType"); }  //$NON-NLS-1$
4660                     consumeClassHeaderExtends();  
4661                         break;
4662  
4663     case 127 : if (DEBUG) { System.out.println("ClassHeaderImplements ::= implements InterfaceTypeList"); }  //$NON-NLS-1$
4664                     consumeClassHeaderImplements();  
4665                         break;
4666  
4667     case 129 : if (DEBUG) { System.out.println("InterfaceTypeList ::= InterfaceTypeList COMMA..."); }  //$NON-NLS-1$
4668                     consumeInterfaceTypeList();  
4669                         break;
4670  
4671     case 130 : if (DEBUG) { System.out.println("InterfaceType ::= ClassOrInterfaceType"); }  //$NON-NLS-1$
4672                     consumeInterfaceType();  
4673                         break;
4674  
4675     case 133 : if (DEBUG) { System.out.println("ClassBodyDeclarations ::= ClassBodyDeclarations..."); }  //$NON-NLS-1$
4676                     consumeClassBodyDeclarations();  
4677                         break;
4678  
4679     case 137 : if (DEBUG) { System.out.println("ClassBodyDeclaration ::= Diet NestedMethod Block"); }  //$NON-NLS-1$
4680                     consumeClassBodyDeclaration();  
4681                         break;
4682  
4683     case 138 : if (DEBUG) { System.out.println("Diet ::="); }  //$NON-NLS-1$
4684                     consumeDiet();  
4685                         break;
4686
4687     case 139 : if (DEBUG) { System.out.println("Initializer ::= Diet NestedMethod Block"); }  //$NON-NLS-1$
4688                     consumeClassBodyDeclaration();  
4689                         break;
4690  
4691     case 146 : if (DEBUG) { System.out.println("ClassMemberDeclaration ::= SEMICOLON"); }  //$NON-NLS-1$
4692                     consumeEmptyClassMemberDeclaration();  
4693                         break;
4694
4695     case 149 : if (DEBUG) { System.out.println("FieldDeclaration ::= Modifiersopt Type..."); }  //$NON-NLS-1$
4696                     consumeFieldDeclaration();  
4697                         break;
4698  
4699     case 151 : if (DEBUG) { System.out.println("VariableDeclarators ::= VariableDeclarators COMMA..."); }  //$NON-NLS-1$
4700                     consumeVariableDeclarators();  
4701                         break;
4702  
4703     case 154 : if (DEBUG) { System.out.println("EnterVariable ::="); }  //$NON-NLS-1$
4704                     consumeEnterVariable();  
4705                         break;
4706  
4707     case 155 : if (DEBUG) { System.out.println("ExitVariableWithInitialization ::="); }  //$NON-NLS-1$
4708                     consumeExitVariableWithInitialization();  
4709                         break;
4710  
4711     case 156 : if (DEBUG) { System.out.println("ExitVariableWithoutInitialization ::="); }  //$NON-NLS-1$
4712                     consumeExitVariableWithoutInitialization();  
4713                         break;
4714  
4715     case 157 : if (DEBUG) { System.out.println("ForceNoDiet ::="); }  //$NON-NLS-1$
4716                     consumeForceNoDiet();  
4717                         break;
4718  
4719     case 158 : if (DEBUG) { System.out.println("RestoreDiet ::="); }  //$NON-NLS-1$
4720                     consumeRestoreDiet();  
4721                         break;
4722  
4723     case 163 : if (DEBUG) { System.out.println("MethodDeclaration ::= MethodHeader MethodBody"); }  //$NON-NLS-1$
4724                     // set to true to consume a method with a body
4725   consumeMethodDeclaration(true);   
4726                         break;
4727  
4728     case 164 : if (DEBUG) { System.out.println("AbstractMethodDeclaration ::= MethodHeader SEMICOLON"); }  //$NON-NLS-1$
4729                     // set to false to consume a method without body
4730   consumeMethodDeclaration(false);  
4731                         break;
4732  
4733     case 165 : if (DEBUG) { System.out.println("MethodHeader ::= MethodHeaderName FormalParameterListopt"); }  //$NON-NLS-1$
4734                     consumeMethodHeader();  
4735                         break;
4736  
4737     case 166 : if (DEBUG) { System.out.println("MethodHeaderName ::= Modifiersopt TypeParameters Type..."); }  //$NON-NLS-1$
4738                     consumeMethodHeaderNameWithTypeParameters(false);  
4739                         break;
4740  
4741     case 167 : if (DEBUG) { System.out.println("MethodHeaderName ::= Modifiersopt Type Identifier LPAREN"); }  //$NON-NLS-1$
4742                     consumeMethodHeaderName(false);  
4743                         break;
4744  
4745     case 168 : if (DEBUG) { System.out.println("MethodHeaderRightParen ::= RPAREN"); }  //$NON-NLS-1$
4746                     consumeMethodHeaderRightParen();  
4747                         break;
4748  
4749     case 169 : if (DEBUG) { System.out.println("MethodHeaderExtendedDims ::= Dimsopt"); }  //$NON-NLS-1$
4750                     consumeMethodHeaderExtendedDims();  
4751                         break;
4752  
4753     case 170 : if (DEBUG) { System.out.println("MethodHeaderThrowsClause ::= throws ClassTypeList"); }  //$NON-NLS-1$
4754                     consumeMethodHeaderThrowsClause();  
4755                         break;
4756  
4757     case 171 : if (DEBUG) { System.out.println("ConstructorHeader ::= ConstructorHeaderName..."); }  //$NON-NLS-1$
4758                     consumeConstructorHeader();  
4759                         break;
4760  
4761     case 172 : if (DEBUG) { System.out.println("ConstructorHeaderName ::= Modifiersopt TypeParameters..."); }  //$NON-NLS-1$
4762                     consumeConstructorHeaderNameWithTypeParameters();  
4763                         break;
4764  
4765     case 173 : if (DEBUG) { System.out.println("ConstructorHeaderName ::= Modifiersopt Identifier LPAREN"); }  //$NON-NLS-1$
4766                     consumeConstructorHeaderName();  
4767                         break;
4768  
4769     case 175 : if (DEBUG) { System.out.println("FormalParameterList ::= FormalParameterList COMMA..."); }  //$NON-NLS-1$
4770                     consumeFormalParameterList();  
4771                         break;
4772  
4773     case 176 : if (DEBUG) { System.out.println("FormalParameter ::= Modifiersopt Type..."); }  //$NON-NLS-1$
4774                     consumeFormalParameter(false);  
4775                         break;
4776  
4777     case 177 : if (DEBUG) { System.out.println("FormalParameter ::= Modifiersopt Type ELLIPSIS..."); }  //$NON-NLS-1$
4778                     consumeFormalParameter(true);  
4779                         break;
4780  
4781     case 179 : if (DEBUG) { System.out.println("ClassTypeList ::= ClassTypeList COMMA ClassTypeElt"); }  //$NON-NLS-1$
4782                     consumeClassTypeList();  
4783                         break;
4784  
4785     case 180 : if (DEBUG) { System.out.println("ClassTypeElt ::= ClassType"); }  //$NON-NLS-1$
4786                     consumeClassTypeElt();  
4787                         break;
4788  
4789     case 181 : if (DEBUG) { System.out.println("MethodBody ::= NestedMethod LBRACE BlockStatementsopt..."); }  //$NON-NLS-1$
4790                     consumeMethodBody();  
4791                         break;
4792  
4793     case 182 : if (DEBUG) { System.out.println("NestedMethod ::="); }  //$NON-NLS-1$
4794                     consumeNestedMethod();  
4795                         break;
4796  
4797     case 183 : if (DEBUG) { System.out.println("StaticInitializer ::= StaticOnly Block"); }  //$NON-NLS-1$
4798                     consumeStaticInitializer();  
4799                         break;
4800
4801     case 184 : if (DEBUG) { System.out.println("StaticOnly ::= static"); }  //$NON-NLS-1$
4802                     consumeStaticOnly();  
4803                         break;
4804  
4805     case 185 : if (DEBUG) { System.out.println("ConstructorDeclaration ::= ConstructorHeader MethodBody"); }  //$NON-NLS-1$
4806                     consumeConstructorDeclaration() ;  
4807                         break;
4808  
4809     case 186 : if (DEBUG) { System.out.println("ConstructorDeclaration ::= ConstructorHeader SEMICOLON"); }  //$NON-NLS-1$
4810                     consumeInvalidConstructorDeclaration() ;  
4811                         break;
4812  
4813     case 187 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= this LPAREN..."); }  //$NON-NLS-1$
4814                     consumeExplicitConstructorInvocation(0, THIS_CALL);  
4815                         break;
4816  
4817     case 188 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= OnlyTypeArguments this"); }  //$NON-NLS-1$
4818                     consumeExplicitConstructorInvocationWithTypeArguments(0,THIS_CALL);  
4819                         break;
4820  
4821     case 189 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= super LPAREN..."); }  //$NON-NLS-1$
4822                     consumeExplicitConstructorInvocation(0,SUPER_CALL);  
4823                         break;
4824  
4825     case 190 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= OnlyTypeArguments..."); }  //$NON-NLS-1$
4826                     consumeExplicitConstructorInvocationWithTypeArguments(0,SUPER_CALL);  
4827                         break;
4828  
4829     case 191 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT super..."); }  //$NON-NLS-1$
4830                     consumeExplicitConstructorInvocation(1, SUPER_CALL);  
4831                         break;
4832  
4833     case 192 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT..."); }  //$NON-NLS-1$
4834                     consumeExplicitConstructorInvocationWithTypeArguments(1, SUPER_CALL);  
4835                         break;
4836  
4837     case 193 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT super LPAREN"); }  //$NON-NLS-1$
4838                     consumeExplicitConstructorInvocation(2, SUPER_CALL);  
4839                         break;
4840  
4841     case 194 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT..."); }  //$NON-NLS-1$
4842                     consumeExplicitConstructorInvocationWithTypeArguments(2, SUPER_CALL);  
4843                         break;
4844  
4845     case 195 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT this..."); }  //$NON-NLS-1$
4846                     consumeExplicitConstructorInvocation(1, THIS_CALL);  
4847                         break;
4848  
4849     case 196 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Primary DOT..."); }  //$NON-NLS-1$
4850                     consumeExplicitConstructorInvocationWithTypeArguments(1, THIS_CALL);  
4851                         break;
4852  
4853     case 197 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT this LPAREN"); }  //$NON-NLS-1$
4854                     consumeExplicitConstructorInvocation(2, THIS_CALL);  
4855                         break;
4856  
4857     case 198 : if (DEBUG) { System.out.println("ExplicitConstructorInvocation ::= Name DOT..."); }  //$NON-NLS-1$
4858                     consumeExplicitConstructorInvocationWithTypeArguments(2, THIS_CALL);  
4859                         break;
4860  
4861     case 199 : if (DEBUG) { System.out.println("InterfaceDeclaration ::= InterfaceHeader InterfaceBody"); }  //$NON-NLS-1$
4862                     consumeInterfaceDeclaration();  
4863                         break;
4864  
4865     case 200 : if (DEBUG) { System.out.println("InterfaceHeader ::= InterfaceHeaderName..."); }  //$NON-NLS-1$
4866                     consumeInterfaceHeader();  
4867                         break;
4868  
4869     case 201 : if (DEBUG) { System.out.println("InterfaceHeaderName ::= InterfaceHeaderName1..."); }  //$NON-NLS-1$
4870                     consumeTypeHeaderNameWithTypeParameters();  
4871                         break;
4872  
4873     case 203 : if (DEBUG) { System.out.println("InterfaceHeaderName1 ::= Modifiersopt interface..."); }  //$NON-NLS-1$
4874                     consumeInterfaceHeaderName1();  
4875                         break;
4876  
4877     case 205 : if (DEBUG) { System.out.println("InterfaceHeaderExtends ::= extends InterfaceTypeList"); }  //$NON-NLS-1$
4878                     consumeInterfaceHeaderExtends();  
4879                         break;
4880  
4881     case 208 : if (DEBUG) { System.out.println("InterfaceMemberDeclarations ::=..."); }  //$NON-NLS-1$
4882                     consumeInterfaceMemberDeclarations();  
4883                         break;
4884  
4885     case 209 : if (DEBUG) { System.out.println("InterfaceMemberDeclaration ::= SEMICOLON"); }  //$NON-NLS-1$
4886                     consumeEmptyInterfaceMemberDeclaration();  
4887                         break;
4888  
4889     case 212 : if (DEBUG) { System.out.println("InterfaceMemberDeclaration ::= InvalidMethodDeclaration"); }  //$NON-NLS-1$
4890                     ignoreMethodBody();  
4891                         break;
4892  
4893     case 213 : if (DEBUG) { System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader..."); }  //$NON-NLS-1$
4894                     ignoreInvalidConstructorDeclaration(true);   
4895                         break;
4896  
4897     case 214 : if (DEBUG) { System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader..."); }  //$NON-NLS-1$
4898                     ignoreInvalidConstructorDeclaration(false);   
4899                         break;
4900  
4901     case 222 : if (DEBUG) { System.out.println("PushLeftBrace ::="); }  //$NON-NLS-1$
4902                     consumePushLeftBrace();  
4903                         break;
4904  
4905     case 223 : if (DEBUG) { System.out.println("ArrayInitializer ::= LBRACE PushLeftBrace ,opt RBRACE"); }  //$NON-NLS-1$
4906                     consumeEmptyArrayInitializer();  
4907                         break;
4908  
4909     case 224 : if (DEBUG) { System.out.println("ArrayInitializer ::= LBRACE PushLeftBrace..."); }  //$NON-NLS-1$
4910                     consumeArrayInitializer();  
4911                         break;
4912  
4913     case 225 : if (DEBUG) { System.out.println("ArrayInitializer ::= LBRACE PushLeftBrace..."); }  //$NON-NLS-1$
4914                     consumeArrayInitializer();  
4915                         break;
4916  
4917     case 227 : if (DEBUG) { System.out.println("VariableInitializers ::= VariableInitializers COMMA..."); }  //$NON-NLS-1$
4918                     consumeVariableInitializers();  
4919                         break;
4920  
4921     case 228 : if (DEBUG) { System.out.println("Block ::= OpenBlock LBRACE BlockStatementsopt RBRACE"); }  //$NON-NLS-1$
4922                     consumeBlock();  
4923                         break;
4924  
4925     case 229 : if (DEBUG) { System.out.println("OpenBlock ::="); }  //$NON-NLS-1$
4926                     consumeOpenBlock() ;  
4927                         break;
4928  
4929     case 231 : if (DEBUG) { System.out.println("BlockStatements ::= BlockStatements BlockStatement"); }  //$NON-NLS-1$
4930                     consumeBlockStatements() ;  
4931                         break;
4932  
4933     case 235 : if (DEBUG) { System.out.println("BlockStatement ::= InvalidInterfaceDeclaration"); }  //$NON-NLS-1$
4934                     ignoreInterfaceDeclaration();  
4935                         break;
4936  
4937     case 236 : if (DEBUG) { System.out.println("LocalVariableDeclarationStatement ::=..."); }  //$NON-NLS-1$
4938                     consumeLocalVariableDeclarationStatement();  
4939                         break;
4940  
4941     case 237 : if (DEBUG) { System.out.println("LocalVariableDeclaration ::= Type PushModifiers..."); }  //$NON-NLS-1$
4942                     consumeLocalVariableDeclaration();  
4943                         break;
4944  
4945     case 238 : if (DEBUG) { System.out.println("LocalVariableDeclaration ::= Modifiers Type..."); }  //$NON-NLS-1$
4946                     consumeLocalVariableDeclaration();  
4947                         break;
4948  
4949     case 239 : if (DEBUG) { System.out.println("PushModifiers ::="); }  //$NON-NLS-1$
4950                     consumePushModifiers();  
4951                         break;
4952  
4953     case 240 : if (DEBUG) { System.out.println("PushModifiersForHeader ::="); }  //$NON-NLS-1$
4954                     consumePushModifiersForHeader();  
4955                         break;
4956  
4957     case 241 : if (DEBUG) { System.out.println("PushRealModifiers ::="); }  //$NON-NLS-1$
4958                     consumePushRealModifiers();  
4959                         break;
4960  
4961     case 267 : if (DEBUG) { System.out.println("EmptyStatement ::= SEMICOLON"); }  //$NON-NLS-1$
4962                     consumeEmptyStatement();  
4963                         break;
4964  
4965     case 268 : if (DEBUG) { System.out.println("LabeledStatement ::= Identifier COLON Statement"); }  //$NON-NLS-1$
4966                     consumeStatementLabel() ;  
4967                         break;
4968  
4969     case 269 : if (DEBUG) { System.out.println("LabeledStatementNoShortIf ::= Identifier COLON..."); }  //$NON-NLS-1$
4970                     consumeStatementLabel() ;  
4971                         break;
4972  
4973      case 270 : if (DEBUG) { System.out.println("ExpressionStatement ::= StatementExpression SEMICOLON"); }  //$NON-NLS-1$
4974                     consumeExpressionStatement();  
4975                         break;
4976  
4977     case 279 : if (DEBUG) { System.out.println("IfThenStatement ::= if LPAREN Expression RPAREN..."); }  //$NON-NLS-1$
4978                     consumeStatementIfNoElse();  
4979                         break;
4980  
4981     case 280 : if (DEBUG) { System.out.println("IfThenElseStatement ::= if LPAREN Expression RPAREN..."); }  //$NON-NLS-1$
4982                     consumeStatementIfWithElse();  
4983                         break;
4984  
4985     case 281 : if (DEBUG) { System.out.println("IfThenElseStatementNoShortIf ::= if LPAREN Expression..."); }  //$NON-NLS-1$
4986                     consumeStatementIfWithElse();  
4987                         break;
4988  
4989     case 282 : if (DEBUG) { System.out.println("SwitchStatement ::= switch LPAREN Expression RPAREN..."); }  //$NON-NLS-1$
4990                     consumeStatementSwitch() ;  
4991                         break;
4992  
4993     case 283 : if (DEBUG) { System.out.println("SwitchBlock ::= LBRACE RBRACE"); }  //$NON-NLS-1$
4994                     consumeEmptySwitchBlock() ;  
4995                         break;
4996  
4997     case 286 : if (DEBUG) { System.out.println("SwitchBlock ::= LBRACE SwitchBlockStatements..."); }  //$NON-NLS-1$
4998                     consumeSwitchBlock() ;  
4999                         break;
5000  
5001     case 288 : if (DEBUG) { System.out.println("SwitchBlockStatements ::= SwitchBlockStatements..."); }  //$NON-NLS-1$
5002                     consumeSwitchBlockStatements() ;  
5003                         break;
5004  
5005     case 289 : if (DEBUG) { System.out.println("SwitchBlockStatement ::= SwitchLabels BlockStatements"); }  //$NON-NLS-1$
5006                     consumeSwitchBlockStatement() ;  
5007                         break;
5008  
5009     case 291 : if (DEBUG) { System.out.println("SwitchLabels ::= SwitchLabels SwitchLabel"); }  //$NON-NLS-1$
5010                     consumeSwitchLabels() ;  
5011                         break;
5012  
5013      case 292 : if (DEBUG) { System.out.println("SwitchLabel ::= case ConstantExpression COLON"); }  //$NON-NLS-1$
5014                     consumeCaseLabel();  
5015                         break;
5016  
5017      case 293 : if (DEBUG) { System.out.println("SwitchLabel ::= default COLON"); }  //$NON-NLS-1$
5018                     consumeDefaultLabel();  
5019                         break;
5020  
5021     case 294 : if (DEBUG) { System.out.println("WhileStatement ::= while LPAREN Expression RPAREN..."); }  //$NON-NLS-1$
5022                     consumeStatementWhile() ;  
5023                         break;
5024  
5025     case 295 : if (DEBUG) { System.out.println("WhileStatementNoShortIf ::= while LPAREN Expression..."); }  //$NON-NLS-1$
5026                     consumeStatementWhile() ;  
5027                         break;
5028  
5029     case 296 : if (DEBUG) { System.out.println("DoStatement ::= do Statement while LPAREN Expression..."); }  //$NON-NLS-1$
5030                     consumeStatementDo() ;  
5031                         break;
5032  
5033     case 297 : if (DEBUG) { System.out.println("ForStatement ::= for LPAREN ForInitopt SEMICOLON..."); }  //$NON-NLS-1$
5034                     consumeStatementFor() ;  
5035                         break;
5036  
5037     case 298 : if (DEBUG) { System.out.println("ForStatementNoShortIf ::= for LPAREN ForInitopt..."); }  //$NON-NLS-1$
5038                     consumeStatementFor() ;  
5039                         break;
5040  
5041     case 299 : if (DEBUG) { System.out.println("ForInit ::= StatementExpressionList"); }  //$NON-NLS-1$
5042                     consumeForInit() ;  
5043                         break;
5044  
5045     case 303 : if (DEBUG) { System.out.println("StatementExpressionList ::= StatementExpressionList..."); }  //$NON-NLS-1$
5046                     consumeStatementExpressionList() ;  
5047                         break;
5048  
5049     case 304 : if (DEBUG) { System.out.println("AssertStatement ::= assert Expression SEMICOLON"); }  //$NON-NLS-1$
5050                     consumeSimpleAssertStatement() ;  
5051                         break;
5052  
5053     case 305 : if (DEBUG) { System.out.println("AssertStatement ::= assert Expression COLON Expression"); }  //$NON-NLS-1$
5054                     consumeAssertStatement() ;  
5055                         break;
5056  
5057     case 306 : if (DEBUG) { System.out.println("BreakStatement ::= break SEMICOLON"); }  //$NON-NLS-1$
5058                     consumeStatementBreak() ;  
5059                         break;
5060  
5061     case 307 : if (DEBUG) { System.out.println("BreakStatement ::= break Identifier SEMICOLON"); }  //$NON-NLS-1$
5062                     consumeStatementBreakWithLabel() ;  
5063                         break;
5064  
5065     case 308 : if (DEBUG) { System.out.println("ContinueStatement ::= continue SEMICOLON"); }  //$NON-NLS-1$
5066                     consumeStatementContinue() ;  
5067                         break;
5068  
5069     case 309 : if (DEBUG) { System.out.println("ContinueStatement ::= continue Identifier SEMICOLON"); }  //$NON-NLS-1$
5070                     consumeStatementContinueWithLabel() ;  
5071                         break;
5072  
5073     case 310 : if (DEBUG) { System.out.println("ReturnStatement ::= return Expressionopt SEMICOLON"); }  //$NON-NLS-1$
5074                     consumeStatementReturn() ;  
5075                         break;
5076  
5077     case 311 : if (DEBUG) { System.out.println("ThrowStatement ::= throw Expression SEMICOLON"); }  //$NON-NLS-1$
5078                     consumeStatementThrow();  
5079                         break;
5080  
5081     case 312 : if (DEBUG) { System.out.println("SynchronizedStatement ::= OnlySynchronized LPAREN..."); }  //$NON-NLS-1$
5082                     consumeStatementSynchronized();  
5083                         break;
5084  
5085     case 313 : if (DEBUG) { System.out.println("OnlySynchronized ::= synchronized"); }  //$NON-NLS-1$
5086                     consumeOnlySynchronized();  
5087                         break;
5088  
5089     case 314 : if (DEBUG) { System.out.println("TryStatement ::= try TryBlock Catches"); }  //$NON-NLS-1$
5090                     consumeStatementTry(false);  
5091                         break;
5092  
5093     case 315 : if (DEBUG) { System.out.println("TryStatement ::= try TryBlock Catchesopt Finally"); }  //$NON-NLS-1$
5094                     consumeStatementTry(true);  
5095                         break;
5096  
5097     case 317 : if (DEBUG) { System.out.println("ExitTryBlock ::="); }  //$NON-NLS-1$
5098                     consumeExitTryBlock();  
5099                         break;
5100  
5101     case 319 : if (DEBUG) { System.out.println("Catches ::= Catches CatchClause"); }  //$NON-NLS-1$
5102                     consumeCatches();  
5103                         break;
5104  
5105     case 320 : if (DEBUG) { System.out.println("CatchClause ::= catch LPAREN FormalParameter RPAREN..."); }  //$NON-NLS-1$
5106                     consumeStatementCatch() ;  
5107                         break;
5108  
5109     case 322 : if (DEBUG) { System.out.println("PushLPAREN ::= LPAREN"); }  //$NON-NLS-1$
5110                     consumeLeftParen();  
5111                         break;
5112  
5113     case 323 : if (DEBUG) { System.out.println("PushRPAREN ::= RPAREN"); }  //$NON-NLS-1$
5114                     consumeRightParen();  
5115                         break;
5116  
5117     case 328 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= this"); }  //$NON-NLS-1$
5118                     consumePrimaryNoNewArrayThis();  
5119                         break;
5120  
5121     case 329 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PushLPAREN Expression_NotName..."); }  //$NON-NLS-1$
5122                     consumePrimaryNoNewArray();  
5123                         break;
5124  
5125     case 330 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PushLPAREN Name PushRPAREN"); }  //$NON-NLS-1$
5126                     consumePrimaryNoNewArrayWithName();  
5127                         break;
5128  
5129     case 333 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name DOT this"); }  //$NON-NLS-1$
5130                     consumePrimaryNoNewArrayNameThis();  
5131                         break;
5132  
5133     case 334 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name DOT super"); }  //$NON-NLS-1$
5134                     consumePrimaryNoNewArrayNameSuper();  
5135                         break;
5136  
5137     case 335 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name DOT class"); }  //$NON-NLS-1$
5138                     consumePrimaryNoNewArrayName();  
5139                         break;
5140  
5141     case 336 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= Name Dims DOT class"); }  //$NON-NLS-1$
5142                     consumePrimaryNoNewArrayArrayType();  
5143                         break;
5144  
5145     case 337 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PrimitiveType Dims DOT class"); }  //$NON-NLS-1$
5146                     consumePrimaryNoNewArrayPrimitiveArrayType();  
5147                         break;
5148  
5149     case 338 : if (DEBUG) { System.out.println("PrimaryNoNewArray ::= PrimitiveType DOT class"); }  //$NON-NLS-1$
5150                     consumePrimaryNoNewArrayPrimitiveType();  
5151                         break;
5152  
5153     case 341 : if (DEBUG) { System.out.println("AllocationHeader ::= new ClassType LPAREN..."); }  //$NON-NLS-1$
5154                     consumeAllocationHeader();  
5155                         break;
5156  
5157     case 342 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= new..."); }  //$NON-NLS-1$
5158                     consumeClassInstanceCreationExpressionWithTypeArguments();  
5159                         break;
5160  
5161     case 343 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= new ClassType LPAREN"); }  //$NON-NLS-1$
5162                     consumeClassInstanceCreationExpression();  
5163                         break;
5164  
5165     case 344 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= Primary DOT new..."); }  //$NON-NLS-1$
5166                     consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() ;  
5167                         break;
5168  
5169     case 345 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::= Primary DOT new..."); }  //$NON-NLS-1$
5170                     consumeClassInstanceCreationExpressionQualified() ;  
5171                         break;
5172  
5173     case 346 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::=..."); }  //$NON-NLS-1$
5174                     consumeClassInstanceCreationExpressionQualified() ;  
5175                         break;
5176  
5177     case 347 : if (DEBUG) { System.out.println("ClassInstanceCreationExpression ::=..."); }  //$NON-NLS-1$
5178                     consumeClassInstanceCreationExpressionQualifiedWithTypeArguments() ;  
5179                         break;
5180  
5181     case 348 : if (DEBUG) { System.out.println("ClassInstanceCreationExpressionName ::= Name DOT"); }  //$NON-NLS-1$
5182                     consumeClassInstanceCreationExpressionName() ;  
5183                         break;
5184  
5185     case 349 : if (DEBUG) { System.out.println("ClassBodyopt ::="); }  //$NON-NLS-1$
5186                     consumeClassBodyopt();  
5187                         break;
5188  
5189     case 351 : if (DEBUG) { System.out.println("ClassBodySimpleNameopt ::="); }  //$NON-NLS-1$
5190                     consumeClassBodyopt();  
5191                         break;
5192  
5193     case 353 : if (DEBUG) { System.out.println("EnterAnonymousClassBodySimpleName ::="); }  //$NON-NLS-1$
5194                     consumeEnterAnonymousClassBodySimpleName();  
5195                         break;
5196  
5197     case 354 : if (DEBUG) { System.out.println("EnterAnonymousClassBody ::="); }  //$NON-NLS-1$
5198                     consumeEnterAnonymousClassBody();  
5199                         break;
5200  
5201     case 356 : if (DEBUG) { System.out.println("ArgumentList ::= ArgumentList COMMA Expression"); }  //$NON-NLS-1$
5202                     consumeArgumentList();  
5203                         break;
5204  
5205     case 357 : if (DEBUG) { System.out.println("ArrayCreationHeader ::= new PrimitiveType..."); }  //$NON-NLS-1$
5206                     consumeArrayCreationHeader();  
5207                         break;
5208  
5209     case 358 : if (DEBUG) { System.out.println("ArrayCreationHeader ::= new ClassOrInterfaceType..."); }  //$NON-NLS-1$
5210                     consumeArrayCreationHeader();  
5211                         break;
5212  
5213     case 359 : if (DEBUG) { System.out.println("ArrayCreationWithoutArrayInitializer ::= new..."); }  //$NON-NLS-1$
5214                     consumeArrayCreationExpressionWithoutInitializer();  
5215                         break;
5216  
5217     case 360 : if (DEBUG) { System.out.println("ArrayCreationWithArrayInitializer ::= new PrimitiveType"); }  //$NON-NLS-1$
5218                     consumeArrayCreationExpressionWithInitializer();  
5219                         break;
5220  
5221     case 361 : if (DEBUG) { System.out.println("ArrayCreationWithoutArrayInitializer ::= new..."); }  //$NON-NLS-1$
5222                     consumeArrayCreationExpressionWithoutInitializer();  
5223                         break;
5224  
5225     case 362 : if (DEBUG) { System.out.println("ArrayCreationWithArrayInitializer ::= new..."); }  //$NON-NLS-1$
5226                     consumeArrayCreationExpressionWithInitializer();  
5227                         break;
5228  
5229     case 364 : if (DEBUG) { System.out.println("DimWithOrWithOutExprs ::= DimWithOrWithOutExprs..."); }  //$NON-NLS-1$
5230                     consumeDimWithOrWithOutExprs();  
5231                         break;
5232  
5233      case 366 : if (DEBUG) { System.out.println("DimWithOrWithOutExpr ::= LBRACKET RBRACKET"); }  //$NON-NLS-1$
5234                     consumeDimWithOrWithOutExpr();  
5235                         break;
5236  
5237      case 367 : if (DEBUG) { System.out.println("Dims ::= DimsLoop"); }  //$NON-NLS-1$
5238                     consumeDims();  
5239                         break;
5240  
5241      case 370 : if (DEBUG) { System.out.println("OneDimLoop ::= LBRACKET RBRACKET"); }  //$NON-NLS-1$
5242                     consumeOneDimLoop();  
5243                         break;
5244  
5245     case 371 : if (DEBUG) { System.out.println("FieldAccess ::= Primary DOT Identifier"); }  //$NON-NLS-1$
5246                     consumeFieldAccess(false);  
5247                         break;
5248  
5249     case 372 : if (DEBUG) { System.out.println("FieldAccess ::= super DOT Identifier"); }  //$NON-NLS-1$
5250                     consumeFieldAccess(true);  
5251                         break;
5252  
5253     case 373 : if (DEBUG) { System.out.println("MethodInvocation ::= Name LPAREN ArgumentListopt RPAREN"); }  //$NON-NLS-1$
5254                     consumeMethodInvocationName();  
5255                         break;
5256  
5257     case 374 : if (DEBUG) { System.out.println("MethodInvocation ::= Name DOT OnlyTypeArguments..."); }  //$NON-NLS-1$
5258                     consumeMethodInvocationNameWithTypeArguments();  
5259                         break;
5260  
5261     case 375 : if (DEBUG) { System.out.println("MethodInvocation ::= Primary DOT OnlyTypeArguments..."); }  //$NON-NLS-1$
5262                     consumeMethodInvocationPrimaryWithTypeArguments();  
5263                         break;
5264  
5265     case 376 : if (DEBUG) { System.out.println("MethodInvocation ::= Primary DOT Identifier LPAREN..."); }  //$NON-NLS-1$
5266                     consumeMethodInvocationPrimary();  
5267                         break;
5268  
5269     case 377 : if (DEBUG) { System.out.println("MethodInvocation ::= super DOT OnlyTypeArguments..."); }  //$NON-NLS-1$
5270                     consumeMethodInvocationSuperWithTypeArguments();  
5271                         break;
5272  
5273     case 378 : if (DEBUG) { System.out.println("MethodInvocation ::= super DOT Identifier LPAREN..."); }  //$NON-NLS-1$
5274                     consumeMethodInvocationSuper();  
5275                         break;
5276  
5277     case 379 : if (DEBUG) { System.out.println("ArrayAccess ::= Name LBRACKET Expression RBRACKET"); }  //$NON-NLS-1$
5278                     consumeArrayAccess(true);  
5279                         break;
5280  
5281     case 380 : if (DEBUG) { System.out.println("ArrayAccess ::= PrimaryNoNewArray LBRACKET Expression..."); }  //$NON-NLS-1$
5282                     consumeArrayAccess(false);  
5283                         break;
5284  
5285     case 381 : if (DEBUG) { System.out.println("ArrayAccess ::= ArrayCreationWithArrayInitializer..."); }  //$NON-NLS-1$
5286                     consumeArrayAccess(false);  
5287                         break;
5288  
5289     case 383 : if (DEBUG) { System.out.println("PostfixExpression ::= Name"); }  //$NON-NLS-1$
5290                     consumePostfixExpression();  
5291                         break;
5292  
5293     case 386 : if (DEBUG) { System.out.println("PostIncrementExpression ::= PostfixExpression PLUS_PLUS"); }  //$NON-NLS-1$
5294                     consumeUnaryExpression(OperatorIds.PLUS,true);  
5295                         break;
5296  
5297     case 387 : if (DEBUG) { System.out.println("PostDecrementExpression ::= PostfixExpression..."); }  //$NON-NLS-1$
5298                     consumeUnaryExpression(OperatorIds.MINUS,true);  
5299                         break;
5300  
5301     case 388 : if (DEBUG) { System.out.println("PushPosition ::="); }  //$NON-NLS-1$
5302                     consumePushPosition();  
5303                         break;
5304  
5305     case 391 : if (DEBUG) { System.out.println("UnaryExpression ::= PLUS PushPosition UnaryExpression"); }  //$NON-NLS-1$
5306                     consumeUnaryExpression(OperatorIds.PLUS);  
5307                         break;
5308  
5309     case 392 : if (DEBUG) { System.out.println("UnaryExpression ::= MINUS PushPosition UnaryExpression"); }  //$NON-NLS-1$
5310                     consumeUnaryExpression(OperatorIds.MINUS);  
5311                         break;
5312  
5313     case 394 : if (DEBUG) { System.out.println("PreIncrementExpression ::= PLUS_PLUS PushPosition..."); }  //$NON-NLS-1$
5314                     consumeUnaryExpression(OperatorIds.PLUS,false);  
5315                         break;
5316  
5317     case 395 : if (DEBUG) { System.out.println("PreDecrementExpression ::= MINUS_MINUS PushPosition..."); }  //$NON-NLS-1$
5318                     consumeUnaryExpression(OperatorIds.MINUS,false);  
5319                         break;
5320  
5321     case 397 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus ::= TWIDDLE PushPosition..."); }  //$NON-NLS-1$
5322                     consumeUnaryExpression(OperatorIds.TWIDDLE);  
5323                         break;
5324  
5325     case 398 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus ::= NOT PushPosition..."); }  //$NON-NLS-1$
5326                     consumeUnaryExpression(OperatorIds.NOT);  
5327                         break;
5328  
5329     case 400 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN PrimitiveType Dimsopt..."); }  //$NON-NLS-1$
5330                     consumeCastExpressionWithPrimitiveType();  
5331                         break;
5332  
5333     case 401 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name..."); }  //$NON-NLS-1$
5334                     consumeCastExpressionWithGenericsArray();  
5335                         break;
5336  
5337     case 402 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name..."); }  //$NON-NLS-1$
5338                     consumeCastExpressionWithQualifiedGenericsArray();  
5339                         break;
5340  
5341     case 403 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name PushRPAREN..."); }  //$NON-NLS-1$
5342                     consumeCastExpressionLL1();  
5343                         break;
5344  
5345     case 404 : if (DEBUG) { System.out.println("CastExpression ::= PushLPAREN Name Dims PushRPAREN..."); }  //$NON-NLS-1$
5346                     consumeCastExpressionWithNameArray();  
5347                         break;
5348  
5349     case 405 : if (DEBUG) { System.out.println("OnlyTypeArgumentsForCastExpression ::= OnlyTypeArguments"); }  //$NON-NLS-1$
5350                     consumeOnlyTypeArgumentsForCastExpression();  
5351                         break;
5352  
5353     case 406 : if (DEBUG) { System.out.println("InsideCastExpression ::="); }  //$NON-NLS-1$
5354                     consumeInsideCastExpression();  
5355                         break;
5356  
5357     case 407 : if (DEBUG) { System.out.println("InsideCastExpressionLL1 ::="); }  //$NON-NLS-1$
5358                     consumeInsideCastExpressionLL1();  
5359                         break;
5360  
5361     case 408 : if (DEBUG) { System.out.println("InsideCastExpressionWithQualifiedGenerics ::="); }  //$NON-NLS-1$
5362                     consumeInsideCastExpressionWithQualifiedGenerics();  
5363                         break;
5364  
5365     case 410 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); }  //$NON-NLS-1$
5366                     consumeBinaryExpression(OperatorIds.MULTIPLY);  
5367                         break;
5368  
5369     case 411 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); }  //$NON-NLS-1$
5370                     consumeBinaryExpression(OperatorIds.DIVIDE);  
5371                         break;
5372  
5373     case 412 : if (DEBUG) { System.out.println("MultiplicativeExpression ::= MultiplicativeExpression..."); }  //$NON-NLS-1$
5374                     consumeBinaryExpression(OperatorIds.REMAINDER);  
5375                         break;
5376  
5377     case 414 : if (DEBUG) { System.out.println("AdditiveExpression ::= AdditiveExpression PLUS..."); }  //$NON-NLS-1$
5378                     consumeBinaryExpression(OperatorIds.PLUS);  
5379                         break;
5380  
5381     case 415 : if (DEBUG) { System.out.println("AdditiveExpression ::= AdditiveExpression MINUS..."); }  //$NON-NLS-1$
5382                     consumeBinaryExpression(OperatorIds.MINUS);  
5383                         break;
5384  
5385     case 417 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression LEFT_SHIFT..."); }  //$NON-NLS-1$
5386                     consumeBinaryExpression(OperatorIds.LEFT_SHIFT);  
5387                         break;
5388  
5389     case 418 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression RIGHT_SHIFT..."); }  //$NON-NLS-1$
5390                     consumeBinaryExpression(OperatorIds.RIGHT_SHIFT);  
5391                         break;
5392  
5393     case 419 : if (DEBUG) { System.out.println("ShiftExpression ::= ShiftExpression UNSIGNED_RIGHT_SHIFT"); }  //$NON-NLS-1$
5394                     consumeBinaryExpression(OperatorIds.UNSIGNED_RIGHT_SHIFT);  
5395                         break;
5396  
5397     case 421 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression LESS..."); }  //$NON-NLS-1$
5398                     consumeBinaryExpression(OperatorIds.LESS);  
5399                         break;
5400  
5401     case 422 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression GREATER..."); }  //$NON-NLS-1$
5402                     consumeBinaryExpression(OperatorIds.GREATER);  
5403                         break;
5404  
5405     case 423 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression LESS_EQUAL"); }  //$NON-NLS-1$
5406                     consumeBinaryExpression(OperatorIds.LESS_EQUAL);  
5407                         break;
5408  
5409     case 424 : if (DEBUG) { System.out.println("RelationalExpression ::= RelationalExpression..."); }  //$NON-NLS-1$
5410                     consumeBinaryExpression(OperatorIds.GREATER_EQUAL);  
5411                         break;
5412  
5413     case 426 : if (DEBUG) { System.out.println("InstanceofExpression ::= InstanceofExpression instanceof"); }  //$NON-NLS-1$
5414                     consumeInstanceOfExpression(OperatorIds.INSTANCEOF);  
5415                         break;
5416  
5417     case 428 : if (DEBUG) { System.out.println("EqualityExpression ::= EqualityExpression EQUAL_EQUAL..."); }  //$NON-NLS-1$
5418                     consumeEqualityExpression(OperatorIds.EQUAL_EQUAL);  
5419                         break;
5420  
5421     case 429 : if (DEBUG) { System.out.println("EqualityExpression ::= EqualityExpression NOT_EQUAL..."); }  //$NON-NLS-1$
5422                     consumeEqualityExpression(OperatorIds.NOT_EQUAL);  
5423                         break;
5424  
5425     case 431 : if (DEBUG) { System.out.println("AndExpression ::= AndExpression AND EqualityExpression"); }  //$NON-NLS-1$
5426                     consumeBinaryExpression(OperatorIds.AND);  
5427                         break;
5428  
5429     case 433 : if (DEBUG) { System.out.println("ExclusiveOrExpression ::= ExclusiveOrExpression XOR..."); }  //$NON-NLS-1$
5430                     consumeBinaryExpression(OperatorIds.XOR);  
5431                         break;
5432  
5433     case 435 : if (DEBUG) { System.out.println("InclusiveOrExpression ::= InclusiveOrExpression OR..."); }  //$NON-NLS-1$
5434                     consumeBinaryExpression(OperatorIds.OR);  
5435                         break;
5436  
5437     case 437 : if (DEBUG) { System.out.println("ConditionalAndExpression ::= ConditionalAndExpression..."); }  //$NON-NLS-1$
5438                     consumeBinaryExpression(OperatorIds.AND_AND);  
5439                         break;
5440  
5441     case 439 : if (DEBUG) { System.out.println("ConditionalOrExpression ::= ConditionalOrExpression..."); }  //$NON-NLS-1$
5442                     consumeBinaryExpression(OperatorIds.OR_OR);  
5443                         break;
5444  
5445     case 441 : if (DEBUG) { System.out.println("ConditionalExpression ::= ConditionalOrExpression..."); }  //$NON-NLS-1$
5446                     consumeConditionalExpression(OperatorIds.QUESTIONCOLON) ;  
5447                         break;
5448  
5449     case 444 : if (DEBUG) { System.out.println("Assignment ::= PostfixExpression AssignmentOperator..."); }  //$NON-NLS-1$
5450                     consumeAssignment();  
5451                         break;
5452  
5453     case 446 : if (DEBUG) { System.out.println("Assignment ::= InvalidArrayInitializerAssignement"); }  //$NON-NLS-1$
5454                     ignoreExpressionAssignment(); 
5455                         break;
5456  
5457     case 447 : if (DEBUG) { System.out.println("AssignmentOperator ::= EQUAL"); }  //$NON-NLS-1$
5458                     consumeAssignmentOperator(EQUAL);  
5459                         break;
5460  
5461     case 448 : if (DEBUG) { System.out.println("AssignmentOperator ::= MULTIPLY_EQUAL"); }  //$NON-NLS-1$
5462                     consumeAssignmentOperator(MULTIPLY);  
5463                         break;
5464  
5465     case 449 : if (DEBUG) { System.out.println("AssignmentOperator ::= DIVIDE_EQUAL"); }  //$NON-NLS-1$
5466                     consumeAssignmentOperator(DIVIDE);  
5467                         break;
5468  
5469     case 450 : if (DEBUG) { System.out.println("AssignmentOperator ::= REMAINDER_EQUAL"); }  //$NON-NLS-1$
5470                     consumeAssignmentOperator(REMAINDER);  
5471                         break;
5472  
5473     case 451 : if (DEBUG) { System.out.println("AssignmentOperator ::= PLUS_EQUAL"); }  //$NON-NLS-1$
5474                     consumeAssignmentOperator(PLUS);  
5475                         break;
5476  
5477     case 452 : if (DEBUG) { System.out.println("AssignmentOperator ::= MINUS_EQUAL"); }  //$NON-NLS-1$
5478                     consumeAssignmentOperator(MINUS);  
5479                         break;
5480  
5481     case 453 : if (DEBUG) { System.out.println("AssignmentOperator ::= LEFT_SHIFT_EQUAL"); }  //$NON-NLS-1$
5482                     consumeAssignmentOperator(LEFT_SHIFT);  
5483                         break;
5484  
5485     case 454 : if (DEBUG) { System.out.println("AssignmentOperator ::= RIGHT_SHIFT_EQUAL"); }  //$NON-NLS-1$
5486                     consumeAssignmentOperator(RIGHT_SHIFT);  
5487                         break;
5488  
5489     case 455 : if (DEBUG) { System.out.println("AssignmentOperator ::= UNSIGNED_RIGHT_SHIFT_EQUAL"); }  //$NON-NLS-1$
5490                     consumeAssignmentOperator(UNSIGNED_RIGHT_SHIFT);  
5491                         break;
5492  
5493     case 456 : if (DEBUG) { System.out.println("AssignmentOperator ::= AND_EQUAL"); }  //$NON-NLS-1$
5494                     consumeAssignmentOperator(AND);  
5495                         break;
5496  
5497     case 457 : if (DEBUG) { System.out.println("AssignmentOperator ::= XOR_EQUAL"); }  //$NON-NLS-1$
5498                     consumeAssignmentOperator(XOR);  
5499                         break;
5500  
5501     case 458 : if (DEBUG) { System.out.println("AssignmentOperator ::= OR_EQUAL"); }  //$NON-NLS-1$
5502                     consumeAssignmentOperator(OR);  
5503                         break;
5504  
5505     case 462 : if (DEBUG) { System.out.println("Expressionopt ::="); }  //$NON-NLS-1$
5506                     consumeEmptyExpression();  
5507                         break;
5508  
5509     case 467 : if (DEBUG) { System.out.println("ClassBodyDeclarationsopt ::="); }  //$NON-NLS-1$
5510                     consumeEmptyClassBodyDeclarationsopt();  
5511                         break;
5512  
5513     case 468 : if (DEBUG) { System.out.println("ClassBodyDeclarationsopt ::= NestedType..."); }  //$NON-NLS-1$
5514                     consumeClassBodyDeclarationsopt();  
5515                         break;
5516  
5517      case 469 : if (DEBUG) { System.out.println("Modifiersopt ::="); }  //$NON-NLS-1$
5518                     consumeDefaultModifiers();  
5519                         break;
5520  
5521     case 470 : if (DEBUG) { System.out.println("Modifiersopt ::= Modifiers"); }  //$NON-NLS-1$
5522                     consumeModifiers();  
5523                         break;
5524  
5525     case 471 : if (DEBUG) { System.out.println("BlockStatementsopt ::="); }  //$NON-NLS-1$
5526                     consumeEmptyBlockStatementsopt();  
5527                         break;
5528  
5529      case 473 : if (DEBUG) { System.out.println("Dimsopt ::="); }  //$NON-NLS-1$
5530                     consumeEmptyDimsopt();  
5531                         break;
5532  
5533      case 475 : if (DEBUG) { System.out.println("ArgumentListopt ::="); }  //$NON-NLS-1$
5534                     consumeEmptyArgumentListopt();  
5535                         break;
5536  
5537     case 479 : if (DEBUG) { System.out.println("FormalParameterListopt ::="); }  //$NON-NLS-1$
5538                     consumeFormalParameterListopt();  
5539                         break;
5540  
5541      case 483 : if (DEBUG) { System.out.println("InterfaceMemberDeclarationsopt ::="); }  //$NON-NLS-1$
5542                     consumeEmptyInterfaceMemberDeclarationsopt();  
5543                         break;
5544  
5545      case 484 : if (DEBUG) { System.out.println("InterfaceMemberDeclarationsopt ::= NestedType..."); }  //$NON-NLS-1$
5546                     consumeInterfaceMemberDeclarationsopt();  
5547                         break;
5548  
5549     case 485 : if (DEBUG) { System.out.println("NestedType ::="); }  //$NON-NLS-1$
5550                     consumeNestedType();  
5551                         break;
5552
5553      case 486 : if (DEBUG) { System.out.println("ForInitopt ::="); }  //$NON-NLS-1$
5554                     consumeEmptyForInitopt();  
5555                         break;
5556  
5557      case 488 : if (DEBUG) { System.out.println("ForUpdateopt ::="); }  //$NON-NLS-1$
5558                     consumeEmptyForUpdateopt();  
5559                         break;
5560  
5561      case 492 : if (DEBUG) { System.out.println("Catchesopt ::="); }  //$NON-NLS-1$
5562                     consumeEmptyCatchesopt();  
5563                         break;
5564  
5565      case 494 : if (DEBUG) { System.out.println("EnumDeclaration ::= EnumHeader EnumBody"); }  //$NON-NLS-1$
5566                     consumeEnumDeclaration();  
5567                         break;
5568  
5569      case 495 : if (DEBUG) { System.out.println("EnumHeader ::= EnumHeaderName ClassHeaderImplementsopt"); }  //$NON-NLS-1$
5570                     consumeEnumHeader();  
5571                         break;
5572  
5573      case 496 : if (DEBUG) { System.out.println("EnumHeaderName ::= Modifiersopt enum Identifier"); }  //$NON-NLS-1$
5574                     consumeEnumHeaderName();  
5575                         break;
5576  
5577      case 497 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumBodyDeclarationsopt RBRACE"); }  //$NON-NLS-1$
5578                     consumeEnumBodyNoConstants();  
5579                         break;
5580  
5581      case 498 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE COMMA EnumBodyDeclarationsopt..."); }  //$NON-NLS-1$
5582                     consumeEnumBodyNoConstants();  
5583                         break;
5584  
5585      case 499 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumConstants COMMA..."); }  //$NON-NLS-1$
5586                     consumeEnumBodyWithConstants();  
5587                         break;
5588  
5589      case 500 : if (DEBUG) { System.out.println("EnumBody ::= LBRACE EnumConstants..."); }  //$NON-NLS-1$
5590                     consumeEnumBodyWithConstants();  
5591                         break;
5592  
5593     case 502 : if (DEBUG) { System.out.println("EnumConstants ::= EnumConstants COMMA EnumConstant"); }  //$NON-NLS-1$
5594                     consumeEnumConstants();  
5595                         break;
5596  
5597     case 503 : if (DEBUG) { System.out.println("EnumConstantHeaderName ::= Modifiersopt Identifier"); }  //$NON-NLS-1$
5598                     consumeEnumConstantHeaderName();  
5599                         break;
5600  
5601     case 504 : if (DEBUG) { System.out.println("EnumConstantHeader ::= EnumConstantHeaderName..."); }  //$NON-NLS-1$
5602                     consumeEnumConstantHeader();  
5603                         break;
5604  
5605     case 505 : if (DEBUG) { System.out.println("EnumConstant ::= EnumConstantHeader ForceNoDiet..."); }  //$NON-NLS-1$
5606                     consumeEnumConstantWithClassBody();  
5607                         break;
5608  
5609     case 506 : if (DEBUG) { System.out.println("EnumConstant ::= EnumConstantHeader"); }  //$NON-NLS-1$
5610                     consumeEnumConstantNoClassBody();  
5611                         break;
5612  
5613     case 507 : if (DEBUG) { System.out.println("Arguments ::= LPAREN ArgumentListopt RPAREN"); }  //$NON-NLS-1$
5614                     consumeArguments();  
5615                         break;
5616  
5617     case 508 : if (DEBUG) { System.out.println("Argumentsopt ::="); }  //$NON-NLS-1$
5618                     consumeEmptyArguments();  
5619                         break;
5620  
5621     case 510 : if (DEBUG) { System.out.println("EnumDeclarations ::= SEMICOLON ClassBodyDeclarationsopt"); }  //$NON-NLS-1$
5622                     consumeEnumDeclarations();  
5623                         break;
5624  
5625     case 511 : if (DEBUG) { System.out.println("EnumBodyDeclarationsopt ::="); }  //$NON-NLS-1$
5626                     consumeEmptyEnumDeclarations();  
5627                         break;
5628  
5629     case 513 : if (DEBUG) { System.out.println("EnhancedForStatement ::= EnhancedForStatementHeader..."); }  //$NON-NLS-1$
5630                     consumeEnhancedForStatement();  
5631                         break;
5632  
5633     case 514 : if (DEBUG) { System.out.println("EnhancedForStatementNoShortIf ::=..."); }  //$NON-NLS-1$
5634                     consumeEnhancedForStatement();  
5635                         break;
5636  
5637     case 515 : if (DEBUG) { System.out.println("EnhancedForStatementHeader ::= for LPAREN Type..."); }  //$NON-NLS-1$
5638                     consumeEnhancedForStatementHeader(false);  
5639                         break;
5640  
5641     case 516 : if (DEBUG) { System.out.println("EnhancedForStatementHeader ::= for LPAREN Modifiers Type"); }  //$NON-NLS-1$
5642                     consumeEnhancedForStatementHeader(true);  
5643                         break;
5644  
5645     case 517 : if (DEBUG) { System.out.println("SingleStaticImportDeclaration ::=..."); }  //$NON-NLS-1$
5646                     consumeImportDeclaration();  
5647                         break;
5648  
5649     case 518 : if (DEBUG) { System.out.println("SingleStaticImportDeclarationName ::= import static Name"); }  //$NON-NLS-1$
5650                     consumeSingleStaticImportDeclarationName();  
5651                         break;
5652  
5653     case 519 : if (DEBUG) { System.out.println("StaticImportOnDemandDeclaration ::=..."); }  //$NON-NLS-1$
5654                     consumeImportDeclaration();  
5655                         break;
5656  
5657     case 520 : if (DEBUG) { System.out.println("StaticImportOnDemandDeclarationName ::= import static..."); }  //$NON-NLS-1$
5658                     consumeStaticImportOnDemandDeclarationName();  
5659                         break;
5660  
5661     case 521 : if (DEBUG) { System.out.println("TypeArguments ::= LESS TypeArgumentList1"); }  //$NON-NLS-1$
5662                     consumeTypeArguments();  
5663                         break;
5664  
5665     case 522 : if (DEBUG) { System.out.println("OnlyTypeArguments ::= LESS TypeArgumentList1"); }  //$NON-NLS-1$
5666                     consumeOnlyTypeArguments();  
5667                         break;
5668  
5669     case 524 : if (DEBUG) { System.out.println("TypeArgumentList1 ::= TypeArgumentList COMMA..."); }  //$NON-NLS-1$
5670                     consumeTypeArgumentList1();  
5671                         break;
5672  
5673     case 526 : if (DEBUG) { System.out.println("TypeArgumentList ::= TypeArgumentList COMMA TypeArgument"); }  //$NON-NLS-1$
5674                     consumeTypeArgumentList();  
5675                         break;
5676  
5677     case 527 : if (DEBUG) { System.out.println("TypeArgument ::= ReferenceType"); }  //$NON-NLS-1$
5678                     consumeTypeArgument();  
5679                         break;
5680  
5681     case 531 : if (DEBUG) { System.out.println("ReferenceType1 ::= ReferenceType GREATER"); }  //$NON-NLS-1$
5682                     consumeReferenceType1();  
5683                         break;
5684  
5685     case 532 : if (DEBUG) { System.out.println("ReferenceType1 ::= ClassOrInterface LESS..."); }  //$NON-NLS-1$
5686                     consumeTypeArgumentReferenceType1();  
5687                         break;
5688  
5689     case 534 : if (DEBUG) { System.out.println("TypeArgumentList2 ::= TypeArgumentList COMMA..."); }  //$NON-NLS-1$
5690                     consumeTypeArgumentList2();  
5691                         break;
5692  
5693     case 537 : if (DEBUG) { System.out.println("ReferenceType2 ::= ReferenceType RIGHT_SHIFT"); }  //$NON-NLS-1$
5694                     consumeReferenceType2();  
5695                         break;
5696  
5697     case 538 : if (DEBUG) { System.out.println("ReferenceType2 ::= ClassOrInterface LESS..."); }  //$NON-NLS-1$
5698                     consumeTypeArgumentReferenceType2();  
5699                         break;
5700  
5701     case 540 : if (DEBUG) { System.out.println("TypeArgumentList3 ::= TypeArgumentList COMMA..."); }  //$NON-NLS-1$
5702                     consumeTypeArgumentList3();  
5703                         break;
5704  
5705     case 543 : if (DEBUG) { System.out.println("ReferenceType3 ::= ReferenceType UNSIGNED_RIGHT_SHIFT"); }  //$NON-NLS-1$
5706                     consumeReferenceType3();  
5707                         break;
5708  
5709     case 544 : if (DEBUG) { System.out.println("Wildcard ::= QUESTION"); }  //$NON-NLS-1$
5710                     consumeWildcard();  
5711                         break;
5712  
5713     case 545 : if (DEBUG) { System.out.println("Wildcard ::= QUESTION WildcardBounds"); }  //$NON-NLS-1$
5714                     consumeWildcardWithBounds();  
5715                         break;
5716  
5717     case 546 : if (DEBUG) { System.out.println("WildcardBounds ::= extends ReferenceType"); }  //$NON-NLS-1$
5718                     consumeWildcardBoundsExtends();  
5719                         break;
5720  
5721     case 547 : if (DEBUG) { System.out.println("WildcardBounds ::= super ReferenceType"); }  //$NON-NLS-1$
5722                     consumeWildcardBoundsSuper();  
5723                         break;
5724  
5725     case 548 : if (DEBUG) { System.out.println("Wildcard1 ::= QUESTION GREATER"); }  //$NON-NLS-1$
5726                     consumeWildcard1();  
5727                         break;
5728  
5729     case 549 : if (DEBUG) { System.out.println("Wildcard1 ::= QUESTION WildcardBounds1"); }  //$NON-NLS-1$
5730                     consumeWildcard1WithBounds();  
5731                         break;
5732  
5733     case 550 : if (DEBUG) { System.out.println("WildcardBounds1 ::= extends ReferenceType1"); }  //$NON-NLS-1$
5734                     consumeWildcardBounds1Extends();  
5735                         break;
5736  
5737     case 551 : if (DEBUG) { System.out.println("WildcardBounds1 ::= super ReferenceType1"); }  //$NON-NLS-1$
5738                     consumeWildcardBounds1Super();  
5739                         break;
5740  
5741     case 552 : if (DEBUG) { System.out.println("Wildcard2 ::= QUESTION RIGHT_SHIFT"); }  //$NON-NLS-1$
5742                     consumeWildcard2();  
5743                         break;
5744  
5745     case 553 : if (DEBUG) { System.out.println("Wildcard2 ::= QUESTION WildcardBounds2"); }  //$NON-NLS-1$
5746                     consumeWildcard2WithBounds();  
5747                         break;
5748  
5749     case 554 : if (DEBUG) { System.out.println("WildcardBounds2 ::= extends ReferenceType2"); }  //$NON-NLS-1$
5750                     consumeWildcardBounds2Extends();  
5751                         break;
5752  
5753     case 555 : if (DEBUG) { System.out.println("WildcardBounds2 ::= super ReferenceType2"); }  //$NON-NLS-1$
5754                     consumeWildcardBounds2Super();  
5755                         break;
5756  
5757     case 556 : if (DEBUG) { System.out.println("Wildcard3 ::= QUESTION UNSIGNED_RIGHT_SHIFT"); }  //$NON-NLS-1$
5758                     consumeWildcard3();  
5759                         break;
5760  
5761     case 557 : if (DEBUG) { System.out.println("Wildcard3 ::= QUESTION WildcardBounds3"); }  //$NON-NLS-1$
5762                     consumeWildcard3WithBounds();  
5763                         break;
5764  
5765     case 558 : if (DEBUG) { System.out.println("WildcardBounds3 ::= extends ReferenceType3"); }  //$NON-NLS-1$
5766                     consumeWildcardBounds3Extends();  
5767                         break;
5768  
5769     case 559 : if (DEBUG) { System.out.println("WildcardBounds3 ::= super ReferenceType3"); }  //$NON-NLS-1$
5770                     consumeWildcardBounds3Super();  
5771                         break;
5772  
5773     case 560 : if (DEBUG) { System.out.println("TypeParameterHeader ::= Identifier"); }  //$NON-NLS-1$
5774                     consumeTypeParameterHeader();  
5775                         break;
5776  
5777     case 561 : if (DEBUG) { System.out.println("TypeParameters ::= LESS TypeParameterList1"); }  //$NON-NLS-1$
5778                     consumeTypeParameters();  
5779                         break;
5780  
5781     case 563 : if (DEBUG) { System.out.println("TypeParameterList ::= TypeParameterList COMMA..."); }  //$NON-NLS-1$
5782                     consumeTypeParameterList();  
5783                         break;
5784  
5785     case 565 : if (DEBUG) { System.out.println("TypeParameter ::= TypeParameterHeader extends..."); }  //$NON-NLS-1$
5786                     consumeTypeParameterWithExtends();  
5787                         break;
5788  
5789     case 566 : if (DEBUG) { System.out.println("TypeParameter ::= TypeParameterHeader extends..."); }  //$NON-NLS-1$
5790                     consumeTypeParameterWithExtendsAndBounds();  
5791                         break;
5792  
5793     case 568 : if (DEBUG) { System.out.println("AdditionalBoundList ::= AdditionalBoundList..."); }  //$NON-NLS-1$
5794                     consumeAdditionalBoundList();  
5795                         break;
5796  
5797     case 569 : if (DEBUG) { System.out.println("AdditionalBound ::= AND ReferenceType"); }  //$NON-NLS-1$
5798                     consumeAdditionalBound();  
5799                         break;
5800  
5801     case 571 : if (DEBUG) { System.out.println("TypeParameterList1 ::= TypeParameterList COMMA..."); }  //$NON-NLS-1$
5802                     consumeTypeParameterList1();  
5803                         break;
5804  
5805     case 572 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader GREATER"); }  //$NON-NLS-1$
5806                     consumeTypeParameter1();  
5807                         break;
5808  
5809     case 573 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader extends..."); }  //$NON-NLS-1$
5810                     consumeTypeParameter1WithExtends();  
5811                         break;
5812  
5813     case 574 : if (DEBUG) { System.out.println("TypeParameter1 ::= TypeParameterHeader extends..."); }  //$NON-NLS-1$
5814                     consumeTypeParameter1WithExtendsAndBounds();  
5815                         break;
5816  
5817     case 576 : if (DEBUG) { System.out.println("AdditionalBoundList1 ::= AdditionalBoundList..."); }  //$NON-NLS-1$
5818                     consumeAdditionalBoundList1();  
5819                         break;
5820  
5821     case 577 : if (DEBUG) { System.out.println("AdditionalBound1 ::= AND ReferenceType1"); }  //$NON-NLS-1$
5822                     consumeAdditionalBound1();  
5823                         break;
5824  
5825     case 583 : if (DEBUG) { System.out.println("UnaryExpression_NotName ::= PLUS PushPosition..."); }  //$NON-NLS-1$
5826                     consumeUnaryExpression(OperatorIds.PLUS);  
5827                         break;
5828  
5829     case 584 : if (DEBUG) { System.out.println("UnaryExpression_NotName ::= MINUS PushPosition..."); }  //$NON-NLS-1$
5830                     consumeUnaryExpression(OperatorIds.MINUS);  
5831                         break;
5832  
5833     case 587 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus_NotName ::= TWIDDLE..."); }  //$NON-NLS-1$
5834                     consumeUnaryExpression(OperatorIds.TWIDDLE);  
5835                         break;
5836  
5837     case 588 : if (DEBUG) { System.out.println("UnaryExpressionNotPlusMinus_NotName ::= NOT PushPosition"); }  //$NON-NLS-1$
5838                     consumeUnaryExpression(OperatorIds.NOT);  
5839                         break;
5840  
5841     case 591 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); }  //$NON-NLS-1$
5842                     consumeBinaryExpression(OperatorIds.MULTIPLY);  
5843                         break;
5844  
5845     case 592 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name MULTIPLY..."); }  //$NON-NLS-1$
5846                     consumeBinaryExpressionWithName(OperatorIds.MULTIPLY);  
5847                         break;
5848  
5849     case 593 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); }  //$NON-NLS-1$
5850                     consumeBinaryExpression(OperatorIds.DIVIDE);  
5851                         break;
5852  
5853     case 594 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name DIVIDE..."); }  //$NON-NLS-1$
5854                     consumeBinaryExpressionWithName(OperatorIds.DIVIDE);  
5855                         break;
5856  
5857     case 595 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::=..."); }  //$NON-NLS-1$
5858                     consumeBinaryExpression(OperatorIds.REMAINDER);  
5859                         break;
5860  
5861     case 596 : if (DEBUG) { System.out.println("MultiplicativeExpression_NotName ::= Name REMAINDER..."); }  //$NON-NLS-1$
5862                     consumeBinaryExpressionWithName(OperatorIds.REMAINDER);  
5863                         break;
5864  
5865     case 598 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::=..."); }  //$NON-NLS-1$
5866                     consumeBinaryExpression(OperatorIds.PLUS);  
5867                         break;
5868  
5869     case 599 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::= Name PLUS..."); }  //$NON-NLS-1$
5870                     consumeBinaryExpressionWithName(OperatorIds.PLUS);  
5871                         break;
5872  
5873     case 600 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::=..."); }  //$NON-NLS-1$
5874                     consumeBinaryExpression(OperatorIds.MINUS);  
5875                         break;
5876  
5877     case 601 : if (DEBUG) { System.out.println("AdditiveExpression_NotName ::= Name MINUS..."); }  //$NON-NLS-1$
5878                     consumeBinaryExpressionWithName(OperatorIds.MINUS);  
5879                         break;
5880  
5881     case 603 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); }  //$NON-NLS-1$
5882                     consumeBinaryExpression(OperatorIds.LEFT_SHIFT);  
5883                         break;
5884  
5885     case 604 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name LEFT_SHIFT..."); }  //$NON-NLS-1$
5886                     consumeBinaryExpressionWithName(OperatorIds.LEFT_SHIFT);  
5887                         break;
5888  
5889     case 605 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); }  //$NON-NLS-1$
5890                     consumeBinaryExpression(OperatorIds.RIGHT_SHIFT);  
5891                         break;
5892  
5893     case 606 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name RIGHT_SHIFT..."); }  //$NON-NLS-1$
5894                     consumeBinaryExpressionWithName(OperatorIds.RIGHT_SHIFT);  
5895                         break;
5896  
5897     case 607 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= ShiftExpression_NotName..."); }  //$NON-NLS-1$
5898                     consumeBinaryExpression(OperatorIds.UNSIGNED_RIGHT_SHIFT);  
5899                         break;
5900  
5901     case 608 : if (DEBUG) { System.out.println("ShiftExpression_NotName ::= Name UNSIGNED_RIGHT_SHIFT..."); }  //$NON-NLS-1$
5902                     consumeBinaryExpressionWithName(OperatorIds.UNSIGNED_RIGHT_SHIFT);  
5903                         break;
5904  
5905     case 610 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= ShiftExpression_NotName"); }  //$NON-NLS-1$
5906                     consumeBinaryExpression(OperatorIds.LESS);  
5907                         break;
5908  
5909     case 611 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name LESS..."); }  //$NON-NLS-1$
5910                     consumeBinaryExpressionWithName(OperatorIds.LESS);  
5911                         break;
5912  
5913     case 612 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= ShiftExpression_NotName"); }  //$NON-NLS-1$
5914                     consumeBinaryExpression(OperatorIds.GREATER);  
5915                         break;
5916  
5917     case 613 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name GREATER..."); }  //$NON-NLS-1$
5918                     consumeBinaryExpressionWithName(OperatorIds.GREATER);  
5919                         break;
5920  
5921     case 614 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::=..."); }  //$NON-NLS-1$
5922                     consumeBinaryExpression(OperatorIds.LESS_EQUAL);  
5923                         break;
5924  
5925     case 615 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name LESS_EQUAL..."); }  //$NON-NLS-1$
5926                     consumeBinaryExpressionWithName(OperatorIds.LESS_EQUAL);  
5927                         break;
5928  
5929     case 616 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::=..."); }  //$NON-NLS-1$
5930                     consumeBinaryExpression(OperatorIds.GREATER_EQUAL);  
5931                         break;
5932  
5933     case 617 : if (DEBUG) { System.out.println("RelationalExpression_NotName ::= Name GREATER_EQUAL..."); }  //$NON-NLS-1$
5934                     consumeBinaryExpressionWithName(OperatorIds.GREATER_EQUAL);  
5935                         break;
5936  
5937     case 619 : if (DEBUG) { System.out.println("InstanceofExpression_NotName ::= Name instanceof..."); }  //$NON-NLS-1$
5938                     consumeInstanceOfExpressionWithName(OperatorIds.INSTANCEOF);  
5939                         break;
5940  
5941     case 620 : if (DEBUG) { System.out.println("InstanceofExpression_NotName ::=..."); }  //$NON-NLS-1$
5942                     consumeInstanceOfExpression(OperatorIds.INSTANCEOF);  
5943                         break;
5944  
5945     case 622 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::=..."); }  //$NON-NLS-1$
5946                     consumeEqualityExpression(OperatorIds.EQUAL_EQUAL);  
5947                         break;
5948  
5949     case 623 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::= Name EQUAL_EQUAL..."); }  //$NON-NLS-1$
5950                     consumeEqualityExpressionWithName(OperatorIds.EQUAL_EQUAL);  
5951                         break;
5952  
5953     case 624 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::=..."); }  //$NON-NLS-1$
5954                     consumeEqualityExpression(OperatorIds.NOT_EQUAL);  
5955                         break;
5956  
5957     case 625 : if (DEBUG) { System.out.println("EqualityExpression_NotName ::= Name NOT_EQUAL..."); }  //$NON-NLS-1$
5958                     consumeEqualityExpressionWithName(OperatorIds.NOT_EQUAL);  
5959                         break;
5960  
5961     case 627 : if (DEBUG) { System.out.println("AndExpression_NotName ::= AndExpression_NotName AND..."); }  //$NON-NLS-1$
5962                     consumeBinaryExpression(OperatorIds.AND);  
5963                         break;
5964  
5965     case 628 : if (DEBUG) { System.out.println("AndExpression_NotName ::= Name AND EqualityExpression"); }  //$NON-NLS-1$
5966                     consumeBinaryExpressionWithName(OperatorIds.AND);  
5967                         break;
5968  
5969     case 630 : if (DEBUG) { System.out.println("ExclusiveOrExpression_NotName ::=..."); }  //$NON-NLS-1$
5970                     consumeBinaryExpression(OperatorIds.XOR);  
5971                         break;
5972  
5973     case 631 : if (DEBUG) { System.out.println("ExclusiveOrExpression_NotName ::= Name XOR AndExpression"); }  //$NON-NLS-1$
5974                     consumeBinaryExpressionWithName(OperatorIds.XOR);  
5975                         break;
5976  
5977     case 633 : if (DEBUG) { System.out.println("InclusiveOrExpression_NotName ::=..."); }  //$NON-NLS-1$
5978                     consumeBinaryExpression(OperatorIds.OR);  
5979                         break;
5980  
5981     case 634 : if (DEBUG) { System.out.println("InclusiveOrExpression_NotName ::= Name OR..."); }  //$NON-NLS-1$
5982                     consumeBinaryExpressionWithName(OperatorIds.OR);  
5983                         break;
5984  
5985     case 636 : if (DEBUG) { System.out.println("ConditionalAndExpression_NotName ::=..."); }  //$NON-NLS-1$
5986                     consumeBinaryExpression(OperatorIds.AND_AND);  
5987                         break;
5988  
5989     case 637 : if (DEBUG) { System.out.println("ConditionalAndExpression_NotName ::= Name AND_AND..."); }  //$NON-NLS-1$
5990                     consumeBinaryExpressionWithName(OperatorIds.AND_AND);  
5991                         break;
5992  
5993     case 639 : if (DEBUG) { System.out.println("ConditionalOrExpression_NotName ::=..."); }  //$NON-NLS-1$
5994                     consumeBinaryExpression(OperatorIds.OR_OR);  
5995                         break;
5996  
5997     case 640 : if (DEBUG) { System.out.println("ConditionalOrExpression_NotName ::= Name OR_OR..."); }  //$NON-NLS-1$
5998                     consumeBinaryExpressionWithName(OperatorIds.OR_OR);  
5999                         break;
6000  
6001     case 642 : if (DEBUG) { System.out.println("ConditionalExpression_NotName ::=..."); }  //$NON-NLS-1$
6002                     consumeConditionalExpression(OperatorIds.QUESTIONCOLON) ;  
6003                         break;
6004  
6005     case 643 : if (DEBUG) { System.out.println("ConditionalExpression_NotName ::= Name QUESTION..."); }  //$NON-NLS-1$
6006                     consumeConditionalExpressionWithName(OperatorIds.QUESTIONCOLON) ;  
6007                         break;
6008  
6009     case 647 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= Modifiers AT..."); }  //$NON-NLS-1$
6010                     consumeAnnotationTypeDeclarationHeaderName() ;  
6011                         break;
6012  
6013     case 648 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeaderName ::= AT..."); }  //$NON-NLS-1$
6014                     consumeAnnotationTypeDeclarationHeaderName() ;  
6015                         break;
6016  
6017     case 649 : if (DEBUG) { System.out.println("AnnotationTypeDeclarationHeader ::=..."); }  //$NON-NLS-1$
6018                     consumeAnnotationTypeDeclarationHeader() ;  
6019                         break;
6020  
6021     case 650 : if (DEBUG) { System.out.println("AnnotationTypeDeclaration ::=..."); }  //$NON-NLS-1$
6022                     consumeAnnotationTypeDeclaration() ;  
6023                         break;
6024  
6025     case 652 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarationsopt ::="); }  //$NON-NLS-1$
6026                     consumeEmptyAnnotationTypeMemberDeclarationsopt() ;  
6027                         break;
6028  
6029     case 655 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclarations ::=..."); }  //$NON-NLS-1$
6030                     consumeAnnotationTypeMemberDeclarations() ;  
6031                         break;
6032  
6033     case 656 : if (DEBUG) { System.out.println("AnnotationMethodHeaderName ::= Modifiersopt..."); }  //$NON-NLS-1$
6034                     consumeMethodHeaderNameWithTypeParameters(true);  
6035                         break;
6036  
6037     case 657 : if (DEBUG) { System.out.println("AnnotationMethodHeaderName ::= Modifiersopt Type..."); }  //$NON-NLS-1$
6038                     consumeMethodHeaderName(true);  
6039                         break;
6040  
6041     case 658 : if (DEBUG) { System.out.println("AnnotationMethodHeaderDefaultValueopt ::="); }  //$NON-NLS-1$
6042                     consumeEmptyMethodHeaderDefaultValue() ;  
6043                         break;
6044  
6045     case 659 : if (DEBUG) { System.out.println("AnnotationMethodHeaderDefaultValueopt ::= DefaultValue"); }  //$NON-NLS-1$
6046                     consumeMethodHeaderDefaultValue();  
6047                         break;
6048  
6049     case 660 : if (DEBUG) { System.out.println("AnnotationMethodHeader ::= AnnotationMethodHeaderName..."); }  //$NON-NLS-1$
6050                     consumeMethodHeader();  
6051                         break;
6052  
6053     case 661 : if (DEBUG) { System.out.println("AnnotationTypeMemberDeclaration ::=..."); }  //$NON-NLS-1$
6054                     consumeAnnotationTypeMemberDeclaration() ;  
6055                         break;
6056  
6057     case 669 : if (DEBUG) { System.out.println("AnnotationName ::= AT Name"); }  //$NON-NLS-1$
6058                     consumeAnnotationName() ;  
6059                         break;
6060  
6061     case 670 : if (DEBUG) { System.out.println("NormalAnnotation ::= AnnotationName LPAREN..."); }  //$NON-NLS-1$
6062                     consumeNormalAnnotation() ;  
6063                         break;
6064  
6065     case 671 : if (DEBUG) { System.out.println("MemberValuePairsopt ::="); }  //$NON-NLS-1$
6066                     consumeEmptyMemberValuePairsopt() ;  
6067                         break;
6068  
6069     case 674 : if (DEBUG) { System.out.println("MemberValuePairs ::= MemberValuePairs COMMA..."); }  //$NON-NLS-1$
6070                     consumeMemberValuePairs() ;  
6071                         break;
6072  
6073     case 675 : if (DEBUG) { System.out.println("MemberValuePair ::= SimpleName EQUAL MemberValue"); }  //$NON-NLS-1$
6074                     consumeMemberValuePair() ;  
6075                         break;
6076  
6077     case 677 : if (DEBUG) { System.out.println("MemberValue ::= Name"); }  //$NON-NLS-1$
6078                     consumeMemberValueAsName() ;  
6079                         break;
6080  
6081     case 680 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::= LBRACE PushLeftBrace..."); }  //$NON-NLS-1$
6082                     consumeMemberValueArrayInitializer() ;  
6083                         break;
6084  
6085     case 681 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::= LBRACE PushLeftBrace..."); }  //$NON-NLS-1$
6086                     consumeMemberValueArrayInitializer() ;  
6087                         break;
6088  
6089     case 682 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::= LBRACE PushLeftBrace..."); }  //$NON-NLS-1$
6090                     consumeEmptyMemberValueArrayInitializer() ;  
6091                         break;
6092  
6093     case 683 : if (DEBUG) { System.out.println("MemberValueArrayInitializer ::= LBRACE PushLeftBrace..."); }  //$NON-NLS-1$
6094                     consumeEmptyMemberValueArrayInitializer() ;  
6095                         break;
6096  
6097     case 685 : if (DEBUG) { System.out.println("MemberValues ::= MemberValues COMMA MemberValue"); }  //$NON-NLS-1$
6098                     consumeMemberValues() ;  
6099                         break;
6100  
6101     case 686 : if (DEBUG) { System.out.println("MarkerAnnotation ::= AnnotationName"); }  //$NON-NLS-1$
6102                     consumeMarkerAnnotation() ;  
6103                         break;
6104  
6105     case 687 : if (DEBUG) { System.out.println("SingleMemberAnnotation ::= AnnotationName LPAREN..."); }  //$NON-NLS-1$
6106                     consumeSingleMemberAnnotation() ;  
6107                         break;
6108  
6109     case 688 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= Modifiersopt TypeParameters"); }  //$NON-NLS-1$
6110                     consumeRecoveryMethodHeaderNameWithTypeParameters();  
6111                         break;
6112  
6113     case 689 : if (DEBUG) { System.out.println("RecoveryMethodHeaderName ::= Modifiersopt Type..."); }  //$NON-NLS-1$
6114                     consumeRecoveryMethodHeaderName();  
6115                         break;
6116  
6117     case 690 : if (DEBUG) { System.out.println("RecoveryMethodHeader ::= RecoveryMethodHeaderName..."); }  //$NON-NLS-1$
6118                     consumeMethodHeader();  
6119                         break;
6120  
6121     case 691 : if (DEBUG) { System.out.println("RecoveryMethodHeader ::= RecoveryMethodHeaderName..."); }  //$NON-NLS-1$
6122                     consumeMethodHeader();  
6123                         break;
6124  
6125         }
6126
6127 protected void consumeSimpleAssertStatement() {
6128         // AssertStatement ::= 'assert' Expression ';'
6129         this.expressionLengthPtr--;
6130         pushOnAstStack(new AssertStatement(this.expressionStack[this.expressionPtr--], this.intStack[this.intPtr--]));  
6131 }
6132 protected void consumeSingleMemberAnnotation() {
6133         // SingleMemberAnnotation ::= '@' Name '(' MemberValue ')'
6134         SingleMemberAnnotation singleMemberAnnotation = null;
6135         int length = this.identifierLengthStack[this.identifierLengthPtr--];
6136         TypeReference typeReference;
6137         if (length == 1) {
6138                 typeReference = new SingleTypeReference(
6139                                 this.identifierStack[this.identifierPtr], 
6140                                 this.identifierPositionStack[this.identifierPtr--]);
6141         } else {
6142                 char[][] tokens = new char[length][];
6143                 this.identifierPtr -= length;
6144                 long[] positions = new long[length];
6145                 System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
6146                 System.arraycopy(
6147                         this.identifierPositionStack, 
6148                         this.identifierPtr + 1, 
6149                         positions, 
6150                         0, 
6151                         length);
6152                 typeReference = new QualifiedTypeReference(tokens, positions);
6153         }
6154         singleMemberAnnotation = new SingleMemberAnnotation(typeReference, this.intStack[this.intPtr--]);
6155         singleMemberAnnotation.memberValue = this.expressionStack[this.expressionPtr--];
6156         this.expressionLengthPtr--;
6157         int sourceStart = singleMemberAnnotation.sourceStart;
6158         if (this.modifiersSourceStart < 0) {
6159                 this.modifiersSourceStart = sourceStart;
6160         } else if (this.modifiersSourceStart > sourceStart) {
6161                 this.modifiersSourceStart = sourceStart;
6162         }
6163         singleMemberAnnotation.declarationSourceEnd = this.rParenPos;
6164         pushOnExpressionStack(singleMemberAnnotation);
6165         if(options.sourceLevel < ClassFileConstants.JDK1_5 &&
6166                         this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
6167                 this.problemReporter().invalidUsageOfAnnotation(singleMemberAnnotation);
6168         }
6169 }
6170 protected void consumeSingleStaticImportDeclarationName() {
6171         // SingleTypeImportDeclarationName ::= 'import' 'static' Name
6172         /* push an ImportRef build from the last name 
6173         stored in the identifier stack. */
6174
6175         ImportReference impt;
6176         int length;
6177         char[][] tokens = new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
6178         this.identifierPtr -= length;
6179         long[] positions = new long[length];
6180         System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
6181         System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
6182         pushOnAstStack(impt = new ImportReference(tokens, positions, false, AccStatic));
6183
6184         this.modifiers = AccDefault;
6185         this.modifiersSourceStart = -1; // <-- see comment into modifiersFlag(int)
6186         
6187         if (this.currentToken == TokenNameSEMICOLON){
6188                 impt.declarationSourceEnd = this.scanner.currentPosition - 1;
6189         } else {
6190                 impt.declarationSourceEnd = impt.sourceEnd;
6191         }
6192         impt.declarationEnd = impt.declarationSourceEnd;
6193         //this.endPosition is just before the ;
6194         impt.declarationSourceStart = this.intStack[this.intPtr--];
6195
6196         if(this.options.sourceLevel < ClassFileConstants.JDK1_5 &&
6197                         this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
6198                 impt.modifiers = AccDefault; // convert the static import reference to a non-static importe reference
6199                 this.problemReporter().invalidUsageOfStaticImports(impt);
6200         }
6201         
6202         // recovery
6203         if (this.currentElement != null){
6204                 this.lastCheckPoint = impt.declarationSourceEnd+1;
6205                 this.currentElement = this.currentElement.add(impt, 0);
6206                 this.lastIgnoredToken = -1;
6207                 this.restartRecovery = true; // used to avoid branching back into the regular automaton         
6208         }
6209 }
6210 protected void consumeSingleTypeImportDeclarationName() {
6211         // SingleTypeImportDeclarationName ::= 'import' Name
6212         /* push an ImportRef build from the last name 
6213         stored in the identifier stack. */
6214
6215         ImportReference impt;
6216         int length;
6217         char[][] tokens = new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
6218         this.identifierPtr -= length;
6219         long[] positions = new long[length];
6220         System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
6221         System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
6222         pushOnAstStack(impt = new ImportReference(tokens, positions, false, AccDefault));
6223
6224         if (this.currentToken == TokenNameSEMICOLON){
6225                 impt.declarationSourceEnd = this.scanner.currentPosition - 1;
6226         } else {
6227                 impt.declarationSourceEnd = impt.sourceEnd;
6228         }
6229         impt.declarationEnd = impt.declarationSourceEnd;
6230         //this.endPosition is just before the ;
6231         impt.declarationSourceStart = this.intStack[this.intPtr--];
6232
6233         // recovery
6234         if (this.currentElement != null){
6235                 this.lastCheckPoint = impt.declarationSourceEnd+1;
6236                 this.currentElement = this.currentElement.add(impt, 0);
6237                 this.lastIgnoredToken = -1;
6238                 this.restartRecovery = true; // used to avoid branching back into the regular automaton         
6239         }
6240 }
6241 protected void consumeStatementBreak() {
6242         // BreakStatement ::= 'break' ';'
6243         // break pushs a position on this.intStack in case there is no label
6244
6245         pushOnAstStack(new BreakStatement(null, this.intStack[this.intPtr--], this.endPosition));
6246 }
6247 protected void consumeStatementBreakWithLabel() {
6248         // BreakStatement ::= 'break' Identifier ';'
6249         // break pushs a position on this.intStack in case there is no label
6250
6251         pushOnAstStack(
6252                 new BreakStatement(
6253                         this.identifierStack[this.identifierPtr--],
6254                         this.intStack[this.intPtr--],
6255                         this.endPosition)); 
6256         this.identifierLengthPtr--;
6257 }
6258 protected void consumeStatementCatch() {
6259         // CatchClause ::= 'catch' '(' FormalParameter ')'    Block
6260
6261         //catch are stored directly into the Try
6262         //has they always comes two by two....
6263         //we remove one entry from the astlengthPtr.
6264         //The construction of the try statement must
6265         //then fetch the catches using  2*i and 2*i + 1
6266
6267         this.astLengthPtr--;
6268         this.listLength = 0; // reset formalParameter counter (incremented for catch variable)
6269 }
6270 protected void consumeStatementContinue() {
6271         // ContinueStatement ::= 'continue' ';'
6272         // continue pushs a position on this.intStack in case there is no label
6273
6274         pushOnAstStack(
6275                 new ContinueStatement(
6276                         null,
6277                         this.intStack[this.intPtr--],
6278                         this.endPosition));
6279 }
6280 protected void consumeStatementContinueWithLabel() {
6281         // ContinueStatement ::= 'continue' Identifier ';'
6282         // continue pushs a position on this.intStack in case there is no label
6283
6284         pushOnAstStack(
6285                 new ContinueStatement(
6286                         this.identifierStack[this.identifierPtr--], 
6287                         this.intStack[this.intPtr--], 
6288                         this.endPosition)); 
6289         this.identifierLengthPtr--;
6290 }
6291 protected void consumeStatementDo() {
6292         // DoStatement ::= 'do' Statement 'while' '(' Expression ')' ';'
6293
6294         //the 'while' pushes a value on this.intStack that we need to remove
6295         this.intPtr--;
6296
6297         Statement statement = (Statement) this.astStack[this.astPtr];
6298         this.expressionLengthPtr--;
6299         this.astStack[this.astPtr] = 
6300                 new DoStatement(
6301                         this.expressionStack[this.expressionPtr--], 
6302                         statement, 
6303                         this.intStack[this.intPtr--], 
6304                         this.endPosition); 
6305 }
6306 protected void consumeStatementExpressionList() {
6307         // StatementExpressionList ::= StatementExpressionList ',' StatementExpression
6308         concatExpressionLists();
6309 }
6310 protected void consumeStatementFor() {
6311         // ForStatement ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' Statement
6312         // ForStatementNoShortIf ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' StatementNoShortIf
6313
6314         int length;
6315         Expression cond = null;
6316         Statement[] inits, updates;
6317         boolean scope = true;
6318
6319         //statements
6320         this.astLengthPtr--;
6321         Statement statement = (Statement) this.astStack[this.astPtr--];
6322
6323         //updates are on the expresion stack
6324         if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) == 0) {
6325                 updates = null;
6326         } else {
6327                 this.expressionPtr -= length;
6328                 System.arraycopy(
6329                         this.expressionStack, 
6330                         this.expressionPtr + 1, 
6331                         updates = new Statement[length], 
6332                         0, 
6333                         length); 
6334         }
6335
6336         if (this.expressionLengthStack[this.expressionLengthPtr--] != 0)
6337                 cond = this.expressionStack[this.expressionPtr--];
6338
6339         //inits may be on two different stacks
6340         if ((length = this.astLengthStack[this.astLengthPtr--]) == 0) {
6341                 inits = null;
6342                 scope = false;
6343         } else {
6344                 if (length == -1) { //on this.expressionStack
6345                         scope = false;
6346                         length = this.expressionLengthStack[this.expressionLengthPtr--];
6347                         this.expressionPtr -= length;
6348                         System.arraycopy(
6349                                 this.expressionStack, 
6350                                 this.expressionPtr + 1, 
6351                                 inits = new Statement[length], 
6352                                 0, 
6353                                 length); 
6354                 } else { //on this.astStack
6355                         this.astPtr -= length;
6356                         System.arraycopy(
6357                                 this.astStack, 
6358                                 this.astPtr + 1, 
6359                                 inits = new Statement[length], 
6360                                 0, 
6361                                 length); 
6362                 }
6363         }
6364         pushOnAstStack(
6365                 new ForStatement(
6366                         inits, 
6367                         cond, 
6368                         updates, 
6369                         statement, 
6370                         scope, 
6371                         this.intStack[this.intPtr--], 
6372                         this.endStatementPosition)); 
6373 }
6374 protected void consumeStatementIfNoElse() {
6375         // IfThenStatement ::=  'if' '(' Expression ')' Statement
6376
6377         //optimize the push/pop
6378         this.expressionLengthPtr--;
6379         Statement thenStatement = (Statement) this.astStack[this.astPtr];
6380         this.astStack[this.astPtr] = 
6381                 new IfStatement(
6382                         this.expressionStack[this.expressionPtr--], 
6383                         thenStatement, 
6384                         this.intStack[this.intPtr--], 
6385                         this.endStatementPosition); 
6386 }
6387 protected void consumeStatementIfWithElse() {
6388         // IfThenElseStatement ::=  'if' '(' Expression ')' StatementNoShortIf 'else' Statement
6389         // IfThenElseStatementNoShortIf ::=  'if' '(' Expression ')' StatementNoShortIf 'else' StatementNoShortIf
6390
6391         this.expressionLengthPtr--;
6392
6393         // optimized {..., Then, Else } ==> {..., If }
6394         this.astLengthPtr--;
6395
6396         //optimize the push/pop
6397         this.astStack[--this.astPtr] = 
6398                 new IfStatement(
6399                         this.expressionStack[this.expressionPtr--], 
6400                         (Statement) this.astStack[this.astPtr], 
6401                         (Statement) this.astStack[this.astPtr + 1], 
6402                         this.intStack[this.intPtr--], 
6403                         this.endStatementPosition); 
6404 }
6405 protected void consumeStatementLabel() {
6406         // LabeledStatement ::= 'Identifier' ':' Statement
6407         // LabeledStatementNoShortIf ::= 'Identifier' ':' StatementNoShortIf
6408
6409         //optimize push/pop
6410         Statement stmt = (Statement) this.astStack[this.astPtr];
6411         this.astStack[this.astPtr] = 
6412                 new LabeledStatement(
6413                         this.identifierStack[this.identifierPtr], 
6414                         stmt, 
6415                         (int) (this.identifierPositionStack[this.identifierPtr--] >>> 32), 
6416                         this.endStatementPosition); 
6417         this.identifierLengthPtr--;
6418 }
6419 protected void consumeStatementReturn() {
6420         // ReturnStatement ::= 'return' Expressionopt ';'
6421         // return pushs a position on this.intStack in case there is no expression
6422
6423         if (this.expressionLengthStack[this.expressionLengthPtr--] != 0) {
6424                 pushOnAstStack(
6425                         new ReturnStatement(
6426                                 this.expressionStack[this.expressionPtr--], 
6427                                 this.intStack[this.intPtr--], 
6428                                 this.endPosition)
6429                 );
6430         } else {
6431                 pushOnAstStack(new ReturnStatement(null, this.intStack[this.intPtr--], this.endPosition));
6432         }
6433 }
6434 protected void consumeStatementSwitch() {
6435         // SwitchStatement ::= 'switch' OpenBlock '(' Expression ')' SwitchBlock
6436
6437         //OpenBlock just makes the semantic action blockStart()
6438         //the block is inlined but a scope need to be created
6439         //if some declaration occurs.
6440
6441         int length;
6442         SwitchStatement switchStatement = new SwitchStatement();
6443         this.expressionLengthPtr--;
6444         switchStatement.expression = this.expressionStack[this.expressionPtr--];
6445         if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
6446                 this.astPtr -= length;
6447                 System.arraycopy(
6448                         this.astStack, 
6449                         this.astPtr + 1, 
6450                         switchStatement.statements = new Statement[length], 
6451                         0, 
6452                         length); 
6453         }
6454         switchStatement.explicitDeclarations = this.realBlockStack[this.realBlockPtr--];
6455         pushOnAstStack(switchStatement);
6456         switchStatement.blockStart = this.intStack[this.intPtr--];
6457         switchStatement.sourceStart = this.intStack[this.intPtr--];
6458         switchStatement.sourceEnd = this.endStatementPosition;
6459         if (length == 0 && !containsComment(switchStatement.blockStart, switchStatement.sourceEnd)) {
6460                 switchStatement.bits |= ASTNode.UndocumentedEmptyBlockMASK;
6461         }
6462 }
6463 protected void consumeStatementSynchronized() {
6464         // SynchronizedStatement ::= OnlySynchronized '(' Expression ')' Block
6465         //optimize the push/pop
6466
6467         if (this.astLengthStack[this.astLengthPtr] == 0) {
6468                 this.astLengthStack[this.astLengthPtr] = 1;
6469                 this.expressionLengthPtr--;
6470                 this.astStack[++this.astPtr] = 
6471                         new SynchronizedStatement(
6472                                 this.expressionStack[this.expressionPtr--], 
6473                                 null, 
6474                                 this.intStack[this.intPtr--], 
6475                                 this.endStatementPosition); 
6476         } else {
6477                 this.expressionLengthPtr--;
6478                 this.astStack[this.astPtr] = 
6479                         new SynchronizedStatement(
6480                                 this.expressionStack[this.expressionPtr--], 
6481                                 (Block) this.astStack[this.astPtr], 
6482                                 this.intStack[this.intPtr--], 
6483                                 this.endStatementPosition); 
6484         }
6485         resetModifiers();
6486 }
6487 protected void consumeStatementThrow() {
6488         // ThrowStatement ::= 'throw' Expression ';'
6489         this.expressionLengthPtr--;
6490         pushOnAstStack(new ThrowStatement(this.expressionStack[this.expressionPtr--], this.intStack[this.intPtr--]));
6491 }
6492 protected void consumeStatementTry(boolean withFinally) {
6493         //TryStatement ::= 'try'  Block Catches
6494         //TryStatement ::= 'try'  Block Catchesopt Finally
6495
6496         int length;
6497         TryStatement tryStmt = new TryStatement();
6498         //finally
6499         if (withFinally) {
6500                 this.astLengthPtr--;
6501                 tryStmt.finallyBlock = (Block) this.astStack[this.astPtr--];
6502         }
6503         //catches are handle by two <argument-block> [see statementCatch]
6504         if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
6505                 if (length == 1) {
6506                         tryStmt.catchBlocks = new Block[] {(Block) this.astStack[this.astPtr--]};
6507                         tryStmt.catchArguments = new Argument[] {(Argument) this.astStack[this.astPtr--]};
6508                 } else {
6509                         Block[] bks = (tryStmt.catchBlocks = new Block[length]);
6510                         Argument[] args = (tryStmt.catchArguments = new Argument[length]);
6511                         while (length-- > 0) {
6512                                 bks[length] = (Block) this.astStack[this.astPtr--];
6513                                 args[length] = (Argument) this.astStack[this.astPtr--];
6514                         }
6515                 }
6516         }
6517         //try
6518         this.astLengthPtr--;
6519         tryStmt.tryBlock = (Block) this.astStack[this.astPtr--];
6520
6521         //positions
6522         tryStmt.sourceEnd = this.endStatementPosition;
6523         tryStmt.sourceStart = this.intStack[this.intPtr--];
6524         pushOnAstStack(tryStmt);
6525 }
6526 protected void consumeStatementWhile() {
6527         // WhileStatement ::= 'while' '(' Expression ')' Statement
6528         // WhileStatementNoShortIf ::= 'while' '(' Expression ')' StatementNoShortIf
6529
6530         this.expressionLengthPtr--;
6531         Statement statement = (Statement) this.astStack[this.astPtr];
6532         this.astStack[this.astPtr] = 
6533                 new WhileStatement(
6534                         this.expressionStack[this.expressionPtr--], 
6535                         statement, 
6536                         this.intStack[this.intPtr--], 
6537                         this.endStatementPosition); 
6538 }
6539 protected void consumeStaticImportOnDemandDeclarationName() {
6540         // TypeImportOnDemandDeclarationName ::= 'import' 'static' Name '.' '*'
6541         /* push an ImportRef build from the last name 
6542         stored in the identifier stack. */
6543
6544         ImportReference impt;
6545         int length;
6546         char[][] tokens = new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
6547         this.identifierPtr -= length;
6548         long[] positions = new long[length];
6549         System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
6550         System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
6551         pushOnAstStack(impt = new ImportReference(tokens, positions, true, AccStatic));
6552
6553         this.modifiers = AccDefault;
6554         this.modifiersSourceStart = -1; // <-- see comment into modifiersFlag(int)
6555         
6556         if (this.currentToken == TokenNameSEMICOLON){
6557                 impt.declarationSourceEnd = this.scanner.currentPosition - 1;
6558         } else {
6559                 impt.declarationSourceEnd = impt.sourceEnd;
6560         }
6561         impt.declarationEnd = impt.declarationSourceEnd;
6562         //this.endPosition is just before the ;
6563         impt.declarationSourceStart = this.intStack[this.intPtr--];
6564
6565         if(options.sourceLevel < ClassFileConstants.JDK1_5 &&
6566                         this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
6567                 impt.modifiers = AccDefault; // convert the static import reference to a non-static importe reference
6568                 this.problemReporter().invalidUsageOfStaticImports(impt);
6569         }
6570         
6571         // recovery
6572         if (this.currentElement != null){
6573                 this.lastCheckPoint = impt.declarationSourceEnd+1;
6574                 this.currentElement = this.currentElement.add(impt, 0);
6575                 this.lastIgnoredToken = -1;
6576                 this.restartRecovery = true; // used to avoid branching back into the regular automaton         
6577         }       
6578 }
6579 protected void consumeStaticInitializer() {
6580         // StaticInitializer ::=  StaticOnly Block
6581         //push an Initializer
6582         //optimize the push/pop
6583         Block block = (Block) this.astStack[this.astPtr];
6584         if (this.diet) block.bits &= ~ASTNode.UndocumentedEmptyBlockMASK; // clear bit set since was diet
6585         Initializer initializer = new Initializer(block, AccStatic);
6586         this.astStack[this.astPtr] = initializer;
6587         initializer.sourceEnd = this.endStatementPosition;      
6588         initializer.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
6589         this.nestedMethod[this.nestedType] --;
6590         initializer.declarationSourceStart = this.intStack[this.intPtr--];
6591         initializer.bodyStart = this.intStack[this.intPtr--];
6592         initializer.bodyEnd = this.endPosition;
6593         // doc comment
6594         initializer.javadoc = this.javadoc;
6595         this.javadoc = null;
6596         
6597         // recovery
6598         if (this.currentElement != null){
6599                 this.lastCheckPoint = initializer.declarationSourceEnd;
6600                 this.currentElement = this.currentElement.add(initializer, 0);
6601                 this.lastIgnoredToken = -1;
6602         }
6603 }
6604 protected void consumeStaticOnly() {
6605         // StaticOnly ::= 'static'
6606         int savedModifiersSourceStart = this.modifiersSourceStart;
6607         checkComment(); // might update declaration source start
6608         if (this.modifiersSourceStart >= savedModifiersSourceStart) {
6609                 this.modifiersSourceStart = savedModifiersSourceStart;
6610         }
6611         pushOnIntStack(this.scanner.currentPosition);
6612         pushOnIntStack(
6613                 this.modifiersSourceStart >= 0 ? this.modifiersSourceStart : this.scanner.startPosition);
6614         jumpOverMethodBody();
6615         this.nestedMethod[this.nestedType]++;
6616         resetModifiers();
6617
6618         // recovery
6619         if (this.currentElement != null){
6620                 this.recoveredStaticInitializerStart = this.intStack[this.intPtr]; // remember start position only for static initializers
6621         }
6622 }
6623 protected void consumeSwitchBlock() {
6624         // SwitchBlock ::= '{' SwitchBlockStatements SwitchLabels '}'
6625         concatNodeLists();
6626 }
6627 protected void consumeSwitchBlockStatement() {
6628         // SwitchBlockStatement ::= SwitchLabels BlockStatements
6629         concatNodeLists();
6630 }
6631 protected void consumeSwitchBlockStatements() {
6632         // SwitchBlockStatements ::= SwitchBlockStatements SwitchBlockStatement
6633         concatNodeLists();
6634 }
6635 protected void consumeSwitchLabels() {
6636         // SwitchLabels ::= SwitchLabels SwitchLabel
6637         optimizedConcatNodeLists();
6638 }
6639 protected void consumeToken(int type) {
6640         /* remember the last consumed value */
6641         /* try to minimize the number of build values */
6642         checkNonExternalizedStringLiteral();
6643 //      // clear the commentPtr of the scanner in case we read something different from a modifier
6644 //      switch(type) {
6645 //              case TokenNameabstract :
6646 //              case TokenNamestrictfp :
6647 //              case TokenNamefinal :
6648 //              case TokenNamenative :
6649 //              case TokenNameprivate :
6650 //              case TokenNameprotected :
6651 //              case TokenNamepublic :
6652 //              case TokenNametransient :
6653 //              case TokenNamevolatile :
6654 //              case TokenNamestatic :
6655 //              case TokenNamesynchronized :
6656 //                      break;
6657 //              default:
6658 //                      this.scanner.commentPtr = -1;
6659 //      }
6660         //System.out.println(this.scanner.toStringAction(type));
6661         switch (type) {
6662                 case TokenNameIdentifier :
6663                         pushIdentifier();
6664                         if (this.scanner.useAssertAsAnIndentifier  &&
6665                                         this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
6666                                 long positions = this.identifierPositionStack[this.identifierPtr];
6667                                 problemReporter().useAssertAsAnIdentifier((int) (positions >>> 32), (int) positions);
6668                         }
6669                         if (this.scanner.useEnumAsAnIndentifier  &&
6670                                         this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
6671                                 long positions = this.identifierPositionStack[this.identifierPtr];
6672                                 problemReporter().useEnumAsAnIdentifier((int) (positions >>> 32), (int) positions);
6673                         }
6674                         break;
6675                 case TokenNameinterface :
6676                         //'class' is pushing two int (positions) on the stack ==> 'interface' needs to do it too....
6677                         pushOnIntStack(this.scanner.currentPosition - 1);                       
6678                         pushOnIntStack(this.scanner.startPosition);
6679                         break;
6680                 case TokenNameabstract :
6681                         checkAndSetModifiers(AccAbstract);
6682                         pushOnExpressionStackLengthStack(0);
6683                         break;
6684                 case TokenNamestrictfp :
6685                         checkAndSetModifiers(AccStrictfp);
6686                         pushOnExpressionStackLengthStack(0);
6687                         break;
6688                 case TokenNamefinal :
6689                         checkAndSetModifiers(AccFinal);
6690                         pushOnExpressionStackLengthStack(0);
6691                         break;
6692                 case TokenNamenative :
6693                         checkAndSetModifiers(AccNative);
6694                         pushOnExpressionStackLengthStack(0);
6695                         break;
6696                 case TokenNameprivate :
6697                         checkAndSetModifiers(AccPrivate);
6698                         pushOnExpressionStackLengthStack(0);
6699                         break;
6700                 case TokenNameprotected :
6701                         checkAndSetModifiers(AccProtected);
6702                         pushOnExpressionStackLengthStack(0);
6703                         break;
6704                 case TokenNamepublic :
6705                         checkAndSetModifiers(AccPublic);
6706                         pushOnExpressionStackLengthStack(0);
6707                         break;
6708                 case TokenNametransient :
6709                         checkAndSetModifiers(AccTransient);
6710                         pushOnExpressionStackLengthStack(0);
6711                         break;
6712                 case TokenNamevolatile :
6713                         checkAndSetModifiers(AccVolatile);
6714                         pushOnExpressionStackLengthStack(0);
6715                         break;
6716                 case TokenNamestatic :
6717                         checkAndSetModifiers(AccStatic);
6718                         pushOnExpressionStackLengthStack(0);
6719                         break;
6720                 case TokenNamesynchronized :
6721                         this.synchronizedBlockSourceStart = this.scanner.startPosition; 
6722                         checkAndSetModifiers(AccSynchronized);
6723                         pushOnExpressionStackLengthStack(0);
6724                         break;
6725                         //==============================
6726                 case TokenNamevoid :
6727                         pushIdentifier(-T_void);
6728                         pushOnIntStack(this.scanner.currentPosition - 1);                               
6729                         pushOnIntStack(this.scanner.startPosition);
6730                         break;
6731                         //push a default dimension while void is not part of the primitive
6732                         //declaration baseType and so takes the place of a type without getting into
6733                         //regular type parsing that generates a dimension on this.intStack
6734                 case TokenNameboolean :
6735                         pushIdentifier(-T_boolean);
6736                         pushOnIntStack(this.scanner.currentPosition - 1);                               
6737                         pushOnIntStack(this.scanner.startPosition);             
6738                         break;
6739                 case TokenNamebyte :
6740                         pushIdentifier(-T_byte);
6741                         pushOnIntStack(this.scanner.currentPosition - 1);                               
6742                         pushOnIntStack(this.scanner.startPosition);                                     
6743                         break;
6744                 case TokenNamechar :
6745                         pushIdentifier(-T_char);
6746                         pushOnIntStack(this.scanner.currentPosition - 1);                               
6747                         pushOnIntStack(this.scanner.startPosition);                                     
6748                         break;
6749                 case TokenNamedouble :
6750                         pushIdentifier(-T_double);
6751                         pushOnIntStack(this.scanner.currentPosition - 1);                               
6752                         pushOnIntStack(this.scanner.startPosition);                                     
6753                         break;
6754                 case TokenNamefloat :
6755                         pushIdentifier(-T_float);
6756                         pushOnIntStack(this.scanner.currentPosition - 1);                               
6757                         pushOnIntStack(this.scanner.startPosition);                                     
6758                         break;
6759                 case TokenNameint :
6760                         pushIdentifier(-T_int);
6761                         pushOnIntStack(this.scanner.currentPosition - 1);                               
6762                         pushOnIntStack(this.scanner.startPosition);                                     
6763                         break;
6764                 case TokenNamelong :
6765                         pushIdentifier(-T_long);
6766                         pushOnIntStack(this.scanner.currentPosition - 1);                               
6767                         pushOnIntStack(this.scanner.startPosition);                                     
6768                         break;
6769                 case TokenNameshort :
6770                         pushIdentifier(-T_short);
6771                         pushOnIntStack(this.scanner.currentPosition - 1);                               
6772                         pushOnIntStack(this.scanner.startPosition);                                     
6773                         break;
6774                         //==============================
6775                 case TokenNameIntegerLiteral :
6776                         pushOnExpressionStack(
6777                                 new IntLiteral(
6778                                         this.scanner.getCurrentTokenSource(), 
6779                                         this.scanner.startPosition, 
6780                                         this.scanner.currentPosition - 1)); 
6781                         break;
6782                 case TokenNameLongLiteral :
6783                         pushOnExpressionStack(
6784                                 new LongLiteral(
6785                                         this.scanner.getCurrentTokenSource(), 
6786                                         this.scanner.startPosition, 
6787                                         this.scanner.currentPosition - 1)); 
6788                         break;
6789                 case TokenNameFloatingPointLiteral :
6790                         pushOnExpressionStack(
6791                                 new FloatLiteral(
6792                                         this.scanner.getCurrentTokenSource(), 
6793                                         this.scanner.startPosition, 
6794                                         this.scanner.currentPosition - 1)); 
6795                         break;
6796                 case TokenNameDoubleLiteral :
6797                         pushOnExpressionStack(
6798                                 new DoubleLiteral(
6799                                         this.scanner.getCurrentTokenSource(), 
6800                                         this.scanner.startPosition, 
6801                                         this.scanner.currentPosition - 1)); 
6802                         break;
6803                 case TokenNameCharacterLiteral :
6804                         pushOnExpressionStack(
6805                                 new CharLiteral(
6806                                         this.scanner.getCurrentTokenSource(), 
6807                                         this.scanner.startPosition, 
6808                                         this.scanner.currentPosition - 1)); 
6809                         break;
6810                 case TokenNameStringLiteral :
6811                         StringLiteral stringLiteral = new StringLiteral(
6812                                         this.scanner.getCurrentTokenSourceString(), 
6813                                         this.scanner.startPosition, 
6814                                         this.scanner.currentPosition - 1); 
6815                         pushOnExpressionStack(stringLiteral); 
6816                         break;
6817                 case TokenNamefalse :
6818                         pushOnExpressionStack(
6819                                 new FalseLiteral(this.scanner.startPosition, this.scanner.currentPosition - 1)); 
6820                         break;
6821                 case TokenNametrue :
6822                         pushOnExpressionStack(
6823                                 new TrueLiteral(this.scanner.startPosition, this.scanner.currentPosition - 1)); 
6824                         break;
6825                 case TokenNamenull :
6826                         pushOnExpressionStack(
6827                                 new NullLiteral(this.scanner.startPosition, this.scanner.currentPosition - 1)); 
6828                         break;
6829                         //============================
6830                 case TokenNamesuper :
6831                 case TokenNamethis :
6832                         this.endPosition = this.scanner.currentPosition - 1;
6833                         pushOnIntStack(this.scanner.startPosition);
6834                         break;
6835                 case TokenNameassert :
6836                 case TokenNameimport :
6837                 case TokenNamepackage :
6838                 case TokenNamethrow :
6839                 case TokenNamedo :
6840                 case TokenNameif :
6841                 case TokenNamefor :
6842                 case TokenNameswitch :
6843                 case TokenNametry :
6844                 case TokenNamewhile :
6845                 case TokenNamebreak :
6846                 case TokenNamecontinue :
6847                 case TokenNamereturn :
6848                 case TokenNamecase :
6849                         pushOnIntStack(this.scanner.startPosition);
6850                         break;
6851                 case TokenNamenew :
6852                         // https://bugs.eclipse.org/bugs/show_bug.cgi?id=40954
6853                         resetModifiers();
6854                         pushOnIntStack(this.scanner.startPosition);
6855                         break;
6856                 case TokenNameclass :
6857                         pushOnIntStack(this.scanner.currentPosition - 1);
6858                         pushOnIntStack(this.scanner.startPosition);
6859                         break;
6860                 case TokenNameenum :
6861                         pushOnIntStack(this.scanner.currentPosition - 1);
6862                         pushOnIntStack(this.scanner.startPosition);
6863                         break;
6864                 case TokenNamedefault :
6865                         pushOnIntStack(this.scanner.startPosition);
6866                         pushOnIntStack(this.scanner.currentPosition - 1);
6867                         break;
6868                         //let extra semantic action decide when to push
6869                 case TokenNameRBRACKET :
6870                         this.endPosition = this.scanner.startPosition;
6871                         this.endStatementPosition = this.scanner.currentPosition - 1;
6872                         break;
6873                 case TokenNamePLUS :
6874                 case TokenNameMINUS :
6875                 case TokenNameNOT :
6876                 case TokenNameTWIDDLE :
6877                 case TokenNameLBRACE :
6878                         this.endPosition = this.scanner.startPosition;
6879                         break;
6880                 case TokenNamePLUS_PLUS :
6881                 case TokenNameMINUS_MINUS :
6882                         this.endPosition = this.scanner.startPosition;
6883                         this.endStatementPosition = this.scanner.currentPosition - 1;
6884                         break;
6885                 case TokenNameRBRACE:
6886                 case TokenNameSEMICOLON :
6887                         this.endStatementPosition = this.scanner.currentPosition - 1;
6888                         this.endPosition = this.scanner.startPosition - 1; 
6889                         //the item is not part of the potential futur expression/statement
6890                         break;
6891                 case TokenNameRPAREN :
6892                         // in order to handle ( expression) ////// (cast)expression///// foo(x)
6893                         this.rParenPos = this.scanner.currentPosition - 1; // position of the end of right parenthesis (in case of unicode \u0029) lex00101
6894                         break;
6895                 case TokenNameLPAREN :
6896                         this.lParenPos = this.scanner.startPosition;
6897                         break;
6898                 case TokenNameAT :
6899                         pushOnIntStack(this.scanner.startPosition);
6900                         break;
6901                 case TokenNameQUESTION  :
6902                         pushOnIntStack(this.scanner.startPosition);
6903                         pushOnIntStack(this.scanner.currentPosition - 1);
6904                         break;
6905                 case TokenNameLESS :
6906                         pushOnIntStack(this.scanner.startPosition);
6907                         break;
6908                 case TokenNameELLIPSIS :
6909                         pushOnIntStack(this.scanner.currentPosition - 1);
6910                         break;                  
6911                         //  case TokenNameCOMMA :
6912                         //  case TokenNameCOLON  :
6913                         //  case TokenNameEQUAL  :
6914                         //  case TokenNameLBRACKET  :
6915                         //  case TokenNameDOT :
6916                         //  case TokenNameERROR :
6917                         //  case TokenNameEOF  :
6918                         //  case TokenNamecase  :
6919                         //  case TokenNamecatch  :
6920                         //  case TokenNameelse  :
6921                         //  case TokenNameextends  :
6922                         //  case TokenNamefinally  :
6923                         //  case TokenNameimplements  :
6924                         //  case TokenNamethrows  :
6925                         //  case TokenNameinstanceof  :
6926                         //  case TokenNameEQUAL_EQUAL  :
6927                         //  case TokenNameLESS_EQUAL  :
6928                         //  case TokenNameGREATER_EQUAL  :
6929                         //  case TokenNameNOT_EQUAL  :
6930                         //  case TokenNameLEFT_SHIFT  :
6931                         //  case TokenNameRIGHT_SHIFT  :
6932                         //  case TokenNameUNSIGNED_RIGHT_SHIFT :
6933                         //  case TokenNamePLUS_EQUAL  :
6934                         //  case TokenNameMINUS_EQUAL  :
6935                         //  case TokenNameMULTIPLY_EQUAL  :
6936                         //  case TokenNameDIVIDE_EQUAL  :
6937                         //  case TokenNameAND_EQUAL  :
6938                         //  case TokenNameOR_EQUAL  :
6939                         //  case TokenNameXOR_EQUAL  :
6940                         //  case TokenNameREMAINDER_EQUAL  :
6941                         //  case TokenNameLEFT_SHIFT_EQUAL  :
6942                         //  case TokenNameRIGHT_SHIFT_EQUAL  :
6943                         //  case TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL  :
6944                         //  case TokenNameOR_OR  :
6945                         //  case TokenNameAND_AND  :
6946                         //  case TokenNameREMAINDER :
6947                         //  case TokenNameXOR  :
6948                         //  case TokenNameAND  :
6949                         //  case TokenNameMULTIPLY :
6950                         //  case TokenNameOR  :
6951                         //  case TokenNameDIVIDE :
6952                         //  case TokenNameGREATER  :
6953         }
6954 }
6955 protected void consumeTypeArgument() {
6956         pushOnGenericsStack(getTypeReference(this.intStack[this.intPtr--]));    
6957 }
6958 protected void consumeTypeArgumentList() {
6959         concatGenericsLists();
6960 }
6961 protected void consumeTypeArgumentList1() {
6962         concatGenericsLists();
6963 }
6964 protected void consumeTypeArgumentList2() {
6965         concatGenericsLists();
6966 }
6967 protected void consumeTypeArgumentList3() {
6968         concatGenericsLists();
6969 }
6970 protected void consumeTypeArgumentReferenceType1() {
6971         concatGenericsLists();
6972         pushOnGenericsStack(getTypeReference(0));       
6973         intPtr--;
6974 }
6975 protected void consumeTypeArgumentReferenceType2() {
6976         concatGenericsLists();
6977         pushOnGenericsStack(getTypeReference(0));       
6978         intPtr--;
6979 }
6980 protected void consumeTypeArguments() {
6981         concatGenericsLists();
6982         intPtr--;
6983
6984         if(options.sourceLevel < ClassFileConstants.JDK1_5 &&
6985                         this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
6986                 int length = this.genericsLengthStack[this.genericsLengthPtr];
6987                 this.problemReporter().invalidUsageOfTypeArguments(
6988                         (TypeReference)this.genericsStack[this.genericsPtr - length + 1],
6989                         (TypeReference)this.genericsStack[this.genericsPtr]);
6990         }
6991 }
6992 protected void consumeTypeDeclarations() {
6993         // TypeDeclarations ::= TypeDeclarations TypeDeclaration
6994         concatNodeLists();
6995 }
6996 protected void consumeTypeImportOnDemandDeclarationName() {
6997         // TypeImportOnDemandDeclarationName ::= 'import' Name '.' '*'
6998         /* push an ImportRef build from the last name 
6999         stored in the identifier stack. */
7000
7001         ImportReference impt;
7002         int length;
7003         char[][] tokens = new char[length = this.identifierLengthStack[this.identifierLengthPtr--]][];
7004         this.identifierPtr -= length;
7005         long[] positions = new long[length];
7006         System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
7007         System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
7008         pushOnAstStack(impt = new ImportReference(tokens, positions, true, AccDefault));
7009
7010         if (this.currentToken == TokenNameSEMICOLON){
7011                 impt.declarationSourceEnd = this.scanner.currentPosition - 1;
7012         } else {
7013                 impt.declarationSourceEnd = impt.sourceEnd;
7014         }
7015         impt.declarationEnd = impt.declarationSourceEnd;
7016         //this.endPosition is just before the ;
7017         impt.declarationSourceStart = this.intStack[this.intPtr--];
7018
7019         // recovery
7020         if (this.currentElement != null){
7021                 this.lastCheckPoint = impt.declarationSourceEnd+1;
7022                 this.currentElement = this.currentElement.add(impt, 0);
7023                 this.lastIgnoredToken = -1;
7024                 this.restartRecovery = true; // used to avoid branching back into the regular automaton         
7025         }       
7026 }
7027 protected void consumeTypeParameterHeader() {
7028         //TypeParameterHeader ::= Identifier
7029         TypeParameter typeParameter = new TypeParameter();
7030         long pos = this.identifierPositionStack[this.identifierPtr];
7031         final int end = (int) pos;
7032         typeParameter.declarationSourceEnd = end;
7033         typeParameter.sourceEnd = end;
7034         final int start = (int) (pos >>> 32);
7035         typeParameter.declarationSourceStart = start;
7036         typeParameter.sourceStart = start;
7037         typeParameter.name = this.identifierStack[this.identifierPtr--];
7038         this.identifierLengthPtr--;
7039         pushOnGenericsStack(typeParameter);
7040         
7041         this.listTypeParameterLength++;
7042 }
7043 protected void consumeTypeParameter1() {
7044         // nothing to do
7045 }
7046 protected void consumeTypeParameter1WithExtends() {
7047         //TypeParameter1 ::= TypeParameterHeader 'extends' ReferenceType1
7048         TypeReference superType = (TypeReference) this.genericsStack[this.genericsPtr--];
7049         this.genericsLengthPtr--;
7050         TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
7051         typeParameter.declarationSourceEnd = superType.sourceEnd;
7052         typeParameter.type = superType;
7053         superType.bits |= ASTNode.IsSuperType;
7054         this.genericsStack[this.genericsPtr] = typeParameter;
7055 }
7056 protected void consumeTypeParameter1WithExtendsAndBounds() {
7057         //TypeParameter1 ::= TypeParameterHeader 'extends' ReferenceType AdditionalBoundList1
7058         int additionalBoundsLength = this.genericsLengthStack[this.genericsLengthPtr--];
7059         TypeReference[] bounds = new TypeReference[additionalBoundsLength];
7060         this.genericsPtr -= additionalBoundsLength;
7061         System.arraycopy(this.genericsStack, this.genericsPtr + 1, bounds, 0, additionalBoundsLength);
7062         TypeReference superType = getTypeReference(this.intStack[this.intPtr--]);
7063         TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
7064         typeParameter.declarationSourceEnd = bounds[additionalBoundsLength - 1].sourceEnd;
7065         typeParameter.type = superType;
7066         superType.bits |= ASTNode.IsSuperType;  
7067         typeParameter.bounds = bounds;
7068         for (int i = 0, max = bounds.length; i < max; i++) {
7069                 bounds[i].bits |= ASTNode.IsSuperType;
7070         }       
7071 }
7072 protected void consumeTypeParameterList() {
7073         //TypeParameterList ::= TypeParameterList ',' TypeParameter
7074         concatGenericsLists();
7075 }
7076 protected void consumeTypeParameterList1() {
7077         //TypeParameterList1 ::= TypeParameterList ',' TypeParameter1
7078         concatGenericsLists();
7079 }
7080 protected void consumeTypeParameters() {
7081         intPtr--;
7082         if(options.sourceLevel < ClassFileConstants.JDK1_5&&
7083                         this.lastErrorEndPositionBeforeRecovery < this.scanner.currentPosition) {
7084                 int length = this.genericsLengthStack[this.genericsLengthPtr];
7085                 this.problemReporter().invalidUsageOfTypeParameters(
7086                         (TypeParameter) this.genericsStack[genericsPtr - length + 1],
7087                         (TypeParameter) this.genericsStack[genericsPtr]);
7088         }
7089 }
7090 protected void consumeTypeParameterWithExtends() {
7091         //TypeParameter ::= TypeParameterHeader 'extends' ReferenceType
7092         TypeReference superType = getTypeReference(this.intStack[this.intPtr--]);
7093         TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
7094         typeParameter.declarationSourceEnd = superType.sourceEnd;
7095         typeParameter.type = superType;
7096         superType.bits |= ASTNode.IsSuperType;
7097 }
7098 protected void consumeTypeParameterWithExtendsAndBounds() {
7099         //TypeParameter ::= TypeParameterHeader 'extends' ReferenceType AdditionalBoundList
7100         int additionalBoundsLength = this.genericsLengthStack[this.genericsLengthPtr--];
7101         TypeReference[] bounds = new TypeReference[additionalBoundsLength];
7102         this.genericsPtr -= additionalBoundsLength;
7103         System.arraycopy(this.genericsStack, this.genericsPtr + 1, bounds, 0, additionalBoundsLength);
7104         TypeReference superType = getTypeReference(this.intStack[this.intPtr--]);
7105         TypeParameter typeParameter = (TypeParameter) this.genericsStack[this.genericsPtr];
7106         typeParameter.type = superType;
7107         superType.bits |= ASTNode.IsSuperType;
7108         typeParameter.bounds = bounds;
7109         typeParameter.declarationSourceEnd = bounds[additionalBoundsLength - 1].sourceEnd;
7110         for (int i = 0, max = bounds.length; i < max; i++) {
7111                 bounds[i].bits |= ASTNode.IsSuperType;
7112         }               
7113 }
7114 protected void consumeUnaryExpression(int op) {
7115         // UnaryExpression ::= '+' PushPosition UnaryExpression
7116         // UnaryExpression ::= '-' PushPosition UnaryExpression
7117         // UnaryExpressionNotPlusMinus ::= '~' PushPosition UnaryExpression
7118         // UnaryExpressionNotPlusMinus ::= '!' PushPosition UnaryExpression
7119
7120         //optimize the push/pop
7121
7122         //handle manually the -2147483648 while it is not a real
7123         //computation of an - and 2147483648 (notice that 2147483648
7124         //is Integer.MAX_VALUE+1.....)
7125         //Same for -9223372036854775808L ............
7126
7127         //this.intStack have the position of the operator
7128
7129         Expression r, exp = this.expressionStack[this.expressionPtr];
7130         if (op == MINUS) {
7131                 if ((exp instanceof IntLiteral) && (((IntLiteral) exp).mayRepresentMIN_VALUE())) {
7132                         r = this.expressionStack[this.expressionPtr] = new IntLiteralMinValue();
7133                 } else {
7134                         if ((exp instanceof LongLiteral) && (((LongLiteral) exp).mayRepresentMIN_VALUE())) {
7135                                 r = this.expressionStack[this.expressionPtr] = new LongLiteralMinValue();
7136                         } else {
7137                                 r = this.expressionStack[this.expressionPtr] = new UnaryExpression(exp, op);
7138                         }
7139                 }
7140         } else {
7141                 r = this.expressionStack[this.expressionPtr] = new UnaryExpression(exp, op);
7142         }
7143         r.sourceStart = this.intStack[this.intPtr--];
7144         r.sourceEnd = exp.sourceEnd;
7145 }
7146 protected void consumeUnaryExpression(int op, boolean post) {
7147         // PreIncrementExpression ::= '++' PushPosition UnaryExpression
7148         // PreDecrementExpression ::= '--' PushPosition UnaryExpression
7149
7150         // ++ and -- operators
7151         //optimize the push/pop
7152
7153         //this.intStack has the position of the operator when prefix
7154
7155         Expression leftHandSide = this.expressionStack[this.expressionPtr];
7156         if (leftHandSide instanceof Reference) {
7157                 // ++foo()++ is unvalid 
7158                 if (post) {
7159                         this.expressionStack[this.expressionPtr] = 
7160                                 new PostfixExpression(
7161                                         leftHandSide,
7162                                         IntLiteral.One,
7163                                         op,
7164                                         this.endStatementPosition); 
7165                 } else {
7166                         this.expressionStack[this.expressionPtr] = 
7167                                 new PrefixExpression(
7168                                         leftHandSide,
7169                                         IntLiteral.One,
7170                                         op,
7171                                         this.intStack[this.intPtr--]); 
7172                 }
7173         } else {
7174                 //the ++ or the -- is NOT taken into account if code gen proceeds
7175                 if (!post) {
7176                         this.intPtr--;
7177                 }
7178                 problemReporter().invalidUnaryExpression(leftHandSide);
7179         }
7180 }
7181 protected void consumeVariableDeclarators() {
7182         // VariableDeclarators ::= VariableDeclarators ',' VariableDeclarator
7183         optimizedConcatNodeLists();
7184 }
7185 protected void consumeVariableInitializers() {
7186         // VariableInitializers ::= VariableInitializers ',' VariableInitializer
7187         concatExpressionLists();
7188 }
7189 protected void consumeWildcard() {
7190         final Wildcard wildcard = new Wildcard(Wildcard.UNBOUND);
7191         wildcard.sourceEnd = this.intStack[this.intPtr--];
7192         wildcard.sourceStart = this.intStack[this.intPtr--];
7193         pushOnGenericsStack(wildcard);
7194 }
7195 protected void consumeWildcard1() {
7196         final Wildcard wildcard = new Wildcard(Wildcard.UNBOUND);
7197         wildcard.sourceEnd = this.intStack[this.intPtr--];
7198         wildcard.sourceStart = this.intStack[this.intPtr--];
7199         pushOnGenericsStack(wildcard);
7200 }
7201 protected void consumeWildcard1WithBounds() {
7202         // Nothing to do
7203         // The wildcard is created by the consumeWildcardBounds1Extends or by consumeWildcardBounds1Super
7204 }
7205 protected void consumeWildcard2() {
7206         final Wildcard wildcard = new Wildcard(Wildcard.UNBOUND);
7207         wildcard.sourceEnd = this.intStack[this.intPtr--];
7208         wildcard.sourceStart = this.intStack[this.intPtr--];
7209         pushOnGenericsStack(wildcard);
7210 }
7211 protected void consumeWildcard2WithBounds() {
7212         // Nothing to do
7213         // The wildcard is created by the consumeWildcardBounds2Extends or by consumeWildcardBounds2Super
7214 }
7215 protected void consumeWildcard3() {
7216         final Wildcard wildcard = new Wildcard(Wildcard.UNBOUND);
7217         wildcard.sourceEnd = this.intStack[this.intPtr--];
7218         wildcard.sourceStart = this.intStack[this.intPtr--];
7219         pushOnGenericsStack(wildcard);
7220 }
7221 protected void consumeWildcard3WithBounds() {
7222         // Nothing to do
7223         // The wildcard is created by the consumeWildcardBounds3Extends or by consumeWildcardBounds3Super
7224 }
7225 protected void consumeWildcardBounds1Extends() {
7226         Wildcard wildcard = new Wildcard(Wildcard.EXTENDS);
7227         wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
7228         wildcard.sourceEnd = wildcard.bound.sourceEnd;
7229         this.intPtr--; // remove end position of the '?'
7230         wildcard.sourceStart = this.intStack[this.intPtr--];
7231         this.genericsStack[this.genericsPtr] = wildcard;
7232 }
7233 protected void consumeWildcardBounds1Super() {
7234         Wildcard wildcard = new Wildcard(Wildcard.SUPER);
7235         wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
7236         this.intPtr--; // remove the starting position of the super keyword
7237         wildcard.sourceEnd = wildcard.bound.sourceEnd;
7238         this.intPtr--; // remove end position of the '?'
7239         wildcard.sourceStart = this.intStack[this.intPtr--];
7240         this.genericsStack[this.genericsPtr] = wildcard;
7241 }
7242 protected void consumeWildcardBounds2Extends() {
7243         Wildcard wildcard = new Wildcard(Wildcard.EXTENDS);
7244         wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
7245         wildcard.sourceEnd = wildcard.bound.sourceEnd;
7246         this.intPtr--; // remove end position of the '?'
7247         wildcard.sourceStart = this.intStack[this.intPtr--];
7248         this.genericsStack[this.genericsPtr] = wildcard;
7249 }
7250 protected void consumeWildcardBounds2Super() {
7251         Wildcard wildcard = new Wildcard(Wildcard.SUPER);
7252         wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
7253         this.intPtr--; // remove the starting position of the super keyword
7254         wildcard.sourceEnd = wildcard.bound.sourceEnd;
7255         this.intPtr--; // remove end position of the '?'
7256         wildcard.sourceStart = this.intStack[this.intPtr--];
7257         this.genericsStack[this.genericsPtr] = wildcard;
7258 }
7259 protected void consumeWildcardBounds3Extends() {
7260         Wildcard wildcard = new Wildcard(Wildcard.EXTENDS);
7261         wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
7262         wildcard.sourceEnd = wildcard.bound.sourceEnd;
7263         this.intPtr--; // remove end position of the '?'
7264         wildcard.sourceStart = this.intStack[this.intPtr--];
7265         this.genericsStack[this.genericsPtr] = wildcard;
7266 }
7267 protected void consumeWildcardBounds3Super() {
7268         Wildcard wildcard = new Wildcard(Wildcard.SUPER);
7269         wildcard.bound = (TypeReference) this.genericsStack[this.genericsPtr];
7270         this.intPtr--; // remove the starting position of the super keyword
7271         wildcard.sourceEnd = wildcard.bound.sourceEnd;
7272         this.intPtr--; // remove end position of the '?'
7273         wildcard.sourceStart = this.intStack[this.intPtr--];
7274         this.genericsStack[this.genericsPtr] = wildcard;
7275 }
7276 protected void consumeWildcardBoundsExtends() {
7277         Wildcard wildcard = new Wildcard(Wildcard.EXTENDS);
7278         wildcard.bound = getTypeReference(this.intStack[this.intPtr--]);
7279         wildcard.sourceEnd = wildcard.bound.sourceEnd;
7280         this.intPtr--; // remove end position of the '?'
7281         wildcard.sourceStart = this.intStack[this.intPtr--];
7282         pushOnGenericsStack(wildcard);
7283 }
7284 protected void consumeWildcardBoundsSuper() {
7285         Wildcard wildcard = new Wildcard(Wildcard.SUPER);
7286         wildcard.bound = getTypeReference(this.intStack[this.intPtr--]);
7287         this.intPtr--; // remove the starting position of the super keyword
7288         wildcard.sourceEnd = wildcard.bound.sourceEnd;
7289         this.intPtr--; // remove end position of the '?'
7290         wildcard.sourceStart = this.intStack[this.intPtr--];
7291         pushOnGenericsStack(wildcard);
7292 }
7293 protected void consumeWildcardWithBounds() {
7294         // Nothing to do
7295         // The wildcard is created by the consumeWildcardBoundsExtends or by consumeWildcardBoundsSuper
7296 }
7297 /**
7298  * Given the current comment stack, answer whether some comment is available in a certain exclusive range
7299  * 
7300  * @param sourceStart int
7301  * @param sourceEnd int
7302  * @return boolean
7303  */
7304 public boolean containsComment(int sourceStart, int sourceEnd) {
7305         int iComment = this.scanner.commentPtr;
7306         for (; iComment >= 0; iComment--) {
7307                 int commentStart = this.scanner.commentStarts[iComment];
7308                 // ignore comments before start
7309                 if (commentStart < sourceStart) continue;
7310                 // ignore comments after end
7311                 if (commentStart > sourceEnd) continue;
7312                 return true;
7313         }
7314         return false;
7315 }
7316 public MethodDeclaration convertToMethodDeclaration(ConstructorDeclaration c, CompilationResult compilationResult) {
7317         MethodDeclaration m = new MethodDeclaration(compilationResult);
7318         m.typeParameters = c.typeParameters;
7319         m.sourceStart = c.sourceStart;
7320         m.sourceEnd = c.sourceEnd;
7321         m.bodyStart = c.bodyStart;
7322         m.bodyEnd = c.bodyEnd;
7323         m.declarationSourceEnd = c.declarationSourceEnd;
7324         m.declarationSourceStart = c.declarationSourceStart;
7325         m.selector = c.selector;
7326         m.statements = c.statements;
7327         m.modifiers = c.modifiers;
7328         m.annotations = c.annotations;
7329         m.arguments = c.arguments;
7330         m.thrownExceptions = c.thrownExceptions;
7331         m.explicitDeclarations = c.explicitDeclarations;
7332         m.returnType = null;
7333         return m;
7334 }
7335 protected TypeReference copyDims(TypeReference typeRef, int dim) {
7336         return typeRef.copyDims(dim);
7337 }
7338 protected FieldDeclaration createFieldDeclaration(char[] fieldDeclarationName, int sourceStart, int sourceEnd) {
7339         return new FieldDeclaration(fieldDeclarationName, sourceStart, sourceEnd);
7340 }
7341
7342 protected LocalDeclaration createLocalDeclaration(char[] localDeclarationName, int sourceStart, int sourceEnd) {
7343         return new LocalDeclaration(localDeclarationName, sourceStart, sourceEnd);
7344 }
7345 protected RecoveredType currentRecoveryType() {
7346         if(this.currentElement != null) {
7347                 if(this.currentElement instanceof RecoveredType) {
7348                         return (RecoveredType) this.currentElement;
7349                 } else {
7350                         return this.currentElement.enclosingType();
7351                 }
7352         }
7353         return null;
7354 }
7355 public CompilationUnitDeclaration dietParse(ICompilationUnit sourceUnit, CompilationResult compilationResult) {
7356
7357         CompilationUnitDeclaration parsedUnit;
7358         boolean old = this.diet;
7359         try {
7360                 this.diet = true;
7361                 parsedUnit = parse(sourceUnit, compilationResult);
7362         }
7363         finally {
7364                 this.diet = old;
7365         }
7366         return parsedUnit;
7367 }
7368 protected void dispatchDeclarationInto(int length) {
7369         /* they are length on this.astStack that should go into
7370            methods fields constructors lists of the typeDecl
7371
7372            Return if there is a constructor declaration in the methods declaration */
7373            
7374         
7375         // Looks for the size of each array . 
7376
7377         if (length == 0)
7378                 return;
7379         int[] flag = new int[length + 1]; //plus one -- see <HERE>
7380         int size1 = 0, size2 = 0, size3 = 0;
7381         boolean hasAbstractMethods = false;
7382         for (int i = length - 1; i >= 0; i--) {
7383                 ASTNode astNode = this.astStack[this.astPtr--];
7384                 if (astNode instanceof AbstractMethodDeclaration) {
7385                         //methods and constructors have been regrouped into one single list
7386                         flag[i] = 2;
7387                         size2++;
7388                         if (((AbstractMethodDeclaration) astNode).isAbstract()) {
7389                                 hasAbstractMethods = true;
7390                         }
7391                 } else if (astNode instanceof TypeDeclaration) {
7392                         flag[i] = 3;
7393                         size3++;
7394                 } else {
7395                         //field
7396                         flag[i] = 1;
7397                         size1++;
7398                 }
7399         }
7400
7401         //arrays creation
7402         TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
7403         if (size1 != 0) {
7404                 typeDecl.fields = new FieldDeclaration[size1];
7405         }
7406         if (size2 != 0) {
7407                 typeDecl.methods = new AbstractMethodDeclaration[size2];
7408                 if (hasAbstractMethods) typeDecl.bits |= ASTNode.HasAbstractMethods;
7409         }
7410         if (size3 != 0) {
7411                 typeDecl.memberTypes = new TypeDeclaration[size3];
7412         }
7413
7414         //arrays fill up
7415         size1 = size2 = size3 = 0;
7416         int flagI = flag[0], start = 0;
7417         int length2;
7418         for (int end = 0; end <= length; end++) //<HERE> the plus one allows to 
7419                 {
7420                 if (flagI != flag[end]) //treat the last element as a ended flag.....
7421                         { //array copy
7422                         switch (flagI) {
7423                                 case 1 :
7424                                         size1 += (length2 = end - start);
7425                                         System.arraycopy(
7426                                                 this.astStack, 
7427                                                 this.astPtr + start + 1, 
7428                                                 typeDecl.fields, 
7429                                                 size1 - length2, 
7430                                                 length2); 
7431                                         break;
7432                                 case 2 :
7433                                         size2 += (length2 = end - start);
7434                                         System.arraycopy(
7435                                                 this.astStack, 
7436                                                 this.astPtr + start + 1, 
7437                                                 typeDecl.methods, 
7438                                                 size2 - length2, 
7439                                                 length2); 
7440                                         break;
7441                                 case 3 :
7442                                         size3 += (length2 = end - start);
7443                                         System.arraycopy(
7444                                                 this.astStack, 
7445                                                 this.astPtr + start + 1, 
7446                                                 typeDecl.memberTypes, 
7447                                                 size3 - length2, 
7448                                                 length2); 
7449                                         break;
7450                         }
7451                         flagI = flag[start = end];
7452                 }
7453         }
7454
7455         if (typeDecl.memberTypes != null) {
7456                 for (int i = typeDecl.memberTypes.length - 1; i >= 0; i--) {
7457                         typeDecl.memberTypes[i].enclosingType = typeDecl;
7458                 }
7459         }
7460 }
7461 protected void dispatchDeclarationIntoEnumDeclaration(int length) {
7462         
7463         if (length == 0)
7464       return;
7465    int[] flag = new int[length + 1]; //plus one -- see <HERE>
7466    int size1 = 0, size2 = 0, size3 = 0;
7467    TypeDeclaration enumDeclaration = (TypeDeclaration) this.astStack[this.astPtr - length];
7468    boolean hasAbstractMethods = false;
7469    for (int i = length - 1; i >= 0; i--) {
7470       ASTNode astNode = this.astStack[this.astPtr--];
7471       if (astNode instanceof AbstractMethodDeclaration) {
7472          //methods and constructors have been regrouped into one single list
7473          flag[i] = 2;
7474          size2++;
7475                 if (((AbstractMethodDeclaration) astNode).isAbstract()) {
7476                         hasAbstractMethods = true;
7477                 }         
7478       } else if (astNode instanceof TypeDeclaration) {
7479          flag[i] = 3;
7480          size3++;
7481       } else if (astNode instanceof FieldDeclaration) {
7482          flag[i] = 1;
7483          size1++;
7484 //         if(astNode instanceof EnumConstant) {
7485 //            EnumConstant constant = (EnumConstant) astNode;
7486 //            ((AllocationExpression)constant.initialization).type = new SingleTypeReference(enumDeclaration.name,
7487 //                  (((long) enumDeclaration.sourceStart) << 32) + enumDeclaration.sourceEnd);
7488 //         }
7489       }
7490    }
7491  
7492    //arrays creation
7493    if (size1 != 0) {
7494       enumDeclaration.fields = new FieldDeclaration[size1];
7495    }
7496    if (size2 != 0) {
7497       enumDeclaration.methods = new AbstractMethodDeclaration[size2];
7498       if (hasAbstractMethods) enumDeclaration.bits |= ASTNode.HasAbstractMethods;
7499    }
7500    if (size3 != 0) {
7501       enumDeclaration.memberTypes = new TypeDeclaration[size3];
7502    }
7503  
7504    //arrays fill up
7505    size1 = size2 = size3 = 0;
7506    int flagI = flag[0], start = 0;
7507    int length2;
7508    for (int end = 0; end <= length; end++) //<HERE> the plus one allows to 
7509       {
7510       if (flagI != flag[end]) //treat the last element as a ended flag.....
7511          { //array copy
7512          switch (flagI) {
7513             case 1 :
7514                size1 += (length2 = end - start);
7515                System.arraycopy(
7516                   this.astStack, 
7517                   this.astPtr + start + 1, 
7518                   enumDeclaration.fields, 
7519                   size1 - length2, 
7520                   length2); 
7521                break;
7522             case 2 :
7523                size2 += (length2 = end - start);
7524                System.arraycopy(
7525                   this.astStack, 
7526                   this.astPtr + start + 1, 
7527                   enumDeclaration.methods, 
7528                   size2 - length2, 
7529                   length2); 
7530                break;
7531             case 3 :
7532                size3 += (length2 = end - start);
7533                System.arraycopy(
7534                   this.astStack, 
7535                   this.astPtr + start + 1, 
7536                   enumDeclaration.memberTypes, 
7537                   size3 - length2, 
7538                   length2); 
7539                break;
7540          }
7541          flagI = flag[start = end];
7542       }
7543    }
7544  
7545    if (enumDeclaration.memberTypes != null) {
7546       for (int i = enumDeclaration.memberTypes.length - 1; i >= 0; i--) {
7547          enumDeclaration.memberTypes[i].enclosingType = enumDeclaration;
7548       }
7549    }}
7550 protected CompilationUnitDeclaration endParse(int act) {
7551
7552         this.lastAct = act;
7553
7554         if (this.currentElement != null){
7555                 this.currentElement.topElement().updateParseTree();
7556                 if (VERBOSE_RECOVERY){
7557                         System.out.print(Util.bind("parser.syntaxRecovery")); //$NON-NLS-1$
7558                         System.out.println("--------------------------");                //$NON-NLS-1$
7559                         System.out.println(this.compilationUnit);               
7560                         System.out.println("----------------------------------"); //$NON-NLS-1$
7561                 }               
7562         } else {
7563                 if (this.diet & VERBOSE_RECOVERY){
7564                         System.out.print(Util.bind("parser.regularParse"));      //$NON-NLS-1$
7565                         System.out.println("--------------------------");        //$NON-NLS-1$
7566                         System.out.println(this.compilationUnit);               
7567                         System.out.println("----------------------------------"); //$NON-NLS-1$
7568                 }
7569         }
7570         persistLineSeparatorPositions();
7571         for (int i = 0; i < this.scanner.foundTaskCount; i++){
7572                 problemReporter().task(
7573                         new String(this.scanner.foundTaskTags[i]), 
7574                         new String(this.scanner.foundTaskMessages[i]),
7575                         this.scanner.foundTaskPriorities[i] == null ? null : new String(this.scanner.foundTaskPriorities[i]), 
7576                         this.scanner.foundTaskPositions[i][0], 
7577                         this.scanner.foundTaskPositions[i][1]);
7578         }
7579         return this.compilationUnit;
7580 }
7581 /*
7582  * Flush comments defined prior to a given positions.
7583  *
7584  * Note: comments are stacked in syntactical order
7585  *
7586  * Either answer given <position>, or the end position of a comment line 
7587  * immediately following the <position> (same line)
7588  *
7589  * e.g.
7590  * void foo(){
7591  * } // end of method foo
7592  */
7593  
7594 public int flushCommentsDefinedPriorTo(int position) {
7595
7596         int lastCommentIndex = this.scanner.commentPtr;
7597         if (lastCommentIndex < 0) return position; // no comment
7598
7599         // compute the index of the first obsolete comment
7600         int index = lastCommentIndex;
7601         int validCount = 0;
7602         while (index >= 0){
7603                 int commentEnd = this.scanner.commentStops[index];
7604                 if (commentEnd < 0) commentEnd = -commentEnd; // negative end position for non-javadoc comments
7605                 if (commentEnd <= position){
7606                         break;
7607                 }
7608                 index--;
7609                 validCount++;
7610         }
7611         // if the source at <position> is immediately followed by a line comment, then
7612         // flush this comment and shift <position> to the comment end.
7613         if (validCount > 0){
7614                 int immediateCommentEnd = -this.scanner.commentStops[index+1]; //non-javadoc comment end positions are negative
7615                 if (immediateCommentEnd > 0){ // only tolerating non-javadoc comments
7616                         // is there any line break until the end of the immediate comment ? (thus only tolerating line comment)
7617                         immediateCommentEnd--; // comment end in one char too far
7618                         if (this.scanner.getLineNumber(position) == this.scanner.getLineNumber(immediateCommentEnd)){
7619                                 position = immediateCommentEnd;
7620                                 validCount--; // flush this comment
7621                                 index++;
7622                         }
7623                 }
7624         }
7625
7626         if (index < 0) return position; // no obsolete comment
7627
7628         if (validCount > 0){ // move valid comment infos, overriding obsolete comment infos
7629                 System.arraycopy(this.scanner.commentStarts, index + 1, this.scanner.commentStarts, 0, validCount);
7630                 System.arraycopy(this.scanner.commentStops, index + 1, this.scanner.commentStops, 0, validCount);               
7631         }
7632         this.scanner.commentPtr = validCount - 1;
7633         return position;
7634 }
7635 public int getFirstToken() {
7636         // the first token is a virtual token that
7637         // allows the parser to parse several goals
7638         // even if they aren't LALR(1)....
7639         // Goal ::= '++' CompilationUnit
7640         // Goal ::= '--' MethodBody
7641         // Goal ::= '==' ConstructorBody
7642         // -- Initializer
7643         // Goal ::= '>>' StaticInitializer
7644         // Goal ::= '>>' Block
7645         // -- error recovery
7646         // Goal ::= '>>>' Headers
7647         // Goal ::= '*' BlockStatements
7648         // Goal ::= '*' MethodPushModifiersHeader
7649         // -- JDOM
7650         // Goal ::= '&&' FieldDeclaration
7651         // Goal ::= '||' ImportDeclaration
7652         // Goal ::= '?' PackageDeclaration
7653         // Goal ::= '+' TypeDeclaration
7654         // Goal ::= '/' GenericMethodDeclaration
7655         // Goal ::= '&' ClassBodyDeclaration
7656         // -- code snippet
7657         // Goal ::= '%' Expression
7658         // -- completion parser
7659         // Goal ::= '!' ConstructorBlockStatementsopt
7660         // Goal ::= '~' BlockStatementsopt
7661         
7662         return this.firstToken;
7663 }
7664 /*
7665  * Answer back an array of sourceStart/sourceEnd positions of the available JavaDoc comments.
7666  * The array is a flattened structure: 2*n entries with consecutives start and end positions.
7667  *
7668  * If no JavaDoc is available, then null is answered instead of an empty array.
7669  *
7670  * e.g. { 10, 20, 25, 45 }  --> javadoc1 from 10 to 20, javadoc2 from 25 to 45
7671  */
7672 public int[] getJavaDocPositions() {
7673
7674         int javadocCount = 0;
7675         for (int i = 0, max = this.scanner.commentPtr; i <= max; i++){
7676                 // javadoc only (non javadoc comment have negative end positions.)
7677                 if (this.scanner.commentStops[i] > 0){
7678                         javadocCount++;
7679                 }
7680         }
7681         if (javadocCount == 0) return null;
7682
7683         int[] positions = new int[2*javadocCount];
7684         int index = 0;
7685         for (int i = 0, max = this.scanner.commentPtr; i <= max; i++){
7686                 // javadoc only (non javadoc comment have negative end positions.)
7687                 if (this.scanner.commentStops[i] > 0){
7688                         positions[index++] = this.scanner.commentStarts[i];
7689                         positions[index++] = this.scanner.commentStops[i]-1; //stop is one over                 
7690                 }
7691         }
7692         return positions;
7693 }
7694         public void getMethodBodies(CompilationUnitDeclaration unit) {
7695                 //fill the methods bodies in order for the code to be generated
7696
7697                 if (unit == null) return;
7698                 
7699                 if (unit.ignoreMethodBodies) {
7700                         unit.ignoreFurtherInvestigation = true;
7701                         return;
7702                         // if initial diet parse did not work, no need to dig into method bodies.
7703                 }
7704
7705                 if ((unit.bits & ASTNode.HasAllMethodBodies) != 0)
7706                         return; //work already done ...
7707
7708                 // save existing values to restore them at the end of the parsing process
7709                 // see bug 47079 for more details
7710                 int[] oldLineEnds = this.scanner.lineEnds;
7711                 int oldLinePtr = this.scanner.linePtr;
7712
7713                 //real parse of the method....
7714                 CompilationResult compilationResult = unit.compilationResult;
7715                 this.scanner.setSource(compilationResult);
7716                 
7717                 if (this.javadocParser != null && this.javadocParser.checkDocComment) {
7718                         char[] contents = compilationResult.compilationUnit.getContents();
7719                         this.javadocParser.scanner.setSource(contents);
7720                 }
7721                 if (unit.types != null) {
7722                         for (int i = unit.types.length; --i >= 0;)
7723                                 unit.types[i].parseMethod(this, unit);
7724                 }
7725                 
7726                 // tag unit has having read bodies
7727                 unit.bits |= ASTNode.HasAllMethodBodies;
7728
7729                 // this is done to prevent any side effects on the compilation unit result
7730                 // line separator positions array.
7731                 this.scanner.lineEnds = oldLineEnds;
7732                 this.scanner.linePtr = oldLinePtr;
7733         }
7734 protected char getNextCharacter(char[] comment, int[] index) {
7735         char nextCharacter = comment[index[0]++];
7736         switch(nextCharacter) {
7737                 case '\\' :
7738                         int c1, c2, c3, c4;
7739                         index[0]++;
7740                         while (comment[index[0]] == 'u') index[0]++;
7741                         if (!(((c1 = Character.getNumericValue(comment[index[0]++])) > 15
7742                                 || c1 < 0)
7743                                 || ((c2 = Character.getNumericValue(comment[index[0]++])) > 15 || c2 < 0)
7744                                 || ((c3 = Character.getNumericValue(comment[index[0]++])) > 15 || c3 < 0)
7745                                 || ((c4 = Character.getNumericValue(comment[index[0]++])) > 15 || c4 < 0))) {
7746                                         nextCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4);
7747                         }
7748                         break;
7749         }
7750         return nextCharacter;
7751 }
7752 protected Expression getTypeReference(Expression exp) {
7753         
7754         exp.bits &= ~ASTNode.RestrictiveFlagMASK;
7755         exp.bits |= Binding.TYPE;
7756         return exp;
7757 }
7758 protected TypeReference getTypeReference(int dim) {
7759         /* build a Reference on a variable that may be qualified or not
7760          This variable is a type reference and dim will be its dimensions*/
7761
7762         TypeReference ref;
7763         int length = this.identifierLengthStack[this.identifierLengthPtr--];
7764         if (length < 0) { //flag for precompiled type reference on base types
7765                 ref = TypeReference.baseTypeReference(-length, dim);
7766                 ref.sourceStart = this.intStack[this.intPtr--];
7767                 if (dim == 0) {
7768                         ref.sourceEnd = this.intStack[this.intPtr--];
7769                 } else {
7770                         this.intPtr--;
7771                         ref.sourceEnd = this.endPosition;
7772                 }
7773         } else {
7774                 int numberOfIdentifiers = this.genericsIdentifiersLengthStack[this.genericsIdentifiersLengthPtr--];
7775                 if (length != numberOfIdentifiers || this.genericsLengthStack[this.genericsLengthPtr] != 0) {
7776                         // generic type
7777                         ref = getTypeReferenceForGenericType(dim, length, numberOfIdentifiers);
7778                 } else if (length == 1) {
7779                         // single variable reference
7780                         this.genericsLengthPtr--; // pop the 0
7781                         if (dim == 0) {
7782                                 ref = 
7783                                         new SingleTypeReference(
7784                                                 this.identifierStack[this.identifierPtr], 
7785                                                 this.identifierPositionStack[this.identifierPtr--]); 
7786                         } else {
7787                                 ref = 
7788                                         new ArrayTypeReference(
7789                                                 this.identifierStack[this.identifierPtr], 
7790                                                 dim, 
7791                                                 this.identifierPositionStack[this.identifierPtr--]); 
7792                                 ref.sourceEnd = this.endPosition;                       
7793                         }
7794                 } else {
7795                         this.genericsLengthPtr--;
7796                         //Qualified variable reference
7797                         char[][] tokens = new char[length][];
7798                         this.identifierPtr -= length;
7799                         long[] positions = new long[length];
7800                         System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
7801                         System.arraycopy(
7802                                 this.identifierPositionStack, 
7803                                 this.identifierPtr + 1, 
7804                                 positions, 
7805                                 0, 
7806                                 length); 
7807                         if (dim == 0) {
7808                                 ref = new QualifiedTypeReference(tokens, positions);
7809                         } else {
7810                                 ref = new ArrayQualifiedTypeReference(tokens, dim, positions);
7811                                 ref.sourceEnd = this.endPosition;
7812                         }
7813                 }
7814         }
7815         return ref;
7816 }
7817 protected TypeReference getTypeReferenceForGenericType(int dim, int identifierLength, int numberOfIdentifiers) {
7818         if (identifierLength == 1 && numberOfIdentifiers == 1) {
7819                 int currentTypeArgumentsLength = this.genericsLengthStack[this.genericsLengthPtr--];
7820                 TypeReference[] typeArguments = new TypeReference[currentTypeArgumentsLength];
7821                 this.genericsPtr -= currentTypeArgumentsLength;
7822                 System.arraycopy(this.genericsStack, this.genericsPtr + 1, typeArguments, 0, currentTypeArgumentsLength);
7823                 ParameterizedSingleTypeReference parameterizedSingleTypeReference = new ParameterizedSingleTypeReference(this.identifierStack[this.identifierPtr], typeArguments, dim, this.identifierPositionStack[this.identifierPtr--]);
7824                 if (dim != 0) {
7825                         parameterizedSingleTypeReference.sourceEnd = this.endPosition;
7826                 }
7827                 return parameterizedSingleTypeReference;
7828         } else {
7829                 TypeReference[][] typeArguments = new TypeReference[numberOfIdentifiers][];
7830                 char[][] tokens = new char[numberOfIdentifiers][];
7831                 long[] positions = new long[numberOfIdentifiers];
7832                 int index = numberOfIdentifiers;
7833                 int currentIdentifiersLength = identifierLength;
7834                 while (index > 0) {
7835                         int currentTypeArgumentsLength = this.genericsLengthStack[this.genericsLengthPtr--];
7836                         if (currentTypeArgumentsLength != 0) {
7837                                 this.genericsPtr -= currentTypeArgumentsLength;
7838                                 System.arraycopy(this.genericsStack, this.genericsPtr + 1, typeArguments[index - 1] = new TypeReference[currentTypeArgumentsLength], 0, currentTypeArgumentsLength);
7839                         }
7840                         switch(currentIdentifiersLength) {
7841                                 case 1 :
7842                                         // we are in a case A<B>.C<D> or A<B>.C<D>
7843                                         tokens[index - 1] = this.identifierStack[this.identifierPtr];
7844                                         positions[index - 1] = this.identifierPositionStack[this.identifierPtr--];
7845                                         break;
7846                                 default:
7847                                         // we are in a case A.B.C<B>.C<D> or A.B.C<B>...
7848                                         this.identifierPtr -= currentIdentifiersLength;
7849                                         System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, index - currentIdentifiersLength, currentIdentifiersLength);
7850                                         System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, index - currentIdentifiersLength, currentIdentifiersLength);
7851                         }
7852                         index -= currentIdentifiersLength;
7853                         if (index > 0) {
7854                                 currentIdentifiersLength = this.identifierLengthStack[this.identifierLengthPtr--];
7855                         }
7856                 }
7857                 return new ParameterizedQualifiedTypeReference(tokens, typeArguments, dim, positions);
7858         }
7859 }
7860 protected NameReference getUnspecifiedReference() {
7861         /* build a (unspecified) NameReference which may be qualified*/
7862
7863         int length;
7864         NameReference ref;
7865         if ((length = this.identifierLengthStack[this.identifierLengthPtr--]) == 1)
7866                 // single variable reference
7867                 ref = 
7868                         new SingleNameReference(
7869                                 this.identifierStack[this.identifierPtr], 
7870                                 this.identifierPositionStack[this.identifierPtr--]); 
7871         else
7872                 //Qualified variable reference
7873                 {
7874                 char[][] tokens = new char[length][];
7875                 this.identifierPtr -= length;
7876                 System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
7877                 long[] positions = new long[length];
7878                 System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
7879                 ref = 
7880                         new QualifiedNameReference(tokens, 
7881                                 positions,
7882                                 (int) (this.identifierPositionStack[this.identifierPtr + 1] >> 32), // sourceStart
7883                                 (int) this.identifierPositionStack[this.identifierPtr + length]); // sourceEnd
7884         }
7885         return ref;
7886 }
7887 protected NameReference getUnspecifiedReferenceOptimized() {
7888         /* build a (unspecified) NameReference which may be qualified
7889         The optimization occurs for qualified reference while we are
7890         certain in this case the last item of the qualified name is
7891         a field access. This optimization is IMPORTANT while it results
7892         that when a NameReference is build, the type checker should always
7893         look for that it is not a type reference */
7894
7895         int length;
7896         NameReference ref;
7897         if ((length = this.identifierLengthStack[this.identifierLengthPtr--]) == 1) {
7898                 // single variable reference
7899                 ref = 
7900                         new SingleNameReference(
7901                                 this.identifierStack[this.identifierPtr], 
7902                                 this.identifierPositionStack[this.identifierPtr--]); 
7903                 ref.bits &= ~ASTNode.RestrictiveFlagMASK;
7904                 ref.bits |= Binding.LOCAL | Binding.FIELD;
7905                 return ref;
7906         }
7907
7908         //Qualified-variable-reference
7909         //In fact it is variable-reference DOT field-ref , but it would result in a type
7910         //conflict tha can be only reduce by making a superclass (or inetrface ) between
7911         //nameReference and FiledReference or putting FieldReference under NameReference
7912         //or else..........This optimisation is not really relevant so just leave as it is
7913
7914         char[][] tokens = new char[length][];
7915         this.identifierPtr -= length;
7916         System.arraycopy(this.identifierStack, this.identifierPtr + 1, tokens, 0, length);
7917         long[] positions = new long[length];
7918         System.arraycopy(this.identifierPositionStack, this.identifierPtr + 1, positions, 0, length);
7919         ref = new QualifiedNameReference(
7920                         tokens,
7921                         positions, 
7922                         (int) (this.identifierPositionStack[this.identifierPtr + 1] >> 32), // sourceStart
7923                         (int) this.identifierPositionStack[this.identifierPtr + length]); // sourceEnd
7924         ref.bits &= ~ASTNode.RestrictiveFlagMASK;
7925         ref.bits |= Binding.LOCAL | Binding.FIELD;
7926         return ref;
7927 }
7928 public void goForBlockStatementsopt() {
7929         //tells the scanner to go for block statements opt parsing
7930
7931         this.firstToken = TokenNameTWIDDLE;
7932         this.scanner.recordLineSeparator = false;
7933 }
7934 public void goForBlockStatementsOrCatchHeader() {
7935         //tells the scanner to go for block statements or method headers parsing 
7936
7937         this.firstToken = TokenNameMULTIPLY;
7938         this.scanner.recordLineSeparator = false;
7939 }
7940 public void goForClassBodyDeclarations() {
7941         //tells the scanner to go for any body declarations parsing
7942
7943         this.firstToken = TokenNameAND;
7944         this.scanner.recordLineSeparator = true;
7945 }
7946 public void goForCompilationUnit(){
7947         //tells the scanner to go for compilation unit parsing
7948
7949         this.firstToken = TokenNamePLUS_PLUS ;
7950         this.scanner.foundTaskCount = 0;
7951         this.scanner.recordLineSeparator = true;
7952         this.scanner.currentLine= null;
7953 }
7954 public void goForExpression() {
7955         //tells the scanner to go for an expression parsing
7956
7957         this.firstToken = TokenNameREMAINDER;
7958         this.scanner.recordLineSeparator = true; // recovery goals must record line separators
7959 }
7960 public void goForFieldDeclaration(){
7961         //tells the scanner to go for field declaration parsing
7962
7963         this.firstToken = TokenNameAND_AND ;
7964         this.scanner.recordLineSeparator = true;
7965 }
7966 public void goForGenericMethodDeclaration(){
7967         //tells the scanner to go for generic method declarations parsing
7968
7969         this.firstToken = TokenNameDIVIDE;
7970         this.scanner.recordLineSeparator = true;
7971 }
7972 public void goForHeaders(){
7973         //tells the scanner to go for headers only parsing
7974         RecoveredType currentType = this.currentRecoveryType();
7975         if(currentType != null && currentType.insideEnumConstantPart) {
7976                 this.firstToken = TokenNameNOT;
7977         } else {
7978                 this.firstToken = TokenNameUNSIGNED_RIGHT_SHIFT;
7979         }
7980         this.scanner.recordLineSeparator = true; // recovery goals must record line separators
7981 }
7982 public void goForImportDeclaration(){
7983         //tells the scanner to go for import declaration parsing
7984
7985         this.firstToken = TokenNameOR_OR ;
7986         this.scanner.recordLineSeparator = true;
7987 }
7988 public void goForInitializer(){
7989         //tells the scanner to go for initializer parsing
7990
7991         this.firstToken = TokenNameRIGHT_SHIFT ;
7992         this.scanner.recordLineSeparator = false;
7993 }
7994 public void goForMemberValue() {
7995         //tells the scanner to go for a memeber value parsing
7996
7997         this.firstToken = TokenNameOR_OR;
7998         this.scanner.recordLineSeparator = true; // recovery goals must record line separators
7999 }
8000 public void goForMethodBody(){
8001         //tells the scanner to go for method body parsing
8002
8003         this.firstToken = TokenNameMINUS_MINUS ;
8004         this.scanner.recordLineSeparator = false;
8005 }
8006 public void goForPackageDeclaration() {
8007         //tells the scanner to go for package declaration parsing
8008
8009         this.firstToken = TokenNameQUESTION;
8010         this.scanner.recordLineSeparator = true;
8011 }
8012 public void goForTypeDeclaration() {
8013         //tells the scanner to go for type (interface or class) declaration parsing
8014
8015         this.firstToken = TokenNamePLUS;
8016         this.scanner.recordLineSeparator = true;
8017 }
8018 protected void ignoreExpressionAssignment() {
8019         // Assignment ::= InvalidArrayInitializerAssignement
8020         // encoded operator would be: this.intStack[this.intPtr]
8021         this.intPtr--;
8022         ArrayInitializer arrayInitializer = (ArrayInitializer) this.expressionStack[this.expressionPtr--];
8023         this.expressionLengthPtr -- ;
8024         // report a syntax error and abort parsing
8025         problemReporter().arrayConstantsOnlyInArrayInitializers(arrayInitializer.sourceStart, arrayInitializer.sourceEnd);      
8026 }
8027 protected void ignoreInterfaceDeclaration() {
8028         // BlockStatement ::= InvalidInterfaceDeclaration
8029         //InterfaceDeclaration ::= Modifiersopt 'interface' 'Identifier' ExtendsInterfacesopt InterfaceHeader InterfaceBody
8030
8031         // length declarations
8032         int length;
8033         if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
8034                 //there are length declarations
8035                 //dispatch according to the type of the declarations
8036                 dispatchDeclarationInto(length);
8037         }
8038         
8039         flushCommentsDefinedPriorTo(this.endStatementPosition);
8040
8041         // report the problem and continue parsing
8042         TypeDeclaration typeDecl = (TypeDeclaration) this.astStack[this.astPtr];
8043         typeDecl.bodyEnd = this.endStatementPosition;
8044         problemReporter().cannotDeclareLocalInterface(typeDecl.name, typeDecl.sourceStart, typeDecl.sourceEnd);
8045
8046         // mark initializers with local type mark if needed
8047         markInitializersWithLocalType(typeDecl);
8048
8049         // remove the ast node created in interface header
8050         this.astPtr--;
8051         pushOnAstLengthStack(-1);
8052         concatNodeLists();
8053 }
8054 protected void ignoreInvalidConstructorDeclaration(boolean hasBody) {
8055         // InvalidConstructorDeclaration ::= ConstructorHeader ConstructorBody ==> true
8056         // InvalidConstructorDeclaration ::= ConstructorHeader ';' ==> false
8057
8058         /*
8059         this.astStack : modifiers arguments throws statements
8060         this.identifierStack : name
8061          ==>
8062         this.astStack : MethodDeclaration
8063         this.identifierStack :
8064         */
8065         if (hasBody) {
8066                 // pop the position of the {  (body of the method) pushed in block decl
8067                 this.intPtr--;
8068         }
8069
8070         //statements
8071         if (hasBody) {
8072                 this.realBlockPtr--;
8073         }
8074
8075         int length;
8076         if (hasBody && ((length = this.astLengthStack[this.astLengthPtr--]) != 0)) {
8077                 this.astPtr -= length;
8078         }
8079         ConstructorDeclaration constructorDeclaration = (ConstructorDeclaration) this.astStack[this.astPtr];
8080         constructorDeclaration.bodyEnd = this.endStatementPosition;
8081         constructorDeclaration.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
8082         if (!hasBody) {
8083                 constructorDeclaration.modifiers |= AccSemicolonBody;
8084         }
8085 }
8086 protected void ignoreMethodBody() {
8087         // InterfaceMemberDeclaration ::= InvalidMethodDeclaration
8088
8089         /*
8090         this.astStack : modifiers arguments throws statements
8091         this.identifierStack : type name
8092         this.intStack : dim dim dim
8093          ==>
8094         this.astStack : MethodDeclaration
8095         this.identifierStack :
8096         this.intStack : 
8097         */
8098
8099         // pop the position of the {  (body of the method) pushed in block decl
8100         this.intPtr--;
8101         // retrieve end position of method declarator
8102
8103         //statements
8104         this.realBlockPtr--;
8105         int length;
8106         if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
8107                 this.astPtr -= length;
8108         }
8109
8110         //watch for } that could be given as a unicode ! ( u007D is '}' )
8111         MethodDeclaration md = (MethodDeclaration) this.astStack[this.astPtr];
8112         md.bodyEnd = this.endPosition;
8113         md.declarationSourceEnd = flushCommentsDefinedPriorTo(this.endStatementPosition);
8114
8115         // report the problem and continue the parsing - narrowing the problem onto the method
8116         problemReporter().abstractMethodNeedingNoBody(md);
8117 }
8118 public void initialize() {
8119         //positionning the parser for a new compilation unit
8120         //avoiding stack reallocation and all that....
8121         this.astPtr = -1;
8122         this.astLengthPtr = -1;
8123         this.expressionPtr = -1;
8124         this.expressionLengthPtr = -1;
8125         this.identifierPtr = -1;        
8126         this.identifierLengthPtr        = -1;
8127         this.intPtr = -1;
8128         this.nestedMethod[this.nestedType = 0] = 0; // need to reset for further reuse
8129         this.variablesCounter[this.nestedType] = 0;
8130         this.dimensions = 0 ;
8131         this.realBlockPtr = -1;
8132         this.compilationUnit = null;
8133         this.referenceContext = null;
8134         this.endStatementPosition = 0;
8135
8136         //remove objects from stack too, while the same parser/compiler couple is
8137         //re-used between two compilations ....
8138         
8139         int astLength = this.astStack.length;
8140         if (this.noAstNodes.length < astLength){
8141                 this.noAstNodes = new ASTNode[astLength];
8142                 //System.out.println("Resized AST stacks : "+ astLength);
8143                 
8144         }
8145         System.arraycopy(this.noAstNodes, 0, this.astStack, 0, astLength);
8146
8147         int expressionLength = this.expressionStack.length;
8148         if (this.noExpressions.length < expressionLength){
8149                 this.noExpressions = new Expression[expressionLength];
8150                 //System.out.println("Resized EXPR stacks : "+ expressionLength);
8151         }
8152         System.arraycopy(this.noExpressions, 0, this.expressionStack, 0, expressionLength);
8153
8154         // reset this.scanner state
8155         this.scanner.commentPtr = -1;
8156         this.scanner.foundTaskCount = 0;
8157         this.scanner.eofPosition = Integer.MAX_VALUE;
8158         this.scanner.wasNonExternalizedStringLiteral = false;
8159         this.scanner.nonNLSStrings = null;
8160         this.scanner.currentLine = null;        
8161
8162         resetModifiers();
8163
8164         // recovery
8165         this.lastCheckPoint = -1;
8166         this.currentElement = null;
8167         this.restartRecovery = false;
8168         this.hasReportedError = false;
8169         this.recoveredStaticInitializerStart = 0;
8170         this.lastIgnoredToken = -1;
8171         this.lastErrorEndPosition = -1;
8172         this.lastErrorEndPositionBeforeRecovery = -1;
8173         this.lastJavadocEnd = -1;
8174         this.listLength = 0;
8175         this.listTypeParameterLength = 0;
8176         
8177         this.rBraceStart = 0;
8178         this.rBraceEnd = 0;
8179         this.rBraceSuccessorStart = 0;
8180
8181         this.genericsIdentifiersLengthPtr = -1;
8182         this.genericsLengthPtr = -1;
8183         this.genericsPtr = -1;
8184 }
8185 public void initializeScanner(){
8186         this.scanner = new Scanner(
8187                 false /*comment*/, 
8188                 false /*whitespace*/, 
8189                 this.options.getSeverity(CompilerOptions.NonExternalizedString) != ProblemSeverities.Ignore /*nls*/, 
8190                 this.options.sourceLevel /*sourceLevel*/, 
8191                 this.options.taskTags/*taskTags*/,
8192                 this.options.taskPriorites/*taskPriorities*/,
8193                 this.options.isTaskCaseSensitive/*taskCaseSensitive*/);
8194 }
8195 public void jumpOverMethodBody() {
8196         //on diet parsing.....do not buffer method statements
8197
8198         //the scanner.diet is reinitialized to false
8199         //automatically by the scanner once it has jumped over
8200         //the statements
8201
8202         if (this.diet && (this.dietInt == 0))
8203                 this.scanner.diet = true;
8204 }
8205 protected void markEnclosingMemberWithLocalType() {
8206         if (this.currentElement != null) return; // this is already done in the recovery code
8207         for (int i = this.astPtr; i >= 0; i--) {
8208                 ASTNode node = this.astStack[i];
8209                 if (node instanceof AbstractMethodDeclaration 
8210                                 || node instanceof FieldDeclaration
8211                                 || node instanceof TypeDeclaration) { // mark type for now: all initializers will be marked when added to this type
8212                         node.bits |= ASTNode.HasLocalTypeMASK;
8213                         return;
8214                 }
8215         }
8216         // default to reference context (case of parse method body)
8217         if (this.referenceContext instanceof AbstractMethodDeclaration
8218                         || this.referenceContext instanceof TypeDeclaration) {
8219                 ((ASTNode)this.referenceContext).bits |= ASTNode.HasLocalTypeMASK;
8220         }
8221 }
8222 protected void markInitializersWithLocalType(TypeDeclaration type) {
8223         if (type.fields == null || (type.bits & ASTNode.HasLocalTypeMASK) == 0) return;
8224         for (int i = 0, length = type.fields.length; i < length; i++) {
8225                 FieldDeclaration field = type.fields[i];
8226                 if (field instanceof Initializer) {
8227                         field.bits |= ASTNode.HasLocalTypeMASK;
8228                 }
8229         }
8230 }
8231 /*
8232  * Move checkpoint location (current implementation is moving it by one token)
8233  *
8234  * Answers true if successfully moved checkpoint (in other words, it did not attempt to move it
8235  * beyond end of file).
8236  */
8237 protected boolean moveRecoveryCheckpoint() {
8238
8239         int pos = this.lastCheckPoint;
8240         /* reset this.scanner, and move checkpoint by one token */
8241         this.scanner.startPosition = pos;
8242         this.scanner.currentPosition = pos;
8243         this.scanner.diet = false; // quit jumping over method bodies
8244         
8245         /* if about to restart, then no need to shift token */
8246         if (this.restartRecovery){
8247                 this.lastIgnoredToken = -1;
8248                 this.scanner.currentLine = null;
8249                 return true;
8250         }
8251         
8252         /* protect against shifting on an invalid token */
8253         this.lastIgnoredToken = this.nextIgnoredToken;
8254         this.nextIgnoredToken = -1;
8255         do {
8256                 try {
8257                         this.nextIgnoredToken = this.scanner.getNextToken();
8258                         if(this.scanner.currentPosition == this.scanner.startPosition){
8259                                 this.scanner.currentPosition++; // on fake completion identifier
8260                                 this.nextIgnoredToken = -1;
8261                         }
8262                         
8263                 } catch(InvalidInputException e){
8264                         pos = this.scanner.currentPosition;
8265                 }
8266         } while (this.nextIgnoredToken < 0);
8267         
8268         if (this.nextIgnoredToken == TokenNameEOF) { // no more recovery after this point
8269                 if (this.currentToken == TokenNameEOF) { // already tried one iteration on EOF
8270                         this.scanner.currentLine = null;
8271                         return false;
8272                 }
8273         }
8274         this.lastCheckPoint = this.scanner.currentPosition;
8275         
8276         /* reset this.scanner again to previous checkpoint location*/
8277         this.scanner.startPosition = pos;
8278         this.scanner.currentPosition = pos;
8279         this.scanner.commentPtr = -1;
8280         this.scanner.foundTaskCount = 0;
8281         this.scanner.currentLine = null;
8282
8283         return true;
8284
8285 /*
8286         The following implementation moves the checkpoint location by one line:
8287          
8288         int pos = this.lastCheckPoint;
8289         // reset this.scanner, and move checkpoint by one token
8290         this.scanner.startPosition = pos;
8291         this.scanner.currentPosition = pos;
8292         this.scanner.diet = false; // quit jumping over method bodies
8293         
8294         // if about to restart, then no need to shift token
8295         if (this.restartRecovery){
8296                 this.lastIgnoredToken = -1;
8297                 return true;
8298         }
8299         
8300         // protect against shifting on an invalid token
8301         this.lastIgnoredToken = this.nextIgnoredToken;
8302         this.nextIgnoredToken = -1;
8303         
8304         boolean wasTokenizingWhiteSpace = this.scanner.tokenizeWhiteSpace;
8305         this.scanner.tokenizeWhiteSpace = true;
8306         checkpointMove: 
8307                 do {
8308                         try {
8309                                 this.nextIgnoredToken = this.scanner.getNextToken();
8310                                 switch(this.nextIgnoredToken){
8311                                         case Scanner.TokenNameWHITESPACE :
8312                                                 if(this.scanner.getLineNumber(this.scanner.startPosition)
8313                                                         == this.scanner.getLineNumber(this.scanner.currentPosition)){
8314                                                         this.nextIgnoredToken = -1;
8315                                                         }
8316                                                 break;
8317                                         case TokenNameSEMICOLON :
8318                                         case TokenNameLBRACE :
8319                                         case TokenNameRBRACE :
8320                                                 break;
8321                                         case TokenNameIdentifier :
8322                                                 if(this.scanner.currentPosition == this.scanner.startPosition){
8323                                                         this.scanner.currentPosition++; // on fake completion identifier
8324                                                 }
8325                                         default:                                                
8326                                                 this.nextIgnoredToken = -1;
8327                                                 break;
8328                                         case TokenNameEOF :
8329                                                 break checkpointMove;
8330                                 }
8331                         } catch(InvalidInputException e){
8332                                 pos = this.scanner.currentPosition;
8333                         }
8334                 } while (this.nextIgnoredToken < 0);
8335         this.scanner.tokenizeWhiteSpace = wasTokenizingWhiteSpace;
8336         
8337         if (this.nextIgnoredToken == TokenNameEOF) { // no more recovery after this point
8338                 if (this.currentToken == TokenNameEOF) { // already tried one iteration on EOF
8339                         return false;
8340                 }
8341         }
8342         this.lastCheckPoint = this.scanner.currentPosition;
8343         
8344         // reset this.scanner again to previous checkpoint location
8345         this.scanner.startPosition = pos;
8346         this.scanner.currentPosition = pos;
8347         this.scanner.commentPtr = -1;
8348
8349         return true;
8350 */
8351 }
8352 protected MessageSend newMessageSend() {
8353         // '(' ArgumentListopt ')'
8354         // the arguments are on the expression stack
8355
8356         MessageSend m = new MessageSend();
8357         int length;
8358         if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
8359                 this.expressionPtr -= length;
8360                 System.arraycopy(
8361                         this.expressionStack, 
8362                         this.expressionPtr + 1, 
8363                         m.arguments = new Expression[length], 
8364                         0, 
8365                         length); 
8366         }
8367         return m;
8368 }
8369 protected MessageSend newMessageSendWithTypeArguments() {
8370         MessageSend m = new MessageSend();
8371         int length;
8372         if ((length = this.expressionLengthStack[this.expressionLengthPtr--]) != 0) {
8373                 this.expressionPtr -= length;
8374                 System.arraycopy(
8375                         this.expressionStack, 
8376                         this.expressionPtr + 1, 
8377                         m.arguments = new Expression[length], 
8378                         0, 
8379                         length); 
8380         }
8381         return m;
8382 }
8383 protected void optimizedConcatNodeLists() {
8384         /*back from a recursive loop. Virtualy group the
8385         astNode into an array using this.astLengthStack*/
8386
8387         /*
8388          * This is a case where you have two sublists into the this.astStack that you want
8389          * to merge in one list. There is no action required on the this.astStack. The only
8390          * thing you need to do is merge the two lengths specified on the astStackLength.
8391          * The top two length are for example:
8392          * ... p   n
8393          * and you want to result in a list like:
8394          * ... n+p 
8395          * This means that the p could be equals to 0 in case there is no astNode pushed
8396          * on the this.astStack.
8397          * Look at the InterfaceMemberDeclarations for an example.
8398          * This case optimizes the fact that p == 1.
8399          */
8400
8401         this.astLengthStack[--this.astLengthPtr]++;
8402 }
8403 /*main loop of the automat
8404 When a rule is reduced, the method consumeRule(int) is called with the number
8405 of the consumed rule. When a terminal is consumed, the method consumeToken(int) is 
8406 called in order to remember (when needed) the consumed token */
8407 // (int)asr[asi(act)]
8408 // name[symbol_index[currentKind]]
8409 protected void parse() {
8410         if (DEBUG) System.out.println("-- ENTER INSIDE PARSE METHOD --");  //$NON-NLS-1$
8411         boolean isDietParse = this.diet;
8412         int oldFirstToken = getFirstToken();
8413         this.hasError = false;
8414         
8415         this.hasReportedError = false;
8416         int act = START_STATE;
8417         this.stateStackTop = -1;
8418         this.currentToken = getFirstToken();
8419         ProcessTerminals : for (;;) {
8420                 int stackLength = this.stack.length;
8421                 if (++this.stateStackTop >= stackLength) {
8422                         System.arraycopy(
8423                                 this.stack, 0,
8424                                 this.stack = new int[stackLength + StackIncrement], 0,
8425                                 stackLength);
8426                 }
8427                 this.stack[this.stateStackTop] = act;
8428
8429                 act = tAction(act, this.currentToken);
8430                 if (act == ERROR_ACTION || this.restartRecovery) {
8431                         int errorPos = this.scanner.currentPosition;
8432                         if (!this.hasReportedError) {
8433                                 this.hasError = true;
8434                         }
8435                         if (resumeOnSyntaxError()) {
8436                                 if (act == ERROR_ACTION) this.lastErrorEndPosition = errorPos;
8437                                 act = START_STATE;
8438                                 this.stateStackTop = -1;
8439                                 this.currentToken = getFirstToken();
8440                                 continue ProcessTerminals;
8441                         }
8442                         act = ERROR_ACTION;
8443                         break ProcessTerminals;
8444                 }
8445                 if (act <= NUM_RULES) {
8446                         this.stateStackTop--;
8447
8448                 } else if (act > ERROR_ACTION) { /* shift-reduce */
8449                         consumeToken(this.currentToken);
8450                         if (this.currentElement != null) this.recoveryTokenCheck();
8451                         try {
8452                                 this.currentToken = this.scanner.getNextToken();
8453                         } catch(InvalidInputException e){
8454                                 if (!this.hasReportedError){
8455                                         this.problemReporter().scannerError(this, e.getMessage());
8456                                         this.hasReportedError = true;
8457                                 }
8458                                 this.lastCheckPoint = this.scanner.currentPosition;
8459                                 this.restartRecovery = true;
8460                         }                                       
8461                         act -= ERROR_ACTION;
8462                         
8463                 } else {
8464                     if (act < ACCEPT_ACTION) { /* shift */
8465                                 consumeToken(this.currentToken);
8466                                 if (this.currentElement != null) this.recoveryTokenCheck();
8467                                 try{
8468                                         this.currentToken = this.scanner.getNextToken();
8469                                 } catch(InvalidInputException e){
8470                                         if (!this.hasReportedError){
8471                                                 this.problemReporter().scannerError(this, e.getMessage());
8472                                                 this.hasReportedError = true;
8473                                         }
8474                                         this.lastCheckPoint = this.scanner.currentPosition;
8475                                         this.restartRecovery = true;
8476                                 }                                       
8477                                 continue ProcessTerminals;
8478                         }
8479                         break ProcessTerminals;
8480                 }
8481                         
8482                 ProcessNonTerminals : do { /* reduce */
8483                         consumeRule(act);
8484                         this.stateStackTop -= (rhs[act] - 1);
8485                         act = ntAction(this.stack[this.stateStackTop], lhs[act]);
8486                 } while (act <= NUM_RULES);
8487         }
8488         endParse(act);
8489         
8490         if (this.reportSyntaxErrorIsRequired && this.hasError) {
8491                 reportSyntaxErrors(isDietParse, oldFirstToken);
8492         }
8493         if (DEBUG) System.out.println("-- EXIT FROM PARSE METHOD --");  //$NON-NLS-1$
8494 }
8495 public void parse(ConstructorDeclaration cd, CompilationUnitDeclaration unit) {
8496         parse(cd, unit, false);
8497 }
8498 public void parse(ConstructorDeclaration cd, CompilationUnitDeclaration unit, boolean recordLineSeparator) {
8499         //only parse the method body of cd
8500         //fill out its statements
8501
8502         //convert bugs into parse error
8503
8504         initialize();
8505         goForBlockStatementsopt();
8506         if (recordLineSeparator) {
8507                 this.scanner.recordLineSeparator = true;
8508         }
8509         this.nestedMethod[this.nestedType]++;
8510         pushOnRealBlockStack(0);
8511         
8512         this.referenceContext = cd;
8513         this.compilationUnit = unit;
8514
8515         this.scanner.resetTo(cd.bodyStart, cd.bodyEnd);
8516         try {
8517                 parse();
8518         } catch (AbortCompilation ex) {
8519                 this.lastAct = ERROR_ACTION;
8520         } finally {
8521                 this.nestedMethod[this.nestedType]--;
8522         }
8523
8524         checkNonNLSAfterBodyEnd(cd.declarationSourceEnd);
8525         
8526         if (this.lastAct == ERROR_ACTION) {
8527                 initialize();
8528                 return;
8529         }
8530
8531         //statements
8532         cd.explicitDeclarations = this.realBlockStack[this.realBlockPtr--];
8533         int length;
8534         if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
8535                 this.astPtr -= length;
8536                 if (this.astStack[this.astPtr + 1] instanceof ExplicitConstructorCall)
8537                         //avoid a isSomeThing that would only be used here BUT what is faster between two alternatives ?
8538                         {
8539                         System.arraycopy(
8540                                 this.astStack, 
8541                                 this.astPtr + 2, 
8542                                 cd.statements = new Statement[length - 1], 
8543                                 0, 
8544                                 length - 1); 
8545                         cd.constructorCall = (ExplicitConstructorCall) this.astStack[this.astPtr + 1];
8546                 } else { //need to add explicitly the super();
8547                         System.arraycopy(
8548                                 this.astStack, 
8549                                 this.astPtr + 1, 
8550                                 cd.statements = new Statement[length], 
8551                                 0, 
8552                                 length); 
8553                         cd.constructorCall = SuperReference.implicitSuperConstructorCall();
8554                 }
8555         } else {
8556                 cd.constructorCall = SuperReference.implicitSuperConstructorCall();
8557                 if (!containsComment(cd.bodyStart, cd.bodyEnd)) {
8558                         cd.bits |= ASTNode.UndocumentedEmptyBlockMASK;
8559                 }               
8560         }
8561
8562         if (cd.constructorCall.sourceEnd == 0) {
8563                 cd.constructorCall.sourceEnd = cd.sourceEnd;
8564                 cd.constructorCall.sourceStart = cd.sourceStart;
8565         }
8566 }
8567 // A P I
8568
8569 public void parse(
8570         FieldDeclaration field, 
8571         TypeDeclaration type, 
8572         CompilationUnitDeclaration unit,
8573         char[] initializationSource) {
8574         //only parse the initializationSource of the given field
8575
8576         //convert bugs into parse error
8577
8578         initialize();
8579         goForExpression();
8580         this.nestedMethod[this.nestedType]++;
8581
8582         this.referenceContext = type;
8583         this.compilationUnit = unit;
8584
8585         this.scanner.setSource(initializationSource);
8586         this.scanner.resetTo(0, initializationSource.length-1);
8587         try {
8588                 parse();
8589         } catch (AbortCompilation ex) {
8590                 this.lastAct = ERROR_ACTION;
8591         } finally {
8592                 this.nestedMethod[this.nestedType]--;
8593         }
8594
8595         if (this.lastAct == ERROR_ACTION) {
8596                 return;
8597         }
8598
8599         field.initialization = this.expressionStack[this.expressionPtr];
8600         
8601         // mark field with local type if one was found during parsing
8602         if ((type.bits & ASTNode.HasLocalTypeMASK) != 0) {
8603                 field.bits |= ASTNode.HasLocalTypeMASK;
8604         }       
8605 }
8606 // A P I
8607
8608 public CompilationUnitDeclaration parse(
8609         ICompilationUnit sourceUnit, 
8610         CompilationResult compilationResult) {
8611         // parses a compilation unit and manages error handling (even bugs....)
8612
8613         return parse(sourceUnit, compilationResult, -1, -1/*parse without reseting the scanner*/);
8614 }
8615 // A P I
8616
8617 public CompilationUnitDeclaration parse(
8618         ICompilationUnit sourceUnit, 
8619         CompilationResult compilationResult,
8620         int start,
8621         int end) {
8622         // parses a compilation unit and manages error handling (even bugs....)
8623
8624         CompilationUnitDeclaration unit;
8625         try {
8626                 /* automaton initialization */
8627                 initialize();
8628                 goForCompilationUnit();
8629
8630                 /* scanners initialization */
8631                 char[] contents = sourceUnit.getContents();
8632                 this.scanner.setSource(contents);
8633                 if (end != -1) this.scanner.resetTo(start, end);
8634                 if (this.javadocParser != null && this.javadocParser.checkDocComment) {
8635                         this.javadocParser.scanner.setSource(contents);
8636                         if (end != -1) {
8637                                 this.javadocParser.scanner.resetTo(start, end);
8638                         }
8639                 }
8640                 /* unit creation */
8641                 this.referenceContext = 
8642                         this.compilationUnit = 
8643                                 new CompilationUnitDeclaration(
8644                                         this.problemReporter, 
8645                                         compilationResult, 
8646                                         this.scanner.source.length);
8647                 /* run automaton */
8648                 parse();
8649         } finally {
8650                 unit = this.compilationUnit;
8651                 this.compilationUnit = null; // reset parser
8652                 // tag unit has having read bodies
8653                 if (!this.diet) unit.bits |= ASTNode.HasAllMethodBodies;                
8654         }
8655         return unit;
8656 }
8657 // A P I
8658
8659 public void parse(
8660         Initializer initializer, 
8661         TypeDeclaration type, 
8662         CompilationUnitDeclaration unit) {
8663         //only parse the method body of md
8664         //fill out method statements
8665
8666         //convert bugs into parse error
8667
8668         initialize();
8669         goForBlockStatementsopt();
8670         this.nestedMethod[this.nestedType]++;
8671         pushOnRealBlockStack(0);
8672         
8673         this.referenceContext = type;
8674         this.compilationUnit = unit;
8675
8676         this.scanner.resetTo(initializer.bodyStart, initializer.bodyEnd); // just on the beginning {
8677         try {
8678                 parse();
8679         } catch (AbortCompilation ex) {
8680                 this.lastAct = ERROR_ACTION;
8681         } finally {
8682                 this.nestedMethod[this.nestedType]--;
8683         }
8684
8685         checkNonNLSAfterBodyEnd(initializer.declarationSourceEnd);
8686         
8687         if (this.lastAct == ERROR_ACTION) {
8688                 return;
8689         }
8690         
8691         //refill statements
8692         initializer.block.explicitDeclarations = this.realBlockStack[this.realBlockPtr--];
8693         int length;
8694         if ((length = this.astLengthStack[this.astLengthPtr--]) > 0) {
8695                 System.arraycopy(this.astStack, (this.astPtr -= length) + 1, initializer.block.statements = new Statement[length], 0, length); 
8696         } else {
8697                 // check whether this block at least contains some comment in it
8698                 if (!containsComment(initializer.block.sourceStart, initializer.block.sourceEnd)) {
8699                         initializer.block.bits |= ASTNode.UndocumentedEmptyBlockMASK;
8700                 }
8701         }
8702         
8703         // mark initializer with local type if one was found during parsing
8704         if ((type.bits & ASTNode.HasLocalTypeMASK) != 0) {
8705                 initializer.bits |= ASTNode.HasLocalTypeMASK;
8706         }       
8707 }
8708 // A P I
8709
8710 public void parse(MethodDeclaration md, CompilationUnitDeclaration unit) {
8711         //only parse the method body of md
8712         //fill out method statements
8713
8714         //convert bugs into parse error
8715
8716         if (md.isAbstract())
8717                 return;
8718         if (md.isNative())
8719                 return;
8720         if ((md.modifiers & AccSemicolonBody) != 0)
8721                 return;
8722
8723         initialize();
8724         goForBlockStatementsopt();
8725         this.nestedMethod[this.nestedType]++;
8726         pushOnRealBlockStack(0);
8727
8728         this.referenceContext = md;
8729         this.compilationUnit = unit;
8730
8731         this.scanner.resetTo(md.bodyStart, md.bodyEnd);
8732         // reset the scanner to parser from { down to }
8733         try {
8734                 parse();
8735         } catch (AbortCompilation ex) {
8736                 this.lastAct = ERROR_ACTION;
8737         } finally {
8738                 this.nestedMethod[this.nestedType]--;           
8739         }
8740
8741         checkNonNLSAfterBodyEnd(md.declarationSourceEnd);
8742         
8743         if (this.lastAct == ERROR_ACTION) {
8744                 return;
8745         }
8746
8747         //refill statements
8748         md.explicitDeclarations = this.realBlockStack[this.realBlockPtr--];
8749         int length;
8750         if ((length = this.astLengthStack[this.astLengthPtr--]) != 0) {
8751                 System.arraycopy(
8752                         this.astStack, 
8753                         (this.astPtr -= length) + 1, 
8754                         md.statements = new Statement[length], 
8755                         0, 
8756                         length); 
8757         } else {
8758                 if (!containsComment(md.bodyStart, md.bodyEnd)) {
8759                         md.bits |= ASTNode.UndocumentedEmptyBlockMASK;
8760                 }
8761         }
8762 }
8763 public ASTNode[] parseClassBodyDeclarations(char[] source, int offset, int length, CompilationUnitDeclaration unit) {
8764         /* automaton initialization */
8765         initialize();
8766         goForClassBodyDeclarations();
8767         /* scanner initialization */
8768         this.scanner.setSource(source);
8769         this.scanner.resetTo(offset, offset + length - 1);
8770         if (this.javadocParser != null && this.javadocParser.checkDocComment) {
8771                 this.javadocParser.scanner.setSource(source);
8772                 this.javadocParser.scanner.resetTo(offset, offset + length - 1);
8773         }
8774
8775         /* type declaration should be parsed as member type declaration */      
8776         this.nestedType = 1;
8777
8778         /* unit creation */
8779         this.referenceContext = unit;
8780         this.compilationUnit = unit;
8781
8782         /* run automaton */
8783         try {
8784                 parse();
8785         } catch (AbortCompilation ex) {
8786                 this.lastAct = ERROR_ACTION;
8787         }
8788
8789         if (this.lastAct == ERROR_ACTION) {
8790                 return null;
8791         }
8792         int astLength;
8793         if ((astLength = this.astLengthStack[this.astLengthPtr--]) != 0) {
8794                 ASTNode[] result = new ASTNode[astLength];
8795                 this.astPtr -= astLength;
8796                 System.arraycopy(this.astStack, this.astPtr + 1, result, 0, astLength);
8797                 return result;
8798         }
8799         return null;
8800 }
8801 public Expression parseExpression(char[] source, int offset, int length, CompilationUnitDeclaration unit) {
8802
8803         initialize();
8804         goForExpression();
8805         this.nestedMethod[this.nestedType]++;
8806
8807         this.referenceContext = unit;
8808         this.compilationUnit = unit;
8809
8810         this.scanner.setSource(source);
8811         this.scanner.resetTo(offset, offset + length - 1);
8812         try {
8813                 parse();
8814         } catch (AbortCompilation ex) {
8815                 this.lastAct = ERROR_ACTION;
8816         } finally {
8817                 this.nestedMethod[this.nestedType]--;
8818         }
8819
8820         if (this.lastAct == ERROR_ACTION) {
8821                 return null;
8822         }
8823
8824         return this.expressionStack[this.expressionPtr];
8825 }
8826 public Expression parseMemberValue(char[] source, int offset, int length, CompilationUnitDeclaration unit) {
8827
8828         initialize();
8829         goForMemberValue();
8830         this.nestedMethod[this.nestedType]++;
8831
8832         this.referenceContext = unit;
8833         this.compilationUnit = unit;
8834
8835         this.scanner.setSource(source);
8836         this.scanner.resetTo(offset, offset + length - 1);
8837         try {
8838                 parse();
8839         } catch (AbortCompilation ex) {
8840                 this.lastAct = ERROR_ACTION;
8841         } finally {
8842                 this.nestedMethod[this.nestedType]--;
8843         }
8844
8845         if (this.lastAct == ERROR_ACTION) {
8846                 return null;
8847         }
8848
8849         return this.expressionStack[this.expressionPtr];
8850 }
8851 public void persistLineSeparatorPositions() {
8852         if (this.scanner.recordLineSeparator) {
8853                 this.compilationUnit.compilationResult.lineSeparatorPositions = this.scanner.getLineEnds();
8854         }
8855 }
8856 /**
8857  * Returns this parser's problem reporter initialized with its reference context.
8858  * Also it is assumed that a problem is going to be reported, so initializes
8859  * the compilation result's line positions.
8860  * 
8861  * @return ProblemReporter
8862  */
8863 public ProblemReporter problemReporter(){
8864         if (this.scanner.recordLineSeparator) {
8865                 this.compilationUnit.compilationResult.lineSeparatorPositions = this.scanner.getLineEnds();
8866         }
8867         this.problemReporter.referenceContext = this.referenceContext;
8868         return this.problemReporter;
8869 }
8870 protected void pushIdentifier() {
8871         /*push the consumeToken on the identifier stack.
8872         Increase the total number of identifier in the stack.
8873         identifierPtr points on the next top */
8874
8875         int stackLength = this.identifierStack.length;
8876         if (++this.identifierPtr >= stackLength) {
8877                 System.arraycopy(
8878                         this.identifierStack, 0,
8879                         this.identifierStack = new char[stackLength + 20][], 0,
8880                         stackLength);
8881                 System.arraycopy(
8882                         this.identifierPositionStack, 0,
8883                         this.identifierPositionStack = new long[stackLength + 20], 0,
8884                         stackLength);
8885         }
8886         this.identifierStack[this.identifierPtr] = this.scanner.getCurrentIdentifierSource();
8887         this.identifierPositionStack[this.identifierPtr] =
8888                 (((long) this.scanner.startPosition) << 32) + (this.scanner.currentPosition - 1); 
8889
8890         stackLength = this.identifierLengthStack.length;
8891         if (++this.identifierLengthPtr >= stackLength) {
8892                 System.arraycopy(
8893                         this.identifierLengthStack, 0,
8894                         this.identifierLengthStack = new int[stackLength + 10], 0,
8895                         stackLength);
8896         }
8897         this.identifierLengthStack[this.identifierLengthPtr] = 1;
8898 }
8899 protected void pushIdentifier(int flag) {
8900         /*push a special flag on the stack :
8901         -zero stands for optional Name
8902         -negative number for direct ref to base types.
8903         identifierLengthPtr points on the top */
8904
8905         int stackLength = this.identifierLengthStack.length;
8906         if (++this.identifierLengthPtr >= stackLength) {
8907                 System.arraycopy(
8908                         this.identifierLengthStack, 0,
8909                         this.identifierLengthStack = new int[stackLength + 10], 0,
8910                         stackLength);
8911         }
8912         this.identifierLengthStack[this.identifierLengthPtr] = flag;
8913 }
8914 protected void pushOnAstLengthStack(int pos) {
8915
8916         int stackLength = this.astLengthStack.length;
8917         if (++this.astLengthPtr >= stackLength) {
8918                 System.arraycopy(
8919                         this.astLengthStack, 0,
8920                         this.astLengthStack = new int[stackLength + StackIncrement], 0,
8921                         stackLength);
8922         }
8923         this.astLengthStack[this.astLengthPtr] = pos;
8924 }
8925 protected void pushOnAstStack(ASTNode node) {
8926         /*add a new obj on top of the ast stack
8927         astPtr points on the top*/
8928
8929         int stackLength = this.astStack.length;
8930         if (++this.astPtr >= stackLength) {
8931                 System.arraycopy(
8932                         this.astStack, 0,
8933                         this.astStack = new ASTNode[stackLength + AstStackIncrement], 0,
8934                         stackLength);
8935                 this.astPtr = stackLength;
8936         }
8937         this.astStack[this.astPtr] = node;
8938
8939         stackLength = this.astLengthStack.length;
8940         if (++this.astLengthPtr >= stackLength) {
8941                 System.arraycopy(
8942                         this.astLengthStack, 0,
8943                         this.astLengthStack = new int[stackLength + AstStackIncrement], 0,
8944                         stackLength);
8945         }
8946         this.astLengthStack[this.astLengthPtr] = 1;
8947 }
8948 protected void pushOnExpressionStack(Expression expr) {
8949
8950         int stackLength = this.expressionStack.length;
8951         if (++this.expressionPtr >= stackLength) {
8952                 System.arraycopy(
8953                         this.expressionStack, 0,
8954                         this.expressionStack = new Expression[stackLength + ExpressionStackIncrement], 0,
8955                         stackLength);
8956         }
8957         this.expressionStack[this.expressionPtr] = expr;
8958
8959         stackLength = this.expressionLengthStack.length;
8960         if (++this.expressionLengthPtr >= stackLength) {
8961                 System.arraycopy(
8962                         this.expressionLengthStack, 0,
8963                         this.expressionLengthStack = new int[stackLength + ExpressionStackIncrement], 0,
8964                         stackLength);
8965         }
8966         this.expressionLengthStack[this.expressionLengthPtr] = 1;
8967 }
8968 protected void pushOnExpressionStackLengthStack(int pos) {
8969
8970         int stackLength = this.expressionLengthStack.length;
8971         if (++this.expressionLengthPtr >= stackLength) {
8972                 System.arraycopy(
8973                         this.expressionLengthStack, 0,
8974                         this.expressionLengthStack = new int[stackLength + StackIncrement], 0,
8975                         stackLength);
8976         }
8977         this.expressionLengthStack[this.expressionLengthPtr] = pos;
8978 }
8979 protected void pushOnGenericsStack(ASTNode node) {
8980         /*add a new obj on top of the generics stack
8981         genericsPtr points on the top*/
8982
8983         int stackLength = this.genericsStack.length;
8984         if (++this.genericsPtr >= stackLength) {
8985                 System.arraycopy(
8986                         this.genericsStack, 0,
8987                         this.genericsStack = new ASTNode[stackLength + GenericsStackIncrement], 0,
8988                         stackLength);
8989         }
8990         this.genericsStack[this.genericsPtr] = node;
8991
8992         stackLength = this.genericsLengthStack.length;
8993         if (++this.genericsLengthPtr >= stackLength) {
8994                 System.arraycopy(
8995                         this.genericsLengthStack, 0,
8996                         this.genericsLengthStack = new int[stackLength + GenericsStackIncrement], 0,
8997                         stackLength);
8998         }
8999         this.genericsLengthStack[this.genericsLengthPtr] = 1;
9000 }
9001 protected void pushOnGenericsIdentifiersLengthStack(int pos) {
9002         int stackLength = this.genericsIdentifiersLengthStack.length;
9003         if (++this.genericsIdentifiersLengthPtr >= stackLength) {
9004                 System.arraycopy(
9005                         this.genericsIdentifiersLengthStack, 0,
9006                         this.genericsIdentifiersLengthStack = new int[stackLength + GenericsStackIncrement], 0,
9007                         stackLength);
9008         }
9009         this.genericsIdentifiersLengthStack[this.genericsIdentifiersLengthPtr] = pos;
9010 }
9011 protected void pushOnGenericsLengthStack(int pos) {
9012         int stackLength = this.genericsLengthStack.length;
9013         if (++this.genericsLengthPtr >= stackLength) {
9014                 System.arraycopy(
9015                         this.genericsLengthStack, 0,
9016                         this.genericsLengthStack = new int[stackLength + GenericsStackIncrement], 0,
9017                         stackLength);
9018         }
9019         this.genericsLengthStack[this.genericsLengthPtr] = pos;
9020 }
9021 protected void pushOnIntStack(int pos) {
9022
9023         int stackLength = this.intStack.length;
9024         if (++this.intPtr >= stackLength) {
9025                 System.arraycopy(
9026                         this.intStack, 0,
9027                         this.intStack = new int[stackLength + StackIncrement], 0,
9028                         stackLength);
9029         }
9030         this.intStack[this.intPtr] = pos;
9031 }
9032 protected void pushOnRealBlockStack(int i){
9033         
9034         int stackLength = this.realBlockStack.length;
9035         if (++this.realBlockPtr >= stackLength) {
9036                 System.arraycopy(
9037                         this.realBlockStack, 0,
9038                         this.realBlockStack = new int[stackLength + StackIncrement], 0,
9039                         stackLength);
9040         }
9041         this.realBlockStack[this.realBlockPtr] = i;
9042 }
9043 public void recoveryExitFromVariable() {
9044         if(this.currentElement != null && this.currentElement.parent != null) {
9045                 if(this.currentElement instanceof RecoveredLocalVariable) {
9046                         
9047                         int end = ((RecoveredLocalVariable)this.currentElement).localDeclaration.sourceEnd;
9048                         this.currentElement.updateSourceEndIfNecessary(end);
9049                         this.currentElement = this.currentElement.parent;
9050                 } else if(this.currentElement instanceof RecoveredField
9051                         && !(this.currentElement instanceof RecoveredInitializer)) {
9052                                 
9053                         int end = ((RecoveredField)this.currentElement).fieldDeclaration.sourceEnd;
9054                         this.currentElement.updateSourceEndIfNecessary(end);
9055                         this.currentElement = this.currentElement.parent;
9056                 }
9057         }
9058 }
9059 /* Token check performed on every token shift once having entered
9060  * recovery mode.
9061  */
9062 public void recoveryTokenCheck() {
9063         switch (this.currentToken) {
9064                 case TokenNameLBRACE : 
9065                         RecoveredElement newElement = null;
9066                         if(!this.ignoreNextOpeningBrace) {
9067                                 newElement = this.currentElement.updateOnOpeningBrace(this.scanner.startPosition - 1, this.scanner.currentPosition - 1);
9068                         }
9069                         this.lastCheckPoint = this.scanner.currentPosition;                             
9070                         if (newElement != null){ // null means nothing happened
9071                                 this.restartRecovery = true; // opening brace detected
9072                                 this.currentElement = newElement;
9073                         }
9074                         break;
9075                 
9076                 case TokenNameRBRACE : 
9077                         this.rBraceStart = this.scanner.startPosition - 1;
9078                         this.rBraceEnd = this.scanner.currentPosition - 1;
9079                         this.endPosition = this.flushCommentsDefinedPriorTo(this.rBraceEnd);
9080                         newElement =
9081                                 this.currentElement.updateOnClosingBrace(this.scanner.startPosition, this.rBraceEnd);
9082                                 this.lastCheckPoint = this.scanner.currentPosition;
9083                         if (newElement != this.currentElement){
9084                                 this.currentElement = newElement;
9085 //                              if (newElement instanceof RecoveredField && this.dietInt <= 0) {
9086 //                                      if (((RecoveredField)newElement).fieldDeclaration.type == null) { // enum constant
9087 //                                              this.isInsideEnumConstantPart = true; // restore status
9088 //                                      }
9089 //                              }
9090                         }
9091                         break;
9092                 case TokenNameSEMICOLON :
9093                         this.endStatementPosition = this.scanner.currentPosition - 1;
9094                         this.endPosition = this.scanner.startPosition - 1; 
9095                         RecoveredType currentType = this.currentRecoveryType();
9096                         if(currentType != null) {
9097                                 currentType.insideEnumConstantPart = false;
9098                         }
9099                         // fall through
9100                 default : {
9101                         if (this.rBraceEnd > this.rBraceSuccessorStart && this.scanner.currentPosition != this.scanner.startPosition){
9102                                 this.rBraceSuccessorStart = this.scanner.startPosition;
9103                         }
9104                         break;
9105                 }
9106         }
9107         this.ignoreNextOpeningBrace = false;
9108 }
9109 // A P I
9110 protected void reportSyntaxErrors(boolean isDietParse, int oldFirstToken) {
9111         if(this.referenceContext instanceof MethodDeclaration) {
9112                 MethodDeclaration methodDeclaration = (MethodDeclaration) this.referenceContext;
9113                 if(methodDeclaration.errorInSignature){
9114                         return;
9115                 }
9116         }
9117         this.compilationUnit.compilationResult.lineSeparatorPositions = this.scanner.getLineEnds();
9118         this.scanner.recordLineSeparator = false;
9119         
9120         int start = this.scanner.initialPosition;
9121         int end = this.scanner.eofPosition <= Integer.MAX_VALUE ? this.scanner.eofPosition - 1 : this.scanner.eofPosition;
9122         if(isDietParse) {
9123                 TypeDeclaration[] types = this.compilationUnit.types;
9124                 
9125                 int[][] intervalToSkip = org.eclipse.jdt.internal.compiler.parser.diagnose.RangeUtil.computeDietRange(types);
9126                 DiagnoseParser diagnoseParser = new DiagnoseParser(this, oldFirstToken, start, end, intervalToSkip[0], intervalToSkip[1], intervalToSkip[2], this.options);
9127                 diagnoseParser.diagnoseParse();
9128                 
9129                 reportSyntaxErrorsForSkippedMethod(types);
9130                 this.scanner.resetTo(start, end);
9131         } else {
9132                 DiagnoseParser diagnoseParser = new DiagnoseParser(this, oldFirstToken, start, end, this.options);
9133                 diagnoseParser.diagnoseParse();
9134         }
9135 }
9136 private void reportSyntaxErrorsForSkippedMethod(TypeDeclaration[] types){
9137         if(types != null) {
9138                 for (int i = 0; i < types.length; i++) {
9139                         TypeDeclaration[] memberTypes = types[i].memberTypes;
9140                         if(memberTypes != null) {
9141                                 reportSyntaxErrorsForSkippedMethod(memberTypes);
9142                         }
9143                         
9144                         AbstractMethodDeclaration[] methods = types[i].methods;
9145                         if(methods != null) {
9146                                 for (int j = 0; j < methods.length; j++) {
9147                                         AbstractMethodDeclaration method = methods[j];
9148                                         if(method.errorInSignature) {
9149                                                 if(method.isAnnotationMethod()) {
9150                                                         DiagnoseParser diagnoseParser = new DiagnoseParser(this, TokenNameQUESTION, method.declarationSourceStart, method.declarationSourceEnd, this.options);
9151                                                         diagnoseParser.diagnoseParse();
9152                                                 } else {
9153                                                         DiagnoseParser diagnoseParser = new DiagnoseParser(this, TokenNameDIVIDE, method.declarationSourceStart, method.declarationSourceEnd, this.options);
9154                                                         diagnoseParser.diagnoseParse();
9155                                                 }
9156                                                 
9157                                         }
9158                                 }
9159                         }
9160                         
9161                         FieldDeclaration[] fields = types[i].fields;
9162                         if (fields != null) {
9163                                 int length = fields.length;
9164                                 for (int j = 0; j < length; j++) {
9165                                         if (fields[j] instanceof Initializer) {
9166                                                 Initializer initializer = (Initializer)fields[j];
9167                                                 if(initializer.errorInSignature){
9168                                                         DiagnoseParser diagnoseParser = new DiagnoseParser(this, TokenNameRIGHT_SHIFT, initializer.declarationSourceStart, initializer.declarationSourceEnd, this.options);
9169                                                         diagnoseParser.diagnoseParse();
9170                                                 }
9171                                         }
9172                                 }
9173                         }
9174                 }
9175         }
9176 }
9177 protected void resetModifiers() {
9178         this.modifiers = AccDefault;
9179         this.modifiersSourceStart = -1; // <-- see comment into modifiersFlag(int)
9180         this.scanner.commentPtr = -1;
9181 }
9182 /*
9183  * Reset context so as to resume to regular parse loop
9184  */
9185 protected void resetStacks() {
9186
9187         this.astPtr = -1;
9188         this.astLengthPtr = -1;
9189         this.expressionPtr = -1;
9190         this.expressionLengthPtr = -1;
9191         this.identifierPtr = -1;        
9192         this.identifierLengthPtr        = -1;
9193         this.intPtr = -1;
9194         this.nestedMethod[this.nestedType = 0] = 0; // need to reset for further reuse
9195         this.variablesCounter[this.nestedType] = 0;
9196         this.dimensions = 0 ;
9197         this.realBlockStack[this.realBlockPtr = 0] = 0;
9198         this.recoveredStaticInitializerStart = 0;
9199         this.listLength = 0;
9200         this.listTypeParameterLength = 0;
9201         // Fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=29365
9202         if (this.scanner != null) this.scanner.currentLine = null;
9203         
9204         this.genericsIdentifiersLengthPtr = -1;
9205         this.genericsLengthPtr = -1;
9206         this.genericsPtr = -1;
9207 }
9208 /*
9209  * Reset context so as to resume to regular parse loop
9210  * If unable to reset for resuming, answers false.
9211  *
9212  * Move checkpoint location, reset internal stacks and
9213  * decide which grammar goal is activated.
9214  */
9215 protected boolean resumeAfterRecovery() {
9216
9217         // reset internal stacks 
9218         this.resetStacks();
9219         this.resetModifiers();
9220         
9221         /* attempt to move checkpoint location */
9222         if (!this.moveRecoveryCheckpoint()) {
9223                 return false;
9224         }
9225
9226         // only look for headers
9227         if (this.referenceContext instanceof CompilationUnitDeclaration){
9228                 goForHeaders();
9229                 this.diet = true; // passed this point, will not consider method bodies
9230                 return true;
9231         }
9232         // does not know how to restart
9233         return false;
9234 }
9235 protected boolean resumeOnSyntaxError() {
9236
9237         /* request recovery initialization */
9238         if (this.currentElement == null){
9239                 // Reset javadoc before restart parsing after recovery
9240                 this.javadoc = null;
9241
9242                 // build some recovered elements
9243                 this.currentElement = buildInitialRecoveryState(); 
9244         }
9245         /* do not investigate deeper in recovery when no recovered element */
9246         if (this.currentElement == null) return false;
9247         
9248         /* manual forced recovery restart - after headers */
9249         if (this.restartRecovery){
9250                 this.restartRecovery = false;
9251         }
9252         /* update recovery state with current error state of the parser */
9253         this.updateRecoveryState();
9254         
9255         /* attempt to reset state in order to resume to parse loop */
9256         return this.resumeAfterRecovery();
9257 }
9258 public String toString() {
9259
9260
9261         String s = "lastCheckpoint : int = " + String.valueOf(this.lastCheckPoint) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
9262         s = s + "identifierStack : char["+(this.identifierPtr + 1)+"][] = {"; //$NON-NLS-1$ //$NON-NLS-2$
9263         for (int i = 0; i <= this.identifierPtr; i++) {
9264                 s = s + "\"" + String.valueOf(this.identifierStack[i]) + "\","; //$NON-NLS-1$ //$NON-NLS-2$
9265         }
9266         s = s + "}\n"; //$NON-NLS-1$
9267
9268         s = s + "identifierLengthStack : int["+(this.identifierLengthPtr + 1)+"] = {"; //$NON-NLS-1$ //$NON-NLS-2$
9269         for (int i = 0; i <= this.identifierLengthPtr; i++) {
9270                 s = s + this.identifierLengthStack[i] + ","; //$NON-NLS-1$
9271         }
9272         s = s + "}\n"; //$NON-NLS-1$
9273
9274         s = s + "astLengthStack : int["+(this.astLengthPtr + 1)+"] = {"; //$NON-NLS-1$ //$NON-NLS-2$
9275         for (int i = 0; i <= this.astLengthPtr; i++) {
9276                 s = s + this.astLengthStack[i] + ","; //$NON-NLS-1$
9277         }
9278         s = s + "}\n"; //$NON-NLS-1$
9279         s = s + "astPtr : int = " + String.valueOf(this.astPtr) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
9280
9281         s = s + "intStack : int["+(this.intPtr + 1)+"] = {"; //$NON-NLS-1$ //$NON-NLS-2$
9282         for (int i = 0; i <= this.intPtr; i++) {
9283                 s = s + this.intStack[i] + ","; //$NON-NLS-1$
9284         }
9285         s = s + "}\n"; //$NON-NLS-1$
9286
9287         s = s + "expressionLengthStack : int["+(this.expressionLengthPtr + 1)+"] = {"; //$NON-NLS-1$ //$NON-NLS-2$
9288         for (int i = 0; i <= this.expressionLengthPtr; i++) {
9289                 s = s + this.expressionLengthStack[i] + ","; //$NON-NLS-1$
9290         }
9291         s = s + "}\n"; //$NON-NLS-1$
9292
9293         s = s + "expressionPtr : int = " + String.valueOf(this.expressionPtr) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
9294         
9295         s = s + "genericsIdentifiersLengthStack : int["+(this.genericsIdentifiersLengthPtr + 1)+"] = {"; //$NON-NLS-1$ //$NON-NLS-2$
9296         for (int i = 0; i <= this.genericsIdentifiersLengthPtr; i++) {
9297                 s = s + this.genericsIdentifiersLengthStack[i] + ","; //$NON-NLS-1$
9298         }
9299         s = s + "}\n"; //$NON-NLS-1$
9300         
9301         s = s + "genericsLengthStack : int["+(this.genericsLengthPtr + 1)+"] = {"; //$NON-NLS-1$ //$NON-NLS-2$
9302         for (int i = 0; i <= this.genericsLengthPtr; i++) {
9303                 s = s + this.genericsLengthStack[i] + ","; //$NON-NLS-1$
9304         }
9305         s = s + "}\n"; //$NON-NLS-1$
9306
9307         s = s + "genericsPtr : int = " + String.valueOf(this.genericsPtr) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
9308
9309         s = s + "\n\n\n----------------Scanner--------------\n" + this.scanner.toString(); //$NON-NLS-1$
9310         return s;
9311
9312 }
9313 /*
9314  * Update recovery state based on current parser/scanner state
9315  */
9316 protected void updateRecoveryState() {
9317
9318         /* expose parser state to recovery state */
9319         this.currentElement.updateFromParserState();
9320
9321         /* check and update recovered state based on current token,
9322                 this action is also performed when shifting token after recovery
9323                 got activated once. 
9324         */
9325         this.recoveryTokenCheck();
9326 }
9327 protected void updateSourceDeclarationParts(int variableDeclaratorsCounter) {
9328         //fields is a definition of fields that are grouped together like in
9329         //public int[] a, b[], c
9330         //which results into 3 fields.
9331
9332         FieldDeclaration field;
9333         int endTypeDeclarationPosition = 
9334                 -1 + this.astStack[this.astPtr - variableDeclaratorsCounter + 1].sourceStart; 
9335         for (int i = 0; i < variableDeclaratorsCounter - 1; i++) {
9336                 //last one is special(see below)
9337                 field = (FieldDeclaration) this.astStack[this.astPtr - i - 1];
9338                 field.endPart1Position = endTypeDeclarationPosition;
9339                 field.endPart2Position = -1 + this.astStack[this.astPtr - i].sourceStart;
9340         }
9341         //last one
9342         (field = (FieldDeclaration) this.astStack[this.astPtr]).endPart1Position = 
9343                 endTypeDeclarationPosition; 
9344         field.endPart2Position = field.declarationSourceEnd;
9345
9346 }
9347 protected void updateSourcePosition(Expression exp) {
9348         //update the source Position of the expression
9349
9350         //this.intStack : int int
9351         //-->
9352         //this.intStack : 
9353
9354         exp.sourceEnd = this.intStack[this.intPtr--];
9355         exp.sourceStart = this.intStack[this.intPtr--];
9356 }
9357 }