From: kpouer Date: Fri, 11 Apr 2003 15:03:01 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://secure.phpeclipse.com *** empty log message *** --- diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Class.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Class.java index cad94c9..2d58b82 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Class.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Class.java @@ -16,12 +16,12 @@ public class Class extends AstNode { public VariableDeclaration[] fields; public int declarationSourceStart; - public int declarationSourceEnd; - public int bodyStart; - public int bodyEnd; - + public int declarationSourceEnd; + public int bodyStart; + public int bodyEnd; + /** The methods of the class. */ public MethodDeclaration[] methods; - + /** The constructor of the class. */ public MethodDeclaration constructor; /** @@ -32,40 +32,53 @@ public class Class extends AstNode { return constructor != null; } - public String toString(int tab) { - - return tabString(tab) + toStringHeader() + toStringBody(tab); - } + /** + * Return the class as String. + * @param tab how many tabs before the class + * @return the code of this class into String + */ + public String toString(int tab) { + return tabString(tab) + toStringHeader() + toStringBody(tab); + } - public String toStringBody(int tab) { + /** + * Return the body of the class as String + * @param tab how many tabs before the body of the class + * @return the body as String + */ + public String toStringBody(int tab) { final StringBuffer buff = new StringBuffer(" {");//$NON-NLS-1$ - if (fields != null) { - for (int fieldI = 0; fieldI < fields.length; fieldI++) { - if (fields[fieldI] != null) { - buff.append("\n"); //$NON-NLS-1$ + if (fields != null) { + for (int fieldI = 0; fieldI < fields.length; fieldI++) { + if (fields[fieldI] != null) { + buff.append("\n"); //$NON-NLS-1$ buff.append(fields[fieldI].toString(tab + 1)); buff.append(";");//$NON-NLS-1$ - } - } - } - if (methods != null) { - for (int i = 0; i < methods.length; i++) { - if (methods[i] != null) { - buff.append("\n");//$NON-NLS-1$ + } + } + } + if (methods != null) { + for (int i = 0; i < methods.length; i++) { + if (methods[i] != null) { + buff.append("\n");//$NON-NLS-1$ buff.append(methods[i].toString(tab + 1)); - } - } - } - buff.append("\n").append(tabString(tab)).append("}"); //$NON-NLS-2$ //$NON-NLS-1$ - return buff.toString(); - } + } + } + } + buff.append("\n").append(tabString(tab)).append("}"); //$NON-NLS-2$ //$NON-NLS-1$ + return buff.toString(); + } - public String toStringHeader() { - final StringBuffer buff = new StringBuffer("class").append(name); - if (superclass != null) { - buff.append(" extends "); //$NON-NLS-1$ + /** + * Return the header of the class as String. + * @return the header of the class + */ + public String toStringHeader() { + final StringBuffer buff = new StringBuffer("class").append(name);//$NON-NLS-1$ + if (superclass != null) { + buff.append(" extends "); //$NON-NLS-1$ buff.append(superclass); } - return buff.toString(); - } + return buff.toString(); + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPSegment.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPSegment.java index 628d254..98efdfa 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPSegment.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPSegment.java @@ -18,6 +18,14 @@ public abstract class PHPSegment { this.position = new Position(index, name.length()); } + /** + * Return the name of the segment. + * @return the name of the segment + */ + public String getName() { + return name; + } + public String toString() { return name; } diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java index 9e7acc4..bc7c112 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -35,7 +35,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon private static final String PARSE_ERROR_STRING = "Parse error"; //$NON-NLS-1$ private static final String PARSE_WARNING_STRING = "Warning"; //$NON-NLS-1$ - PHPOutlineInfo outlineInfo; + static PHPOutlineInfo outlineInfo; private static PHPFunctionDeclaration currentFunction; private static boolean assigning; @@ -48,9 +48,9 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon private static int errorStart = -1; private static int errorEnd = -1; - //ast stack - private final static int AstStackIncrement = 100; - /** The stack of node. */ + //ast stack + private final static int AstStackIncrement = 100; + /** The stack of node. */ private static AstNode[] astStack; /** The cursor in expression stack. */ private static int expressionPtr; @@ -617,6 +617,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon PHPVarDeclaration variableDeclaration; jj_consume_token(VAR); variableDeclaration = VariableDeclarator(); + outlineInfo.addVariable(variableDeclaration.getVariable().getName()); if (currentSegment != null) { currentSegment.add(variableDeclaration); } @@ -678,7 +679,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon final StringBuffer buff = new StringBuffer(); try { expr = Variable(); - buff.append(expr); + buff.append(expr); label_5: while (true) { if (jj_2_1(2)) { @@ -687,7 +688,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon break label_5; } expr = VariableSuffix(); - buff.append(expr); + buff.append(expr); } {if (true) return buff.toString();} } catch (ParseException e) { @@ -951,6 +952,7 @@ final StringBuffer buff = new StringBuffer("("); functionToken = jj_consume_token(FUNCTION); try { functionDeclaration = MethodDeclarator(); + outlineInfo.addVariable(functionDeclaration.getName()); } catch (ParseException e) { if (errorMessage != null) { {if (true) throw e;} @@ -1098,39 +1100,39 @@ final StringBuffer buff = new StringBuffer("("); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case STRING: jj_consume_token(STRING); - {if (true) return "string";} + {if (true) return "string";} break; case BOOL: jj_consume_token(BOOL); - {if (true) return "bool";} + {if (true) return "bool";} break; case BOOLEAN: jj_consume_token(BOOLEAN); - {if (true) return "boolean";} + {if (true) return "boolean";} break; case REAL: jj_consume_token(REAL); - {if (true) return "real";} + {if (true) return "real";} break; case DOUBLE: jj_consume_token(DOUBLE); - {if (true) return "double";} + {if (true) return "double";} break; case FLOAT: jj_consume_token(FLOAT); - {if (true) return "float";} + {if (true) return "float";} break; case INT: jj_consume_token(INT); - {if (true) return "int";} + {if (true) return "int";} break; case INTEGER: jj_consume_token(INTEGER); - {if (true) return "integer";} + {if (true) return "integer";} break; case OBJECT: jj_consume_token(OBJECT); - {if (true) return "object";} + {if (true) return "object";} break; default: jj_la1[25] = jj_gen; @@ -1147,17 +1149,17 @@ final StringBuffer buff = new StringBuffer("("); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PRINT: expr = PrintExpression(); - {if (true) return expr;} + {if (true) return expr;} break; case LIST: expr = ListExpression(); - {if (true) return expr;} + {if (true) return expr;} break; default: jj_la1[26] = jj_gen; if (jj_2_3(2147483647)) { expr = varAssignation(); - {if (true) return expr;} + {if (true) return expr;} } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ARRAY: @@ -1180,7 +1182,7 @@ final StringBuffer buff = new StringBuffer("("); case BIT_AND: case DOLLAR_ID: expr = ConditionalExpression(); - {if (true) return expr;} + {if (true) return expr;} break; default: jj_la1[27] = jj_gen; @@ -1222,55 +1224,55 @@ final StringBuffer buff = new StringBuffer("("); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ASSIGN: jj_consume_token(ASSIGN); - {if (true) return "=";} + {if (true) return "=";} break; case STARASSIGN: jj_consume_token(STARASSIGN); - {if (true) return "*=";} + {if (true) return "*=";} break; case SLASHASSIGN: jj_consume_token(SLASHASSIGN); - {if (true) return "/=";} + {if (true) return "/=";} break; case REMASSIGN: jj_consume_token(REMASSIGN); - {if (true) return "%=";} + {if (true) return "%=";} break; case PLUSASSIGN: jj_consume_token(PLUSASSIGN); - {if (true) return "+=";} + {if (true) return "+=";} break; case MINUSASSIGN: jj_consume_token(MINUSASSIGN); - {if (true) return "-=";} + {if (true) return "-=";} break; case LSHIFTASSIGN: jj_consume_token(LSHIFTASSIGN); - {if (true) return "<<=";} + {if (true) return "<<=";} break; case RSIGNEDSHIFTASSIGN: jj_consume_token(RSIGNEDSHIFTASSIGN); - {if (true) return ">>=";} + {if (true) return ">>=";} break; case ANDASSIGN: jj_consume_token(ANDASSIGN); - {if (true) return "&=";} + {if (true) return "&=";} break; case XORASSIGN: jj_consume_token(XORASSIGN); - {if (true) return "|=";} + {if (true) return "|=";} break; case ORASSIGN: jj_consume_token(ORASSIGN); - {if (true) return "|=";} + {if (true) return "|=";} break; case DOTASSIGN: jj_consume_token(DOTASSIGN); - {if (true) return ".=";} + {if (true) return ".=";} break; case TILDEEQUAL: jj_consume_token(TILDEEQUAL); - {if (true) return "~=";} + {if (true) return "~=";} break; default: jj_la1[28] = jj_gen; @@ -1833,13 +1835,13 @@ final Token token; case BANG: jj_consume_token(BANG); expr = UnaryExpression(); - {if (true) return "!" + expr;} + {if (true) return "!" + expr;} break; default: jj_la1[53] = jj_gen; if (jj_2_4(2147483647)) { expr = CastExpression(); - {if (true) return expr;} + {if (true) return expr;} } else { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ARRAY: @@ -1848,7 +1850,7 @@ final Token token; case DOLLAR: case DOLLAR_ID: expr = PostfixExpression(); - {if (true) return expr;} + {if (true) return expr;} break; case NULL: case TRUE: @@ -1857,7 +1859,7 @@ final Token token; case FLOATING_POINT_LITERAL: case STRING_LITERAL: expr = Literal(); - {if (true) return expr;} + {if (true) return expr;} break; case LPAREN: jj_consume_token(LPAREN); @@ -1867,8 +1869,8 @@ final Token token; } catch (ParseException e) { errorMessage = "')' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = jj_input_stream.getPosition() + 1; {if (true) throw e;} } {if (true) return "("+expr+")";} @@ -2021,17 +2023,17 @@ final String type, expr; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER: token = jj_consume_token(IDENTIFIER); - {if (true) return token.image;} + {if (true) return token.image;} break; case NEW: jj_consume_token(NEW); expr = ClassIdentifier(); - {if (true) return "new " + expr;} + {if (true) return "new " + expr;} break; case DOLLAR: case DOLLAR_ID: expr = VariableDeclaratorId(); - {if (true) return expr;} + {if (true) return expr;} break; default: jj_la1[61] = jj_gen; @@ -2070,12 +2072,12 @@ final String type, expr; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case IDENTIFIER: token = jj_consume_token(IDENTIFIER); - {if (true) return token.image;} + {if (true) return token.image;} break; case DOLLAR: case DOLLAR_ID: expr = VariableDeclaratorId(); - {if (true) return expr;} + {if (true) return expr;} break; default: jj_la1[63] = jj_gen; @@ -2090,12 +2092,12 @@ final String type, expr; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case LPAREN: expr = Arguments(); - {if (true) return expr;} + {if (true) return expr;} break; case CLASSACCESS: case LBRACKET: expr = VariableSuffix(); - {if (true) return expr;} + {if (true) return expr;} break; default: jj_la1[64] = jj_gen; @@ -2227,24 +2229,24 @@ final String type, expr; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case INTEGER_LITERAL: token = jj_consume_token(INTEGER_LITERAL); - {if (true) return token.image;} + {if (true) return token.image;} break; case FLOATING_POINT_LITERAL: token = jj_consume_token(FLOATING_POINT_LITERAL); - {if (true) return token.image;} + {if (true) return token.image;} break; case STRING_LITERAL: token = jj_consume_token(STRING_LITERAL); - {if (true) return token.image;} + {if (true) return token.image;} break; case TRUE: case FALSE: expr = BooleanLiteral(); - {if (true) return expr;} + {if (true) return expr;} break; case NULL: jj_consume_token(NULL); - {if (true) return "null";} + {if (true) return "null";} break; default: jj_la1[68] = jj_gen; @@ -2258,11 +2260,11 @@ final String type, expr; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case TRUE: jj_consume_token(TRUE); - {if (true) return "true";} + {if (true) return "true";} break; case FALSE: jj_consume_token(FALSE); - {if (true) return "false";} + {if (true) return "false";} break; default: jj_la1[69] = jj_gen; @@ -2338,20 +2340,20 @@ final StringBuffer buff = new StringBuffer(); try { expr = Expression(); } catch (ParseException e) { - errorMessage = "expression expected after a comma in argument list"; + errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. An expression expected after a comma in argument list"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = jj_input_stream.getPosition() + 1; {if (true) throw e;} } - buff.append(",").append(expr); + buff.append(",").append(expr); } {if (true) return buff.toString();} throw new Error("Missing return statement in function"); } /** - * A Statement without break + * A Statement without break. */ static final public void StatementNoBreak() throws ParseException { if (jj_2_6(2)) { @@ -2390,8 +2392,8 @@ final StringBuffer buff = new StringBuffer(); } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = jj_input_stream.getPosition() + 1; {if (true) throw e;} } break; @@ -2452,7 +2454,7 @@ final StringBuffer buff = new StringBuffer(); } /** - * A Normal statement + * A Normal statement. */ static final public void Statement() throws ParseException { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -2506,6 +2508,9 @@ final StringBuffer buff = new StringBuffer(); } } +/** + * An html block inside a php syntax. + */ static final public void htmlBlock() throws ParseException { jj_consume_token(PHPEND); label_23: @@ -2520,17 +2525,25 @@ final StringBuffer buff = new StringBuffer(); } phpEchoBlock(); } - switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { - case PHPSTARTLONG: - jj_consume_token(PHPSTARTLONG); - break; - case PHPSTARTSHORT: - jj_consume_token(PHPSTARTSHORT); - break; - default: - jj_la1[76] = jj_gen; - jj_consume_token(-1); - throw new ParseException(); + try { + switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { + case PHPSTARTLONG: + jj_consume_token(PHPSTARTLONG); + break; + case PHPSTARTSHORT: + jj_consume_token(PHPSTARTSHORT); + break; + default: + jj_la1[76] = jj_gen; + jj_consume_token(-1); + throw new ParseException(); + } + } catch (ParseException e) { + errorMessage = "End of file unexpected, ' @@ -743,8 +741,7 @@ void ClassBodyDeclaration() : {} { MethodDeclaration() -| - FieldDeclaration() +| FieldDeclaration() } /** @@ -757,6 +754,7 @@ void FieldDeclaration() : { variableDeclaration = VariableDeclarator() { + outlineInfo.addVariable(variableDeclaration.getVariable().getName()); if (currentSegment != null) { currentSegment.add(variableDeclaration); } @@ -810,10 +808,9 @@ String VariableDeclaratorId() : } { try { - expr = Variable() - {buff.append(expr);} - ( LOOKAHEAD(2) expr = VariableSuffix() - {buff.append(expr);} + expr = Variable() {buff.append(expr);} + ( LOOKAHEAD(2) + expr = VariableSuffix() {buff.append(expr);} )* {return buff.toString();} } catch (ParseException e) { @@ -971,6 +968,7 @@ void MethodDeclaration() : functionToken = try { functionDeclaration = MethodDeclarator() + {outlineInfo.addVariable(functionDeclaration.getName());} } catch (ParseException e) { if (errorMessage != null) { throw e; @@ -1097,32 +1095,15 @@ PHPVarDeclaration FormalParameter() : String Type() : {} { - - {return "string";} -| - - {return "bool";} -| - - {return "boolean";} -| - - {return "real";} -| - - {return "double";} -| - - {return "float";} -| - - {return "int";} -| - - {return "integer";} -| - - {return "object";} + {return "string";} +| {return "bool";} +| {return "boolean";} +| {return "real";} +| {return "double";} +| {return "float";} +| {return "int";} +| {return "integer";} +| {return "object";} } String Expression() : @@ -1132,18 +1113,11 @@ String Expression() : final String expr2; } { - expr = PrintExpression() - {return expr;} -| - expr = ListExpression() - {return expr;} -| - LOOKAHEAD(varAssignation()) - expr = varAssignation() - {return expr;} -| - expr = ConditionalExpression() - {return expr;} + expr = PrintExpression() {return expr;} +| expr = ListExpression() {return expr;} +| LOOKAHEAD(varAssignation()) + expr = varAssignation() {return expr;} +| expr = ConditionalExpression() {return expr;} } /** @@ -1177,32 +1151,19 @@ String varAssignation() : String AssignmentOperator() : {} { - -{return "=";} -| -{return "*=";} -| -{return "/=";} -| -{return "%=";} -| -{return "+=";} -| -{return "-=";} -| -{return "<<=";} -| -{return ">>=";} -| -{return "&=";} -| -{return "|=";} -| -{return "|=";} -| -{return ".=";} -| -{return "~=";} + {return "=";} +| {return "*=";} +| {return "/=";} +| {return "%=";} +| {return "+=";} +| {return "-=";} +| {return "<<=";} +| {return ">>=";} +| {return "&=";} +| {return "|=";} +| {return "|=";} +| {return ".=";} +| {return "~=";} } String ConditionalExpression() : @@ -1463,8 +1424,8 @@ String UnaryExpression() : } return token.image + expr; } -| - ( {buff.append("@");})* expr = UnaryExpressionNoPrefix() +| ( {buff.append("@");})* + expr = UnaryExpressionNoPrefix() {return buff.append(expr).toString();} } @@ -1502,27 +1463,19 @@ String UnaryExpressionNotPlusMinus() : final String expr; } { - expr = UnaryExpression() - {return "!" + expr;} -| - LOOKAHEAD( (Type() | ) ) - expr = CastExpression() - {return expr;} -| - expr = PostfixExpression() - {return expr;} -| - expr = Literal() - {return expr;} -| - expr = Expression() + expr = UnaryExpression() {return "!" + expr;} +| LOOKAHEAD( (Type() | ) ) + expr = CastExpression() {return expr;} +| expr = PostfixExpression() {return expr;} +| expr = Literal() {return expr;} +| expr = Expression() try { } catch (ParseException e) { errorMessage = "')' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = jj_input_stream.getPosition() + 1; throw e; } {return "("+expr+")";} @@ -1591,16 +1544,9 @@ String PrimaryPrefix() : final Token token; } { - token = - {return token.image;} -| - expr = ClassIdentifier() - { - return "new " + expr; - } -| - expr = VariableDeclaratorId() - {return expr;} + token = {return token.image;} +| expr = ClassIdentifier() {return "new " + expr;} +| expr = VariableDeclaratorId() {return expr;} } String classInstantiation() : @@ -1624,11 +1570,8 @@ String ClassIdentifier(): final Token token; } { - token = - {return token.image;} -| - expr = VariableDeclaratorId() - {return expr;} + token = {return token.image;} +| expr = VariableDeclaratorId() {return expr;} } String PrimarySuffix() : @@ -1636,11 +1579,8 @@ String PrimarySuffix() : final String expr; } { - expr = Arguments() - {return expr;} -| - expr = VariableSuffix() - {return expr;} + expr = Arguments() {return expr;} +| expr = VariableSuffix() {return expr;} } String VariableSuffix() : @@ -1684,30 +1624,18 @@ String Literal() : final Token token; } { - token = - {return token.image;} -| - token = - {return token.image;} -| - token = - {return token.image;} -| - expr = BooleanLiteral() - {return expr;} -| - - {return "null";} + token = {return token.image;} +| token = {return token.image;} +| token = {return token.image;} +| expr = BooleanLiteral() {return expr;} +| {return "null";} } String BooleanLiteral() : {} { - - {return "true";} -| - - {return "false";} + {return "true";} +| {return "false";} } String Arguments() : @@ -1745,21 +1673,19 @@ final StringBuffer buff = new StringBuffer(); try { expr = Expression() } catch (ParseException e) { - errorMessage = "expression expected after a comma in argument list"; + errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. An expression expected after a comma in argument list"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = jj_input_stream.getPosition() + 1; throw e; } - { - buff.append(",").append(expr); - } + {buff.append(",").append(expr);} )* {return buff.toString();} } /** - * A Statement without break + * A Statement without break. */ void StatementNoBreak() : {} @@ -1777,65 +1703,60 @@ void StatementNoBreak() : throw e; } } -| - LOOKAHEAD(2) +| LOOKAHEAD(2) LabeledStatement() -| - Block() -| - EmptyStatement() -| - StatementExpression() +| Block() +| EmptyStatement() +| StatementExpression() try { } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = jj_input_stream.getPosition() + 1; throw e; } -| - SwitchStatement() -| - IfStatement() -| - WhileStatement() -| - DoStatement() -| - ForStatement() -| - ForeachStatement() -| - ContinueStatement() -| - ReturnStatement() -| - EchoStatement() -| - [] IncludeStatement() -| - StaticStatement() -| - GlobalStatement() +| SwitchStatement() +| IfStatement() +| WhileStatement() +| DoStatement() +| ForStatement() +| ForeachStatement() +| ContinueStatement() +| ReturnStatement() +| EchoStatement() +| [] IncludeStatement() +| StaticStatement() +| GlobalStatement() } /** - * A Normal statement + * A Normal statement. */ void Statement() : {} { StatementNoBreak() -| - BreakStatement() +| BreakStatement() } +/** + * An html block inside a php syntax. + */ void htmlBlock() : {} { - (phpEchoBlock())* ( | ) + (phpEchoBlock())* + try { + ( | ) + } catch (ParseException e) { + errorMessage = "End of file unexpected, ' | token = | token = ) - expr = Expression() + try { + expr = Expression() + } catch (ParseException e) { + if (errorMessage != null) { + throw e; + } + errorMessage = "unexpected token '"+ e.currentToken.next.image+"', expression expected"; + errorLevel = ERROR; + errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = jj_input_stream.getPosition() + 1; + throw e; + } { if (currentSegment != null) { currentSegment.add(new PHPReqIncDeclaration(currentSegment, token.image,pos,expr)); @@ -1863,23 +1795,18 @@ void IncludeStatement() : } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = jj_input_stream.getPosition() + 1; throw e; } } String PrintExpression() : { - final StringBuffer buff = new StringBuffer("print "); final String expr; } { - expr = Expression() - { - buff.append(expr); - return buff.toString(); - } + expr = Expression() {return "print " + expr;} } String ListExpression() : @@ -1894,8 +1821,8 @@ String ListExpression() : } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = jj_input_stream.getPosition() + 1; throw e; } [ @@ -1908,8 +1835,8 @@ String ListExpression() : } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ',' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = jj_input_stream.getPosition() + 1; throw e; } expr = VariableDeclaratorId() @@ -1930,7 +1857,8 @@ String ListExpression() : } /** - * An echo statement is like this : echo anyexpression (, otherexpression)* + * An echo statement. + * echo anyexpression (, otherexpression)* */ void EchoStatement() : {} @@ -1942,8 +1870,8 @@ void EchoStatement() : if (e.currentToken.next.kind != 4) { errorMessage = "';' expected after 'echo' statement"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = jj_input_stream.getPosition() + 1; throw e; } } @@ -1969,7 +1897,7 @@ void GlobalStatement() : try { } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; + errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. a ';' was expected"; errorLevel = ERROR; errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; errorEnd = jj_input_stream.getPosition() + 1; @@ -1984,7 +1912,7 @@ void StaticStatement() : try { } catch (ParseException e) { - errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; + errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. a ';' was expected"; errorLevel = ERROR; errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; errorEnd = jj_input_stream.getPosition() + 1; @@ -2026,10 +1954,8 @@ void BlockStatement() : {} { Statement() -| - ClassDeclaration() -| - MethodDeclaration() +| ClassDeclaration() +| MethodDeclaration() } /** @@ -2039,10 +1965,8 @@ void BlockStatementNoBreak() : {} { StatementNoBreak() -| - ClassDeclaration() -| - MethodDeclaration() +| ClassDeclaration() +| MethodDeclaration() } void LocalVariableDeclaration() : @@ -2069,13 +1993,9 @@ void StatementExpression() : PreIncDecExpression() | PrimaryExpression() - [ - - | - - | - AssignmentOperator() Expression() - ] + [ + | + | AssignmentOperator() Expression() ] } void SwitchStatement() : diff --git a/net.sourceforge.phpeclipse/src/test/PHPParserTokenManager.java b/net.sourceforge.phpeclipse/src/test/PHPParserTokenManager.java index beb1960..bffc8ef 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParserTokenManager.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParserTokenManager.java @@ -1444,7 +1444,8 @@ static private final int jjMoveNfa_1(int startState, int curPos) jjCheckNAddStates(13, 20); break; case 38: - jjCheckNAddStates(33, 36); + if ((0xfffffffbffffffffL & l) != 0L) + jjCheckNAddStates(33, 36); break; case 39: if (curChar == 34) @@ -1459,7 +1460,8 @@ static private final int jjMoveNfa_1(int startState, int curPos) kind = 80; break; case 45: - jjCheckNAddStates(37, 40); + if ((0xfffffffbffffffffL & l) != 0L) + jjCheckNAddStates(37, 40); break; case 46: if (curChar == 34) @@ -1584,7 +1586,8 @@ static private final int jjMoveNfa_1(int startState, int curPos) jjCheckNAddTwoStates(35, 6); break; case 38: - jjCheckNAddStates(33, 36); + if ((0xd7ffffffffffffffL & l) != 0L) + jjCheckNAddStates(33, 36); break; case 40: if (curChar == 92) @@ -1602,7 +1605,8 @@ static private final int jjMoveNfa_1(int startState, int curPos) jjCheckNAddStates(33, 36); break; case 45: - jjCheckNAddStates(37, 40); + if ((0xd7ffffffffffffffL & l) != 0L) + jjCheckNAddStates(37, 40); break; case 47: if (curChar == 92)