1 package org.eclipse.jdt.internal.compiler.parser; 2 import java.io.*; 3 import org.eclipse.jdt.core.compiler.CharOperation; 4 import org.eclipse.jdt.core.compiler.InvalidInputException; 5 import org.eclipse.jdt.internal.compiler.CompilationResult; 6 import org.eclipse.jdt.internal.compiler.ast.*; 7 import org.eclipse.jdt.internal.compiler.env.ICompilationUnit; 8 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; 9 import org.eclipse.jdt.internal.compiler.impl.ReferenceContext; 10 import org.eclipse.jdt.internal.compiler.lookup.BindingIds; 11 import org.eclipse.jdt.internal.compiler.lookup.CompilerModifiers; 12 import org.eclipse.jdt.internal.compiler.lookup.TypeIds; 13 import org.eclipse.jdt.internal.compiler.parser.diagnose.DiagnoseParser; 14 import org.eclipse.jdt.internal.compiler.problem.AbortCompilation; 15 import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; 16 import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities; 17 import org.eclipse.jdt.internal.compiler.util.Util; 18 public class Parser 19 implements 20 BindingIds, 21 ParserBasicInformation, 22 TerminalTokens, 23 CompilerModifiers, 24 OperatorIds, 25 TypeIds { 26 protected ProblemReporter problemReporter; 27 public int firstToken; // handle for multiple parsing goals 28 public int lastAct; //handle for multiple parsing goals 29 protected ReferenceContext referenceContext; 30 public int currentToken; 31 private int synchronizedBlockSourceStart; 32 //error recovery management 33 protected int lastCheckPoint; 34 protected RecoveredElement currentElement; 35 public static boolean VERBOSE_RECOVERY = false; 36 protected boolean restartRecovery; 37 protected int listLength; // for recovering some incomplete list (interfaces, throws or parameters) 38 protected boolean hasError; 39 protected boolean hasReportedError; 40 public static boolean fineErrorDiagnose = true; //TODO remove the static modifier when new diagnose is ready 41 public boolean reportSyntaxErrorIsRequired = true; 42 public boolean reportOnlyOneSyntaxError = false; 43 protected int recoveredStaticInitializerStart; 44 protected int lastIgnoredToken, nextIgnoredToken; 45 protected int lastErrorEndPosition; 46 protected boolean ignoreNextOpeningBrace; 47 // assert is 1.4 feature only 48 protected long sourceLevel; 49 //internal data for the automat 50 protected final static int StackIncrement = 255; 51 protected int stateStackTop; 52 protected int[] stack = new int[StackIncrement]; 53 //scanner token 54 public Scanner scanner; 55 //ast stack 56 final static int AstStackIncrement = 100; 57 protected int astPtr; 58 protected AstNode[] astStack = new AstNode[AstStackIncrement]; 59 protected int astLengthPtr; 60 protected int[] astLengthStack; 61 public CompilationUnitDeclaration compilationUnit; /*the result from parse()*/ 62 AstNode[] noAstNodes = new AstNode[AstStackIncrement]; 63 //expression stack 64 final static int ExpressionStackIncrement = 100; 65 protected int expressionPtr; 66 protected Expression[] expressionStack = new Expression[ExpressionStackIncrement]; 67 protected int expressionLengthPtr; 68 protected int[] expressionLengthStack; 69 Expression[] noExpressions = new Expression[ExpressionStackIncrement]; 70 //identifiers stacks 71 protected int identifierPtr; 72 protected char[][] identifierStack; 73 protected int identifierLengthPtr; 74 protected int[] identifierLengthStack; 75 protected long[] identifierPositionStack; 76 //positions , dimensions , .... (what ever is int) ..... stack 77 protected int intPtr; 78 protected int[] intStack; 79 protected int endPosition; //accurate only when used ! (the start position is pushed into intStack while the end the current one) 80 protected int endStatementPosition; 81 protected int lParenPos, rParenPos; //accurate only when used ! 82 //modifiers dimensions nestedType etc....... 83 protected boolean optimizeStringLiterals = true; 84 protected int modifiers; 85 protected int modifiersSourceStart; 86 protected int nestedType, dimensions; 87 protected int[] nestedMethod; //the ptr is nestedType 88 protected int[] realBlockStack; 89 protected int realBlockPtr; 90 protected boolean diet = false; //tells the scanner to jump over some parts of the code/expressions like method bodies 91 protected int dietInt = 0; // if > 0 force the none-diet-parsing mode (even if diet if requested) [field parsing with anonymous inner classes...] 92 protected int[] variablesCounter; foo()93 public void foo() { 94 byte rhs[] = {0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 95 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 96 1, 1, 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