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 aba9b11..b1eb71b 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -8,7 +8,6 @@ import org.eclipse.ui.texteditor.MarkerUtilities; import org.eclipse.jface.preference.IPreferenceStore; import java.util.Hashtable; -import java.util.Enumeration; import java.util.ArrayList; import java.io.StringReader; import java.io.*; @@ -18,6 +17,7 @@ import net.sourceforge.phpeclipse.actions.PHPStartApacheAction; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpdt.internal.compiler.ast.*; import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren; +import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; import net.sourceforge.phpdt.internal.compiler.parser.PHPOutlineInfo; /** @@ -26,6 +26,7 @@ import net.sourceforge.phpdt.internal.compiler.parser.PHPOutlineInfo; * given with JavaCC. You can get JavaCC at http://www.webgain.com * You can test the parser with the PHPParserTestCase2.java * @author Matthieu Casanova + * @version $Reference: 1.0$ */ public final class PHPParser extends PHPParserSuperclass implements PHPParserConstants { @@ -87,12 +88,12 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon * Add an php node on the stack. * @param node the node that will be added to the stack */ - private static final void pushOnAstNodes(AstNode node) { + private static final void pushOnAstNodes(final AstNode node) { try { nodes[++nodePtr] = node; } catch (IndexOutOfBoundsException e) { - int oldStackLength = nodes.length; - AstNode[] oldStack = nodes; + final int oldStackLength = nodes.length; + final AstNode[] oldStack = nodes; nodes = new AstNode[oldStackLength + AstStackIncrement]; System.arraycopy(oldStack, 0, nodes, 0, oldStackLength); nodePtr = oldStackLength; @@ -137,6 +138,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } setMarker(e); errorMessage = null; + if (PHPeclipsePlugin.DEBUG) PHPeclipsePlugin.log(e); } /** @@ -167,31 +169,6 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } } - /** - * Create markers according to the external parser output - */ - private static void createMarkers(final String output, final IFile file) throws CoreException { - // delete all markers - file.deleteMarkers(IMarker.PROBLEM, false, 0); - - int indx = 0; - int brIndx; - boolean flag = true; - while ((brIndx = output.indexOf("
", indx)) != -1) { - // newer php error output (tested with 4.2.3) - scanLine(output, file, indx, brIndx); - indx = brIndx + 6; - flag = false; - } - if (flag) { - while ((brIndx = output.indexOf("
", indx)) != -1) { - // older php error output (tested with 4.2.3) - scanLine(output, file, indx, brIndx); - indx = brIndx + 4; - } - } - } - private static void scanLine(final String output, final IFile file, final int indx, @@ -274,13 +251,32 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon */ public static final void createNewHTMLCode() { final int currentPosition = SimpleCharStream.getPosition(); - if (currentPosition == htmlStart) { + if (currentPosition == htmlStart || currentPosition > SimpleCharStream.currentBuffer.length()) { return; } final char[] chars = SimpleCharStream.currentBuffer.substring(htmlStart,currentPosition+1).toCharArray(); pushOnAstNodes(new HTMLCode(chars, htmlStart,currentPosition)); } + /** + * Create a new task. + */ + public static final void createNewTask() { + final int currentPosition = SimpleCharStream.getPosition(); + final String todo = SimpleCharStream.currentBuffer.substring(currentPosition+1, + SimpleCharStream.currentBuffer.indexOf("\n", + currentPosition)-1); + try { + setMarker(fileToParse, + "todo : " + todo, + SimpleCharStream.getBeginLine(), + TASK, + "Line "+SimpleCharStream.getBeginLine()); + } catch (CoreException e) { + PHPeclipsePlugin.log(e); + } + } + private static final void parse() throws ParseException { phpFile(); } @@ -307,6 +303,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon case INCLUDE_ONCE: case REQUIRE_ONCE: case GLOBAL: + case DEFINE: case STATIC: case CONTINUE: case DO: @@ -322,8 +319,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon case AT: case DOLLAR: case BANG: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case PLUS: case MINUS: case BIT_AND: @@ -343,7 +340,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } PhpBlock(); } - jj_consume_token(0); + PHPParser.createNewHTMLCode(); } catch (TokenMgrError e) { PHPeclipsePlugin.log(e); errorStart = SimpleCharStream.getPosition(); @@ -383,6 +380,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon case INCLUDE_ONCE: case REQUIRE_ONCE: case GLOBAL: + case DEFINE: case STATIC: case CONTINUE: case DO: @@ -398,8 +396,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon case AT: case DOLLAR: case BANG: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case PLUS: case MINUS: case BIT_AND: @@ -462,7 +460,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon static final public PHPEchoBlock phpEchoBlock() throws ParseException { final Expression expr; final int pos = SimpleCharStream.getPosition(); - PHPEchoBlock echoBlock; + final PHPEchoBlock echoBlock; jj_consume_token(PHPECHOSTART); expr = Expression(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -497,6 +495,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon case INCLUDE_ONCE: case REQUIRE_ONCE: case GLOBAL: + case DEFINE: case STATIC: case CONTINUE: case DO: @@ -512,8 +511,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon case AT: case DOLLAR: case BANG: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case PLUS: case MINUS: case BIT_AND: @@ -537,8 +536,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon static final public ClassDeclaration ClassDeclaration() throws ParseException { final ClassDeclaration classDeclaration; - final Token className; - Token superclassName = null; + final Token className,superclassName; final int pos; char[] classNameImage = SYNTAX_ERROR_CHAR; char[] superclassNameImage = null; @@ -595,7 +593,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon throw new Error("Missing return statement in function"); } - static final public void ClassBody(ClassDeclaration classDeclaration) throws ParseException { + static final public void ClassBody(final ClassDeclaration classDeclaration) throws ParseException { try { jj_consume_token(LBRACE); } catch (ParseException e) { @@ -632,16 +630,17 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon /** * A class can contain only methods and fields. */ - static final public void ClassBodyDeclaration(ClassDeclaration classDeclaration) throws ParseException { - MethodDeclaration method; - FieldDeclaration field; + static final public void ClassBodyDeclaration(final ClassDeclaration classDeclaration) throws ParseException { + final MethodDeclaration method; + final FieldDeclaration field; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case FUNCTION: method = MethodDeclaration(); - method.setParent(classDeclaration); + classDeclaration.addMethod(method); break; case VAR: field = FieldDeclaration(); + classDeclaration.addField(field); break; default: jj_la1[8] = jj_gen; @@ -655,14 +654,13 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon */ static final public FieldDeclaration FieldDeclaration() throws ParseException { VariableDeclaration variableDeclaration; - VariableDeclaration[] list; + final VariableDeclaration[] list; final ArrayList arrayList = new ArrayList(); final int pos = SimpleCharStream.getPosition(); jj_consume_token(VAR); variableDeclaration = VariableDeclarator(); arrayList.add(variableDeclaration); outlineInfo.addVariable(new String(variableDeclaration.name)); - currentSegment.add(variableDeclaration); label_4: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -677,7 +675,6 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon variableDeclaration = VariableDeclarator(); arrayList.add(variableDeclaration); outlineInfo.addVariable(new String(variableDeclaration.name)); - currentSegment.add(variableDeclaration); } try { jj_consume_token(SEMICOLON); @@ -737,14 +734,12 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon * @return the variable name (with suffix) */ static final public String VariableDeclaratorId() throws ParseException { - String expr; - Expression expression; - final StringBuffer buff = new StringBuffer(); + final String expr; + Expression expression = null; final int pos = SimpleCharStream.getPosition(); ConstantIdentifier ex; try { expr = Variable(); - buff.append(expr); label_5: while (true) { if (jj_2_1(2)) { @@ -756,9 +751,11 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon pos, SimpleCharStream.getPosition()); expression = VariableSuffix(ex); - buff.append(expression.toStringExpression()); } - {if (true) return buff.toString();} + if (expression == null) { + {if (true) return expr;} + } + {if (true) return expression.toStringExpression();} } catch (ParseException e) { errorMessage = "'$' expected for variable identifier"; errorLevel = ERROR; @@ -769,6 +766,10 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon throw new Error("Missing return statement in function"); } +/** + * Return a variablename without the $. + * @return a variable name + */ static final public String Variable() throws ParseException { final StringBuffer buff; Expression expression = null; @@ -799,7 +800,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon case DOLLAR: jj_consume_token(DOLLAR); expr = VariableName(); - {if (true) return "$" + expr;} + {if (true) return expr;} break; default: jj_la1[12] = jj_gen; @@ -815,7 +816,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon */ static final public String VariableName() throws ParseException { final StringBuffer buff; - String expr = null; + final String expr; Expression expression = null; final Token token; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -939,7 +940,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } static final public ArrayVariableDeclaration ArrayVariable() throws ParseException { -Expression expr,expr2; +final Expression expr,expr2; expr = Expression(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ARRAYASSIGN: @@ -970,8 +971,8 @@ Expression expr,expr2; case AT: case DOLLAR: case BANG: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case PLUS: case MINUS: case BIT_AND: @@ -1009,7 +1010,7 @@ Expression expr,expr2; ; } jj_consume_token(RPAREN); - ArrayVariableDeclaration[] vars = new ArrayVariableDeclaration[list.size()]; + final ArrayVariableDeclaration[] vars = new ArrayVariableDeclaration[list.size()]; list.toArray(vars); {if (true) return vars;} throw new Error("Missing return statement in function"); @@ -1022,6 +1023,7 @@ Expression expr,expr2; static final public MethodDeclaration MethodDeclaration() throws ParseException { final MethodDeclaration functionDeclaration; final Block block; + final OutlineableWithChildren seg = currentSegment; jj_consume_token(FUNCTION); try { functionDeclaration = MethodDeclarator(); @@ -1034,16 +1036,11 @@ Expression expr,expr2; errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } - if (currentSegment != null) { - currentSegment.add(functionDeclaration); - currentSegment = functionDeclaration; - } + currentSegment = functionDeclaration; block = Block(); - functionDeclaration.statements = block.statements; - if (currentSegment != null) { - currentSegment = (OutlineableWithChildren) currentSegment.getParent(); - } - {if (true) return functionDeclaration;} + functionDeclaration.statements = block.statements; + currentSegment = seg; + {if (true) return functionDeclaration;} throw new Error("Missing return statement in function"); } @@ -1078,11 +1075,11 @@ Expression expr,expr2; } formalParameters = FormalParameters(); {if (true) return new MethodDeclaration(currentSegment, - identifierChar, - formalParameters, - reference != null, - pos, - SimpleCharStream.getPosition());} + identifierChar, + formalParameters, + reference != null, + pos, + SimpleCharStream.getPosition());} throw new Error("Missing return statement in function"); } @@ -1100,7 +1097,7 @@ Expression expr,expr2; errorLevel = ERROR; errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; errorEnd = SimpleCharStream.getPosition() + 1; - {if (true) throw e;} + processParseException(e); } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case DOLLAR: @@ -1134,7 +1131,7 @@ Expression expr,expr2; errorLevel = ERROR; errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; errorEnd = SimpleCharStream.getPosition() + 1; - {if (true) throw e;} + processParseException(e); } {if (true) return parameters;} throw new Error("Missing return statement in function"); @@ -1221,6 +1218,80 @@ Expression expr,expr2; static final public Expression Expression() throws ParseException { final Expression expr; + Expression initializer = null; + int assignOperator = -1; + final int pos = SimpleCharStream.getPosition(); + if (jj_2_3(2)) { + expr = ConditionalExpression(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case ASSIGN: + case PLUSASSIGN: + case MINUSASSIGN: + case STARASSIGN: + case SLASHASSIGN: + case ANDASSIGN: + case ORASSIGN: + case XORASSIGN: + case DOTASSIGN: + case REMASSIGN: + case TILDEEQUAL: + case LSHIFTASSIGN: + case RSIGNEDSHIFTASSIGN: + assignOperator = AssignmentOperator(); + initializer = Expression(); + break; + default: + jj_la1[26] = jj_gen; + ; + } + if (assignOperator == -1) {if (true) return expr;} + {if (true) return new VarAssignation(expr, + initializer, + assignOperator, + pos, + SimpleCharStream.getPosition());} + {if (true) return expr;} + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LIST: + case PRINT: + case BANG: + expr = ExpressionWBang(); + {if (true) return expr;} + break; + default: + jj_la1[27] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } + throw new Error("Missing return statement in function"); + } + + static final public Expression ExpressionWBang() throws ParseException { + final Expression expr; + final int pos = SimpleCharStream.getPosition(); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BANG: + jj_consume_token(BANG); + expr = ExpressionWBang(); + {if (true) return new PrefixedUnaryExpression(expr,OperatorIds.NOT,pos);} + break; + case LIST: + case PRINT: + expr = ExpressionNoBang(); + {if (true) return expr;} + break; + default: + jj_la1[28] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + throw new Error("Missing return statement in function"); + } + + static final public Expression ExpressionNoBang() throws ParseException { + final Expression expr; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PRINT: expr = PrintExpression(); @@ -1231,75 +1302,17 @@ Expression expr,expr2; {if (true) return expr;} break; default: - jj_la1[26] = jj_gen; - if (jj_2_3(2147483647)) { - expr = varAssignation(); - {if (true) return expr;} - } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ARRAY: - case NEW: - case NULL: - case TRUE: - case FALSE: - case AT: - case DOLLAR: - case BANG: - case INCR: - case DECR: - case PLUS: - case MINUS: - case BIT_AND: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - case IDENTIFIER: - case LPAREN: - case DOLLAR_ID: - expr = ConditionalExpression(); - {if (true) return expr;} - break; - default: - jj_la1[27] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - } + jj_la1[29] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); } throw new Error("Missing return statement in function"); } /** - * A Variable assignation. - * varName (an assign operator) any expression + * Any assignement operator. + * @return the assignement operator id */ - static final public VarAssignation varAssignation() throws ParseException { - String varName; - final Expression expression; - final int assignOperator; - final int pos = SimpleCharStream.getPosition(); - varName = VariableDeclaratorId(); - assignOperator = AssignmentOperator(); - try { - expression = Expression(); - } catch (ParseException e) { - if (errorMessage != null) { - {if (true) throw e;} - } - errorMessage = "expression expected"; - errorLevel = ERROR; - errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = SimpleCharStream.getPosition() + 1; - {if (true) throw e;} - } - {if (true) return new VarAssignation(varName.toCharArray(), - expression, - assignOperator, - pos, - SimpleCharStream.getPosition());} - throw new Error("Missing return statement in function"); - } - static final public int AssignmentOperator() throws ParseException { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ASSIGN: @@ -1355,7 +1368,7 @@ Expression expr,expr2; {if (true) return VarAssignation.TILDE_EQUAL;} break; default: - jj_la1[28] = jj_gen; + jj_la1[30] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1375,7 +1388,7 @@ Expression expr,expr2; expr3 = ConditionalExpression(); break; default: - jj_la1[29] = jj_gen; + jj_la1[31] = jj_gen; ; } if (expr3 == null) { @@ -1397,7 +1410,7 @@ Expression expr,expr2; ; break; default: - jj_la1[30] = jj_gen; + jj_la1[32] = jj_gen; break label_8; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -1410,7 +1423,7 @@ Expression expr,expr2; operator = OperatorIds.ORL; break; default: - jj_la1[31] = jj_gen; + jj_la1[33] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1433,7 +1446,7 @@ Expression expr,expr2; ; break; default: - jj_la1[32] = jj_gen; + jj_la1[34] = jj_gen; break label_9; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -1446,7 +1459,7 @@ Expression expr,expr2; operator = OperatorIds.ANDL; break; default: - jj_la1[33] = jj_gen; + jj_la1[35] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1467,7 +1480,7 @@ Expression expr,expr2; ; break; default: - jj_la1[34] = jj_gen; + jj_la1[36] = jj_gen; break label_10; } jj_consume_token(DOT); @@ -1488,7 +1501,7 @@ Expression expr,expr2; ; break; default: - jj_la1[35] = jj_gen; + jj_la1[37] = jj_gen; break label_11; } jj_consume_token(BIT_OR); @@ -1509,7 +1522,7 @@ Expression expr,expr2; ; break; default: - jj_la1[36] = jj_gen; + jj_la1[38] = jj_gen; break label_12; } jj_consume_token(XOR); @@ -1530,7 +1543,7 @@ Expression expr,expr2; ; break; default: - jj_la1[37] = jj_gen; + jj_la1[39] = jj_gen; break label_13; } jj_consume_token(BIT_AND); @@ -1556,7 +1569,7 @@ Expression expr,expr2; ; break; default: - jj_la1[38] = jj_gen; + jj_la1[40] = jj_gen; break label_14; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -1581,7 +1594,7 @@ Expression expr,expr2; operator = OperatorIds.EQUAL_EQUAL_EQUAL; break; default: - jj_la1[39] = jj_gen; + jj_la1[41] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1617,7 +1630,7 @@ Expression expr,expr2; ; break; default: - jj_la1[40] = jj_gen; + jj_la1[42] = jj_gen; break label_15; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -1638,7 +1651,7 @@ Expression expr,expr2; operator = OperatorIds.GREATER_EQUAL; break; default: - jj_la1[41] = jj_gen; + jj_la1[43] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1662,7 +1675,7 @@ Expression expr,expr2; ; break; default: - jj_la1[42] = jj_gen; + jj_la1[44] = jj_gen; break label_16; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -1679,7 +1692,7 @@ Expression expr,expr2; operator = OperatorIds.UNSIGNED_RIGHT_SHIFT; break; default: - jj_la1[43] = jj_gen; + jj_la1[45] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1702,7 +1715,7 @@ Expression expr,expr2; ; break; default: - jj_la1[44] = jj_gen; + jj_la1[46] = jj_gen; break label_17; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -1715,7 +1728,7 @@ Expression expr,expr2; operator = OperatorIds.MINUS; break; default: - jj_la1[45] = jj_gen; + jj_la1[47] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1748,7 +1761,7 @@ Expression expr,expr2; ; break; default: - jj_la1[46] = jj_gen; + jj_la1[48] = jj_gen; break label_18; } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -1765,7 +1778,7 @@ Expression expr,expr2; operator = OperatorIds.REMAINDER; break; default: - jj_la1[47] = jj_gen; + jj_la1[49] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1780,7 +1793,7 @@ Expression expr,expr2; * An unary expression starting with @, & or nothing */ static final public Expression UnaryExpression() throws ParseException { - Expression expr; + final Expression expr; final int pos = SimpleCharStream.getPosition(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BIT_AND: @@ -1796,8 +1809,8 @@ Expression expr,expr2; case AT: case DOLLAR: case BANG: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case PLUS: case MINUS: case INTEGER_LITERAL: @@ -1810,7 +1823,7 @@ Expression expr,expr2; {if (true) return expr;} break; default: - jj_la1[48] = jj_gen; + jj_la1[50] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1818,7 +1831,7 @@ Expression expr,expr2; } static final public Expression AtUnaryExpression() throws ParseException { - Expression expr; + final Expression expr; final int pos = SimpleCharStream.getPosition(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case AT: @@ -1833,8 +1846,8 @@ Expression expr,expr2; case FALSE: case DOLLAR: case BANG: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case PLUS: case MINUS: case INTEGER_LITERAL: @@ -1847,7 +1860,7 @@ Expression expr,expr2; {if (true) return expr;} break; default: - jj_la1[49] = jj_gen; + jj_la1[51] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1855,8 +1868,8 @@ Expression expr,expr2; } static final public Expression UnaryExpressionNoPrefix() throws ParseException { - Expression expr; - int operator; + final Expression expr; + final int operator; final int pos = SimpleCharStream.getPosition(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PLUS: @@ -1871,15 +1884,15 @@ Expression expr,expr2; operator = OperatorIds.MINUS; break; default: - jj_la1[50] = jj_gen; + jj_la1[52] = jj_gen; jj_consume_token(-1); throw new ParseException(); } expr = UnaryExpression(); {if (true) return new PrefixedUnaryExpression(expr,operator,pos);} break; - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: expr = PreIncDecExpression(); {if (true) return expr;} break; @@ -1900,7 +1913,7 @@ Expression expr,expr2; {if (true) return expr;} break; default: - jj_la1[51] = jj_gen; + jj_la1[53] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1912,16 +1925,16 @@ final Expression expr; final int operator; final int pos = SimpleCharStream.getPosition(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case INCR: - jj_consume_token(INCR); - operator = OperatorIds.PLUS_PLUS; + case PLUS_PLUS: + jj_consume_token(PLUS_PLUS); + operator = OperatorIds.PLUS_PLUS; break; - case DECR: - jj_consume_token(DECR); - operator = OperatorIds.MINUS_MINUS; + case MINUS_MINUS: + jj_consume_token(MINUS_MINUS); + operator = OperatorIds.MINUS_MINUS; break; default: - jj_la1[52] = jj_gen; + jj_la1[54] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -1931,57 +1944,53 @@ final int operator; } static final public Expression UnaryExpressionNotPlusMinus() throws ParseException { - Expression expr; + final Expression expr; final int pos = SimpleCharStream.getPosition(); - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case BANG: - jj_consume_token(BANG); - expr = UnaryExpression(); - {if (true) return new PrefixedUnaryExpression(expr,OperatorIds.NOT,pos);} - break; - default: - jj_la1[53] = jj_gen; - if (jj_2_4(2147483647)) { - expr = CastExpression(); + if (jj_2_4(2147483647)) { + expr = CastExpression(); {if (true) return expr;} - } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case ARRAY: - case NEW: - case DOLLAR: - case IDENTIFIER: - case DOLLAR_ID: - expr = PostfixExpression(); + } else { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case BANG: + jj_consume_token(BANG); + expr = UnaryExpression(); + {if (true) return new PrefixedUnaryExpression(expr,OperatorIds.NOT,pos);} + break; + case ARRAY: + case NEW: + case DOLLAR: + case IDENTIFIER: + case DOLLAR_ID: + expr = PostfixExpression(); {if (true) return expr;} - break; - case NULL: - case TRUE: - case FALSE: - case INTEGER_LITERAL: - case FLOATING_POINT_LITERAL: - case STRING_LITERAL: - expr = Literal(); + break; + case NULL: + case TRUE: + case FALSE: + case INTEGER_LITERAL: + case FLOATING_POINT_LITERAL: + case STRING_LITERAL: + expr = Literal(); {if (true) return expr;} - break; - case LPAREN: - jj_consume_token(LPAREN); - expr = Expression(); - try { - jj_consume_token(RPAREN); - } catch (ParseException e) { + break; + case LPAREN: + jj_consume_token(LPAREN); + expr = Expression(); + try { + jj_consume_token(RPAREN); + } catch (ParseException e) { errorMessage = "')' expected"; errorLevel = ERROR; errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} - } - {if (true) return expr;} - break; - default: - jj_la1[54] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); } + {if (true) return expr;} + break; + default: + jj_la1[55] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); } } throw new Error("Missing return statement in function"); @@ -2009,7 +2018,7 @@ final int pos = SimpleCharStream.getPosition(); type = new ConstantIdentifier(Types.ARRAY,pos,SimpleCharStream.getPosition()); break; default: - jj_la1[55] = jj_gen; + jj_la1[56] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -2020,30 +2029,30 @@ final int pos = SimpleCharStream.getPosition(); } static final public Expression PostfixExpression() throws ParseException { - Expression expr; + final Expression expr; int operator = -1; final int pos = SimpleCharStream.getPosition(); expr = PrimaryExpression(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case INCR: - jj_consume_token(INCR); - operator = OperatorIds.PLUS_PLUS; + case PLUS_PLUS: + jj_consume_token(PLUS_PLUS); + operator = OperatorIds.PLUS_PLUS; break; - case DECR: - jj_consume_token(DECR); - operator = OperatorIds.MINUS_MINUS; + case MINUS_MINUS: + jj_consume_token(MINUS_MINUS); + operator = OperatorIds.MINUS_MINUS; break; default: - jj_la1[56] = jj_gen; + jj_la1[57] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; default: - jj_la1[57] = jj_gen; + jj_la1[58] = jj_gen; ; } if (operator == -1) { @@ -2057,75 +2066,35 @@ final int pos = SimpleCharStream.getPosition(); final Token identifier; Expression expr; final int pos = SimpleCharStream.getPosition(); - if (jj_2_5(2)) { - identifier = jj_consume_token(IDENTIFIER); - jj_consume_token(STATICCLASSACCESS); - expr = ClassIdentifier(); - expr = new ClassAccess(new ConstantIdentifier(identifier.image.toCharArray(), - pos, - SimpleCharStream.getPosition()), - expr, - ClassAccess.STATIC); + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case NEW: + case DOLLAR: + case IDENTIFIER: + case DOLLAR_ID: + expr = PrimaryPrefix(); label_19: while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CLASSACCESS: - case LPAREN: - case LBRACKET: + if (jj_2_5(2147483647)) { ; - break; - default: - jj_la1[58] = jj_gen; + } else { break label_19; } expr = PrimarySuffix(expr); } {if (true) return expr;} - } else { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case NEW: - case DOLLAR: - case IDENTIFIER: - case DOLLAR_ID: - expr = PrimaryPrefix(); - label_20: - while (true) { - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case CLASSACCESS: - case LPAREN: - case LBRACKET: - ; - break; - default: - jj_la1[59] = jj_gen; - break label_20; - } - expr = PrimarySuffix(expr); - } - {if (true) return expr;} - break; - case ARRAY: - expr = ArrayDeclarator(); + break; + case ARRAY: + expr = ArrayDeclarator(); {if (true) return expr;} - break; - default: - jj_la1[60] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } + break; + default: + jj_la1[59] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); } throw new Error("Missing return statement in function"); } - static final public ArrayInitializer ArrayDeclarator() throws ParseException { - final ArrayVariableDeclaration[] vars; - final int pos = SimpleCharStream.getPosition(); - jj_consume_token(ARRAY); - vars = ArrayInitializer(); - {if (true) return new ArrayInitializer(vars,pos,SimpleCharStream.getPosition());} - throw new Error("Missing return statement in function"); - } - static final public Expression PrimaryPrefix() throws ParseException { final Expression expr; final Token token; @@ -2148,9 +2117,39 @@ final int pos = SimpleCharStream.getPosition(); case DOLLAR: case DOLLAR_ID: var = VariableDeclaratorId(); - {if (true) return new ConstantIdentifier(var.toCharArray(), - pos, - SimpleCharStream.getPosition());} + {if (true) return new VariableDeclaration(currentSegment, + var.toCharArray(), + pos, + SimpleCharStream.getPosition());} + break; + default: + jj_la1[60] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + throw new Error("Missing return statement in function"); + } + + static final public AbstractSuffixExpression PrimarySuffix(final Expression prefix) throws ParseException { + final AbstractSuffixExpression suffix; + final Expression expr; + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case LPAREN: + suffix = Arguments(prefix); + {if (true) return suffix;} + break; + case CLASSACCESS: + case LBRACKET: + suffix = VariableSuffix(prefix); + {if (true) return suffix;} + break; + case STATICCLASSACCESS: + jj_consume_token(STATICCLASSACCESS); + expr = ClassIdentifier(); + suffix = new ClassAccess(prefix, + expr, + ClassAccess.STATIC); + {if (true) return suffix;} break; default: jj_la1[61] = jj_gen; @@ -2160,6 +2159,20 @@ final int pos = SimpleCharStream.getPosition(); throw new Error("Missing return statement in function"); } +/** + * An array declarator. + * array(vars) + * @return an array + */ + static final public ArrayInitializer ArrayDeclarator() throws ParseException { + final ArrayVariableDeclaration[] vars; + final int pos = SimpleCharStream.getPosition(); + jj_consume_token(ARRAY); + vars = ArrayInitializer(); + {if (true) return new ArrayInitializer(vars,pos,SimpleCharStream.getPosition());} + throw new Error("Missing return statement in function"); + } + static final public PrefixedUnaryExpression classInstantiation() throws ParseException { Expression expr; final StringBuffer buff; @@ -2193,6 +2206,7 @@ final int pos = SimpleCharStream.getPosition(); final String expr; final Token token; final int pos = SimpleCharStream.getPosition(); + final ConstantIdentifier type; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER: token = jj_consume_token(IDENTIFIER); @@ -2200,6 +2214,18 @@ final int pos = SimpleCharStream.getPosition(); pos, SimpleCharStream.getPosition());} break; + case STRING: + case OBJECT: + case BOOL: + case BOOLEAN: + case REAL: + case DOUBLE: + case FLOAT: + case INT: + case INTEGER: + type = Type(); + {if (true) return type;} + break; case DOLLAR: case DOLLAR_ID: expr = VariableDeclaratorId(); @@ -2215,27 +2241,7 @@ final int pos = SimpleCharStream.getPosition(); throw new Error("Missing return statement in function"); } - static final public AbstractSuffixExpression PrimarySuffix(Expression prefix) throws ParseException { - final AbstractSuffixExpression expr; - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case LPAREN: - expr = Arguments(prefix); - {if (true) return expr;} - break; - case CLASSACCESS: - case LBRACKET: - expr = VariableSuffix(prefix); - {if (true) return expr;} - break; - default: - jj_la1[64] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); - } - throw new Error("Missing return statement in function"); - } - - static final public AbstractSuffixExpression VariableSuffix(Expression prefix) throws ParseException { + static final public AbstractSuffixExpression VariableSuffix(final Expression prefix) throws ParseException { String expr = null; final int pos = SimpleCharStream.getPosition(); Expression expression = null; @@ -2277,8 +2283,8 @@ final int pos = SimpleCharStream.getPosition(); case AT: case DOLLAR: case BANG: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case PLUS: case MINUS: case BIT_AND: @@ -2299,8 +2305,8 @@ final int pos = SimpleCharStream.getPosition(); case AT: case DOLLAR: case BANG: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case PLUS: case MINUS: case BIT_AND: @@ -2324,13 +2330,13 @@ final int pos = SimpleCharStream.getPosition(); expression = Type(); break; default: - jj_la1[65] = jj_gen; + jj_la1[64] = jj_gen; jj_consume_token(-1); throw new ParseException(); } break; default: - jj_la1[66] = jj_gen; + jj_la1[65] = jj_gen; ; } try { @@ -2345,7 +2351,7 @@ final int pos = SimpleCharStream.getPosition(); {if (true) return new ArrayDeclarator(prefix,expression,SimpleCharStream.getPosition());} break; default: - jj_la1[67] = jj_gen; + jj_la1[66] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -2387,14 +2393,14 @@ final int pos = SimpleCharStream.getPosition(); {if (true) return new NullLiteral(pos-4,pos);} break; default: - jj_la1[68] = jj_gen; + jj_la1[67] = jj_gen; jj_consume_token(-1); throw new ParseException(); } throw new Error("Missing return statement in function"); } - static final public FunctionCall Arguments(Expression func) throws ParseException { + static final public FunctionCall Arguments(final Expression func) throws ParseException { Expression[] args = null; jj_consume_token(LPAREN); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -2408,8 +2414,8 @@ Expression[] args = null; case AT: case DOLLAR: case BANG: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case PLUS: case MINUS: case BIT_AND: @@ -2422,7 +2428,7 @@ Expression[] args = null; args = ArgumentList(); break; default: - jj_la1[69] = jj_gen; + jj_la1[68] = jj_gen; ; } try { @@ -2448,15 +2454,15 @@ Expression arg; final ArrayList list = new ArrayList(); arg = Expression(); list.add(arg); - label_21: + label_20: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case COMMA: ; break; default: - jj_la1[70] = jj_gen; - break label_21; + jj_la1[69] = jj_gen; + break label_20; } jj_consume_token(COMMA); try { @@ -2470,7 +2476,7 @@ final ArrayList list = new ArrayList(); {if (true) throw e;} } } - Expression[] arguments = new Expression[list.size()]; + final Expression[] arguments = new Expression[list.size()]; list.toArray(arguments); {if (true) return arguments;} throw new Error("Missing return statement in function"); @@ -2512,8 +2518,8 @@ final ArrayList list = new ArrayList(); case ARRAY: case NEW: case DOLLAR: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case IDENTIFIER: case DOLLAR_ID: statement = StatementExpression(); @@ -2574,7 +2580,7 @@ final ArrayList list = new ArrayList(); token = jj_consume_token(AT); break; default: - jj_la1[71] = jj_gen; + jj_la1[70] = jj_gen; ; } statement = IncludeStatement(); @@ -2591,8 +2597,12 @@ final ArrayList list = new ArrayList(); statement = GlobalStatement(); {if (true) return statement;} break; + case DEFINE: + statement = defineStatement(); + currentSegment.add((Outlineable)statement);{if (true) return statement;} + break; default: - jj_la1[72] = jj_gen; + jj_la1[71] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -2600,6 +2610,63 @@ final ArrayList list = new ArrayList(); throw new Error("Missing return statement in function"); } + static final public Define defineStatement() throws ParseException { + final int start = SimpleCharStream.getPosition(); + Expression defineName,defineValue; + jj_consume_token(DEFINE); + try { + jj_consume_token(LPAREN); + } catch (ParseException e) { + errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected"; + errorLevel = ERROR; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; + processParseException(e); + } + try { + defineName = Expression(); + } catch (ParseException e) { + errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected"; + errorLevel = ERROR; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; + {if (true) throw e;} + } + try { + jj_consume_token(COMMA); + } catch (ParseException e) { + errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ',' expected"; + errorLevel = ERROR; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; + processParseException(e); + } + try { + defineValue = Expression(); + } catch (ParseException e) { + errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected"; + errorLevel = ERROR; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; + {if (true) throw e;} + } + try { + jj_consume_token(RPAREN); + } catch (ParseException e) { + errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected"; + errorLevel = ERROR; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; + processParseException(e); + } + {if (true) return new Define(currentSegment, + defineName, + defineValue, + start, + SimpleCharStream.getPosition());} + throw new Error("Missing return statement in function"); + } + /** * A Normal statement. */ @@ -2616,6 +2683,7 @@ final ArrayList list = new ArrayList(); case INCLUDE_ONCE: case REQUIRE_ONCE: case GLOBAL: + case DEFINE: case STATIC: case CONTINUE: case DO: @@ -2631,8 +2699,8 @@ final ArrayList list = new ArrayList(); case AT: case DOLLAR: case BANG: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case PLUS: case MINUS: case BIT_AND: @@ -2652,7 +2720,7 @@ final ArrayList list = new ArrayList(); {if (true) return statement;} break; default: - jj_la1[73] = jj_gen; + jj_la1[72] = jj_gen; jj_consume_token(-1); throw new ParseException(); } @@ -2664,18 +2732,18 @@ final ArrayList list = new ArrayList(); */ static final public HTMLBlock htmlBlock() throws ParseException { final int startIndex = nodePtr; - AstNode[] blockNodes; - int nbNodes; + final AstNode[] blockNodes; + final int nbNodes; jj_consume_token(PHPEND); - label_22: + label_21: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PHPECHOSTART: ; break; default: - jj_la1[74] = jj_gen; - break label_22; + jj_la1[73] = jj_gen; + break label_21; } phpEchoBlock(); } @@ -2688,12 +2756,12 @@ final ArrayList list = new ArrayList(); jj_consume_token(PHPSTARTSHORT); break; default: - jj_la1[75] = jj_gen; + jj_la1[74] = jj_gen; jj_consume_token(-1); throw new ParseException(); } } catch (ParseException e) { - errorMessage = "End of file unexpected, '= 0) { @@ -6841,7 +6964,7 @@ final int startBlock, endBlock; } } } - for (int i = 0; i < 141; i++) { + for (int i = 0; i < 143; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i;