From 19a49e81eae2c74c736c31b9a53f20dfa0eb4c1d Mon Sep 17 00:00:00 2001 From: kpouer Date: Thu, 10 Apr 2003 20:33:31 +0000 Subject: [PATCH] *** empty log message *** --- net.sourceforge.phpeclipse/src/test/PHPParser.java | 110 ++++++++++++-------- net.sourceforge.phpeclipse/src/test/PHPParser.jj | 28 +++++- .../src/test/PHPParserTestCase2.java | 1 + .../src/test/PHPParserTokenManager.java | 1 + 4 files changed, 95 insertions(+), 45 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java index 02ad35b..9e7acc4 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -16,6 +16,7 @@ import java.text.MessageFormat; import net.sourceforge.phpeclipse.actions.PHPStartApacheAction; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpdt.internal.compiler.parser.*; +import net.sourceforge.phpdt.internal.compiler.ast.*; /** * A new php parser. @@ -47,6 +48,13 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon private static int errorStart = -1; private static int errorEnd = -1; + //ast stack + private final static int AstStackIncrement = 100; + /** The stack of node. */ + private static AstNode[] astStack; + /** The cursor in expression stack. */ + private static int expressionPtr; + public final void setFileToParse(final IFile fileToParse) { this.fileToParse = fileToParse; } @@ -66,6 +74,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon jj_input_stream = new SimpleCharStream(stream, 1, 1); } ReInit(new StringReader(strEval)); + astStack = new AstNode[AstStackIncrement]; phpTest(); } @@ -76,6 +85,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon jj_input_stream = new SimpleCharStream(stream, 1, 1); } ReInit(stream); + astStack = new AstNode[AstStackIncrement]; phpFile(); } catch (FileNotFoundException e) { e.printStackTrace(); //To change body of catch statement use Options | File Templates. @@ -88,6 +98,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon jj_input_stream = new SimpleCharStream(stream, 1, 1); } ReInit(stream); + astStack = new AstNode[AstStackIncrement]; phpFile(); } @@ -99,6 +110,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon jj_input_stream = new SimpleCharStream(stream, 1, 1); } ReInit(stream); + astStack = new AstNode[AstStackIncrement]; try { parse(); } catch (ParseException e) { @@ -223,6 +235,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon jj_input_stream = new SimpleCharStream(stream, 1, 1); } ReInit(stream); + astStack = new AstNode[AstStackIncrement]; try { parse(); } catch (ParseException e) { @@ -252,7 +265,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } } - public static final void parse() throws ParseException { + private static final void parse() throws ParseException { phpFile(); } @@ -3094,7 +3107,18 @@ final StringBuffer buff = new StringBuffer(); errorEnd = jj_input_stream.getPosition() + 1; {if (true) throw e;} } - Expression(); + try { + Expression(); + } catch (ParseException e) { + if (errorMessage != null) { + {if (true) throw e;} + } + errorMessage = "expression expected"; + errorLevel = ERROR; + errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = jj_input_stream.getPosition() + 1; + {if (true) throw e;} + } try { jj_consume_token(RPAREN); } catch (ParseException e) { @@ -4557,41 +4581,6 @@ final int pos = jj_input_stream.getPosition(); return retval; } - static final private boolean jj_3R_46() { - if (jj_scan_token(ARRAY)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_167() { - if (jj_scan_token(LPAREN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_179()) { - jj_scanpos = xsp; - if (jj_3R_180()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(RPAREN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_141()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3_3() { - if (jj_3R_44()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_45() { - if (jj_3R_54()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_58() { if (jj_3R_88()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5054,6 +5043,12 @@ final int pos = jj_input_stream.getPosition(); return false; } + static final private boolean jj_3_8() { + if (jj_3R_49()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_133() { if (jj_scan_token(GT)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5100,12 +5095,6 @@ final int pos = jj_input_stream.getPosition(); return false; } - static final private boolean jj_3_8() { - if (jj_3R_49()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3_6() { if (jj_3R_47()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -6112,6 +6101,41 @@ final int pos = jj_input_stream.getPosition(); return false; } + static final private boolean jj_3R_46() { + if (jj_scan_token(ARRAY)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_167() { + if (jj_scan_token(LPAREN)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_179()) { + jj_scanpos = xsp; + if (jj_3R_180()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(RPAREN)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_141()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3_3() { + if (jj_3R_44()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_45() { + if (jj_3R_54()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static private boolean jj_initialized_once = false; static public PHPParserTokenManager token_source; static SimpleCharStream jj_input_stream; diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.jj b/net.sourceforge.phpeclipse/src/test/PHPParser.jj index abf9f51..e411485 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.jj +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.jj @@ -37,6 +37,7 @@ import java.text.MessageFormat; import net.sourceforge.phpeclipse.actions.PHPStartApacheAction; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpdt.internal.compiler.parser.*; +import net.sourceforge.phpdt.internal.compiler.ast.*; /** * A new php parser. @@ -68,6 +69,13 @@ public final class PHPParser extends PHPParserSuperclass { private static int errorStart = -1; private static int errorEnd = -1; + //ast stack + private final static int AstStackIncrement = 100; + /** The stack of node. */ + private static AstNode[] astStack; + /** The cursor in expression stack. */ + private static int expressionPtr; + public final void setFileToParse(final IFile fileToParse) { this.fileToParse = fileToParse; } @@ -87,6 +95,7 @@ public final class PHPParser extends PHPParserSuperclass { jj_input_stream = new SimpleCharStream(stream, 1, 1); } ReInit(new StringReader(strEval)); + astStack = new AstNode[AstStackIncrement]; phpTest(); } @@ -97,6 +106,7 @@ public final class PHPParser extends PHPParserSuperclass { jj_input_stream = new SimpleCharStream(stream, 1, 1); } ReInit(stream); + astStack = new AstNode[AstStackIncrement]; phpFile(); } catch (FileNotFoundException e) { e.printStackTrace(); //To change body of catch statement use Options | File Templates. @@ -109,6 +119,7 @@ public final class PHPParser extends PHPParserSuperclass { jj_input_stream = new SimpleCharStream(stream, 1, 1); } ReInit(stream); + astStack = new AstNode[AstStackIncrement]; phpFile(); } @@ -120,6 +131,7 @@ public final class PHPParser extends PHPParserSuperclass { jj_input_stream = new SimpleCharStream(stream, 1, 1); } ReInit(stream); + astStack = new AstNode[AstStackIncrement]; try { parse(); } catch (ParseException e) { @@ -244,6 +256,7 @@ public final class PHPParser extends PHPParserSuperclass { jj_input_stream = new SimpleCharStream(stream, 1, 1); } ReInit(stream); + astStack = new AstNode[AstStackIncrement]; try { parse(); } catch (ParseException e) { @@ -273,7 +286,7 @@ public final class PHPParser extends PHPParserSuperclass { } } - public static final void parse() throws ParseException { + private static final void parse() throws ParseException { phpFile(); } } @@ -2080,7 +2093,18 @@ void SwitchStatement() : errorEnd = jj_input_stream.getPosition() + 1; throw e; } - Expression() + try { + Expression() + } catch (ParseException e) { + if (errorMessage != null) { + throw e; + } + errorMessage = "expression expected"; + errorLevel = ERROR; + errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = jj_input_stream.getPosition() + 1; + throw e; + } try { } catch (ParseException e) { diff --git a/net.sourceforge.phpeclipse/src/test/PHPParserTestCase2.java b/net.sourceforge.phpeclipse/src/test/PHPParserTestCase2.java index 143f9a9..28f2a6e 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParserTestCase2.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParserTestCase2.java @@ -32,6 +32,7 @@ public class PHPParserTestCase2 extends TestCase { */ public void testPHPParser() { //checkHTML(new File("class.adm_gestuser.php")); + checkHTML(""); checkHTML(""); checkHTML("" + diff --git a/net.sourceforge.phpeclipse/src/test/PHPParserTokenManager.java b/net.sourceforge.phpeclipse/src/test/PHPParserTokenManager.java index 480026c..beb1960 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParserTokenManager.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParserTokenManager.java @@ -13,6 +13,7 @@ import java.text.MessageFormat; import net.sourceforge.phpeclipse.actions.PHPStartApacheAction; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpdt.internal.compiler.parser.*; +import net.sourceforge.phpdt.internal.compiler.ast.*; public class PHPParserTokenManager implements PHPParserConstants { -- 1.7.1