From 80fdb900601385e6c9d53a3a6b56e3657b249c22 Mon Sep 17 00:00:00 2001 From: kpouer Date: Sat, 8 Mar 2003 20:42:25 +0000 Subject: [PATCH] *** empty log message *** --- net.sourceforge.phpeclipse/src/test/PHPParser.java | 711 +++++++++++--------- net.sourceforge.phpeclipse/src/test/PHPParser.jj | 235 +++++-- 2 files changed, 578 insertions(+), 368 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java index 515e143..4a04ce3 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -27,7 +27,7 @@ import net.sourceforge.phpdt.internal.compiler.parser.PHPReqIncDeclaration; * You can test the parser with the PHPParserTestCase2.java * @author Matthieu Casanova */ -public class PHPParser extends PHPParserSuperclass implements PHPParserConstants { +public final class PHPParser extends PHPParserSuperclass implements PHPParserConstants { private static IFile fileToParse; @@ -43,7 +43,7 @@ public class PHPParser extends PHPParserSuperclass implements PHPParserConstants public PHPParser() { } - public void setFileToParse(IFile fileToParse) { + public final void setFileToParse(IFile fileToParse) { this.fileToParse = fileToParse; } @@ -52,7 +52,7 @@ public class PHPParser extends PHPParserSuperclass implements PHPParserConstants this.fileToParse = fileToParse; } - public void phpParserTester(String strEval) throws CoreException, ParseException { + public static final void phpParserTester(String strEval) throws CoreException, ParseException { PHPParserTokenManager.SwitchTo(PHPParserTokenManager.PHPPARSING); StringReader stream = new StringReader(strEval); if (jj_input_stream == null) { @@ -62,7 +62,7 @@ public class PHPParser extends PHPParserSuperclass implements PHPParserConstants phpTest(); } - public void htmlParserTester(String strEval) throws CoreException, ParseException { + public static final void htmlParserTester(String strEval) throws CoreException, ParseException { StringReader stream = new StringReader(strEval); if (jj_input_stream == null) { jj_input_stream = new SimpleCharStream(stream, 1, 1); @@ -71,7 +71,7 @@ public class PHPParser extends PHPParserSuperclass implements PHPParserConstants phpFile(); } - public PHPOutlineInfo parseInfo(Object parent, String s) { + public final PHPOutlineInfo parseInfo(Object parent, String s) { outlineInfo = new PHPOutlineInfo(parent); currentSegment = outlineInfo.getDeclarations(); StringReader stream = new StringReader(s); @@ -180,7 +180,7 @@ public class PHPParser extends PHPParserSuperclass implements PHPParserConstants } } - public void parse(String s) throws CoreException { + public final void parse(String s) throws CoreException { StringReader stream = new StringReader(s); if (jj_input_stream == null) { jj_input_stream = new SimpleCharStream(stream, 1, 1); @@ -215,7 +215,7 @@ public class PHPParser extends PHPParserSuperclass implements PHPParserConstants } } - public void parse() throws ParseException { + public static final void parse() throws ParseException { phpFile(); } @@ -245,7 +245,13 @@ public class PHPParser extends PHPParserSuperclass implements PHPParserConstants } jj_consume_token(PHPSTART); Php(); - jj_consume_token(PHPEND); + try { + jj_consume_token(PHPEND); + } catch (ParseException e) { + errorMessage = "'?>' expected"; + errorLevel = ERROR; + {if (true) throw e;} + } } jj_consume_token(0); } catch (TokenMgrError e) { @@ -312,7 +318,7 @@ public class PHPParser extends PHPParserSuperclass implements PHPParserConstants static final public void ClassDeclaration() throws ParseException { PHPClassDeclaration classDeclaration; Token className; - int pos = jj_input_stream.bufpos; + final int pos = jj_input_stream.bufpos; jj_consume_token(CLASS); className = jj_consume_token(IDENTIFIER); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -415,7 +421,7 @@ public class PHPParser extends PHPParserSuperclass implements PHPParserConstants static final public PHPVarDeclaration VariableDeclarator() throws ParseException { String varName; String varValue = null; - int pos = jj_input_stream.bufpos; + final int pos = jj_input_stream.bufpos; varName = VariableDeclaratorId(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ASSIGN: @@ -441,7 +447,7 @@ public class PHPParser extends PHPParserSuperclass implements PHPParserConstants static final public String VariableDeclaratorId() throws ParseException { String expr; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); try { expr = Variable(); buff.append(expr); @@ -619,7 +625,7 @@ Token token; static final public String ArrayVariable() throws ParseException { String expr; -StringBuffer buff = new StringBuffer(); +final StringBuffer buff = new StringBuffer(); expr = Expression(); buff.append(expr); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -638,7 +644,7 @@ StringBuffer buff = new StringBuffer(); static final public String ArrayInitializer() throws ParseException { String expr = null; -StringBuffer buff = new StringBuffer("("); +final StringBuffer buff = new StringBuffer("("); jj_consume_token(LPAREN); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ARRAY: @@ -703,7 +709,7 @@ StringBuffer buff = new StringBuffer("("); Token identifier; StringBuffer methodDeclaration = new StringBuffer(); String formalParameters; - int pos = jj_input_stream.bufpos; + final int pos = jj_input_stream.bufpos; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BIT_AND: jj_consume_token(BIT_AND); @@ -770,7 +776,7 @@ StringBuffer buff = new StringBuffer("("); static final public String FormalParameter() throws ParseException { PHPVarDeclaration variableDeclaration; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BIT_AND: jj_consume_token(BIT_AND); @@ -992,7 +998,7 @@ StringBuffer buff = new StringBuffer("("); String expr; Token operator; String expr2 = null; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); expr = ConditionalAndExpression(); buff.append(expr); label_8: @@ -1030,7 +1036,7 @@ StringBuffer buff = new StringBuffer("("); String expr; Token operator; String expr2 = null; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); expr = ConcatExpression(); buff.append(expr); label_9: @@ -1067,7 +1073,7 @@ StringBuffer buff = new StringBuffer("("); static final public String ConcatExpression() throws ParseException { String expr; String expr2 = null; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); expr = InclusiveOrExpression(); buff.append(expr); label_10: @@ -1092,7 +1098,7 @@ StringBuffer buff = new StringBuffer("("); static final public String InclusiveOrExpression() throws ParseException { String expr; String expr2 = null; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); expr = ExclusiveOrExpression(); buff.append(expr); label_11: @@ -1117,7 +1123,7 @@ StringBuffer buff = new StringBuffer("("); static final public String ExclusiveOrExpression() throws ParseException { String expr; String expr2 = null; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); expr = AndExpression(); buff.append(expr); label_12: @@ -1140,9 +1146,9 @@ StringBuffer buff = new StringBuffer("("); } static final public String AndExpression() throws ParseException { - String expr; + final String expr; String expr2 = null; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); expr = EqualityExpression(); buff.append(expr); label_13: @@ -1168,7 +1174,7 @@ StringBuffer buff = new StringBuffer("("); String expr; Token operator; String expr2; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); expr = RelationalExpression(); buff.append(expr); label_14: @@ -1218,7 +1224,7 @@ StringBuffer buff = new StringBuffer("("); String expr; Token operator; String expr2; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); expr = ShiftExpression(); buff.append(expr); label_15: @@ -1263,8 +1269,7 @@ StringBuffer buff = new StringBuffer("("); static final public String ShiftExpression() throws ParseException { String expr; Token operator; - String expr2; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); expr = AdditiveExpression(); buff.append(expr); label_16: @@ -1294,9 +1299,9 @@ StringBuffer buff = new StringBuffer("("); jj_consume_token(-1); throw new ParseException(); } - expr2 = AdditiveExpression(); + expr = AdditiveExpression(); buff.append(operator.image); - buff.append(expr2); + buff.append(expr); } {if (true) return buff.toString();} throw new Error("Missing return statement in function"); @@ -1305,8 +1310,7 @@ StringBuffer buff = new StringBuffer("("); static final public String AdditiveExpression() throws ParseException { String expr; Token operator; - String expr2; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); expr = MultiplicativeExpression(); buff.append(expr); label_17: @@ -1332,16 +1336,16 @@ StringBuffer buff = new StringBuffer("("); jj_consume_token(-1); throw new ParseException(); } - expr2 = MultiplicativeExpression(); + expr = MultiplicativeExpression(); buff.append(operator.image); - buff.append(expr2); + buff.append(expr); } {if (true) return buff.toString();} throw new Error("Missing return statement in function"); } static final public String MultiplicativeExpression() throws ParseException { - String expr, expr2; + String expr; Token operator; final StringBuffer buff = new StringBuffer(); expr = UnaryExpression(); @@ -1373,9 +1377,9 @@ StringBuffer buff = new StringBuffer("("); jj_consume_token(-1); throw new ParseException(); } - expr2 = UnaryExpression(); + expr = UnaryExpression(); buff.append(operator.image); - buff.append(expr2); + buff.append(expr); } {if (true) return buff.toString();} throw new Error("Missing return statement in function"); @@ -1557,8 +1561,7 @@ String expr; } static final public String CastExpression() throws ParseException { -String type; -String expr; +final String type, expr; jj_consume_token(LPAREN); type = Type(); jj_consume_token(RPAREN); @@ -1662,7 +1665,7 @@ String expr; } static final public String ArrayDeclarator() throws ParseException { - String expr; + final String expr; jj_consume_token(ARRAY); expr = ArrayInitializer(); {if (true) return "array" + expr;} @@ -1896,7 +1899,7 @@ String expr = null; static final public String ArgumentList() throws ParseException { String expr; -StringBuffer buff = new StringBuffer(); +final StringBuffer buff = new StringBuffer(); expr = Expression(); buff.append(expr); label_22: @@ -2034,7 +2037,7 @@ StringBuffer buff = new StringBuffer(); static final public void IncludeStatement() throws ParseException { String expr; - int pos = jj_input_stream.bufpos; + final int pos = jj_input_stream.bufpos; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case REQUIRE: jj_consume_token(REQUIRE); @@ -2144,7 +2147,7 @@ StringBuffer buff = new StringBuffer(); } static final public String PrintExpression() throws ParseException { - StringBuffer buff = new StringBuffer("print "); + final StringBuffer buff = new StringBuffer("print "); String expr; jj_consume_token(PRINT); expr = Expression(); @@ -2568,9 +2571,11 @@ StringBuffer buff = new StringBuffer(); } static final public void IfStatement() throws ParseException { - jj_consume_token(IF); + Token token; + final int pos = jj_input_stream.bufpos; + token = jj_consume_token(IF); Condition("if"); - IfStatement0(); + IfStatement0(pos,pos+token.image.length()); } static final public void Condition(String keyword) throws ParseException { @@ -2591,7 +2596,7 @@ StringBuffer buff = new StringBuffer(); } } - static final public void IfStatement0() throws ParseException { + static final public void IfStatement0(int start,int end) throws ParseException { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COLON: jj_consume_token(COLON); @@ -2664,7 +2669,23 @@ StringBuffer buff = new StringBuffer(); jj_la1[89] = jj_gen; ; } - jj_consume_token(ENDIF); + try { + setMarker(fileToParse, + "Ugly syntax detected, you should if () {...} instead of if (): ... endif;", + start, + end, + INFO, + "Line " + token.beginLine); + } catch (CoreException e) { + PHPeclipsePlugin.log(e); + } + try { + jj_consume_token(ENDIF); + } catch (ParseException e) { + errorMessage = "'endif' expected"; + errorLevel = ERROR; + {if (true) throw e;} + } try { jj_consume_token(SEMICOLON); } catch (ParseException e) { @@ -2796,11 +2817,6 @@ StringBuffer buff = new StringBuffer(); } } - static final public void ElseStatement() throws ParseException { - jj_consume_token(ELSE); - Statement(); - } - static final public void ElseStatementColon() throws ParseException { jj_consume_token(ELSE); jj_consume_token(COLON); @@ -2862,12 +2878,14 @@ StringBuffer buff = new StringBuffer(); } static final public void WhileStatement() throws ParseException { - jj_consume_token(WHILE); + Token token; + final int pos = jj_input_stream.bufpos; + token = jj_consume_token(WHILE); Condition("while"); - WhileStatement0(); + WhileStatement0(pos,pos + token.image.length()); } - static final public void WhileStatement0() throws ParseException { + static final public void WhileStatement0(final int start, final int end) throws ParseException { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COLON: jj_consume_token(COLON); @@ -2920,7 +2938,23 @@ StringBuffer buff = new StringBuffer(); } Statement(); } - jj_consume_token(ENDWHILE); + try { + setMarker(fileToParse, + "Ugly syntax detected, you should while () {...} instead of while (): ... endwhile;", + start, + end, + INFO, + "Line " + token.beginLine); + } catch (CoreException e) { + PHPeclipsePlugin.log(e); + } + try { + jj_consume_token(ENDWHILE); + } catch (ParseException e) { + errorMessage = "'endwhile' expected"; + errorLevel = ERROR; + {if (true) throw e;} + } try { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case SEMICOLON: @@ -3014,10 +3048,34 @@ StringBuffer buff = new StringBuffer(); static final public void ForeachStatement() throws ParseException { jj_consume_token(FOREACH); - jj_consume_token(LPAREN); - Variable(); - jj_consume_token(AS); - Variable(); + try { + jj_consume_token(LPAREN); + } catch (ParseException e) { + errorMessage = "'(' expected after 'foreach' keyword"; + errorLevel = ERROR; + {if (true) throw e;} + } + try { + Variable(); + } catch (ParseException e) { + errorMessage = "variable expected"; + errorLevel = ERROR; + {if (true) throw e;} + } + try { + jj_consume_token(AS); + } catch (ParseException e) { + errorMessage = "'as' expected"; + errorLevel = ERROR; + {if (true) throw e;} + } + try { + Variable(); + } catch (ParseException e) { + errorMessage = "variable expected"; + errorLevel = ERROR; + {if (true) throw e;} + } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ARRAYASSIGN: jj_consume_token(ARRAYASSIGN); @@ -3027,13 +3085,34 @@ StringBuffer buff = new StringBuffer(); jj_la1[99] = jj_gen; ; } - jj_consume_token(RPAREN); - Statement(); + try { + jj_consume_token(RPAREN); + } catch (ParseException e) { + errorMessage = "')' expected after 'foreach' keyword"; + errorLevel = ERROR; + {if (true) throw e;} + } + try { + Statement(); + } catch (ParseException e) { + if (errorMessage != null) {if (true) throw e;} + errorMessage = "statement expected"; + errorLevel = ERROR; + {if (true) throw e;} + } } static final public void ForStatement() throws ParseException { - jj_consume_token(FOR); - jj_consume_token(LPAREN); +Token token; +final int pos = jj_input_stream.bufpos; + token = jj_consume_token(FOR); + try { + jj_consume_token(LPAREN); + } catch (ParseException e) { + errorMessage = "'(' expected after 'for' keyword"; + errorLevel = ERROR; + {if (true) throw e;} + } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ARRAY: case NEW: @@ -3184,7 +3263,23 @@ StringBuffer buff = new StringBuffer(); } Statement(); } - jj_consume_token(ENDFOR); + try { + setMarker(fileToParse, + "Ugly syntax detected, you should for () {...} instead of for (): ... endfor;", + pos, + pos+token.image.length(), + INFO, + "Line " + token.beginLine); + } catch (CoreException e) { + PHPeclipsePlugin.log(e); + } + try { + jj_consume_token(ENDFOR); + } catch (ParseException e) { + errorMessage = "'endfor' expected"; + errorLevel = ERROR; + {if (true) throw e;} + } try { jj_consume_token(SEMICOLON); } catch (ParseException e) { @@ -3350,67 +3445,6 @@ StringBuffer buff = new StringBuffer(); return retval; } - static final private boolean jj_3_5() { - if (jj_3R_41()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_42()) { - jj_scanpos = xsp; - if (jj_3R_43()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_142() { - if (jj_scan_token(TRIPLEEQUAL)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_141() { - if (jj_scan_token(BANGDOUBLEEQUAL)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_107() { - if (jj_scan_token(INTEGER_LITERAL)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_140() { - if (jj_scan_token(NE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_139() { - if (jj_scan_token(DIF)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_98() { - if (jj_scan_token(IDENTIFIER)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_105() { - if (jj_scan_token(INTEGER_LITERAL)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_138() { - if (jj_scan_token(EQ)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_97() { if (jj_3R_109()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -3509,21 +3543,21 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_202() { - if (jj_scan_token(COMMA)) return true; + static final private boolean jj_3R_122() { + if (jj_scan_token(LBRACE)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; if (jj_3R_41()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(RBRACE)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_122() { - if (jj_scan_token(LBRACE)) return true; + static final private boolean jj_3R_202() { + if (jj_scan_token(COMMA)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; if (jj_3R_41()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(RBRACE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -3557,12 +3591,6 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_200() { - if (jj_3R_201()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_70() { if (jj_scan_token(DOLLAR)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -3583,6 +3611,12 @@ StringBuffer buff = new StringBuffer(); return false; } + static final private boolean jj_3R_200() { + if (jj_3R_201()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_69() { if (jj_scan_token(IDENTIFIER)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -3603,18 +3637,6 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_198() { - 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_200()) jj_scanpos = xsp; - 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; - return false; - } - static final private boolean jj_3R_68() { if (jj_scan_token(LBRACE)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -3642,16 +3664,22 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_128() { - if (jj_scan_token(XOR)) return true; + static final private boolean jj_3R_198() { + if (jj_scan_token(LPAREN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_127()) return true; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_200()) jj_scanpos = xsp; + 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; return false; } - static final private boolean jj_3R_125() { - if (jj_scan_token(NULL)) return true; + static final private boolean jj_3R_128() { + if (jj_scan_token(XOR)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_127()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -3664,6 +3692,12 @@ StringBuffer buff = new StringBuffer(); return false; } + static final private boolean jj_3R_125() { + if (jj_scan_token(NULL)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_120() { if (jj_3R_127()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -3676,12 +3710,6 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_130() { - if (jj_scan_token(FALSE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_92() { if (jj_scan_token(DOLLAR_ID)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -3703,6 +3731,12 @@ StringBuffer buff = new StringBuffer(); return false; } + static final private boolean jj_3R_130() { + if (jj_scan_token(FALSE)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_124() { Token xsp; xsp = jj_scanpos; @@ -3726,12 +3760,6 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_117() { - if (jj_3R_124()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3_1() { if (jj_3R_38()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -3746,14 +3774,14 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_116() { - if (jj_scan_token(STRING_LITERAL)) return true; + static final private boolean jj_3R_117() { + if (jj_3R_124()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_115() { - if (jj_scan_token(FLOATING_POINT_LITERAL)) return true; + static final private boolean jj_3R_116() { + if (jj_scan_token(STRING_LITERAL)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -3782,6 +3810,12 @@ StringBuffer buff = new StringBuffer(); return false; } + static final private boolean jj_3R_115() { + if (jj_scan_token(FLOATING_POINT_LITERAL)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_104() { Token xsp; xsp = jj_scanpos; @@ -3848,25 +3882,25 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_47() { - if (jj_scan_token(LBRACKET)) return true; + static final private boolean jj_3R_59() { + if (jj_3R_66()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; Token xsp; xsp = jj_scanpos; - if (jj_3R_62()) jj_scanpos = xsp; + if (jj_3R_67()) jj_scanpos = xsp; else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(RBRACKET)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_59() { - if (jj_3R_66()) return true; + static final private boolean jj_3R_47() { + if (jj_scan_token(LBRACKET)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; Token xsp; xsp = jj_scanpos; - if (jj_3R_67()) jj_scanpos = xsp; + if (jj_3R_62()) jj_scanpos = xsp; else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(RBRACKET)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -3895,23 +3929,6 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_194() { - if (jj_3R_198()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_192() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_194()) { - jj_scanpos = xsp; - if (jj_3R_195()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_112() { if (jj_scan_token(SC_AND)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -3937,6 +3954,23 @@ StringBuffer buff = new StringBuffer(); return false; } + static final private boolean jj_3R_194() { + if (jj_3R_198()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_192() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_194()) { + jj_scanpos = xsp; + if (jj_3R_195()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_77() { if (jj_3R_99()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -3955,6 +3989,18 @@ StringBuffer buff = new StringBuffer(); return false; } + static final private boolean jj_3R_73() { + if (jj_scan_token(HOOK)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_41()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(COLON)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_64()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_196() { if (jj_scan_token(IDENTIFIER)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -3972,24 +4018,6 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_73() { - if (jj_scan_token(HOOK)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_41()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(COLON)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_64()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_188() { - if (jj_3R_66()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_101() { if (jj_scan_token(SC_OR)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4009,6 +4037,12 @@ StringBuffer buff = new StringBuffer(); return false; } + static final private boolean jj_3R_188() { + if (jj_3R_66()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_187() { if (jj_scan_token(NEW)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4017,6 +4051,18 @@ StringBuffer buff = new StringBuffer(); return false; } + static final private boolean jj_3R_72() { + if (jj_3R_77()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_78()) { jj_scanpos = xsp; break; } + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } + return false; + } + static final private boolean jj_3R_190() { if (jj_scan_token(DECR)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4043,18 +4089,6 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_72() { - if (jj_3R_77()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_78()) { jj_scanpos = xsp; break; } - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } - return false; - } - static final private boolean jj_3R_60() { if (jj_scan_token(COMMA)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4071,6 +4105,16 @@ StringBuffer buff = new StringBuffer(); return false; } + static final private boolean jj_3R_64() { + if (jj_3R_72()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_73()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_189() { if (jj_scan_token(INCR)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4094,16 +4138,6 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_64() { - if (jj_3R_72()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_73()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_191() { if (jj_3R_192()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4122,6 +4156,12 @@ StringBuffer buff = new StringBuffer(); return false; } + static final private boolean jj_3R_91() { + if (jj_scan_token(TILDEEQUAL)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_45() { if (jj_3R_59()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4140,8 +4180,14 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_91() { - if (jj_scan_token(TILDEEQUAL)) return true; + static final private boolean jj_3R_90() { + if (jj_scan_token(DOTASSIGN)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_89() { + if (jj_scan_token(ORASSIGN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -4160,12 +4206,6 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_90() { - if (jj_scan_token(DOTASSIGN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3_4() { if (jj_scan_token(IDENTIFIER)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4182,12 +4222,6 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_89() { - if (jj_scan_token(ORASSIGN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_88() { if (jj_scan_token(XORASSIGN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4224,16 +4258,6 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_181() { - if (jj_3R_179()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_185()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_82() { if (jj_scan_token(REMASSIGN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4246,6 +4270,16 @@ StringBuffer buff = new StringBuffer(); return false; } + static final private boolean jj_3R_181() { + if (jj_3R_179()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_185()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_80() { if (jj_scan_token(STARASSIGN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4423,16 +4457,16 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_172() { - if (jj_scan_token(DECR)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_179()) return true; + static final private boolean jj_3R_56() { + if (jj_scan_token(OBJECT)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_56() { - if (jj_scan_token(OBJECT)) return true; + static final private boolean jj_3R_172() { + if (jj_scan_token(DECR)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_179()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -4449,6 +4483,12 @@ StringBuffer buff = new StringBuffer(); return false; } + static final private boolean jj_3R_53() { + if (jj_scan_token(FLOAT)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_171() { if (jj_scan_token(INCR)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4457,8 +4497,8 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_53() { - if (jj_scan_token(FLOAT)) return true; + static final private boolean jj_3R_52() { + if (jj_scan_token(DOUBLE)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -4469,14 +4509,14 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_52() { - if (jj_scan_token(DOUBLE)) return true; + static final private boolean jj_3R_51() { + if (jj_scan_token(REAL)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_51() { - if (jj_scan_token(REAL)) return true; + static final private boolean jj_3R_50() { + if (jj_scan_token(BOOLEAN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -4489,12 +4529,6 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_50() { - if (jj_scan_token(BOOLEAN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_168() { if (jj_3R_173()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4513,12 +4547,6 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_162() { - if (jj_scan_token(REM)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_40() { Token xsp; xsp = jj_scanpos; @@ -4557,6 +4585,12 @@ StringBuffer buff = new StringBuffer(); return false; } + static final private boolean jj_3R_162() { + if (jj_scan_token(REM)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_166() { if (jj_3R_171()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4569,6 +4603,12 @@ StringBuffer buff = new StringBuffer(); return false; } + static final private boolean jj_3_7() { + if (jj_3R_45()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_163() { Token xsp; xsp = jj_scanpos; @@ -4660,6 +4700,12 @@ StringBuffer buff = new StringBuffer(); return false; } + static final private boolean jj_3R_148() { + if (jj_scan_token(GE)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_155() { Token xsp; xsp = jj_scanpos; @@ -4676,12 +4722,6 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_148() { - if (jj_scan_token(GE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_149() { if (jj_3R_154()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4737,6 +4777,12 @@ StringBuffer buff = new StringBuffer(); return false; } + static final private boolean jj_3R_146() { + if (jj_scan_token(GT)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_151() { if (jj_scan_token(LSHIFT)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4759,12 +4805,6 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_146() { - if (jj_scan_token(GT)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_136() { if (jj_3R_143()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4809,12 +4849,6 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_43() { - if (jj_scan_token(135)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_145() { if (jj_scan_token(LT)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4852,6 +4886,12 @@ StringBuffer buff = new StringBuffer(); return false; } + static final private boolean jj_3R_43() { + if (jj_scan_token(135)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_134() { if (jj_3R_136()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -4864,17 +4904,27 @@ StringBuffer buff = new StringBuffer(); return false; } + static final private boolean jj_3R_133() { + if (jj_scan_token(ARRAYASSIGN)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_41()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3_6() { if (jj_3R_44()) 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(ARRAYASSIGN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + static final private boolean jj_3R_39() { if (jj_3R_41()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_133()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -4884,18 +4934,63 @@ StringBuffer buff = new StringBuffer(); return false; } - static final private boolean jj_3R_39() { + static final private boolean jj_3R_142() { + if (jj_scan_token(TRIPLEEQUAL)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_141() { + if (jj_scan_token(BANGDOUBLEEQUAL)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_107() { + if (jj_scan_token(INTEGER_LITERAL)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_140() { + if (jj_scan_token(NE)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3_5() { if (jj_3R_41()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; Token xsp; xsp = jj_scanpos; - if (jj_3R_133()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_42()) { + jj_scanpos = xsp; + if (jj_3R_43()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3_7() { - if (jj_3R_45()) return true; + static final private boolean jj_3R_139() { + if (jj_scan_token(DIF)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_98() { + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_105() { + if (jj_scan_token(INTEGER_LITERAL)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_138() { + if (jj_scan_token(EQ)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.jj b/net.sourceforge.phpeclipse/src/test/PHPParser.jj index 2a86a45..e3b05cf 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.jj +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.jj @@ -48,7 +48,7 @@ import net.sourceforge.phpdt.internal.compiler.parser.PHPReqIncDeclaration; * You can test the parser with the PHPParserTestCase2.java * @author Matthieu Casanova */ -public class PHPParser extends PHPParserSuperclass { +public final class PHPParser extends PHPParserSuperclass { private static IFile fileToParse; @@ -64,7 +64,7 @@ public class PHPParser extends PHPParserSuperclass { public PHPParser() { } - public void setFileToParse(IFile fileToParse) { + public final void setFileToParse(IFile fileToParse) { this.fileToParse = fileToParse; } @@ -73,7 +73,7 @@ public class PHPParser extends PHPParserSuperclass { this.fileToParse = fileToParse; } - public void phpParserTester(String strEval) throws CoreException, ParseException { + public static final void phpParserTester(String strEval) throws CoreException, ParseException { PHPParserTokenManager.SwitchTo(PHPParserTokenManager.PHPPARSING); StringReader stream = new StringReader(strEval); if (jj_input_stream == null) { @@ -83,7 +83,7 @@ public class PHPParser extends PHPParserSuperclass { phpTest(); } - public void htmlParserTester(String strEval) throws CoreException, ParseException { + public static final void htmlParserTester(String strEval) throws CoreException, ParseException { StringReader stream = new StringReader(strEval); if (jj_input_stream == null) { jj_input_stream = new SimpleCharStream(stream, 1, 1); @@ -92,7 +92,7 @@ public class PHPParser extends PHPParserSuperclass { phpFile(); } - public PHPOutlineInfo parseInfo(Object parent, String s) { + public final PHPOutlineInfo parseInfo(Object parent, String s) { outlineInfo = new PHPOutlineInfo(parent); currentSegment = outlineInfo.getDeclarations(); StringReader stream = new StringReader(s); @@ -201,7 +201,7 @@ public class PHPParser extends PHPParserSuperclass { } } - public void parse(String s) throws CoreException { + public final void parse(String s) throws CoreException { StringReader stream = new StringReader(s); if (jj_input_stream == null) { jj_input_stream = new SimpleCharStream(stream, 1, 1); @@ -236,7 +236,7 @@ public class PHPParser extends PHPParserSuperclass { } } - public void parse() throws ParseException { + public static final void parse() throws ParseException { phpFile(); } } @@ -549,7 +549,15 @@ void phpFile() : {} { try { - ( Php() )* + ( Php() + try { + + } catch (ParseException e) { + errorMessage = "'?>' expected"; + errorLevel = ERROR; + throw e; + } + )* } catch (TokenMgrError e) { errorMessage = e.getMessage(); @@ -568,7 +576,7 @@ void ClassDeclaration() : { PHPClassDeclaration classDeclaration; Token className; - int pos = jj_input_stream.bufpos; + final int pos = jj_input_stream.bufpos; } { className = [ ] @@ -647,7 +655,7 @@ PHPVarDeclaration VariableDeclarator() : { String varName; String varValue = null; - int pos = jj_input_stream.bufpos; + final int pos = jj_input_stream.bufpos; } { varName = VariableDeclaratorId() @@ -672,7 +680,7 @@ PHPVarDeclaration VariableDeclarator() : String VariableDeclaratorId() : { String expr; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); } { try { @@ -761,7 +769,7 @@ String VariableInitializer() : String ArrayVariable() : { String expr; -StringBuffer buff = new StringBuffer(); +final StringBuffer buff = new StringBuffer(); } { expr = Expression() @@ -774,7 +782,7 @@ StringBuffer buff = new StringBuffer(); String ArrayInitializer() : { String expr = null; -StringBuffer buff = new StringBuffer("("); +final StringBuffer buff = new StringBuffer("("); } { [ expr = ArrayVariable() @@ -814,7 +822,7 @@ PHPFunctionDeclaration MethodDeclarator() : Token identifier; StringBuffer methodDeclaration = new StringBuffer(); String formalParameters; - int pos = jj_input_stream.bufpos; + final int pos = jj_input_stream.bufpos; } { [ {methodDeclaration.append("&");} ] @@ -863,7 +871,7 @@ String FormalParameters() : String FormalParameter() : { PHPVarDeclaration variableDeclaration; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); } { [ {buff.append("&");}] variableDeclaration = VariableDeclarator() @@ -987,7 +995,7 @@ String ConditionalOrExpression() : String expr; Token operator; String expr2 = null; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); } { expr = ConditionalAndExpression() @@ -1011,7 +1019,7 @@ String ConditionalAndExpression() : String expr; Token operator; String expr2 = null; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); } { expr = ConcatExpression() @@ -1034,7 +1042,7 @@ String ConcatExpression() : { String expr; String expr2 = null; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); } { expr = InclusiveOrExpression() @@ -1057,7 +1065,7 @@ String InclusiveOrExpression() : { String expr; String expr2 = null; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); } { expr = ExclusiveOrExpression() @@ -1080,7 +1088,7 @@ String ExclusiveOrExpression() : { String expr; String expr2 = null; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); } { expr = AndExpression() @@ -1101,9 +1109,9 @@ String ExclusiveOrExpression() : String AndExpression() : { - String expr; + final String expr; String expr2 = null; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); } { expr = EqualityExpression() @@ -1127,7 +1135,7 @@ String EqualityExpression() : String expr; Token operator; String expr2; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); } { expr = RelationalExpression() @@ -1153,7 +1161,7 @@ String RelationalExpression() : String expr; Token operator; String expr2; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); } { expr = ShiftExpression() @@ -1172,17 +1180,16 @@ String ShiftExpression() : { String expr; Token operator; - String expr2; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); } { expr = AdditiveExpression() {buff.append(expr);} ( - (operator = | operator = | operator = ) expr2 = AdditiveExpression() + (operator = | operator = | operator = ) expr = AdditiveExpression() { buff.append(operator.image); - buff.append(expr2); + buff.append(expr); } )* {return buff.toString();} @@ -1192,17 +1199,16 @@ String AdditiveExpression() : { String expr; Token operator; - String expr2; - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); } { expr = MultiplicativeExpression() {buff.append(expr);} ( - ( operator = | operator = ) expr2 = MultiplicativeExpression() + ( operator = | operator = ) expr = MultiplicativeExpression() { buff.append(operator.image); - buff.append(expr2); + buff.append(expr); } )* {return buff.toString();} @@ -1210,17 +1216,17 @@ String AdditiveExpression() : String MultiplicativeExpression() : { - String expr, expr2; + String expr; Token operator; final StringBuffer buff = new StringBuffer();} { expr = UnaryExpression() {buff.append(expr);} ( - ( operator = | operator = | operator = ) expr2 = UnaryExpression() + ( operator = | operator = | operator = ) expr = UnaryExpression() { buff.append(operator.image); - buff.append(expr2); + buff.append(expr); } )* {return buff.toString();} @@ -1312,8 +1318,7 @@ String UnaryExpressionNotPlusMinus() : String CastExpression() : { -String type; -String expr; +final String type, expr; } { type = Type() expr = UnaryExpression() @@ -1361,7 +1366,7 @@ String PrimaryExpression() : String ArrayDeclarator() : { - String expr; + final String expr; } { expr = ArrayInitializer() @@ -1498,7 +1503,7 @@ String expr = null; String ArgumentList() : { String expr; -StringBuffer buff = new StringBuffer(); +final StringBuffer buff = new StringBuffer(); } { expr = Expression() @@ -1581,7 +1586,7 @@ void Statement() : void IncludeStatement() : { String expr; - int pos = jj_input_stream.bufpos; + final int pos = jj_input_stream.bufpos; } { @@ -1647,7 +1652,7 @@ void IncludeStatement() : String PrintExpression() : { - StringBuffer buff = new StringBuffer("print "); + final StringBuffer buff = new StringBuffer("print "); String expr; } { @@ -1778,9 +1783,12 @@ void IfStatement() : * else's to the innermost if statement. The LOOKAHEAD specification * is to tell JavaCC that we know what we are doing. */ -{} { - Condition("if") IfStatement0() + Token token; + final int pos = jj_input_stream.bufpos; +} +{ + token = Condition("if") IfStatement0(pos,pos+token.image.length()) } void Condition(String keyword) : @@ -1803,10 +1811,29 @@ void Condition(String keyword) : } } -void IfStatement0() : -{} +void IfStatement0(int start,int end) : +{ +} { - (Statement())* (ElseIfStatementColon())* [ElseStatementColon()] + (Statement())* (ElseIfStatementColon())* [ElseStatementColon()] + + {try { + setMarker(fileToParse, + "Ugly syntax detected, you should if () {...} instead of if (): ... endif;", + start, + end, + INFO, + "Line " + token.beginLine); + } catch (CoreException e) { + PHPeclipsePlugin.log(e); + }} + try { + + } catch (ParseException e) { + errorMessage = "'endif' expected"; + errorLevel = ERROR; + throw e; + } try { } catch (ParseException e) { @@ -1824,12 +1851,6 @@ void ElseIfStatementColon() : Condition("elseif") (Statement())* } -void ElseStatement() : -{} -{ - Statement() -} - void ElseStatementColon() : {} { @@ -1843,15 +1864,35 @@ void ElseIfStatement() : } void WhileStatement() : -{} { - Condition("while") WhileStatement0() + Token token; + final int pos = jj_input_stream.bufpos; +} +{ + token = Condition("while") WhileStatement0(pos,pos + token.image.length()) } -void WhileStatement0() : +void WhileStatement0(final int start, final int end) : {} { - (Statement())* + (Statement())* + {try { + setMarker(fileToParse, + "Ugly syntax detected, you should while () {...} instead of while (): ... endwhile;", + start, + end, + INFO, + "Line " + token.beginLine); + } catch (CoreException e) { + PHPeclipsePlugin.log(e); + }} + try { + + } catch (ParseException e) { + errorMessage = "'endwhile' expected"; + errorLevel = ERROR; + throw e; + } try { ( | "?>") } catch (ParseException e) { @@ -1879,17 +1920,91 @@ void DoStatement() : void ForeachStatement() : {} { - Variable() Variable() [ Expression() ] Statement() + + try { + + } catch (ParseException e) { + errorMessage = "'(' expected after 'foreach' keyword"; + errorLevel = ERROR; + throw e; + } + try { + Variable() + } catch (ParseException e) { + errorMessage = "variable expected"; + errorLevel = ERROR; + throw e; + } + try { + + } catch (ParseException e) { + errorMessage = "'as' expected"; + errorLevel = ERROR; + throw e; + } + try { + Variable() + } catch (ParseException e) { + errorMessage = "variable expected"; + errorLevel = ERROR; + throw e; + } + [ Expression() ] + try { + + } catch (ParseException e) { + errorMessage = "')' expected after 'foreach' keyword"; + errorLevel = ERROR; + throw e; + } + try { + Statement() + } catch (ParseException e) { + if (errorMessage != null) throw e; + errorMessage = "statement expected"; + errorLevel = ERROR; + throw e; + } } void ForStatement() : -{} { - [ ForInit() ] [ Expression() ] [ ForUpdate() ] +Token token; +final int pos = jj_input_stream.bufpos; +} +{ + token = + try { + + } catch (ParseException e) { + errorMessage = "'(' expected after 'for' keyword"; + errorLevel = ERROR; + throw e; + } + [ ForInit() ] [ Expression() ] [ ForUpdate() ] ( Statement() | - (Statement())* + (Statement())* + { + try { + setMarker(fileToParse, + "Ugly syntax detected, you should for () {...} instead of for (): ... endfor;", + pos, + pos+token.image.length(), + INFO, + "Line " + token.beginLine); + } catch (CoreException e) { + PHPeclipsePlugin.log(e); + } + } + try { + + } catch (ParseException e) { + errorMessage = "'endfor' expected"; + errorLevel = ERROR; + throw e; + } try { } catch (ParseException e) { -- 1.7.1