}
public void phpParse(String s, int rowCount) throws CoreException {
- // start up
- try {
- this.str = s;
- if (s == null) {
- if (phpList.size() != 0) {
- this.str = ((PHPString) phpList.get(currentPHPString++)).getPHPString();
- }
- }
- this.token = TT_EOF;
- this.chIndx = 0;
- this.rowCount = rowCount;
- this.columnCount = 0;
- this.phpEnd = false;
- getNextToken();
- if (token != TT_EOF && token != TT_UNDEFINED) {
- statementList();
+ this.str = s;
+ if (s == null) {
+ if (phpList.size() != 0) {
+ this.str = ((PHPString) phpList.get(currentPHPString++)).getPHPString();
}
- if (token != TT_EOF && token != TT_UNDEFINED) {
- if (token == TT_ARGCLOSE) {
- throwSyntaxError("too many closing ')'; end-of-file not reached");
- }
- if (token == TT_LISTCLOSE) {
- throwSyntaxError("too many closing '}'; end-of-file not reached");
- }
- if (token == TT_PARTCLOSE) {
- throwSyntaxError("too many closing ']'; end-of-file not reached");
+ }
+ this.token = TT_EOF;
+ this.chIndx = 0;
+ this.rowCount = rowCount;
+ this.columnCount = 0;
+ this.phpEnd = false;
+ getNextToken();
+ do {
+ try {
+ if (token != TT_EOF && token != TT_UNDEFINED) {
+ statementList();
}
+ if (token != TT_EOF && token != TT_UNDEFINED) {
+ if (token == TT_ARGCLOSE) {
+ throwSyntaxError("Too many closing ')'; end-of-file not reached.");
+ }
+ if (token == TT_LISTCLOSE) {
+ throwSyntaxError("Too many closing '}'; end-of-file not reached.");
+ }
+ if (token == TT_PARTCLOSE) {
+ throwSyntaxError("Too many closing ']'; end-of-file not reached.");
+ }
- if (token == TT_ARGOPEN) {
- throwSyntaxError("read character '('; end-of-file not reached");
+ if (token == TT_ARGOPEN) {
+ throwSyntaxError("Read character '('; end-of-file not reached.");
+ }
+ if (token == TT_LISTOPEN) {
+ throwSyntaxError("Read character '{'; end-of-file not reached.");
+ }
+ if (token == TT_PARTOPEN) {
+ throwSyntaxError("Read character '['; end-of-file not reached.");
+ }
+
+ throwSyntaxError("End-of-file not reached.");
}
- if (token == TT_LISTOPEN) {
- throwSyntaxError("read character '{'; end-of-file not reached");
+ return;
+ } catch (SyntaxError err) {
+ if (s != null) {
+ throw err;
+ } else {
+ setMarker(err.getMessage(), err.getLine(), ERROR);
}
- if (token == TT_PARTOPEN) {
- throwSyntaxError("read character '['; end-of-file not reached");
+ // if an error occured,
+ // try to find keywords 'class' or 'function'
+ // to parse the rest of the string
+ while (token != TT_EOF && token != TT_UNDEFINED) {
+ if (token == TT_class || token == TT_function) {
+ break;
+ }
+ getNextToken();
+ }
+ if (token == TT_EOF || token == TT_UNDEFINED) {
+ return;
}
-
- throwSyntaxError("end-of-file not reached");
- }
- } catch (SyntaxError err) {
- if (s != null) {
- throw err;
- } else {
- setMarker(err.getMessage(), err.getLine(), ERROR);
}
}
+ while (true);
}
private void statementList() throws CoreException {
throwSyntaxError("Constant expected.");
}
}
-
+
/**
* Call the php parse command ( php -l -f <filename> )
* and create markers according to the external parser output
} catch (CoreException e) {
}
}
-
+
/**
* Create markers according to the external parser output
*/
}
}
}
-
+
private static void scanLine(String output, IFile file, int indx, int brIndx) throws CoreException {
String current;
String outLineNumberString;