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 2018/02/25 09:44:23 UTC

groovy git commit: Support command expression in parentheses

Repository: groovy
Updated Branches:
  refs/heads/master 0aba754d9 -> ddd15c41d


Support command expression in parentheses


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/ddd15c41
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/ddd15c41
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/ddd15c41

Branch: refs/heads/master
Commit: ddd15c41d93f886a45b625000e7a679c2e295735
Parents: 0aba754
Author: danielsun1106 <re...@hotmail.com>
Authored: Sun Feb 25 17:44:02 2018 +0800
Committer: danielsun1106 <re...@hotmail.com>
Committed: Sun Feb 25 17:44:18 2018 +0800

----------------------------------------------------------------------
 src/antlr/GroovyParser.g4                                    | 4 +++-
 .../java/org/apache/groovy/parser/antlr4/AstBuilder.java     | 8 ++++----
 .../org/apache/groovy/parser/antlr4/GroovyParserTest.groovy  | 2 +-
 3 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/ddd15c41/src/antlr/GroovyParser.g4
----------------------------------------------------------------------
diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4
index 21bf2c2..a19fd0a 100644
--- a/src/antlr/GroovyParser.g4
+++ b/src/antlr/GroovyParser.g4
@@ -748,7 +748,7 @@ parExpression
     ;
 
 expressionInPar
-    :   LPAREN enhancedExpression rparen
+    :   LPAREN enhancedStatementExpression rparen
     ;
 
 expressionList[boolean canSpread]
@@ -876,10 +876,12 @@ expression
                      enhancedStatementExpression                                            #assignmentExprAlt
     ;
 
+/*
 enhancedExpression
     :   expression
     |   standardLambdaExpression
     ;
+*/
 
 commandExpression
     :   pathExpression

http://git-wip-us.apache.org/repos/asf/groovy/blob/ddd15c41/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
index e3c87eb..8f4f382 100644
--- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
@@ -202,7 +202,6 @@ import static org.apache.groovy.parser.antlr4.GroovyLangParser.ElementValuePairs
 import static org.apache.groovy.parser.antlr4.GroovyLangParser.ElementValuesContext;
 import static org.apache.groovy.parser.antlr4.GroovyLangParser.EnhancedArgumentListContext;
 import static org.apache.groovy.parser.antlr4.GroovyLangParser.EnhancedArgumentListElementContext;
-import static org.apache.groovy.parser.antlr4.GroovyLangParser.EnhancedExpressionContext;
 import static org.apache.groovy.parser.antlr4.GroovyLangParser.EnhancedForControlContext;
 import static org.apache.groovy.parser.antlr4.GroovyLangParser.EnhancedStatementExpressionContext;
 import static org.apache.groovy.parser.antlr4.GroovyLangParser.EnumConstantContext;
@@ -2064,6 +2063,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
         return configureAST(new ExpressionStatement((Expression) this.visit(ctx.expression())), ctx);
     }
 
+/*
     @Override
     public Expression visitEnhancedExpression(EnhancedExpressionContext ctx) {
         Expression expression;
@@ -2078,7 +2078,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
 
         return configureAST(expression, ctx);
     }
-
+*/
 
     @Override
     public ExpressionStatement visitCommandExprAlt(CommandExprAltContext ctx) {
@@ -2209,7 +2209,8 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
 
     @Override
     public Expression visitExpressionInPar(ExpressionInParContext ctx) {
-        return this.visitEnhancedExpression(ctx.enhancedExpression());
+        //return this.visitEnhancedExpression(ctx.enhancedExpression());
+        return this.visitEnhancedStatementExpression(ctx.enhancedStatementExpression());
     }
 
     @Override
@@ -3379,7 +3380,6 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
         return configureAST(new VariableExpression(text), ctx);
     }
 
-
     @Override
     public ListExpression visitList(ListContext ctx) {
         if (asBoolean(ctx.COMMA()) && !asBoolean(ctx.expressionList())) {

http://git-wip-us.apache.org/repos/asf/groovy/blob/ddd15c41/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
index a0b1b3d..c909e82 100644
--- a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
+++ b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
@@ -335,7 +335,7 @@ class GroovyParserTest extends GroovyTestCase {
         doTest('core/Command_03.groovy', [ExpressionStatement, Parameter])
         doTest('core/Command_04.groovy', [ExpressionStatement])
         doTest('core/Command_05.groovy')
-//        doRunAndTest('core/Command_06x.groovy')
+        doRunAndTest('core/Command_06x.groovy')
     }
 
     /*