import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter;
import net.sourceforge.phpdt.internal.compiler.problem.ProblemSeverities;
import net.sourceforge.phpdt.internal.compiler.util.Util;
+import net.sourceforge.phpeclipse.builder.IdentifierIndexManager;
import net.sourceforge.phpeclipse.internal.compiler.ast.AbstractMethodDeclaration;
import net.sourceforge.phpeclipse.internal.compiler.ast.AstNode;
import net.sourceforge.phpeclipse.internal.compiler.ast.CompilationUnitDeclaration;
//private boolean phpMode;
protected int modifiers;
protected int modifiersSourceStart;
+// protected IdentifierIndexManager indexManager;
+
protected Parser(ProblemReporter problemReporter) {
this.problemReporter = problemReporter;
this.options = problemReporter.options;
this.currentPHPString = 0;
// PHPParserSuperclass.fileToParse = fileToParse;
this.phpList = null;
+// this.indexManager = null;
this.str = "";
this.token = TokenNameEOF;
// this.chIndx = 0;
this.currentPHPString = 0;
// PHPParserSuperclass.fileToParse = fileToParse;
this.phpList = null;
+// this.indexManager = null;
this.str = "";
this.token = TokenNameEOF;
this.phpEnd = false;
scanner.setPHPMode(false);
}
protected void initialize(boolean phpMode) {
+ initialize(phpMode, null);
+ }
+ protected void initialize(boolean phpMode, IdentifierIndexManager indexManager) {
compilationUnit = null;
referenceContext = null;
includesList = new ArrayList();
+// this.indexManager = indexManager;
this.str = "";
this.token = TokenNameEOF;
// this.chIndx = 0;
} else if (token == TokenNamefunction) {
MethodDeclaration methodDecl = new MethodDeclaration(this.compilationUnit.compilationResult);
methodDecl.declarationSourceStart = scanner.getCurrentTokenStartPosition();
+ methodDecl.modifiers = AccDefault;
getNextToken();
functionDefinition(methodDecl);
return;
getNextToken();
class_variable_declaration(declarationSourceStart, list);
} else if (token == TokenNameconst) {
- class_constant_declaration();
+ checkAndSetModifiers(AccFinal|AccPublic);
+ class_constant_declaration(declarationSourceStart, list);
if (token != TokenNameSEMICOLON) {
throwSyntaxError("';' expected after class const declaration.");
}
class_variable_declaration(declarationSourceStart, list);
}
}
- // if (token == TokenNamefunction) {
- // MethodDeclaration methodDecl = new MethodDeclaration(
- // this.compilationUnit.compilationResult);
- // methodDecl.declarationSourceStart = scanner
- // .getCurrentTokenStartPosition();
- // getNextToken();
- // functionDefinition(methodDecl);
- // } else if (token == TokenNamevar) {
- // getNextToken();
- // classProperty();
- // } else {
- // throwSyntaxError("'function' or 'var' expected.");
- // }
}
- private void class_constant_declaration() {
+ private void class_constant_declaration(int declarationSourceStart, ArrayList list) {
// class_constant_declaration ',' T_STRING '=' static_scalar
// | T_CONST T_STRING '=' static_scalar
if (token != TokenNameconst) {
if (token != TokenNameIdentifier) {
throwSyntaxError("Identifier expected in class const declaration.");
}
+ FieldDeclaration fieldDeclaration = new FieldDeclaration(scanner.getCurrentIdentifierSource(), scanner
+ .getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition());
+ fieldDeclaration.modifiers = this.modifiers;
+ fieldDeclaration.declarationSourceStart = declarationSourceStart;
+ fieldDeclaration.declarationSourceEnd = scanner.getCurrentTokenEndPosition();
+ fieldDeclaration.modifiersSourceStart = declarationSourceStart;
+ // fieldDeclaration.type
+ list.add(fieldDeclaration);
getNextToken();
if (token != TokenNameEQUAL) {
throwSyntaxError("'=' expected in class const declaration.");
// | class_variable_declaration ',' T_VARIABLE '=' static_scalar
// | T_VARIABLE
// | T_VARIABLE '=' static_scalar
+ char[] classVariable;
do {
if (token == TokenNameVariable) {
- FieldDeclaration fieldDeclaration = new FieldDeclaration(scanner.getCurrentIdentifierSource(), scanner
+ classVariable = scanner.getCurrentIdentifierSource();
+ // indexManager.addIdentifierInformation('v', classVariable, buf, -1, -1);
+ FieldDeclaration fieldDeclaration = new FieldDeclaration(classVariable, scanner
.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition());
fieldDeclaration.modifiers = this.modifiers;
fieldDeclaration.declarationSourceStart = declarationSourceStart;
if (token == TokenNameAND) {
getNextToken();
}
- if (token == TokenNameIdentifier) {
- methodDecl.sourceStart = scanner.getCurrentTokenStartPosition();
- methodDecl.sourceEnd = scanner.getCurrentTokenEndPosition();
+ methodDecl.sourceStart = scanner.getCurrentTokenStartPosition();
+ methodDecl.sourceEnd = scanner.getCurrentTokenEndPosition();
+ if (Scanner.isIdentifierOrKeyword(token)) {
methodDecl.selector = scanner.getCurrentIdentifierSource();
+ if (token > TokenNameKEYWORD) {
+ reportSyntaxWarning("Don't use keyword for function declaration [" + scanner.toStringAction(token) + "].",
+ scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition());
+// throwSyntaxError("Don't use keyword for function declaration [" + scanner.toStringAction(token) + "].");
+ }
getNextToken();
if (token == TokenNameLPAREN) {
getNextToken();
getNextToken();
}
} else {
- if (token > TokenNameKEYWORD) {
- throwSyntaxError("Don't use keyword for function declaration [" + token + "].");
- }
+ methodDecl.selector = "<undefined>".toCharArray();
throwSyntaxError("Function name expected after keyword 'function'.");
}
}