X-Git-Url: http://git.phpeclipse.com 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;