groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [2/6] groovy git commit: split out LineColumn tests which differ between the old and new parsers (part 2)
Date Sat, 13 May 2017 12:16:25 GMT
split out LineColumn tests which differ between the old and new parsers (part 2)


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

Branch: refs/heads/GROOVY_2_6_X
Commit: 2deb1e9b01a5e5b342d6ea310ccdac201ada26c0
Parents: 0d18108
Author: paulk <paulk@asert.com.au>
Authored: Fri May 12 16:55:15 2017 +1000
Committer: paulk <paulk@asert.com.au>
Committed: Sat May 13 21:58:00 2017 +1000

----------------------------------------------------------------------
 .../org/codehaus/groovy/ast/LineColumnCheck.txt | 92 ++------------------
 .../groovy/ast/LineColumnCheck_antlr2.txt       | 80 +++++++++++++++++
 .../groovy/ast/LineColumnCheck_antlr4.txt       | 88 ++++++++++++++++++-
 .../apache/groovy/parser/antlr4/GroovyParser.g4 |  2 +-
 .../apache/groovy/parser/antlr4/AstBuilder.java |  3 +-
 5 files changed, 175 insertions(+), 90 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/2deb1e9b/src/test/org/codehaus/groovy/ast/LineColumnCheck.txt
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/ast/LineColumnCheck.txt b/src/test/org/codehaus/groovy/ast/LineColumnCheck.txt
index a6f9af4..616d9e8 100644
--- a/src/test/org/codehaus/groovy/ast/LineColumnCheck.txt
+++ b/src/test/org/codehaus/groovy/ast/LineColumnCheck.txt
@@ -61,26 +61,6 @@ for (a in (1..42)) {
 }
 :::[ForStatement,(1:1),(4:2)];[BlockStatement,(1:20),(4:2)]
 
