You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2019/11/04 18:46:43 UTC

[groovy] 01/01: GROOVY-9301: Parser error for enum constant with comma followed by method

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY-9301
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 7787e6b2e4bcd485f38bae10bd83bd839b6c3350
Author: Daniel Sun <su...@apache.org>
AuthorDate: Tue Nov 5 02:46:32 2019 +0800

    GROOVY-9301: Parser error for enum constant with comma followed by method
    
    The fix is for the Parrot parser
---
 src/antlr/GroovyParser.g4                                        | 2 +-
 .../src/test/resources/core/EnumDeclaration_02.groovy            | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4
index ba238c5..03e6b66 100644
--- a/src/antlr/GroovyParser.g4
+++ b/src/antlr/GroovyParser.g4
@@ -259,7 +259,7 @@ classBody[int t]
     ;
 
 enumConstants
-    :   enumConstant (nls COMMA nls enumConstant)* (nls COMMA)?
+    :   enumConstant (nls COMMA nls enumConstant)*? (nls COMMA)?
     ;
 
 enumConstant
diff --git a/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_02.groovy b/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_02.groovy
index b4d8d13..633da0e 100644
--- a/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_02.groovy
+++ b/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_02.groovy
@@ -93,3 +93,12 @@ class TestClass {
         }
     }
 }
+
+enum Orientation {
+    LANDSCAPE, PORTRAIT,
+
+    @Override
+    String toString() {
+        name().toLowerCase().capitalize()
+    }
+}