From 61d618c29e9fa7da3d4d8336f709228c63d34b0a Mon Sep 17 00:00:00 2001 From: kpouer Date: Tue, 17 Jun 2003 21:06:35 +0000 Subject: [PATCH 1/1] *** empty log message *** --- .../internal/compiler/ast/BinaryExpression.java | 2 +- .../compiler/ast/ConditionalExpression.java | 2 +- .../phpdt/internal/compiler/ast/ForStatement.java | 22 +- .../internal/compiler/ast/OperatorExpression.java | 152 ++++---- .../compiler/ast/PostfixedUnaryExpression.java | 2 +- .../compiler/ast/PrefixedUnaryExpression.java | 2 +- net.sourceforge.phpeclipse/src/test/PHPParser.java | 451 ++++++++++---------- net.sourceforge.phpeclipse/src/test/PHPParser.jj | 56 ++-- .../src/test/PHPParserConstants.java | 4 +- 9 files changed, 352 insertions(+), 341 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/BinaryExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/BinaryExpression.java index ff93371..5f54d9e 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/BinaryExpression.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/BinaryExpression.java @@ -16,7 +16,7 @@ public class BinaryExpression extends OperatorExpression { this.right = right; } - public String toStringExpressionNoParenthesis() { + public String toStringExpression() { final StringBuffer buff = new StringBuffer(left.toStringExpression()); buff.append(operatorToString()); buff.append(right.toStringExpression()); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConditionalExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConditionalExpression.java index d85c89c..b2e39fb 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConditionalExpression.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConditionalExpression.java @@ -17,7 +17,7 @@ public class ConditionalExpression extends OperatorExpression { this.valueIfFalse = valueIfFalse; } - public String toStringExpressionNoParenthesis() { + public String toStringExpression() { final StringBuffer buff = new StringBuffer("("); buff.append(condition.toStringExpression()); buff.append(") ? "); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ForStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ForStatement.java index 8a16b5e..f808542 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ForStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ForStatement.java @@ -1,18 +1,25 @@ package net.sourceforge.phpdt.internal.compiler.ast; /** + * A For statement. + * for(initializations;condition;increments) action * @author Matthieu Casanova */ public class ForStatement extends Statement { - public Statement[] initializations; + /** the initializations. */ + public Expression[] initializations; + + /** the condition. */ public Expression condition; - public Statement[] increments; + /** the increments. */ + public Expression[] increments; + public Statement action; - public ForStatement(Statement[] initializations, + public ForStatement(Expression[] initializations, Expression condition, - Statement[] increments, + Expression[] increments, Statement action, int sourceStart, int sourceEnd) { @@ -29,8 +36,7 @@ public class ForStatement extends Statement { //inits if (initializations != null) { for (int i = 0; i < initializations.length; i++) { - //nice only with expressions - buff.append(initializations[i].toString()); + buff.append(initializations[i].toStringExpression()); if (i != (initializations.length - 1)) buff.append(" , "); //$NON-NLS-1$ } @@ -45,7 +51,7 @@ public class ForStatement extends Statement { if (increments != null) { for (int i = 0; i < increments.length; i++) { //nice only with expressions - buff.append(increments[i].toString()); + buff.append(increments[i].toStringExpression()); if (i != (increments.length - 1)) buff.append(" , "); //$NON-NLS-1$ } @@ -55,7 +61,7 @@ public class ForStatement extends Statement { if (action == null) buff.append("{}"); //$NON-NLS-1$ else - buff.append( "\n").append(action.toString(tab + 1)); //$NON-NLS-1$ + buff.append(action.toString(tab + 1)); //$NON-NLS-1$ return buff.toString(); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/OperatorExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/OperatorExpression.java index deacaf5..9efa5fd 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/OperatorExpression.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/OperatorExpression.java @@ -5,85 +5,83 @@ package net.sourceforge.phpdt.internal.compiler.ast; * @author Matthieu Casanova */ public abstract class OperatorExpression - extends Expression - implements OperatorIds { + extends Expression + implements OperatorIds { - public int operator; + public int operator; - public OperatorExpression(int operator, int sourceStart, int sourceEnd) { - super(sourceStart, sourceEnd); - this.operator = operator; - } - - public String operatorToString() { - switch (operator) { - case EQUAL_EQUAL: - return "=="; //$NON-NLS-1$ - case LESS_EQUAL: - return "<="; //$NON-NLS-1$ - case GREATER_EQUAL: - return ">="; //$NON-NLS-1$ - case NOT_EQUAL: - return "!="; //$NON-NLS-1$ - case LEFT_SHIFT: - return "<<"; //$NON-NLS-1$ - case RIGHT_SHIFT: - return ">>"; //$NON-NLS-1$ - case UNSIGNED_RIGHT_SHIFT: - return ">>>"; //$NON-NLS-1$ - case OR_OR: - return "||"; //$NON-NLS-1$ - case AND_AND: - return "&&"; //$NON-NLS-1$ - case PLUS: - return "+"; //$NON-NLS-1$ - case MINUS: - return "-"; //$NON-NLS-1$ - case NOT: - return "!"; //$NON-NLS-1$ - case REMAINDER: - return "%"; //$NON-NLS-1$ - case XOR: - return "^"; //$NON-NLS-1$ - case AND: - return "&"; //$NON-NLS-1$ - case MULTIPLY: - return "*"; //$NON-NLS-1$ - case OR: - return "|"; //$NON-NLS-1$ - case TWIDDLE: - return "~"; //$NON-NLS-1$ - case DIVIDE: - return "/"; //$NON-NLS-1$ - case GREATER: - return ">"; //$NON-NLS-1$ - case LESS: - return "<"; //$NON-NLS-1$ - case ORL: - return "OR"; //$NON-NLS-1$ - case ANDL: - return "AND"; //$NON-NLS-1$ - case DOT: - return "."; //$NON-NLS-1$ - case DIF: - return "<>"; //$NON-NLS-1$ - case BANG_EQUAL_EQUAL: - return "!=="; //$NON-NLS-1$ - case EQUAL_EQUAL_EQUAL: - return "==="; //$NON-NLS-1$ - case EQUAL: - return "="; //$NON-NLS-1$ - case AT: - return "@"; //$NON-NLS-1$ - } - ; - return "unknown operator"; //$NON-NLS-1$ - } + public OperatorExpression(int operator, int sourceStart, int sourceEnd) { + super(sourceStart, sourceEnd); + this.operator = operator; + } - public String toStringExpression() { - //subclass redefine toStringExpressionNoParenthesis() - return "(" + toStringExpressionNoParenthesis() + ")"; //$NON-NLS-2$ //$NON-NLS-1$ + public String operatorToString() { + switch (operator) { + case EQUAL_EQUAL: + return "=="; //$NON-NLS-1$ + case LESS_EQUAL: + return "<="; //$NON-NLS-1$ + case GREATER_EQUAL: + return ">="; //$NON-NLS-1$ + case NOT_EQUAL: + return "!="; //$NON-NLS-1$ + case LEFT_SHIFT: + return "<<"; //$NON-NLS-1$ + case RIGHT_SHIFT: + return ">>"; //$NON-NLS-1$ + case UNSIGNED_RIGHT_SHIFT: + return ">>>"; //$NON-NLS-1$ + case OR_OR: + return "||"; //$NON-NLS-1$ + case AND_AND: + return "&&"; //$NON-NLS-1$ + case PLUS: + return "+"; //$NON-NLS-1$ + case MINUS: + return "-"; //$NON-NLS-1$ + case NOT: + return "!"; //$NON-NLS-1$ + case REMAINDER: + return "%"; //$NON-NLS-1$ + case XOR: + return "^"; //$NON-NLS-1$ + case AND: + return "&"; //$NON-NLS-1$ + case MULTIPLY: + return "*"; //$NON-NLS-1$ + case OR: + return "|"; //$NON-NLS-1$ + case TWIDDLE: + return "~"; //$NON-NLS-1$ + case DIVIDE: + return "/"; //$NON-NLS-1$ + case GREATER: + return ">"; //$NON-NLS-1$ + case LESS: + return "<"; //$NON-NLS-1$ + case ORL: + return "OR"; //$NON-NLS-1$ + case ANDL: + return "AND"; //$NON-NLS-1$ + case DOT: + return "."; //$NON-NLS-1$ + case DIF: + return "<>"; //$NON-NLS-1$ + case BANG_EQUAL_EQUAL: + return "!=="; //$NON-NLS-1$ + case EQUAL_EQUAL_EQUAL: + return "==="; //$NON-NLS-1$ + case EQUAL: + return "="; //$NON-NLS-1$ + case AT: + return "@"; //$NON-NLS-1$ + case PLUS_PLUS: + return "++"; //$NON-NLS-1$ + case MINUS_MINUS: + return "--"; //$NON-NLS-1$ + case NEW: + return "new "; //$NON-NLS-1$ } - - public abstract String toStringExpressionNoParenthesis(); + return "unknown operator " +operator; //$NON-NLS-1$ + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PostfixedUnaryExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PostfixedUnaryExpression.java index c58ea67..d95e08a 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PostfixedUnaryExpression.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PostfixedUnaryExpression.java @@ -9,7 +9,7 @@ public class PostfixedUnaryExpression extends UnaryExpression { super(expression, operator, expression.sourceStart, sourceEnd); } - public String toStringExpressionNoParenthesis() { + public String toStringExpression() { StringBuffer buff = new StringBuffer(expression.toStringExpression()); buff.append(operatorToString()); return buff.toString(); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PrefixedUnaryExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PrefixedUnaryExpression.java index 67dbaee..318d2c3 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PrefixedUnaryExpression.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PrefixedUnaryExpression.java @@ -9,7 +9,7 @@ public class PrefixedUnaryExpression extends UnaryExpression { super(expression, operator, sourceStart, expression.sourceEnd); } - public String toStringExpressionNoParenthesis() { + public String toStringExpression() { StringBuffer buff = new StringBuffer(operatorToString()); buff.append(expression.toStringExpression()); return buff.toString(); diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java index 8b59f42..ac04d6b 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -315,8 +315,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: @@ -391,8 +391,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: @@ -505,8 +505,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: @@ -967,8 +967,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: @@ -1238,8 +1238,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: @@ -1789,8 +1789,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: @@ -1826,8 +1826,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: @@ -1871,8 +1871,8 @@ Expression expr,expr2; 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; @@ -1905,13 +1905,13 @@ 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; @@ -2018,16 +2018,16 @@ final int pos = SimpleCharStream.getPosition(); 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; @@ -2141,9 +2141,10 @@ 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[61] = jj_gen; @@ -2270,8 +2271,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: @@ -2292,8 +2293,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: @@ -2401,8 +2402,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: @@ -2505,8 +2506,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(); @@ -2624,8 +2625,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: @@ -3032,8 +3033,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: @@ -3080,8 +3081,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: @@ -3150,8 +3151,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: @@ -3225,8 +3226,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: @@ -3318,12 +3319,12 @@ final ArrayList list = new ArrayList(); throw new Error("Missing return statement in function"); } - static final public Statement StatementExpression() throws ParseException { + static final public Expression StatementExpression() throws ParseException { Expression expr,expr2; int operator; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: expr = PreIncDecExpression(); {if (true) return expr;} break; @@ -3334,8 +3335,8 @@ final ArrayList list = new ArrayList(); case DOLLAR_ID: expr = PrimaryExpression(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case ASSIGN: case PLUSASSIGN: case MINUSASSIGN: @@ -3350,15 +3351,15 @@ final ArrayList list = new ArrayList(); case LSHIFTASSIGN: case RSIGNEDSHIFTASSIGN: switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case INCR: - jj_consume_token(INCR); - {if (true) return new PostfixedUnaryExpression(expr, + case PLUS_PLUS: + jj_consume_token(PLUS_PLUS); + {if (true) return new PostfixedUnaryExpression(expr, OperatorIds.PLUS_PLUS, SimpleCharStream.getPosition());} break; - case DECR: - jj_consume_token(DECR); - {if (true) return new PostfixedUnaryExpression(expr, + case MINUS_MINUS: + jj_consume_token(MINUS_MINUS); + {if (true) return new PostfixedUnaryExpression(expr, OperatorIds.MINUS_MINUS, SimpleCharStream.getPosition());} break; @@ -3577,8 +3578,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: @@ -3624,8 +3625,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: @@ -3736,8 +3737,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: @@ -3847,8 +3848,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: @@ -3893,8 +3894,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: @@ -4016,8 +4017,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: @@ -4056,8 +4057,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: @@ -4169,8 +4170,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: @@ -4215,8 +4216,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: @@ -4283,8 +4284,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: @@ -4329,8 +4330,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: @@ -4423,8 +4424,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: @@ -4503,8 +4504,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: @@ -4620,9 +4621,9 @@ final ArrayList list = new ArrayList(); static final public ForStatement ForStatement() throws ParseException { final Token token; final int pos = SimpleCharStream.getPosition(); -Statement[] initializations = null; +Expression[] initializations = null; Expression condition = null; -Statement[] increments = null; +Expression[] increments = null; Statement action; final ArrayList list = new ArrayList(); final int startBlock, endBlock; @@ -4640,8 +4641,8 @@ final int startBlock, endBlock; case ARRAY: case NEW: case DOLLAR: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case IDENTIFIER: case DOLLAR_ID: initializations = ForInit(); @@ -4662,8 +4663,8 @@ final int startBlock, endBlock; case AT: case DOLLAR: case BANG: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case PLUS: case MINUS: case BIT_AND: @@ -4684,8 +4685,8 @@ final int startBlock, endBlock; case ARRAY: case NEW: case DOLLAR: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case IDENTIFIER: case DOLLAR_ID: increments = StatementExpressionList(); @@ -4722,8 +4723,8 @@ final int startBlock, endBlock; case AT: case DOLLAR: case BANG: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case PLUS: case MINUS: case BIT_AND: @@ -4770,8 +4771,8 @@ final int startBlock, endBlock; case AT: case DOLLAR: case BANG: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case PLUS: case MINUS: case BIT_AND: @@ -4833,22 +4834,22 @@ final int startBlock, endBlock; throw new Error("Missing return statement in function"); } - static final public Statement[] ForInit() throws ParseException { - Statement[] statements; + static final public Expression[] ForInit() throws ParseException { + Expression[] exprs; if (jj_2_8(2147483647)) { - statements = LocalVariableDeclaration(); - {if (true) return statements;} + exprs = LocalVariableDeclaration(); + {if (true) return exprs;} } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ARRAY: case NEW: case DOLLAR: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case IDENTIFIER: case DOLLAR_ID: - statements = StatementExpressionList(); - {if (true) return statements;} + exprs = StatementExpressionList(); + {if (true) return exprs;} break; default: jj_la1[119] = jj_gen; @@ -4859,9 +4860,9 @@ final int startBlock, endBlock; throw new Error("Missing return statement in function"); } - static final public Statement[] StatementExpressionList() throws ParseException { + static final public Expression[] StatementExpressionList() throws ParseException { final ArrayList list = new ArrayList(); - Statement expr; + Expression expr; expr = StatementExpression(); list.add(expr); label_39: @@ -4878,9 +4879,9 @@ final int startBlock, endBlock; StatementExpression(); list.add(expr); } - Statement[] stmtsArray = new Statement[list.size()]; - list.toArray(stmtsArray); - {if (true) return stmtsArray;} + Expression[] exprsArray = new Expression[list.size()]; + list.toArray(exprsArray); + {if (true) return exprsArray;} throw new Error("Missing return statement in function"); } @@ -4899,8 +4900,8 @@ final int startBlock, endBlock; case AT: case DOLLAR: case BANG: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case PLUS: case MINUS: case BIT_AND: @@ -4944,8 +4945,8 @@ final int startBlock, endBlock; case AT: case DOLLAR: case BANG: - case INCR: - case DECR: + case PLUS_PLUS: + case MINUS_MINUS: case PLUS: case MINUS: case BIT_AND: @@ -5060,12 +5061,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_183() { - if (jj_3R_52()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_85() { if (jj_scan_token(LIST)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5088,6 +5083,12 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_183() { + if (jj_3R_52()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_78() { if (jj_scan_token(REAL)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5247,13 +5248,13 @@ final int startBlock, endBlock; } static final private boolean jj_3R_160() { - if (jj_scan_token(DECR)) return true; + if (jj_scan_token(MINUS_MINUS)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } static final private boolean jj_3R_159() { - if (jj_scan_token(INCR)) return true; + if (jj_scan_token(PLUS_PLUS)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -5438,12 +5439,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_198() { - if (jj_scan_token(COMMA)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_57() { if (jj_3R_50()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5454,6 +5449,12 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_198() { + if (jj_scan_token(COMMA)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_135() { Token xsp; xsp = jj_scanpos; @@ -5519,6 +5520,18 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_47() { + if (jj_3R_57()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_58()) { jj_scanpos = xsp; break; } + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } + return false; + } + static final private boolean jj_3R_192() { if (jj_scan_token(LPAREN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5540,18 +5553,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_47() { - if (jj_3R_57()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_58()) { jj_scanpos = xsp; break; } - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } - return false; - } - static final private boolean jj_3R_136() { if (jj_scan_token(LSHIFT)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5574,6 +5575,14 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3_6() { + if (jj_3R_45()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(SEMICOLON)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_121() { if (jj_3R_128()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5586,14 +5595,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3_6() { - if (jj_3R_45()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(SEMICOLON)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_201() { if (jj_scan_token(ARRAYASSIGN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5687,14 +5688,14 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_127() { - if (jj_scan_token(TRIPLEEQUAL)) return true; + static final private boolean jj_3R_200() { + if (jj_3R_202()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_200() { - if (jj_3R_202()) return true; + static final private boolean jj_3R_127() { + if (jj_scan_token(TRIPLEEQUAL)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -5799,6 +5800,12 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_177() { + 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_118() { if (jj_scan_token(BIT_AND)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5807,14 +5814,14 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_177() { - if (jj_scan_token(NULL)) return true; + static final private boolean jj_3R_176() { + 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_176() { - if (jj_scan_token(FALSE)) return true; + static final private boolean jj_3R_175() { + if (jj_scan_token(TRUE)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -5831,12 +5838,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_175() { - if (jj_scan_token(TRUE)) 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(IDENTIFIER)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5859,33 +5860,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_88() { - if (jj_scan_token(LBRACE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_45()) 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_59() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_88()) { - jj_scanpos = xsp; - if (jj_3R_89()) { - jj_scanpos = xsp; - if (jj_3R_90()) { - jj_scanpos = xsp; - if (jj_3R_91()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else 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_169() { Token xsp; xsp = jj_scanpos; @@ -5915,23 +5889,38 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_116() { - if (jj_scan_token(XOR)) return true; + static final private boolean jj_3R_88() { + if (jj_scan_token(LBRACE)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_115()) return true; + if (jj_3R_45()) 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_113() { + static final private boolean jj_3R_59() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_88()) { + jj_scanpos = xsp; + if (jj_3R_89()) { + jj_scanpos = xsp; + if (jj_3R_90()) { + jj_scanpos = xsp; + if (jj_3R_91()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else 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_116() { + if (jj_scan_token(XOR)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; if (jj_3R_115()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_116()) { jj_scanpos = xsp; break; } - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } return false; } @@ -5958,6 +5947,18 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_113() { + if (jj_3R_115()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_116()) { jj_scanpos = xsp; break; } + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } + return false; + } + static final private boolean jj_3R_98() { if (jj_scan_token(LBRACE)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -6094,19 +6095,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_105() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_111()) { - jj_scanpos = xsp; - if (jj_3R_112()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_104()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_195() { if (jj_3R_199()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -6124,6 +6112,19 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_105() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_111()) { + jj_scanpos = xsp; + if (jj_3R_112()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_104()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_97() { if (jj_scan_token(HOOK)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -6502,6 +6503,14 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_100() { + if (jj_scan_token(COMMA)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_50()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_45() { Token xsp; xsp = jj_scanpos; @@ -6525,22 +6534,14 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_100() { - if (jj_scan_token(COMMA)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_50()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_194() { - if (jj_scan_token(DECR)) return true; + if (jj_scan_token(MINUS_MINUS)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } static final private boolean jj_3R_193() { - if (jj_scan_token(INCR)) return true; + if (jj_scan_token(PLUS_PLUS)) 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 c348a5e..00cc6c9 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.jj +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.jj @@ -456,8 +456,8 @@ MORE : { | -| -| +| +| | | | @@ -1480,8 +1480,8 @@ final int operator; final int pos = SimpleCharStream.getPosition(); } { - ( {operator = OperatorIds.PLUS_PLUS;} - | {operator = OperatorIds.MINUS_MINUS;}) + ( {operator = OperatorIds.PLUS_PLUS;} + | {operator = OperatorIds.MINUS_MINUS;}) expr = PrimaryExpression() {return new PrefixedUnaryExpression(expr,operator,pos);} } @@ -1532,8 +1532,8 @@ Expression PostfixExpression() : } { expr = PrimaryExpression() - [ {operator = OperatorIds.PLUS_PLUS;} - | {operator = OperatorIds.MINUS_MINUS;}] + [ {operator = OperatorIds.PLUS_PLUS;} + | {operator = OperatorIds.MINUS_MINUS;}] { if (operator == -1) { return expr; @@ -1567,6 +1567,11 @@ Expression PrimaryExpression() : {return expr;} } +/** + * An array declarator. + * array(vars) + * @return an array + */ ArrayInitializer ArrayDeclarator() : { final ArrayVariableDeclaration[] vars; @@ -1591,9 +1596,10 @@ Expression PrimaryPrefix() : | expr = ClassIdentifier() {return new PrefixedUnaryExpression(expr, OperatorIds.NEW, pos);} -| var = VariableDeclaratorId() {return new ConstantIdentifier(var.toCharArray(), - pos, - SimpleCharStream.getPosition());} +| var = VariableDeclaratorId() {return new VariableDeclaration(currentSegment, + var.toCharArray(), + pos, + SimpleCharStream.getPosition());} } PrefixedUnaryExpression classInstantiation() : @@ -2182,7 +2188,7 @@ EmptyStatement EmptyStatement() : return new EmptyStatement(pos-1,pos);} } -Statement StatementExpression() : +Expression StatementExpression() : { Expression expr,expr2; int operator; @@ -2191,10 +2197,10 @@ Statement StatementExpression() : expr = PreIncDecExpression() {return expr;} | expr = PrimaryExpression() - [ {return new PostfixedUnaryExpression(expr, + [ {return new PostfixedUnaryExpression(expr, OperatorIds.PLUS_PLUS, SimpleCharStream.getPosition());} - | {return new PostfixedUnaryExpression(expr, + | {return new PostfixedUnaryExpression(expr, OperatorIds.MINUS_MINUS, SimpleCharStream.getPosition());} | operator = AssignmentOperator() expr2 = Expression() @@ -2743,9 +2749,9 @@ ForStatement ForStatement() : { final Token token; final int pos = SimpleCharStream.getPosition(); -Statement[] initializations = null; +Expression[] initializations = null; Expression condition = null; -Statement[] increments = null; +Expression[] increments = null; Statement action; final ArrayList list = new ArrayList(); final int startBlock, endBlock; @@ -2809,31 +2815,31 @@ final int startBlock, endBlock; ) } -Statement[] ForInit() : +Expression[] ForInit() : { - Statement[] statements; + Expression[] exprs; } { LOOKAHEAD(LocalVariableDeclaration()) - statements = LocalVariableDeclaration() - {return statements;} + exprs = LocalVariableDeclaration() + {return exprs;} | - statements = StatementExpressionList() - {return statements;} + exprs = StatementExpressionList() + {return exprs;} } -Statement[] StatementExpressionList() : +Expression[] StatementExpressionList() : { final ArrayList list = new ArrayList(); - Statement expr; + Expression expr; } { expr = StatementExpression() {list.add(expr);} ( StatementExpression() {list.add(expr);})* { - Statement[] stmtsArray = new Statement[list.size()]; - list.toArray(stmtsArray); - return stmtsArray;} + Expression[] exprsArray = new Expression[list.size()]; + list.toArray(exprsArray); + return exprsArray;} } Continue ContinueStatement() : diff --git a/net.sourceforge.phpeclipse/src/test/PHPParserConstants.java b/net.sourceforge.phpeclipse/src/test/PHPParserConstants.java index 088a46a..663594d 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParserConstants.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParserConstants.java @@ -69,8 +69,8 @@ public interface PHPParserConstants { int COLON = 78; int OR_OR = 79; int AND_AND = 80; - int INCR = 81; - int DECR = 82; + int PLUS_PLUS = 81; + int MINUS_MINUS = 82; int PLUS = 83; int MINUS = 84; int STAR = 85; -- 1.7.1