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