From b3b7fbfad10db1e32a5fbd725f7e793a3d5a6eaa Mon Sep 17 00:00:00 2001 From: khartlage Date: Sun, 1 Dec 2002 13:21:07 +0000 Subject: [PATCH] minor changes --- .../sourceforge/phpeclipse/PHPParserTestCase.java | 2 +- .../phpeclipse/phpeditor/PHPParser.java | 99 +++++++++++-------- 2 files changed, 58 insertions(+), 43 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/junit/sourceforge/phpeclipse/PHPParserTestCase.java b/net.sourceforge.phpeclipse/src/junit/sourceforge/phpeclipse/PHPParserTestCase.java index 0227343..7770048 100644 --- a/net.sourceforge.phpeclipse/src/junit/sourceforge/phpeclipse/PHPParserTestCase.java +++ b/net.sourceforge.phpeclipse/src/junit/sourceforge/phpeclipse/PHPParserTestCase.java @@ -28,7 +28,7 @@ public class PHPParserTestCase extends TestCase { * Test the PHP Parser with different PHP snippets */ public void testPHPParser() { - checkHTML(""); + checkHTML("\n\n\n\n "); checkHTML(""); checkHTML(""); checkHTML(" foo "); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPParser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPParser.java index 7da9027..a1282df 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPParser.java @@ -1026,53 +1026,68 @@ public class PHPParser extends PHPKeywords { } 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 { @@ -2556,7 +2571,7 @@ public class PHPParser extends PHPKeywords { throwSyntaxError("Constant expected."); } } - + /** * Call the php parse command ( php -l -f <filename> ) * and create markers according to the external parser output @@ -2579,7 +2594,7 @@ public class PHPParser extends PHPKeywords { } catch (CoreException e) { } } - + /** * Create markers according to the external parser output */ @@ -2604,7 +2619,7 @@ public class PHPParser extends PHPKeywords { } } } - + private static void scanLine(String output, IFile file, int indx, int brIndx) throws CoreException { String current; String outLineNumberString; -- 1.7.1