groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject groovy git commit: Minor refactoring
Date Sat, 27 May 2017 15:16:48 GMT
Repository: groovy
Updated Branches:
  refs/heads/master 86be867e7 -> 5462d5ff4


Minor refactoring


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

Branch: refs/heads/master
Commit: 5462d5ff4677655b41796faa85a2b83b397092ff
Parents: 86be867
Author: sunlan <sunlan@apache.org>
Authored: Sat May 27 23:16:11 2017 +0800
Committer: sunlan <sunlan@apache.org>
Committed: Sat May 27 23:16:35 2017 +0800

----------------------------------------------------------------------
 .../apache/groovy/parser/antlr4/GroovyParser.g4 | 21 ++++++++++----------
 .../apache/groovy/parser/antlr4/AstBuilder.java | 12 +++++------
 2 files changed, 16 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/5462d5ff/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4
b/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4
index 655008b..cfdd3c1 100644
--- a/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4
+++ b/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyParser.g4
@@ -490,12 +490,12 @@ gstringPath
 
 
 // LAMBDA EXPRESSION
-lambda
-options { baseContext = standardLambda; }
+lambdaExpression
+options { baseContext = standardLambdaExpression; }
 	:	lambdaParameters nls ARROW nls lambdaBody
 	;
 
-standardLambda
+standardLambdaExpression
 	:	standardLambdaParameters nls ARROW nls lambdaBody
 	;
 
@@ -734,7 +734,6 @@ finallyBlock
     :   FINALLY nls block
     ;
 
-
 resources
     :   LPAREN nls resourceList sep? rparen
     ;
@@ -798,11 +797,6 @@ expressionInPar
     :   LPAREN enhancedStatementExpression rparen
     ;
 
-enhancedStatementExpression
-    :   statementExpression
-    |   standardLambda
-    ;
-
 expressionList[boolean canSpread]
     :   expressionListElement[$canSpread] (COMMA expressionListElement[$canSpread])*
     ;
@@ -813,6 +807,11 @@ expressionListElement[boolean canSpread]
         ) expression
     ;
 
+enhancedStatementExpression
+    :   statementExpression
+    |   standardLambdaExpression
+    ;
+
 /**
  *  In order to resolve the syntactic ambiguities, e.g. (String)'abc' can be parsed as a
cast expression or a parentheses-less method call(method name: (String), arguments: 'abc')
  *      try to match expression first.
@@ -1072,7 +1071,7 @@ primary
     |   SUPER                                                                           
   #superPrmrAlt
     |   parExpression                                                                   
   #parenPrmrAlt
     |   closure                                                                         
   #closurePrmrAlt
-    |   lambda                                                                          
   #lambdaPrmrAlt
+    |   lambdaExpression                                                                
             #lambdaPrmrAlt
     |   list                                                                            
   #listPrmrAlt
     |   map                                                                             
   #mapPrmrAlt
     |   builtInType                                                                     
   #typePrmrAlt
@@ -1178,7 +1177,7 @@ options { baseContext = enhancedArgumentListElement; }
 
 enhancedArgumentListElement
     :   expressionListElement[true]
-    |   standardLambda
+    |   standardLambdaExpression
     |   mapEntry
     ;
 

http://git-wip-us.apache.org/repos/asf/groovy/blob/5462d5ff/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 faab339..e498a03 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
@@ -1839,8 +1839,8 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object>
implements Groov
 
         if (asBoolean(ctx.statementExpression())) {
             expression = ((ExpressionStatement) this.visit(ctx.statementExpression())).getExpression();
-        } else if (asBoolean(ctx.standardLambda())) {
-            expression = this.visitStandardLambda(ctx.standardLambda());
+        } else if (asBoolean(ctx.standardLambdaExpression())) {
+            expression = this.visitStandardLambdaExpression(ctx.standardLambdaExpression());
         } else {
             throw createParsingFailedException("Unsupported enhanced statement expression:
" + ctx.getText(), ctx);
         }
@@ -2236,8 +2236,8 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object>
implements Groov
             return this.configureAST(this.visitExpressionListElement(ctx.expressionListElement()),
ctx);
         }
 
-        if (asBoolean(ctx.standardLambda())) {
-            return this.configureAST(this.visitStandardLambda(ctx.standardLambda()), ctx);
+        if (asBoolean(ctx.standardLambdaExpression())) {
+            return this.configureAST(this.visitStandardLambdaExpression(ctx.standardLambdaExpression()),
ctx);
         }
 
         if (asBoolean(ctx.mapEntry())) {
@@ -2683,7 +2683,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object>
implements Groov
 
     @Override
     public ClosureExpression visitLambdaPrmrAlt(LambdaPrmrAltContext ctx) {
-        return this.configureAST(this.visitStandardLambda(ctx.standardLambda()), ctx);
+        return this.configureAST(this.visitStandardLambdaExpression(ctx.standardLambdaExpression()),
ctx);
     }
 
     @Override
@@ -3148,7 +3148,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object>
implements Groov
 // } gstring       --------------------------------------------------------------------
 
     @Override
-    public LambdaExpression visitStandardLambda(StandardLambdaContext ctx) {
+    public LambdaExpression visitStandardLambdaExpression(StandardLambdaExpressionContext
ctx) {
         return this.configureAST(this.createLambda(ctx.standardLambdaParameters(), ctx.lambdaBody()),
ctx);
     }
 


Mime
View raw message