groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [groovy] 01/02: GROOVY-9038: rework antlr2 java grammar to partially understand try-with-resources (just enough to keep groovydoc processing of java files happy)
Date Sat, 16 Mar 2019 03:34:11 GMT
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 09b35885aa9f39f384f315d6493555775ec2d294
Author: Paul King <paulk@asert.com.au>
AuthorDate: Sat Mar 16 13:32:41 2019 +1000

    GROOVY-9038: rework antlr2 java grammar to partially understand try-with-resources (just
enough to keep groovydoc processing of java files happy)
---
 src/main/antlr2/org/codehaus/groovy/antlr/java/java.g | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/main/antlr2/org/codehaus/groovy/antlr/java/java.g b/src/main/antlr2/org/codehaus/groovy/antlr/java/java.g
index 2386ff3..4bb2128 100644
--- a/src/main/antlr2/org/codehaus/groovy/antlr/java/java.g
+++ b/src/main/antlr2/org/codehaus/groovy/antlr/java/java.g
@@ -1210,12 +1210,27 @@ forIter  {Token first = LT(1);}
 	;
 
 // an exception handler try/catch block
+// TODO currently handles try-with-resources only enough for groovydoc, not java2groovy
+// plan is to switch java2groovy over to using parrot parser (or some other alternative)
 tryBlock
-	:	"try"^ compoundStatement
+	:	"try"^ ((LPAREN) => resources)? compoundStatement
 		(handler)*
 		( finallyClause )?
 	;
 
+resources
+    :   LPAREN! resourceList (SEMI!)? RPAREN!
+    ;
+
+resourceList
+    :   resource (SEMI! resource)*
+    ;
+
+resource
+    : (declaration) => declaration
+	| expression
+    ;
+
 finallyClause
 	:	"finally"^ compoundStatement
 	;


Mime
View raw message