-###switchCase:::
-switch (expression) {
-	case 1 : log = 1
-	case 2 : log = 2
-}
-:::[SwitchStatement,(1:1),(4:2)];
-[CaseStatement,(2:2),(2:6)];[BlockStatement,(2:11),(3:2)];
-[CaseStatement,(3:2),(3:6)];[BlockStatement,(3:11),(4:1)]
-
-###switchCaseDefault:::
-switch (expression) {
-	case 1 : log = 1 ; break
-	case 2 : log = 2 ; break
-	default : log = 6
-}
-:::[SwitchStatement,(1:1),(5:2)];
-[CaseStatement,(2:2),(2:6)];[BlockStatement,(2:11),(3:2)];[BreakStatement,(2:21),(2:26)];
-[CaseStatement,(3:2),(3:6)];[BlockStatement,(3:11),(4:2)];[BreakStatement,(3:21),(3:26)];
-[BlockStatement,(4:12),(5:1)]
-
 ###synchronizedStatement:::
 synchronized (obj) {
 
@@ -89,27 +69,21 @@ synchronized (obj) {
 :::[SynchronizedStatement,(1:1),(4:2)];[BlockStatement,(1:20),(4:2)]
 
 ###breakStatement:::
-break label
-:::[BreakStatement,(1:1),(1:12)]
+while (true) {
+  break label
+}
+:::[BreakStatement,(2:3),(2:14)]
 
 ###continueStatement:::
-continue label
-:::[ContinueStatement,(1:1),(1:15)]
+while (true) {
+  continue label
+}
+:::[ContinueStatement,(2:3),(2:17)]
 
 ###assertStatement():::
 assert (expression)
 :::[AssertStatement,(1:1),(1:20)]
 
-###assertStatementAdv:::
-assert (expression) , "AssertTest"
-:::[AssertStatement,(1:1),(1:35)][BooleanExpression,(1:8),(1:21)];
-[VariableExpression,(1:8),(1:21)][ConstantExpression,(1:23),(1:35)]
-
-###throwStatement:::
-throw new Exception("exception")
-:::[ThrowStatement,(1:1),(1:33)][ConstructorCallExpression,(1:7),(1:33)];
-[ArgumentListExpression,(1:21),(1:32)][ConstantExpression,(1:21),(1:32)]
-
 ###nonBracedStatementIf:::
 if (expression) 
 	while (expression2) 
@@ -167,28 +141,11 @@ class Test {
 	}
 }:::[StaticMethodCallExpression,(3:3),(3:12)]
 
-###methodCallExpressionInAssignment:::
-sub = "groovy".substring(3)
-:::[MethodCallExpression,(1:7),(1:28)][ConstantExpression,(1:7),(1:15)];
-[ConstantExpression,(1:16),(1:25)][ArgumentListExpression,(1:26),(1:27)];
-[ConstantExpression,(1:26),(1:27)]
-
-###constructorCallExpressionInAssignment:::
-txt = new String("groovy")
-:::[ConstructorCallExpression,(1:7),(1:27)][ClassNode,(1:11),(1:17)][ArgumentListExpression,(1:18),(1:26)];
-[ConstantExpression,(1:18),(1:26)]
-
 ###methodCallExpressionAppendedBlockInAssignment:::
 var = f{closure}
 :::[MethodCallExpression,(1:7),(1:17)];
 [ConstantExpression,(1:7),(1:8)][ArgumentListExpression,(1:8),(1:17)][ClosureExpression,(1:8),(1:17)]
 
-###methodCallExpressionArgsAndAppendedBlock:::
-a = f(x){y}
-:::[MethodCallExpression,(1:5),(1:12)];
-[ConstantExpression,(1:5),(1:6)][ArgumentListExpression,(1:7),(1:8)][VariableExpression,(1:7),(1:8)];
-[ClosureExpression,(1:9),(1:12)]
-
 ###ArrayExpressionD1:::
 def array = new int[1]
 :::[ArrayExpression,(1:13),(1:23)][ClassNode,(1:17),(1:20)][ConstantExpression,(1:21),(1:22)]
@@ -198,23 +155,6 @@ def array = new int[1][2]
 :::[ArrayExpression,(1:13),(1:26)][ClassNode,(1:17),(1:20)];
 [ConstantExpression,(1:21),(1:22)][ConstantExpression,(1:24),(1:25)]
 
-###methodCallExpressionChain:::
-b = getClass().getName().substring(42)
-:::[MethodCallExpression,(1:5),(1:39)][MethodCallExpression,(1:5),(1:25)];
-[MethodCallExpression,(1:5),(1:15)];
-[ConstantExpression,(1:5),(1:13)][ArgumentListExpression,(1:14),(1:14)];
-[ConstantExpression,(1:16),(1:23)][ArgumentListExpression,(1:24),(1:24)];
-[ConstantExpression,(1:26),(1:35)][ArgumentListExpression,(1:36),(1:38)];
-[ConstantExpression,(1:36),(1:38)]
-
-###methodCallExpressionNested:::
-b = outerMethod(obj.innerMethod(abc))
-:::[MethodCallExpression,(1:5),(1:38)];
-[ConstantExpression,(1:5),(1:16)][ArgumentListExpression,(1:17),(1:37)];
-[MethodCallExpression,(1:17),(1:37)][VariableExpression,(1:17),(1:20)];
-[ConstantExpression,(1:21),(1:32)][ArgumentListExpression,(1:33),(1:36)];
-[VariableExpression,(1:33),(1:36)]
-
 ###indexPropertyArgsWithObj:::
 a = obj.prop[]
 :::[BinaryExpression,(1:5),(1:15)]
@@ -223,14 +163,6 @@ a = obj.prop[]
 a = obj['prop']
 :::[BinaryExpression,(1:5),(1:16)]
 
-###declaratorBracketD1:::
-int[] array
-:::[ExpressionStatement,(1:1),(1:12)][ClassNode,(1:1),(1:7)][DeclarationExpression,(1:1),(1:12)]
-
-###declaratorBracketD3:::
-int[][][] array
-:::[ExpressionStatement,(1:1),(1:16)][ClassNode,(1:1),(1:11)][DeclarationExpression,(1:1),(1:16)]
-
 ###resolvedDeclarationExpression:::
 def i = Integer.parseInt("42")
 :::[DeclarationExpression,(1:1),(1:31)]
@@ -239,14 +171,6 @@ def i = Integer.parseInt("42")
 def method() throws Exception {}
 :::[ClassNode,(1:21),(1:30)]
 
-###throwsClauseQualifiedName:::
-def method() throws java.lang.Exception {}
-:::[ClassNode,(1:21),(1:41)]
-
-###throwsClauseMultiQualifiedName:::
-def method() throws java.lang.Exception, java.lang.RuntimeException {}
-:::[ClassNode,(1:21),(1:40)][ClassNode,(1:42),(1:69)]
-
 ###extendsClassNode:::
 class BaseClass {}
 class ExtendedBaseClass extends BaseClass {}

http://git-wip-us.apache.org/repos/asf/groovy/blob/2deb1e9b/src/test/org/codehaus/groovy/ast/LineColumnCheck_antlr2.txt
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/ast/LineColumnCheck_antlr2.txt b/src/test/org/codehaus/groovy/ast/LineColumnCheck_antlr2.txt
index 95866a0..5da0000 100644
--- a/src/test/org/codehaus/groovy/ast/LineColumnCheck_antlr2.txt
+++ b/src/test/org/codehaus/groovy/ast/LineColumnCheck_antlr2.txt
@@ -94,3 +94,83 @@ try {
 [CatchStatement,(3:3),(5:3)][BlockStatement,(3:12),(5:3)];
 [CatchStatement,(5:3),(7:3)][BlockStatement,(5:12),(7:3)];
 [BlockStatement,(7:3),(9:2)][BlockStatement,(7:11),(9:2)]
+
+###switchCase:::
+switch (expression) {
+	case 1 : log = 1
+	case 2 : log = 2
+}
+:::[SwitchStatement,(1:1),(4:2)];
+[CaseStatement,(2:2),(2:6)];[BlockStatement,(2:11),(3:2)];
+[CaseStatement,(3:2),(3:6)];[BlockStatement,(3:11),(4:1)]
+
+###switchCaseDefault:::
+switch (expression) {
+	case 1 : log = 1 ; break
+	case 2 : log = 2 ; break
+	default : log = 6
+}
+:::[SwitchStatement,(1:1),(5:2)];
+[CaseStatement,(2:2),(2:6)];[BlockStatement,(2:11),(3:2)];[BreakStatement,(2:21),(2:26)];
+[CaseStatement,(3:2),(3:6)];[BlockStatement,(3:11),(4:2)];[BreakStatement,(3:21),(3:26)];
+[BlockStatement,(4:12),(5:1)]
+
+###assertStatementAdv:::
+assert (expression) , "AssertTest"
+:::[AssertStatement,(1:1),(1:35)][BooleanExpression,(1:8),(1:21)];
+[VariableExpression,(1:8),(1:21)][ConstantExpression,(1:23),(1:35)]
+
+###throwStatement:::
+throw new Exception("exception")
+:::[ThrowStatement,(1:1),(1:33)][ConstructorCallExpression,(1:7),(1:33)];
+[ArgumentListExpression,(1:21),(1:32)][ConstantExpression,(1:21),(1:32)]
+
+###methodCallExpressionInAssignment:::
+sub = "groovy".substring(3)
+:::[MethodCallExpression,(1:7),(1:28)][ConstantExpression,(1:7),(1:15)];
+[ConstantExpression,(1:16),(1:25)][ArgumentListExpression,(1:26),(1:27)];
+[ConstantExpression,(1:26),(1:27)]
+
+###constructorCallExpressionInAssignment:::
+txt = new String("groovy")
+:::[ConstructorCallExpression,(1:7),(1:27)][ClassNode,(1:11),(1:17)][ArgumentListExpression,(1:18),(1:26)];
+[ConstantExpression,(1:18),(1:26)]
+
+###methodCallExpressionArgsAndAppendedBlock:::
+a = f(x){y}
+:::[MethodCallExpression,(1:5),(1:12)];
+[ConstantExpression,(1:5),(1:6)][ArgumentListExpression,(1:7),(1:8)][VariableExpression,(1:7),(1:8)];
+[ClosureExpression,(1:9),(1:12)]
+
+###methodCallExpressionChain:::
+b = getClass().getName().substring(42)
+:::[MethodCallExpression,(1:5),(1:39)][MethodCallExpression,(1:5),(1:25)];
+[MethodCallExpression,(1:5),(1:15)];
+[ConstantExpression,(1:5),(1:13)][ArgumentListExpression,(1:14),(1:14)];
+[ConstantExpression,(1:16),(1:23)][ArgumentListExpression,(1:24),(1:24)];
+[ConstantExpression,(1:26),(1:35)][ArgumentListExpression,(1:36),(1:38)];
+[ConstantExpression,(1:36),(1:38)]
+
+###methodCallExpressionNested:::
+b = outerMethod(obj.innerMethod(abc))
+:::[MethodCallExpression,(1:5),(1:38)];
+[ConstantExpression,(1:5),(1:16)][ArgumentListExpression,(1:17),(1:37)];
+[MethodCallExpression,(1:17),(1:37)][VariableExpression,(1:17),(1:20)];
+[ConstantExpression,(1:21),(1:32)][ArgumentListExpression,(1:33),(1:36)];
+[VariableExpression,(1:33),(1:36)]
+
+###declaratorBracketD1:::
+int[] array
+:::[ExpressionStatement,(1:1),(1:12)][ClassNode,(1:1),(1:7)][DeclarationExpression,(1:1),(1:12)]
+
+###declaratorBracketD3:::
+int[][][] array
+:::[ExpressionStatement,(1:1),(1:16)][ClassNode,(1:1),(1:11)][DeclarationExpression,(1:1),(1:16)]
+
+###throwsClauseQualifiedName:::
+def method() throws java.lang.Exception {}
+:::[ClassNode,(1:21),(1:41)]
+
+###throwsClauseMultiQualifiedName:::
+def method() throws java.lang.Exception, java.lang.RuntimeException {}
+:::[ClassNode,(1:21),(1:40)][ClassNode,(1:42),(1:69)]

http://git-wip-us.apache.org/repos/asf/groovy/blob/2deb1e9b/src/test/org/codehaus/groovy/ast/LineColumnCheck_antlr4.txt
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/ast/LineColumnCheck_antlr4.txt b/src/test/org/codehaus/groovy/ast/LineColumnCheck_antlr4.txt
index da8d573..2b43cc3 100644
--- a/src/test/org/codehaus/groovy/ast/LineColumnCheck_antlr4.txt
+++ b/src/test/org/codehaus/groovy/ast/LineColumnCheck_antlr4.txt
@@ -56,7 +56,7 @@ try {
 
 }
 :::[TryCatchStatement,(1:1),(6:2)][BlockStatement,(1:5),(3:2)];
-[CatchStatement,(3:12),(6:2)][BlockStatement,(3:12),(6:2)]
+[CatchStatement,(3:3),(6:2)][BlockStatement,(3:12),(6:2)]
 
 ###tryFinally:::
 try {
@@ -77,7 +77,7 @@ try {
 
 }
 :::[TryCatchStatement,(1:1),(7:2)][BlockStatement,(1:5),(3:2)];
-[CatchStatement,(3:12),(5:2)][BlockStatement,(3:12),(5:2)];
+[CatchStatement,(3:3),(5:2)][BlockStatement,(3:12),(5:2)];
 [BlockStatement,(5:3),(7:2)][BlockStatement,(5:11),(7:2)]
 
 ###tryMultiCatchFinally:::
@@ -91,6 +91,86 @@ try {
 
 }
 :::[TryCatchStatement,(1:1),(9:2)][BlockStatement,(1:5),(3:2)];
-[CatchStatement,(3:12),(5:2)][BlockStatement,(3:12),(5:2)];
-[CatchStatement,(5:12),(7:2)][BlockStatement,(5:12),(7:2)];
+[CatchStatement,(3:3),(5:2)][BlockStatement,(3:12),(5:2)];
+[CatchStatement,(5:3),(7:2)][BlockStatement,(5:12),(7:2)];
 [BlockStatement,(7:3),(9:2)][BlockStatement,(7:11),(9:2)]
+
+###switchCase:::
+switch (expression) {
+	case 1 : log = 1
+	case 2 : log = 2
+}
+:::[SwitchStatement,(1:1),(4:2)];
+[CaseStatement,(2:2),(2:6)];[BlockStatement,(2:11),(3:1)];
+[CaseStatement,(3:2),(3:6)];[BlockStatement,(3:11),(4:1)]
+
+###switchCaseDefault:::
+switch (expression) {
+	case 1 : log = 1 ; break
+	case 2 : log = 2 ; break
+	default : log = 6
+}
+:::[SwitchStatement,(1:1),(5:2)];
+[CaseStatement,(2:2),(2:6)];[BlockStatement,(2:11),(3:1)];[BreakStatement,(2:21),(2:26)];
+[CaseStatement,(3:2),(3:6)];[BlockStatement,(3:11),(4:1)];[BreakStatement,(3:21),(3:26)];
+[BlockStatement,(4:12),(5:1)]
+
+###assertStatementAdv:::
+assert (expression) , "AssertTest"
+:::[AssertStatement,(1:1),(1:35)][BooleanExpression,(1:8),(1:20)];
+[VariableExpression,(1:8),(1:20)][ConstantExpression,(1:23),(1:35)]
+
+###throwStatement:::
+throw new Exception("exception")
+:::[ThrowStatement,(1:1),(1:33)][ConstructorCallExpression,(1:7),(1:33)];
+[ArgumentListExpression,(1:20),(1:33)][ConstantExpression,(1:21),(1:32)]
+
+###methodCallExpressionInAssignment:::
+sub = "groovy".substring(3)
+:::[MethodCallExpression,(1:7),(1:28)][ConstantExpression,(1:7),(1:15)];
+[ConstantExpression,(1:16),(1:25)][ArgumentListExpression,(1:25),(1:28)];
+[ConstantExpression,(1:26),(1:27)]
+
+###constructorCallExpressionInAssignment:::
+txt = new String("groovy")
+:::[ConstructorCallExpression,(1:7),(1:27)][ClassNode,(1:11),(1:17)][ArgumentListExpression,(1:17),(1:27)];
+[ConstantExpression,(1:18),(1:26)]
+
+###methodCallExpressionArgsAndAppendedBlock:::
+a = f(x){y}
+:::[MethodCallExpression,(1:5),(1:12)];
+[ConstantExpression,(1:5),(1:6)][ArgumentListExpression,(1:6),(1:9)][VariableExpression,(1:7),(1:8)];
+[ClosureExpression,(1:9),(1:12)]
+
+###methodCallExpressionChain:::
+b = getClass().getName().substring(42)
+:::[MethodCallExpression,(1:5),(1:39)][MethodCallExpression,(1:23),(1:25)];
+[MethodCallExpression,(1:13),(1:15)];
+[ConstantExpression,(1:5),(1:13)][ArgumentListExpression,(1:13),(1:15)];
+[ConstantExpression,(1:16),(1:23)][ArgumentListExpression,(1:23),(1:25)];
+[ConstantExpression,(1:26),(1:35)][ArgumentListExpression,(1:35),(1:39)];
+[ConstantExpression,(1:36),(1:38)]
+
+###methodCallExpressionNested:::
+b = outerMethod(obj.innerMethod(abc))
+:::[MethodCallExpression,(1:5),(1:38)];
+[ConstantExpression,(1:5),(1:16)][ArgumentListExpression,(1:16),(1:38)];
+[MethodCallExpression,(1:17),(1:37)][VariableExpression,(1:17),(1:20)];
+[ConstantExpression,(1:21),(1:32)][ArgumentListExpression,(1:32),(1:37)];
+[VariableExpression,(1:33),(1:36)]
+
+###declaratorBracketD1:::
+int[] array
+:::[ExpressionStatement,(1:1),(1:12)][ClassNode,(1:1),(1:6)][DeclarationExpression,(1:1),(1:12)]
+
+###declaratorBracketD3:::
+int[][][] array
+:::[ExpressionStatement,(1:1),(1:16)][ClassNode,(1:1),(1:10)][DeclarationExpression,(1:1),(1:16)]
+
+###throwsClauseQualifiedName:::
+def method() throws java.lang.Exception {}
+:::[ClassNode,(1:21),(1:40)]
+
+###throwsClauseMultiQualifiedName:::
+def method() throws java.lang.Exception, java.lang.RuntimeException {}
+:::[ClassNode,(1:21),(1:40)][ClassNode,(1:42),(1:68)]

http://git-wip-us.apache.org/repos/asf/groovy/blob/2deb1e9b/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 0eaa3a1..3949350 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
@@ -679,7 +679,7 @@ locals[boolean resourcesExists = false]
         |
             nls finallyBlock
         |
-            // try-with-resources can have no catche and finally clauses
+            // a catch or finally clause is required unless it's try-with-resources
             { $resourcesExists }?<fail={"catch or finally clauses are required for try-catch
statement"}>
         )
     ;

http://git-wip-us.apache.org/repos/asf/groovy/blob/2deb1e9b/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 589eb0a..f0c490a 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
@@ -607,7 +607,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object>
implements Groov
 
                             new Parameter(e, this.visitIdentifier(ctx.identifier())),
                             this.visitBlock(ctx.block())),
-                    ctx.block());
+                    ctx);
             list.add(catchStatement);
         }
         return list;
@@ -1961,6 +1961,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object>
implements Groov
 
         if (asBoolean(ctx.arguments())) {
             Expression argumentsExpr = this.visitArguments(ctx.arguments());
+            this.configureAST(argumentsExpr, ctx);
 
             if (isTrue(baseExpr, IS_INSIDE_PARENTHESES)) { // e.g. (obj.x)(), (obj.@x)()
                 MethodCallExpression methodCallExpression =


Mime
View raw message