**********************************************************************/
package net.sourceforge.phpdt.internal.compiler.parser;
import java.util.ArrayList;
+
import net.sourceforge.phpdt.core.compiler.CharOperation;
import net.sourceforge.phpdt.core.compiler.ITerminalSymbols;
import net.sourceforge.phpdt.core.compiler.InvalidInputException;
+import net.sourceforge.phpdt.internal.compiler.impl.CompilerOptions;
import net.sourceforge.phpdt.internal.compiler.impl.ReferenceContext;
import net.sourceforge.phpdt.internal.compiler.lookup.CompilerModifiers;
import net.sourceforge.phpdt.internal.compiler.lookup.TypeConstants;
import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter;
+import net.sourceforge.phpdt.internal.compiler.problem.ProblemSeverities;
import net.sourceforge.phpeclipse.internal.compiler.ast.AbstractMethodDeclaration;
import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
import net.sourceforge.phpeclipse.internal.compiler.ast.MethodDeclaration;
import net.sourceforge.phpeclipse.internal.compiler.ast.SingleTypeReference;
import net.sourceforge.phpeclipse.internal.compiler.ast.TypeDeclaration;
+import net.sourceforge.phpdt.internal.compiler.util.Util;
+
import org.eclipse.core.resources.IFile;
public class Parser //extends PHPParserSuperclass
implements ITerminalSymbols, CompilerModifiers, ParserBasicInformation {
//private boolean phpMode;
protected int modifiers;
protected int modifiersSourceStart;
- protected Parser() {
+ protected Parser(ProblemReporter problemReporter) {
+ this.problemReporter = problemReporter;
+ this.options = problemReporter.options;
this.currentPHPString = 0;
// PHPParserSuperclass.fileToParse = fileToParse;
this.phpList = null;
this.initializeScanner();
}
public void initializeScanner() {
- this.scanner = new Scanner(false, false, false, false);
+ this.scanner = new Scanner(
+ false /*comment*/,
+ false /*whitespace*/,
+ this.options.getSeverity(CompilerOptions.NonExternalizedString) != ProblemSeverities.Ignore /*nls*/,
+ false,
+ false,
+ this.options.taskTags/*taskTags*/,
+ this.options.taskPriorites/*taskPriorities*/);
}
/**
* Create marker for the parse error
}
throwSyntaxError("End-of-file not reached.");
}
- return;
+ break;
} catch (SyntaxError sytaxErr1) {
// setMarker(sytaxErr1.getMessage(), sytaxErr1.getLine(),
// ERROR);
getNextToken();
}
if (token == TokenNameEOF || token == TokenNameERROR) {
- return;
+ break;
}
} catch (SyntaxError sytaxErr2) {
// setMarker(sytaxErr2.getMessage(), sytaxErr2.getLine(),
// setMarker(sytaxErr2.getMessage(),
// scanner.getCurrentTokenStartPosition(),
// scanner.getCurrentTokenEndPosition(), ERROR);
- return;
+ break;
}
}
} while (true);
+
+ endParse(0);
+ }
+
+ protected CompilationUnitDeclaration endParse(int act) {
+
+ this.lastAct = act;
+
+ if (currentElement != null) {
+ currentElement.topElement().updateParseTree();
+ if (VERBOSE_RECOVERY) {
+ System.out.print(Util.bind("parser.syntaxRecovery")); //$NON-NLS-1$
+ System.out.println("--------------------------"); //$NON-NLS-1$
+ System.out.println(compilationUnit);
+ System.out.println("----------------------------------"); //$NON-NLS-1$
+ }
+ } else {
+ if (diet & VERBOSE_RECOVERY) {
+ System.out.print(Util.bind("parser.regularParse")); //$NON-NLS-1$
+ System.out.println("--------------------------"); //$NON-NLS-1$
+ System.out.println(compilationUnit);
+ System.out.println("----------------------------------"); //$NON-NLS-1$
+ }
+ }
+ if (scanner.recordLineSeparator) {
+ compilationUnit.compilationResult.lineSeparatorPositions = scanner.getLineEnds();
+ }
+ if (scanner.taskTags != null) {
+ for (int i = 0; i < scanner.foundTaskCount; i++) {
+ problemReporter().task(
+ new String(scanner.foundTaskTags[i]),
+ new String(scanner.foundTaskMessages[i]),
+ scanner.foundTaskPriorities[i] == null ? null : new String(scanner.foundTaskPriorities[i]),
+ scanner.foundTaskPositions[i][0],
+ scanner.foundTaskPositions[i][1]);
+ }
+ }
+ return compilationUnit;
}
// public PHPOutlineInfo parseInfo(Object parent, String s) {
// PHPOutlineInfo outlineInfo = new PHPOutlineInfo(parent);
*/
protected ReferenceContext referenceContext;
protected ProblemReporter problemReporter;
+ protected CompilerOptions options;
// protected CompilationResult compilationResult;
/**
* Returns this parser's problem reporter initialized with its reference