From: kpouer Date: Mon, 24 Mar 2003 17:29:03 +0000 (+0000) Subject: a lot of new exception handled X-Git-Url: http://git.phpeclipse.com a lot of new exception handled --- diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java index 8cb0143..773f40e 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -363,16 +363,16 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon break; case PHPSTARTSHORT: jj_consume_token(PHPSTARTSHORT); - try { - setMarker(fileToParse, - "You should use ' Expression() [ ] | [ - | - {try { - setMarker(fileToParse, - "You should use ' + {try { + setMarker(fileToParse, + "You should use ' } catch (ParseException e) { @@ -687,7 +688,7 @@ void FieldDeclaration() : PHPVarDeclaration VariableDeclarator() : { final String varName; - String varValue = null; + String varValue; final int pos = jj_input_stream.bufpos; } { @@ -1305,7 +1306,14 @@ String UnaryExpressionNotPlusMinus() : expr = Literal() {return expr;} | - expr = Expression() + expr = Expression() + try { + + } catch (ParseException e) { + errorMessage = "')' expected"; + errorLevel = ERROR; + throw e; + } {return "("+expr+")";} } @@ -1520,7 +1528,7 @@ final StringBuffer buff = new StringBuffer(); * Statement syntax follows. */ -void Statement() : +void StatementNoBreak() : {} { LOOKAHEAD(2) @@ -1561,8 +1569,6 @@ void Statement() : | ForeachStatement() | - BreakStatement() -| ContinueStatement() | ReturnStatement() @@ -1576,6 +1582,14 @@ void Statement() : GlobalStatement() } +void Statement() : +{} +{ + StatementNoBreak() +| + BreakStatement() +} + void IncludeStatement() : { final String expr; @@ -1673,11 +1687,10 @@ String ListExpression() : expr = VariableDeclaratorId() {buff.append(expr);} ] + {buff.append(")");} - { - buff.append(")"); - return buff.toString(); - } + [ expr = Expression() {buff.append("(").append(expr);}] + {return buff.toString();} } void EchoStatement() : @@ -1736,7 +1749,13 @@ void Block() : throw e; } ( BlockStatement() )* - + try { + + } catch (ParseException e) { + errorMessage = "unexpected token : "+ e.currentToken.image +", '}' expected"; + errorLevel = ERROR; + throw e; + } } void BlockStatement() : @@ -1749,6 +1768,16 @@ void BlockStatement() : MethodDeclaration() } +void BlockStatementNoBreak() : +{} +{ + StatementNoBreak() +| + ClassDeclaration() +| + MethodDeclaration() +} + void LocalVariableDeclaration() : {} { @@ -1815,8 +1844,16 @@ void SwitchStatement() : } ( line = SwitchLabel() - ( BlockStatement() )* - [ breakToken = ] + ( BlockStatementNoBreak() )* + [ breakToken = + try { + + } catch (ParseException e) { + errorMessage = "';' expected after 'break' keyword"; + errorLevel = ERROR; + throw e; + } + ] { try { if (breakToken == null) { @@ -1904,8 +1941,7 @@ void Condition(final String keyword) : } void IfStatement0(final int start,final int end) : -{ -} +{} { (Statement())* (ElseIfStatementColon())* [ElseStatementColon()] @@ -1929,7 +1965,7 @@ void IfStatement0(final int start,final int end) : try { } catch (ParseException e) { - errorMessage = "';' expected 'endif' keyword"; + errorMessage = "';' expected after 'endif' keyword"; errorLevel = ERROR; throw e; } @@ -2074,7 +2110,7 @@ final int pos = jj_input_stream.bufpos; errorLevel = ERROR; throw e; } - [ ForInit() ] [ Expression() ] [ ForUpdate() ] + [ ForInit() ] [ Expression() ] [ StatementExpressionList() ] ( Statement() | @@ -2101,7 +2137,7 @@ final int pos = jj_input_stream.bufpos; try { } catch (ParseException e) { - errorMessage = "';' expected 'endfor' keyword"; + errorMessage = "';' expected after 'endfor' keyword"; errorLevel = ERROR; throw e; } @@ -2123,26 +2159,41 @@ void StatementExpressionList() : StatementExpression() ( StatementExpression() )* } -void ForUpdate() : -{} -{ - StatementExpressionList() -} - void BreakStatement() : {} { - [ ] + [ ] + try { + + } catch (ParseException e) { + errorMessage = "';' expected after 'break' statement"; + errorLevel = ERROR; + throw e; + } } void ContinueStatement() : {} { - [ ] + [ ] + try { + + } catch (ParseException e) { + errorMessage = "';' expected after 'continue' statement"; + errorLevel = ERROR; + throw e; + } } void ReturnStatement() : {} { - [ Expression() ] + [ Expression() ] + try { + + } catch (ParseException e) { + errorMessage = "';' expected after 'return' statement"; + errorLevel = ERROR; + throw e; + } } \ No newline at end of file