diff --git a/tool/test/org/antlr/v4/test/Java-LR.g4 b/tool/test/org/antlr/v4/test/Java-LR.g4 index 5d97bd432..a29027a49 100644 --- a/tool/test/org/antlr/v4/test/Java-LR.g4 +++ b/tool/test/org/antlr/v4/test/Java-LR.g4 @@ -628,11 +628,8 @@ statement | 'for' '(' forControl ')' statement | 'while' parExpression statement | 'do' statement 'while' parExpression ';' - | 'try' block - ( catches 'finally' block - | catches - | 'finally' block - ) + | 'try' block (catches finallyBlock? | finallyBlock) + | 'try' resourceSpecification block catches? finallyBlock? | 'switch' parExpression '{' switchBlockStatementGroups '}' | 'synchronized' parExpression block | 'return' expression? ';' @@ -643,15 +640,35 @@ statement | statementExpression ';' | Identifier ':' statement ; - + catches - : catchClause (catchClause)* + : catchClause+ ; - + catchClause - : 'catch' '(' formalParameter ')' block + : 'catch' '(' variableModifiers catchType Identifier ')' block ; +catchType + : qualifiedName ('|' qualifiedName)* + ; + +finallyBlock + : 'finally' block + ; + +resourceSpecification + : '(' resources ';'? ')' + ; + +resources + : resource (';' resource)* + ; + +resource + : variableModifiers classOrInterfaceType variableDeclaratorId '=' expression + ; + formalParameter : variableModifiers type variableDeclaratorId ; diff --git a/tool/test/org/antlr/v4/test/Java.g4 b/tool/test/org/antlr/v4/test/Java.g4 index ccf221cb1..22d326953 100644 --- a/tool/test/org/antlr/v4/test/Java.g4 +++ b/tool/test/org/antlr/v4/test/Java.g4 @@ -625,11 +625,8 @@ statement | 'for' '(' forControl ')' statement | 'while' parExpression statement | 'do' statement 'while' parExpression ';' - | 'try' block - ( catches 'finally' block - | catches - | 'finally' block - ) + | 'try' block (catches finallyBlock? | finallyBlock) + | 'try' resourceSpecification block catches? finallyBlock? | 'switch' parExpression '{' switchBlockStatementGroups '}' | 'synchronized' parExpression block | 'return' expression? ';' @@ -640,15 +637,35 @@ statement | statementExpression ';' | Identifier ':' statement ; - + catches - : catchClause (catchClause)* + : catchClause+ ; catchClause - : 'catch' '(' formalParameter ')' block + : 'catch' '(' variableModifiers catchType Identifier ')' block ; +catchType + : qualifiedName ('|' qualifiedName)* + ; + +finallyBlock + : 'finally' block + ; + +resourceSpecification + : '(' resources ';'? ')' + ; + +resources + : resource (';' resource)* + ; + +resource + : variableModifiers classOrInterfaceType variableDeclaratorId '=' expression + ; + formalParameter : variableModifiers type variableDeclaratorId ;