[01/17] groovy git commit: rename antlr4 parser to remove groovy- prefix since that is by convention for modules

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
17 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[01/17] groovy git commit: rename antlr4 parser to remove groovy- prefix since that is by convention for modules

paulk
Repository: groovy
Updated Branches:
  refs/heads/master 27bedfe89 -> 73acbcfec


http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/TryWithResources_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/TryWithResources_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/TryWithResources_01x.groovy
new file mode 100644
index 0000000..94a183e
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/TryWithResources_01x.groovy
@@ -0,0 +1,284 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import groovy.transform.CompileStatic
+
+import java.io.*
+
+
+class Resource implements Closeable {
+    int resourceId;
+    static closedResourceIds = [];
+    static exMsg = "failed to close";
+
+    public Resource(int resourceId) {
+        this.resourceId = resourceId;
+    }
+
+    public void close() {
+        if (3 == resourceId) throw new IOException(exMsg);
+
+        closedResourceIds << resourceId
+    }
+}
+
+// test case 1
+def a = 1;
+try (Resource r1 = new Resource(1)) {
+    a = 2;
+}
+assert Resource.closedResourceIds == [1]
+assert 2 == a
+
+// test case 2
+Resource.closedResourceIds = []
+final exMsg = "resource not found";
+try {
+    // try { ... } should throw the IOException, while the resource should be closed
+    try (Resource r1 = new Resource(2)) {
+        throw new FileNotFoundException(exMsg)
+    }
+} catch(FileNotFoundException e) {
+    assert exMsg == e.getMessage()
+}
+assert Resource.closedResourceIds == [2]
+
+// test case 3
+Resource.closedResourceIds = []
+a = 1;
+try {
+    try (Resource r1 = new Resource(3)) {
+        a = 2;
+    }
+} catch (IOException e) {
+    assert Resource.exMsg == e.getMessage()
+}
+assert 2 == a;
+assert Resource.closedResourceIds == []
+
+// test case 4
+Resource.closedResourceIds = []
+try {
+    // try { ... } should throw the IOException, while the resource should be closed
+    try (Resource r1 = new Resource(3)) {
+        throw new FileNotFoundException(exMsg)
+    }
+} catch(FileNotFoundException e) {
+    assert exMsg == e.getMessage()
+
+    def suppressedExceptions = e.getSuppressed();
+    assert suppressedExceptions.length == 1
+    assert suppressedExceptions[0] instanceof IOException
+    assert suppressedExceptions[0].getMessage() == Resource.exMsg
+}
+assert Resource.closedResourceIds == []
+
+
+// test case 5
+Resource.closedResourceIds = []
+a = 1;
+try (Resource r1 = new Resource(5);
+Resource r2 = new Resource(6);) {
+    a = 2;
+}
+assert Resource.closedResourceIds == [6, 5]
+assert 2 == a
+
+// test case 6
+Resource.closedResourceIds = []
+a = 1;
+try (Resource r1 = new Resource(5);
+Resource r2 = new Resource(6);
+Resource r3 = new Resource(7);) {
+    a = 2;
+}
+assert Resource.closedResourceIds == [7, 6, 5]
+assert 2 == a
+
+
+// test case 7
+Resource.closedResourceIds = []
+try (Resource r1 = new Resource(7)) {
+    throw new FileNotFoundException(exMsg)
+} catch(FileNotFoundException e) {
+    assert exMsg == e.getMessage()
+}
+assert Resource.closedResourceIds == [7]
+
+// test case 8
+Resource.closedResourceIds = []
+try (Resource r1 = new Resource(7);
+Resource r2 = new Resource(8)) {
+    throw new FileNotFoundException(exMsg)
+} catch(FileNotFoundException e) {
+    assert exMsg == e.getMessage()
+}
+assert Resource.closedResourceIds == [8, 7]
+
+
+// test case 9
+Resource.closedResourceIds = []
+a = 1;
+try (Resource r1 = new Resource(3)) {
+    a = 2;
+} catch (IOException e) {
+    assert Resource.exMsg == e.getMessage()
+}
+assert 2 == a;
+assert Resource.closedResourceIds == []
+
+
+// test case 10
+Resource.closedResourceIds = []
+a = 1;
+try (Resource r1 = new Resource(3);
+Resource r2 = new Resource(4)) {
+    a = 2;
+} catch (IOException e) {
+    assert Resource.exMsg == e.getMessage()
+}
+assert 2 == a;
+assert Resource.closedResourceIds == [4]
+
+// test case 11
+Resource.closedResourceIds = []
+a = 1;
+try (Resource r0 = new Resource(2);
+Resource r1 = new Resource(3);
+Resource r2 = new Resource(4)) {
+    a = 2;
+} catch (IOException e) {
+    assert Resource.exMsg == e.getMessage()
+}
+assert 2 == a;
+assert Resource.closedResourceIds == [4, 2]
+
+
+// test case 12
+Resource.closedResourceIds = []
+try (Resource r1 = new Resource(3);
+Resource r2 = new Resource(4)) {
+    throw new FileNotFoundException(exMsg)
+} catch(FileNotFoundException e) {
+    assert exMsg == e.getMessage()
+
+    def suppressedExceptions = e.getSuppressed();
+    assert suppressedExceptions.length == 1
+    assert suppressedExceptions[0] instanceof IOException
+    assert suppressedExceptions[0].getMessage() == Resource.exMsg
+}
+assert Resource.closedResourceIds == [4]
+
+// test case 13
+Resource.closedResourceIds = []
+try (Resource r0 = new Resource(2);
+Resource r1 = new Resource(3);
+Resource r2 = new Resource(4)) {
+    throw new FileNotFoundException(exMsg)
+} catch(FileNotFoundException e) {
+    assert exMsg == e.getMessage()
+
+    def suppressedExceptions = e.getSuppressed();
+    assert suppressedExceptions.length == 1
+    assert suppressedExceptions[0] instanceof IOException
+    assert suppressedExceptions[0].getMessage() == Resource.exMsg
+}
+assert Resource.closedResourceIds == [4, 2]
+
+// test case 14
+Resource.closedResourceIds = []
+a = 1;
+try (Resource r1 = new Resource(1)) {
+    a += 2;
+    try (Resource r2 = new Resource(2);Resource r4 = new Resource(4)) {
+        a += 3;
+        try (Resource r5 = new Resource(5);Resource r6 = new Resource(6);Resource r7 = new Resource(7)) {
+            a += 4;
+            try {
+                try (Resource r3 = new Resource(3)) {
+                    a += 5;
+                }
+            } catch (IOException e) {
+                assert Resource.exMsg == e.getMessage()
+            }
+        }
+    } catch(Exception e) {
+        // ignored
+    } finally {
+        a += 10
+    }
+}
+assert Resource.closedResourceIds == [7, 6, 5, 4, 2, 1]
+assert 25 == a
+
+// test case 15
+@CompileStatic
+void tryWithResources() {
+    Resource.closedResourceIds = []
+    int cs = 1;
+    try (Resource r1 = new Resource(1)) {
+        cs += 2;
+        try (Resource r2 = new Resource(2);Resource r4 = new Resource(4)) {
+            cs += 3;
+            try (Resource r5 = new Resource(5);Resource r6 = new Resource(6);Resource r7 = new Resource(7)) {
+                cs += 4;
+                try {
+                    try (Resource r3 = new Resource(3)) {
+                        cs += 5;
+                    }
+                } catch (IOException e) {
+                    assert Resource.exMsg == e.getMessage()
+                }
+            }
+        } catch(Exception e) {
+            // ignored
+        } finally {
+            cs += 10
+        }
+    }
+    assert Resource.closedResourceIds == [7, 6, 5, 4, 2, 1]
+    assert 25 == cs
+}
+
+tryWithResources()
+
+
+// test case 16
+Resource.closedResourceIds = []
+a = 1;
+try (
+        Resource r1 = new Resource(
+        1
+)
+        Resource r2 = new Resource(2)
+) {
+    a = 2;
+}
+assert Resource.closedResourceIds == [2, 1]
+assert 2 == a
+
+// test case 17
+Resource.closedResourceIds = []
+a = 1;
+try (r1 = new Resource(1)
+     r2 = new Resource(2)) {
+    a = 2;
+}
+assert Resource.closedResourceIds == [2, 1]
+assert 2 == a
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Unicode_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Unicode_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/Unicode_01.groovy
new file mode 100644
index 0000000..a065baa
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Unicode_01.groovy
@@ -0,0 +1,42 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+def \u0061 = '\uuuuu0061'
+def \u0061\u0062
+def \u0061\u0062\u0063
+def \u0061\u0062\u00639
+def \u0061cC\u0062Bb\u00639aA
+def a\u00615\u00626\u0063Z
+def A\u00617\u00628\u0063z
+
+def \u0061\u0062() {}
+
+class \u0061 {
+    def \u0061\u0062
+
+    def \u0061cC\u0062Bb\u00639aA() {}
+}
+interface \u0061 {}
+enum \u0061 {
+    \u0061cC\u0062Bb\u00639aA, \u0061cC\u0062Bb\u00639aA2
+}
+trait \u0061 {}
+@interface \u0061 {}
+
+
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/While_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/While_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/While_01.groovy
new file mode 100644
index 0000000..cbf0249
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/While_01.groovy
@@ -0,0 +1,76 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+while(true) assert true
+
+while(
+        true
+) assert true
+
+while(true)
+    assert true
+
+while(true) {
+    break;
+}
+
+out:
+while(true) {
+    break out;
+}
+
+out1:
+while(true) {
+    break out1;
+    out2: while (true) {
+        break out2;
+    }
+}
+
+
+while(true) {
+    continue
+}
+
+out:
+while(true) {
+    continue out;
+}
+
+out1:
+while(true) {
+    continue out1;
+    out2: while (true) {
+        continue out2;
+    }
+}
+
+out1:
+while(true) {
+    continue out1;
+    out2: while (true) {
+        break out2;
+    }
+}
+
+
+while (false)
+    int number = 1
+
+while(true);
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/While_02x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/While_02x.groovy b/subprojects/parser-antlr4/src/test/resources/core/While_02x.groovy
new file mode 100644
index 0000000..e099280
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/While_02x.groovy
@@ -0,0 +1,23 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+int i = 0
+while (i < 5) {
+    i++
+}
+assert 5 == i;

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_01x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_01x.groovy
new file mode 100644
index 0000000..8dae1bd
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_01x.groovy
@@ -0,0 +1,21 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+class A {
+    def x()
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_02x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_02x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_02x.groovy
new file mode 100644
index 0000000..80a041c
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_02x.groovy
@@ -0,0 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+enum E {
+    A, B
+    def y()
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_03x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_03x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_03x.groovy
new file mode 100644
index 0000000..92ace61
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_03x.groovy
@@ -0,0 +1,21 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+trait B {
+    def z()
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_04x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_04x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_04x.groovy
new file mode 100644
index 0000000..409fa18
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_04x.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+def w()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_05x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_05x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_05x.groovy
new file mode 100644
index 0000000..aec108e
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_05x.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+abstract v()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_06x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_06x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_06x.groovy
new file mode 100644
index 0000000..7672201
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/AbstractMethod_06x.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+abstract u() {}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Break_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Break_01x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Break_01x.groovy
new file mode 100644
index 0000000..14c8d30
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Break_01x.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+break
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Break_02x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Break_02x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Break_02x.groovy
new file mode 100644
index 0000000..f08680b
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Break_02x.groovy
@@ -0,0 +1,21 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+if (true) {
+    break;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/ClassDeclaration_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/ClassDeclaration_01x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/ClassDeclaration_01x.groovy
new file mode 100644
index 0000000..b60a794
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/ClassDeclaration_01x.groovy
@@ -0,0 +1,25 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package fail
+
+class A {
+    String foo() {}
+    def foo() {}
+}
+new A()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/ClosureListExpression_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/ClosureListExpression_01.groovy b/subprojects/parser-antlr4/src/test/resources/fail/ClosureListExpression_01.groovy
new file mode 100644
index 0000000..607c5b5
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/ClosureListExpression_01.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+[].for(1;2;3){println "in loop"}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/ClosureListExpression_02.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/ClosureListExpression_02.groovy b/subprojects/parser-antlr4/src/test/resources/fail/ClosureListExpression_02.groovy
new file mode 100644
index 0000000..29a16ec
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/ClosureListExpression_02.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+def x = (1;2;3)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/ClosureListExpression_03.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/ClosureListExpression_03.groovy b/subprojects/parser-antlr4/src/test/resources/fail/ClosureListExpression_03.groovy
new file mode 100644
index 0000000..dab42a1
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/ClosureListExpression_03.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+[].bar(1;2;3)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/ClosureListExpression_04.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/ClosureListExpression_04.groovy b/subprojects/parser-antlr4/src/test/resources/fail/ClosureListExpression_04.groovy
new file mode 100644
index 0000000..5783cbd
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/ClosureListExpression_04.groovy
@@ -0,0 +1,28 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+class Crasher {
+    public void m() {
+        def fields = [1,2,3]
+        def expectedFieldNames = ["patentnumber", "status"].
+                for (int i=0; i<fields.size(); i++) {
+                    Object f = fields[i]
+                    System.out.println(f);
+                }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/ConstructorDeclaration_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/ConstructorDeclaration_01.groovy b/subprojects/parser-antlr4/src/test/resources/fail/ConstructorDeclaration_01.groovy
new file mode 100644
index 0000000..1318c4a
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/ConstructorDeclaration_01.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+class Foo { static final Foo() {}}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Continue_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Continue_01x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Continue_01x.groovy
new file mode 100644
index 0000000..4a23bf8
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Continue_01x.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+continue;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Continue_02x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Continue_02x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Continue_02x.groovy
new file mode 100644
index 0000000..744b34a
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Continue_02x.groovy
@@ -0,0 +1,21 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+if (true) {
+    continue;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/DoWhile_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/DoWhile_01x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/DoWhile_01x.groovy
new file mode 100644
index 0000000..b770cfb
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/DoWhile_01x.groovy
@@ -0,0 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+do
+println 123
+println 123
+while(false)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Expression_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Expression_01.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Expression_01.groovy
new file mode 100644
index 0000000..4313d66
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Expression_01.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+int()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Expression_02.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Expression_02.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Expression_02.groovy
new file mode 100644
index 0000000..d469216
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Expression_02.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+1 = 2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Expression_03.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Expression_03.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Expression_03.groovy
new file mode 100644
index 0000000..904f84e
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Expression_03.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+m() = 2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Expression_04.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Expression_04.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Expression_04.groovy
new file mode 100644
index 0000000..0d4e9af
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Expression_04.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+this = 2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Expression_05.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Expression_05.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Expression_05.groovy
new file mode 100644
index 0000000..58cf67c
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Expression_05.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+super = 2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Expression_06.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Expression_06.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Expression_06.groovy
new file mode 100644
index 0000000..220518d
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Expression_06.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+[1, 2] = 2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Expression_07.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Expression_07.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Expression_07.groovy
new file mode 100644
index 0000000..6f6f9b0
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Expression_07.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+[a: 1, b: 2] = 2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Expression_08.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Expression_08.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Expression_08.groovy
new file mode 100644
index 0000000..fb47d45
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Expression_08.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+"$x" = 2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Expression_09.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Expression_09.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Expression_09.groovy
new file mode 100644
index 0000000..4c1958c
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Expression_09.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+'x' = 2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/For_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/For_01.groovy b/subprojects/parser-antlr4/src/test/resources/fail/For_01.groovy
new file mode 100644
index 0000000..694dfed
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/For_01.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+for (*a; a.size() < 10;) {}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/For_02.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/For_02.groovy b/subprojects/parser-antlr4/src/test/resources/fail/For_02.groovy
new file mode 100644
index 0000000..359b9ca
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/For_02.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+for (; a.size() < 10; *a) {}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/InterfaceDeclaration_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/InterfaceDeclaration_01.groovy b/subprojects/parser-antlr4/src/test/resources/fail/InterfaceDeclaration_01.groovy
new file mode 100644
index 0000000..312818e
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/InterfaceDeclaration_01.groovy
@@ -0,0 +1,21 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+interface Foo {
+    def doit( String param = "Groovy", int o )
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/List_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/List_01.groovy b/subprojects/parser-antlr4/src/test/resources/fail/List_01.groovy
new file mode 100644
index 0000000..b625423
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/List_01.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+[,]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/LocalVariableDeclaration_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/LocalVariableDeclaration_01.groovy b/subprojects/parser-antlr4/src/test/resources/fail/LocalVariableDeclaration_01.groovy
new file mode 100644
index 0000000..590cb87
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/LocalVariableDeclaration_01.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+@Test2 (int c, int d) = [1, 2]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/MethodDeclaration_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/MethodDeclaration_01.groovy b/subprojects/parser-antlr4/src/test/resources/fail/MethodDeclaration_01.groovy
new file mode 100644
index 0000000..a8f27ad
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/MethodDeclaration_01.groovy
@@ -0,0 +1,23 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+{ ->
+    def say(String msg) {
+        println(msg)
+    }
+}()

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Modifier_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Modifier_01x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Modifier_01x.groovy
new file mode 100644
index 0000000..d7d4ce7
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Modifier_01x.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+def def m() {}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Modifier_02x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Modifier_02x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Modifier_02x.groovy
new file mode 100644
index 0000000..fcb609a
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Modifier_02x.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+public public class A {}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Modifier_03x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Modifier_03x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Modifier_03x.groovy
new file mode 100644
index 0000000..de1f024
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Modifier_03x.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+final final int a = 1;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Modifier_04x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Modifier_04x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Modifier_04x.groovy
new file mode 100644
index 0000000..4b495ad
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Modifier_04x.groovy
@@ -0,0 +1,21 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+class A {
+    private public a
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Modifier_05x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Modifier_05x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Modifier_05x.groovy
new file mode 100644
index 0000000..d19ca6c
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Modifier_05x.groovy
@@ -0,0 +1,21 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+class A {
+    protected public a
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Modifier_07.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Modifier_07.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Modifier_07.groovy
new file mode 100644
index 0000000..2134472
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Modifier_07.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+volatile x() {}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/ParExpression_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/ParExpression_01x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/ParExpression_01x.groovy
new file mode 100644
index 0000000..dc1585a
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/ParExpression_01x.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+(1 + 2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/ParExpression_02x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/ParExpression_02x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/ParExpression_02x.groovy
new file mode 100644
index 0000000..e2ce8a4
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/ParExpression_02x.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+(1 + 2))
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/ParExpression_03x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/ParExpression_03x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/ParExpression_03x.groovy
new file mode 100644
index 0000000..af33a2e
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/ParExpression_03x.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+(1 + 2]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Parentheses_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Parentheses_01.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Parentheses_01.groovy
new file mode 100644
index 0000000..976b0d2
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Parentheses_01.groovy
@@ -0,0 +1,20 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+def a( {
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Super_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Super_01x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Super_01x.groovy
new file mode 100644
index 0000000..8abe436
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Super_01x.groovy
@@ -0,0 +1,24 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+class A {
+    A(int a) {
+        println a
+        super(123)
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Switch_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Switch_01.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Switch_01.groovy
new file mode 100644
index 0000000..c548d86
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Switch_01.groovy
@@ -0,0 +1,27 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+switch (a) {
+    case 1:
+        break;
+    default:
+        break;
+    default:
+        break;
+}
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/This_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/This_01x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/This_01x.groovy
new file mode 100644
index 0000000..d3fdc44
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/This_01x.groovy
@@ -0,0 +1,26 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+class A {
+    A(int a) {
+        println a
+        this()
+    }
+
+    A() {}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/UnexpectedCharacter_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/UnexpectedCharacter_01x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/UnexpectedCharacter_01x.groovy
new file mode 100644
index 0000000..5beccbe
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/UnexpectedCharacter_01x.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Void_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Void_01x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Void_01x.groovy
new file mode 100644
index 0000000..fdeb7c4
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Void_01x.groovy
@@ -0,0 +1,21 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+class MyClass {
+    void field
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/fail/Void_02x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/fail/Void_02x.groovy b/subprojects/parser-antlr4/src/test/resources/fail/Void_02x.groovy
new file mode 100644
index 0000000..748003e
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/fail/Void_02x.groovy
@@ -0,0 +1,23 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+class MyClass {
+    def foo() {
+        void bar = null
+    }
+}

Reply | Threaded
Open this post in threaded view
|

[02/17] groovy git commit: rename antlr4 parser to remove groovy- prefix since that is by convention for modules

paulk
http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_07.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_07.groovy b/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_07.groovy
new file mode 100644
index 0000000..36b6215
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_07.groovy
@@ -0,0 +1,24 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package core;
+import java.util.*
+import java.math.BigDecimal;
+import java.io.*
+import static java.lang.Math.*
+import static java.lang.Math.pow

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_08.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_08.groovy b/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_08.groovy
new file mode 100644
index 0000000..c6f8d2e
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_08.groovy
@@ -0,0 +1,46 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+#!/usr/bin/env groovy
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package core;
+
+import java.util.*
+import java.math.BigDecimal;
+import java.io.*
+import java.sql.Blob as Bb
+import static java.lang.Math.*;
+import static java.lang.Math.pow as pw
+import def.in.as.trait.*;

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/InterfaceDeclaration_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/InterfaceDeclaration_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/InterfaceDeclaration_01.groovy
new file mode 100644
index 0000000..992926c
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/InterfaceDeclaration_01.groovy
@@ -0,0 +1,54 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package core
+
+interface A1 {}
+interface A2<T> {}
+interface A3<T extends A> {}
+interface A4<T extends A & B> {}
+interface A5<T extends A & B & C> {}
+interface A6<T extends A & B & C> extends A {}
+interface A62 extends A<T> {}
+interface A7<T extends A & B & C> extends A, B {}
+interface A8<T extends A & B & C> extends A, B, C {}
+@Test2 interface A9<T extends A & B & C> extends A, B, C {}
+@Test2 @Test3 public interface A10<T extends A & B & C> extends A, B, C {}
+
+@Test2
+@Test3
+@Test4
+public
+interface A11
+<
+        T extends
+A &
+B &
+C
+>
+extends
+A,
+B,
+C
+        {
+
+        }
+
+interface Iterator extends java.util.Iterator {}
+
+interface i {}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/InterfaceDeclaration_02.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/InterfaceDeclaration_02.groovy b/subprojects/parser-antlr4/src/test/resources/core/InterfaceDeclaration_02.groovy
new file mode 100644
index 0000000..a6e49ba
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/InterfaceDeclaration_02.groovy
@@ -0,0 +1,60 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package core
+
+import java.sql.SQLException
+
+public interface AA1 {
+        int a;
+        long b;
+        double c;
+        char d;
+        short e;
+        byte f;
+        float g;
+        boolean h;
+        String i;
+
+        public static final NAME = "AA1"
+
+        @Test3
+        public static final NAME2 = "AA1"
+
+        void sayHello();
+        abstract void sayHello2();
+        public void sayHello3();
+        public abstract void sayHello4();
+        @Test2
+        public abstract void sayHello5();
+
+        @Test2
+        public abstract void sayHello6() throws IOException, SQLException;
+
+        @Test2
+        @Test3
+        public abstract <T> T sayHello7() throws IOException, SQLException;
+
+        @Test2
+        @Test3
+        public abstract <T extends A> T sayHello8() throws IOException, SQLException;
+
+        @Test2
+        @Test3
+        public abstract <T extends A & B> T sayHello9() throws IOException, SQLException;
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/InterfaceDeclaration_03.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/InterfaceDeclaration_03.groovy b/subprojects/parser-antlr4/src/test/resources/core/InterfaceDeclaration_03.groovy
new file mode 100644
index 0000000..9c78681
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/InterfaceDeclaration_03.groovy
@@ -0,0 +1,25 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+interface Koo {
+    class Inner {}
+}
+
+interface Koo2 {
+    public static final Inner INNER = new Inner() {}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Label_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Label_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/Label_01.groovy
new file mode 100644
index 0000000..9e9645b
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Label_01.groovy
@@ -0,0 +1,33 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+a: assert true;
+a: assert true
+a:
+assert true;
+a:
+assert true
+
+
+before:
+setup:
+int a = 1
+int b = 1
+expect:
+a == b
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Lambda_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Lambda_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/Lambda_01x.groovy
new file mode 100644
index 0000000..5c147ac
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Lambda_01x.groovy
@@ -0,0 +1,66 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+assert 9 == [1, 2, 3].stream().map(e -> e + 1).reduce(0, (r, e) -> r + e)
+assert 9 == [1, 2, 3].stream().map(e -> {e + 1}).reduce(0, (r, e) -> r + e)
+assert 9 == [1, 2, 3].stream().map((e) -> e + 1).reduce(0, (r, e) -> r + e)
+assert 9 == [1, 2, 3].stream().map((e) -> e + 1).reduce(0, (r, e) -> {r + e})
+assert 32 == ((e) -> e + 1)(2) + ((e, f) -> e + f)(2, 3) + ((e, f, g) -> e * f * g)(2, 3, 4)
+
+assert 24 == ((e, f, g) -> {e * f * g})(2, 3, 4)
+assert 24 == ((int e, int f, int g) -> {
+    int tmpE = e;
+    int tmpF = f;
+    int tmpG = g;
+    return tmpE * tmpF * tmpG;
+})(2, 3, 4)
+assert 24 == ((int e, int f, int g=4) -> {
+    int tmpE = e;
+    int tmpF = f;
+    int tmpG = g;
+    return tmpE * tmpF * tmpG;
+})(2, 3)
+
+def list = [2, 3, 1]
+Collections.sort(list, (n1, n2) -> n1 <=> n2)
+assert [1, 2, 3] == list
+
+assert 1 == (e -> e)(1)
+assert 2 == (() -> 2)()
+
+def lambda = e -> e;
+assert 1 == lambda(1)
+
+lambda = e -> e + 1;
+assert 2 == lambda(1)
+
+int sum = 0;
+[1, 2, 3].forEach(e -> {
+    sum += e
+})
+assert 6 == sum;
+
+def c = { (e) -> e * 2 }
+assert 6 == c()(3)
+
+c = { (e) -> { e * 2 } }
+assert 6 == c()(3)
+
+assert ['1', '2', '3'] == [0, 1, 2].collect(e -> String.valueOf e + 1)
+assert [3, 4, 5] == ['0', '1', '2'].collect(e -> Integer.parseInt e plus 1 plus 2)
+assert [4] == ['0'].collect(e -> e.length() plus 1 plus 2)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/List_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/List_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/List_01.groovy
new file mode 100644
index 0000000..f7c122e
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/List_01.groovy
@@ -0,0 +1,33 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+[]
+[
+        
+]
+[1, 2, 3]
+[1, 2, 3,]
+[[1, 2, 3], 2, 3]
+[
+        [1,
+         2,
+         3],
+        2,
+        3]
+
+[1, *[2, 3, 4], 5, 6, *[7, 8], *[9]]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Literal_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Literal_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/Literal_01.groovy
new file mode 100644
index 0000000..c3a1f3a
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Literal_01.groovy
@@ -0,0 +1,97 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+null
+true
+false
+
+
+1
+12
+123
+
+1.2
+1.2f
+1.2F
+1.2d
+1.2D
+1.2g
+1.2G
+
+0x1234567890abcdef
+0X1234567890ABCDEF
+0x1234567890abcdefi
+0x1234567890abcdefl
+0x1234567890abcdefg
+0x1234567890abcdefI
+0x1234567890abcdefL
+0x1234567890abcdefG
+0xabcdef
+0xABCDEF
+0xABCDEF
+0xabcdef
+0xABCDEF
+
+01234567
+01234567
+01234567
+01234567i
+01234567l
+01234567g
+01234567I
+01234567L
+01234567G
+
+1__2
+2_12_3
+2__12__3
+2__12__3.1__2
+2__12__3.1__2
+12e10
+12e-10
+12e10
+12e-10
+12.12e10
+12.12e-10
+12.12e10
+12.12e-10
+12.12e-10f
+12.12e-10d
+12.12e-10g
+12e-10F
+120e-10D
+11F
+12D
+1.1F
+1.2D
+12e-10G
+12.1__2e-10f
+12.1_2e-10d
+1__12_2.12e-10g
+0xab__cdef
+0xAB__CD_EF
+012__34567L
+
+0b010101
+0B10101011
+0B10101011i
+0B10101011I
+0B10101011l
+0B10101011L
+0B10101011g
+0B10101011G
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Literal_02.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Literal_02.groovy b/subprojects/parser-antlr4/src/test/resources/core/Literal_02.groovy
new file mode 100644
index 0000000..de55750
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Literal_02.groovy
@@ -0,0 +1,66 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+'123'
+'abc'
+'a1b2c3'
+'a\tb\tc'
+'a\nb\r\nc'
+'$a$b$c'
+'$1$2$3'
+'$1$2\$3'
+'\$1\$2\$3\
+  hello world\
+'
+"\$1\$2\$3\
+  hello world\
+"
+' nested "double quotes" '
+" nested 'quotes' "
+' \6 1 digit is escaped'
+' \665 2 digits are escaped, \'5\' is a character.'
+' \3666 3 digits are escaped'
+' \166 '
+" \166 "
+' \u1234 '
+
+'''abc'''
+'''123'''
+'''
+            ''hello world''
+            'hello'
+            ''world'
+            'hi''
+            \
+            \t\r\n
+            $\$
+            \u1234
+            \123
+'''
+
+"""
+            ''hello world''
+            'hello'
+            ''world'
+            'hi''
+            \
+            \t\r\n
+            \$
+            \u1234
+            \123
+"""

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Literal_03.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Literal_03.groovy b/subprojects/parser-antlr4/src/test/resources/core/Literal_03.groovy
new file mode 100644
index 0000000..865596b
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Literal_03.groovy
@@ -0,0 +1,21 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+/\123 \/ abc \u1234 \r\n\$/
+
+$/\123 \/ abc \u1234 \r\n/$

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/LocalVariableDeclaration_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/LocalVariableDeclaration_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/LocalVariableDeclaration_01.groovy
new file mode 100644
index 0000000..7db2948
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/LocalVariableDeclaration_01.groovy
@@ -0,0 +1,128 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import groovy.transform.Field
+
+int a;
+int b = 1;
+int c =
+        1;
+final d = 1;
+@Test2 e = 1;
+@Test2 final f = 1;
+final
+@Test2 g = 1;
+
+int h, i = 1;
+int j,
+        k =
+                1;
+int l =
+        2,
+    m =
+            1;
+int n =
+        1
+int o =
+        2,
+    p =
+            1
+
+List list = [1, 2 + 6, [1, 2 + 3]]
+List list2 =
+        [
+                1,
+         2 +
+                6,
+                [1,
+                 2 +
+                         3]
+        ]
+
+def (int x, int y) = [1, 2]
+
+@Test2
+def
+        (int q,
+                int r) =
+                        [1, 2]
+
+def (int s, int t) = otherTuple
+
+def (int w, z) = [1, 2]
+def (a2, int b2) = [1, 2]
+
+def (u, v) = [1, 2]
+
+def (int c2, String d2, java.lang.Double e2) = [1, '2', 3.3D]
+
+def cc = {
+        String bb = 'Test'
+        return bb;
+}
+
+int xx = b c d e
+
+@Field static List list = [1, 2, 3]
+
+if (false)
+        def a = 5
+
+if(false)
+        def a, b = 10
+
+if(false)
+        def a = 9, b = 10
+
+if (false)
+        def a = 5
+else
+        def b = 2
+
+if(false)
+        def a, b = 10
+else
+        def a, b = 8
+
+if(false)
+        def a = 9, b = 10
+else
+        def a = 6, b = 8
+
+while(false)
+        def a = 5
+
+while(false)
+        def a, b = 10
+
+while(false)
+        def a = 9, b = 10
+
+for(;;)
+        def a = 5
+
+for(;;)
+        def a, b = 10
+
+for(;;)
+        def a = 9, b = 10
+
+
+
+Class<String>[] c
+Class<?>[] c2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Map_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Map_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/Map_01.groovy
new file mode 100644
index 0000000..bcc0f3e
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Map_01.groovy
@@ -0,0 +1,47 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+[a: 1, b: 2, c: 3]
+[(a): 1, (b**2): x, c: 2 + 3]
+['a': '1', 'b': 2, 'c': '3']
+[1: 2, 2: 3, 3: 4]
+[1.1: 2, 2.2: 3, 3.3: 4]
+[
+        (a)
+        :
+                1
+        ,
+        (
+                b**2
+        )
+        :
+                x
+        ,
+        c
+        :
+                2 +
+                        3
+]
+
+[(a): '1', *: [(a + 1): 1, (b): 2], *: ['a': 1 + 2]]
+
+[:]
+[
+        :
+]
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/MethodDeclaration_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/MethodDeclaration_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/MethodDeclaration_01.groovy
new file mode 100644
index 0000000..e7220e0
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/MethodDeclaration_01.groovy
@@ -0,0 +1,50 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+int plus(int a, int b) {
+        return a + b;
+}
+
+int plus2(int a,
+          int b)
+{
+        return a + b;
+}
+
+int plus3(int a,
+          int b)
+throws
+        Exception1,
+        Exception2
+{
+        return a + b;
+}
+
+def <T> T someMethod() {}
+def <T extends List> T someMethod2() {}
+def <T extends A & B> T someMethod3() {}
+
+static m(a) {}
+static m2(a, b) {}
+static m3(a, b, c) {}
+static Object m4(a, b, c) {}
+
+private String relativePath() { '' }
+def foo() {}
+
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/MethodDeclaration_02.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/MethodDeclaration_02.groovy b/subprojects/parser-antlr4/src/test/resources/core/MethodDeclaration_02.groovy
new file mode 100644
index 0000000..91879a9
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/MethodDeclaration_02.groovy
@@ -0,0 +1,59 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+final int plus(int a, int b) {
+        return a + b;
+}
+
+final plus(int a, int b) {
+        return a + b;
+}
+
+@Test2 plus(int a, int b) {
+        return a + b;
+}
+
+@Test2
+int plus(int a, int b) {
+        return a + b;
+}
+
+@Test2
+final int plus(int a, int b) {
+        return a + b;
+}
+
+@Test2
+@Test3
+synchronized final int plus(int a, int b) {
+        return a + b;
+}
+
+
+public void someMethod (java.lang.Class<String> clazz) {}
+public void someMethod2 (java.lang.Class clazz) {}
+public boolean someMethod3 (java.util.List<String> list) {
+        list instanceof java.util.List
+}
+
+/* return element i,j of infinite matrix A */
+def A(i, j) {
+        return 1.0D / ((i+j) * (i + j + 1.0D) / 2.0D  + i + 1.0D)
+}
+
+String m(Integer a, ... params) {}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/MethodPointer_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/MethodPointer_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/MethodPointer_01x.groovy
new file mode 100644
index 0000000..eaddb93
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/MethodPointer_01x.groovy
@@ -0,0 +1,23 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+def shell = new GroovyShell()
+assert shell.evaluate("x = String.&toUpperCase; x('abc')") == "ABC"
+assert shell.evaluate("x = 'abc'.&toUpperCase; x()") == "ABC"
+assert shell.evaluate("x = Integer.&parseInt; x('123')") == 123
+assert shell.evaluate("x = 3.&parseInt; x('123')") == 123
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/MethodReference_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/MethodReference_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/MethodReference_01x.groovy
new file mode 100644
index 0000000..a31b5b8
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/MethodReference_01x.groovy
@@ -0,0 +1,103 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import java.util.stream.Collectors
+
+// class::staticMethod
+assert ['1', '2', '3'] == [1, 2, 3].stream().map(Integer::toString).collect(Collectors.toList())
+
+// class::instanceMethod
+assert ['A', 'B', 'C'] == ['a', 'b', 'c'].stream().map(String::toUpperCase).collect(Collectors.toList())
+
+
+
+def robot = new Robot();
+
+// instance::instanceMethod
+assert ['Hi, Jochen', 'Hi, Paul', 'Hi, Daniel'] == [new Person('Jochen'), new Person('Paul'), new Person('Daniel')].stream().map(robot::greet).collect(Collectors.toList())
+
+// class::staticMethod
+assert ['Jochen', 'Paul', 'Daniel'] == [new Person('Jochen'), new Person('Paul'), new Person('Daniel')].stream().map(Person::getText).collect(Collectors.toList())
+assert ['Jochen', 'Paul', 'Daniel'] == [new Person('Jochen'), new Person('Paul'), new Person('Daniel')].stream().map(BasePerson::getText).collect(Collectors.toList())
+
+// instance::staticMethod
+assert ['J', 'P', 'D'] == [new Person('Jochen'), new Person('Paul'), new Person('Daniel')].stream().map(robot::firstCharOfName).collect(Collectors.toList())
+
+// class::instanceMethod
+assert ['Jochen', 'Paul', 'Daniel'] == [new Person('Jochen'), new Person('Paul'), new Person('Daniel')].stream().map(Person::getName).collect(Collectors.toList())
+
+
+// ----------------------------------
+class BasePerson {
+    public static String getText(Person p) {
+        return p.name;
+    }
+}
+
+class Person extends BasePerson {
+    private String name;
+
+    public Person(String name) {
+        this.name = name
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+}
+class Robot {
+    public String greet(Person p) {
+        return "Hi, ${p.name}"
+    }
+
+    public static char firstCharOfName(Person p) {
+        return p.getName().charAt(0);
+    }
+}
+
+def mr = String::toUpperCase
+assert 'ABC' == mr('abc')
+assert 'ABC' == String::toUpperCase('abc')
+
+assert new HashSet() == HashSet::new()
+assert new String() == String::new()
+assert 1 == Integer::new(1)
+assert new String[0] == String[]::new(0)
+assert new String[0] == String[]::new('0')
+assert new String[1][2] == String[][]::new(1, 2)
+assert new String[1][2][3] == String[][][]::new(1, 2, 3)
+
+assert [new String[1], new String[2], new String[3]] == [1, 2, 3].stream().map(String[]::new).collect(Collectors.toList())
+assert [1, 2, 3] as String[] == [1, 2, 3].stream().map(String::valueOf).toArray(String[]::new)
+
+
+def a = String[][]::new(1, 2)
+def b = new String[1][2]
+assert a.class == b.class && a == b
+
+a = String[][][]::new(1, 2)
+b = new String[1][2][]
+assert a.class == b.class && a == b
+
+a = String[][][][]::new(1, 2)
+b = new String[1][2][][]
+assert a.class == b.class && a == b
+
+
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/NegativeRelationalOperators_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/NegativeRelationalOperators_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/NegativeRelationalOperators_01x.groovy
new file mode 100644
index 0000000..7c91cd3
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/NegativeRelationalOperators_01x.groovy
@@ -0,0 +1,39 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+assert 'a' instanceof String
+assert 'a' !instanceof Integer
+assert 1 !instanceof String
+assert null !instanceof String
+assert 1 in [1, 2]
+assert 3 !in [1, 2]
+assert 3 !in ['1', '2']
+assert '3' !in [1, 2]
+assert '3' !in ['1', '2']
+assert null !in ['1', '2']
+assert null !in [1, 2]
+
+boolean interesting = false
+assert !interesting
+
+boolean instanceofboolean = false
+assert !instanceofboolean
+
+assert 1 !in[2, 3]
+assert 1 !in([2, 3])
+assert 1 !in{return [2, 3]}()

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/NegativeRelationalOperators_02x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/NegativeRelationalOperators_02x.groovy b/subprojects/parser-antlr4/src/test/resources/core/NegativeRelationalOperators_02x.groovy
new file mode 100644
index 0000000..1400f9f
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/NegativeRelationalOperators_02x.groovy
@@ -0,0 +1,36 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import groovy.transform.CompileStatic
+
+@CompileStatic
+def cs() {
+    assert 'a' instanceof String
+    assert 'a' !instanceof Integer
+    assert 1 !instanceof String
+    assert null !instanceof String
+    assert 1 in [1, 2]
+    assert 3 !in [1, 2]
+    assert 3 !in ['1', '2']
+    assert '3' !in [1, 2]
+    assert '3' !in ['1', '2']
+    assert null !in ['1', '2']
+    assert null !in [1, 2]
+}
+
+cs();
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_01.groovy
new file mode 100644
index 0000000..17619c2
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_01.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package com.groovyhelp.core
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_02.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_02.groovy b/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_02.groovy
new file mode 100644
index 0000000..ec6d67f
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_02.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package com.groovyhelp.core

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_03.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_03.groovy b/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_03.groovy
new file mode 100644
index 0000000..6114f1c
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_03.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package com.groovyhelp.core;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_04.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_04.groovy b/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_04.groovy
new file mode 100644
index 0000000..88b48aa
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_04.groovy
@@ -0,0 +1,38 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+#!/usr/bin/env groovy
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package com.groovyhelp.core;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_05.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_05.groovy b/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_05.groovy
new file mode 100644
index 0000000..c60b3c3
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_05.groovy
@@ -0,0 +1,41 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+#!/usr/bin/env groovy
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package com.groovyhelp.core;
+/**
+ * Created by Daniel.Sun on 2016/08/17.
+ */
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_06.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_06.groovy b/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_06.groovy
new file mode 100644
index 0000000..313cc8f
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/PackageDeclaration_06.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package def.in.as.trait;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Return_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Return_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/Return_01.groovy
new file mode 100644
index 0000000..2f0f983
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Return_01.groovy
@@ -0,0 +1,26 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+return
+return;
+return 1;
+return 2
+return
+3;
+return
+4
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/SafeIndex_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/SafeIndex_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/SafeIndex_01x.groovy
new file mode 100644
index 0000000..1cbcf66
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/SafeIndex_01x.groovy
@@ -0,0 +1,28 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+assert null == null?[1];
+assert null == null?[1]?[1, 2];
+assert null == null?[1]?[1, 2]?[1, 2, 3];
+
+def a = null;
+assert null == a?[1, 2];
+
+def f() {return null}
+assert null == f()?[1];
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/SafeIndex_02x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/SafeIndex_02x.groovy b/subprojects/parser-antlr4/src/test/resources/core/SafeIndex_02x.groovy
new file mode 100644
index 0000000..aa13c83
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/SafeIndex_02x.groovy
@@ -0,0 +1,65 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import groovy.transform.*
+
+class SomeContainer {
+    public Object getAt(int i) {
+        return "123";
+    }
+
+    public void putAt(int i, Object obj) {
+    }
+}
+
+def safe() {
+    List list = null;
+    assert null == list?[1];
+    list?[1] = 'a';
+    assert null == list?[1];
+
+    Map map = null;
+    assert null == map?[1];
+    map?[1] = 'a';
+    assert null == map?[1];
+
+    SomeContainer sc = null;
+    assert null == sc?[1];
+    sc?[1] = 'a';
+    assert null == sc?[1];
+}
+safe();
+
+@CompileStatic
+def csSafe() {
+    List list = null;
+    assert null == list?[1];
+    list?[1] = 'a';
+    assert null == list?[1];
+
+    Map map = null;
+    assert null == map?[1];
+    map?[1] = 'a';
+    assert null == map?[1];
+
+    SomeContainer sc = null;
+    assert null == sc?[1];
+    sc?[1] = 'a';
+    assert null == sc?[1];
+}
+csSafe();

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/SafeIndex_03x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/SafeIndex_03x.groovy b/subprojects/parser-antlr4/src/test/resources/core/SafeIndex_03x.groovy
new file mode 100644
index 0000000..d94d414
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/SafeIndex_03x.groovy
@@ -0,0 +1,298 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import groovy.transform.*
+
+@CompileStatic
+def csObjArray() {
+    String[] array = ['a', 'b'];
+    assert 'b' == array?[1];
+
+    array?[1] = 'c';
+    assert 'c' == array?[1];
+
+    array = null;
+    assert null == array?[1];
+
+    array?[1] = 'c';
+    assert null == array?[1];
+}
+csObjArray();
+
+def objArray() {
+    String[] array = ['a', 'b'];
+    assert 'b' == array?[1];
+
+    array?[1] = 'c';
+    assert 'c' == array?[1];
+
+    array = null;
+    assert null == array?[1];
+
+    array?[1] = 'c';
+    assert null == array?[1];
+}
+objArray();
+
+@CompileStatic
+def csBooleanArray() {
+    boolean[] array = [true, false];
+    assert false == array?[1];
+
+    array?[1] = true;
+    assert true == array?[1];
+
+    array = null;
+    assert null == array?[1];
+
+    array?[1] = true;
+    assert null == array?[1];
+}
+csBooleanArray();
+
+def booleanArray() {
+    boolean[] array = [true, false];
+    assert false == array?[1];
+
+    array?[1] = true;
+    assert true == array?[1];
+
+    array = null;
+    assert null == array?[1];
+
+    array?[1] = true;
+    assert null == array?[1];
+}
+booleanArray();
+
+@CompileStatic
+def csCharArray() {
+    char[] array = ['a' as char, 'b' as char];
+    assert ('b' as char) == array?[1];
+
+    array?[1] = 'c';
+    assert ('c' as char) == array?[1];
+
+    array = null;
+    assert null == array?[1];
+
+    array?[1] = 'c';
+    assert null == array?[1];
+}
+csCharArray();
+
+def charArray() {
+    char[] array = ['a' as char, 'b' as char];
+    assert ('b' as char) == array?[1];
+
+    array?[1] = 'c';
+    assert ('c' as char) == array?[1];
+
+    array = null;
+    assert null == array?[1];
+
+    array?[1] = 'c';
+    assert null == array?[1];
+}
+charArray();
+
+@CompileStatic
+def csByteArray() {
+    byte[] array = [1 as byte, 2 as byte];
+    assert (2 as byte) == array?[1];
+
+    array?[1] = 3 as byte;
+    assert (3 as byte) == array?[1];
+
+    array = null;
+    assert null == array?[1];
+
+    array?[1] = 3 as byte;
+    assert null == array?[1];
+}
+csByteArray();
+
+def byteArray() {
+    byte[] array = [1 as byte, 2 as byte];
+    assert (2 as byte) == array?[1];
+
+    array?[1] = 3 as byte;
+    assert (3 as byte) == array?[1];
+
+    array = null;
+    assert null == array?[1];
+
+    array?[1] = 3 as byte;
+    assert null == array?[1];
+}
+byteArray();
+
+@CompileStatic
+def csShortArray() {
+    short[] array = [1 as short, 2 as short];
+    assert (2 as short) == array?[1];
+
+    array?[1] = 3 as short;
+    assert (3 as short) == array?[1];
+
+    array = null;
+    assert null == array?[1];
+
+    array?[1] = 3 as short;
+    assert null == array?[1];
+}
+csShortArray();
+
+def shortArray() {
+    short[] array = [1 as short, 2 as short];
+    assert (2 as short) == array?[1];
+
+    array?[1] = 3 as short;
+    assert (3 as short) == array?[1];
+
+    array = null;
+    assert null == array?[1];
+
+    array?[1] = 3 as short;
+    assert null == array?[1];
+}
+shortArray();
+
+@CompileStatic
+def csIntArray() {
+    int[] array = [1, 2];
+    assert 2 == array?[1];
+
+    array?[1] = 3;
+    assert 3 == array?[1];
+
+    array = null;
+    assert null == array?[1];
+
+    array?[1] = 3;
+    assert null == array?[1];
+}
+csIntArray();
+
+def intArray() {
+    int[] array = [1, 2];
+    assert 2 == array?[1];
+
+    array?[1] = 3;
+    assert 3 == array?[1];
+
+    array = null;
+    assert null == array?[1];
+
+    array?[1] = 3;
+    assert null == array?[1];
+}
+intArray();
+
+@CompileStatic
+def csLongArray() {
+    long[] array = [1L, 2L];
+    assert 2L == array?[1];
+
+    array?[1] = 3L;
+    assert 3L == array?[1];
+
+    array = null;
+    assert null == array?[1];
+
+    array?[1] = 3L;
+    assert null == array?[1];
+}
+csLongArray();
+
+def longArray() {
+    long[] array = [1L, 2L];
+    assert 2L == array?[1];
+
+    array?[1] = 3L;
+    assert 3L == array?[1];
+
+    array = null;
+    assert null == array?[1];
+
+    array?[1] = 3L;
+    assert null == array?[1];
+}
+longArray();
+
+@CompileStatic
+def csFloatArray() {
+    float[] array = [1.1f, 2.2f];
+    assert 2.2f == array?[1];
+
+    array?[1] = 3.3f;
+    assert 3.3f == array?[1];
+
+    array = null;
+    assert null == array?[1];
+
+    array?[1] = 3.3f;
+    assert null == array?[1];
+}
+csFloatArray();
+
+def floatArray() {
+    float[] array = [1.1f, 2.2f];
+    assert 2.2f == array?[1];
+
+    array?[1] = 3.3f;
+    assert 3.3f == array?[1];
+
+    array = null;
+    assert null == array?[1];
+
+    array?[1] = 3.3f;
+    assert null == array?[1];
+}
+floatArray();
+
+@CompileStatic
+def csDoubleArray() {
+    double[] array = [1.1d, 2.2d];
+    assert 2.2d == array?[1];
+
+    array?[1] = 3.3d;
+    assert 3.3d == array?[1];
+
+    array = null;
+    assert null == array?[1];
+
+    array?[1] = 3.3d;
+    assert null == array?[1];
+}
+csDoubleArray();
+
+def doubleArray() {
+    double[] array = [1.1d, 2.2d];
+    assert 2.2d == array?[1];
+
+    array?[1] = 3.3d;
+    assert 3.3d == array?[1];
+
+    array = null;
+    assert null == array?[1];
+
+    array?[1] = 3.3d;
+    assert null == array?[1];
+}
+doubleArray();
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Script_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Script_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/Script_01x.groovy
new file mode 100644
index 0000000..0e47db0
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Script_01x.groovy
@@ -0,0 +1,23 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+protected String getGroovySql() {
+    return "abc"
+}
+
+assert "abc" == getGroovySql()

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Switch_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Switch_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/Switch_01.groovy
new file mode 100644
index 0000000..f26d15b
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Switch_01.groovy
@@ -0,0 +1,78 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+switch (a) {
+    case 1:
+        break;
+    case 2:
+        break;
+}
+
+switch (a) {
+    case 1:
+        break;
+    case 2:
+        break;
+    default:
+        break;
+}
+
+switch (a) {
+    case 1:
+    case 2:
+        break;
+    case 3:
+        break;
+    default:
+        break;
+}
+
+switch (a) {
+    case 1:
+    case 2 + 3:
+        break;
+    case 3:
+        break;
+    case 4 + 2:
+    case 5:
+    default:
+        break;
+}
+
+switch (a) {
+    case 1:
+    case 2 + 3: break;
+    case 3: break;
+    case 4 + 2:
+    case 5:
+    default: break;
+}
+
+switch (a) {case 1:
+    case 2 + 3: break;
+    case 3: break;
+    case 4 + 2:
+    case 5:
+    default: break;}
+
+switch (a) {
+    case 1:
+        int x = 1;
+    default:
+        int y = 2;
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Synchronized_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Synchronized_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/Synchronized_01.groovy
new file mode 100644
index 0000000..bc1bc88
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Synchronized_01.groovy
@@ -0,0 +1,54 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+synchronized ('a')
+{
+    assert true
+}
+
+synchronized ('a') {
+    assert true
+}
+
+synchronized ('a') {assert true
+}
+
+synchronized ('a') {assert true}
+
+synchronized ('a') {assert true;}
+
+synchronized ('a') {
+    assert true
+    assert true
+}
+
+synchronized ('a') {
+    assert true;
+    assert true
+}
+
+synchronized ('a') {
+    assert true; assert true
+}
+
+synchronized ('a') {assert true; assert true
+}
+
+synchronized ('a') {assert true; assert true}
+
+synchronized ('a') {assert true; assert true;}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Throw_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Throw_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/Throw_01.groovy
new file mode 100644
index 0000000..f78903c
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Throw_01.groovy
@@ -0,0 +1,20 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+throw e;
+throw e
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_01.groovy
new file mode 100644
index 0000000..b5ed026
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_01.groovy
@@ -0,0 +1,60 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package core
+
+trait A {}
+trait B<T> {}
+trait C<T extends A> {}
+trait D<T extends A & B> {}
+trait E<T extends A & B & C> {}
+trait F<T extends A & B & C> extends A {}
+trait F2 extends A<T> {}
+trait G1<T extends A & B & C> extends A implements X {}
+trait G2<T extends A & B & C> extends A<T> implements X<T> {}
+trait G3                      extends A<T> implements X<T> {}
+trait G4                      extends A    implements X<T> {}
+trait G5                      extends A    implements X    {}
+trait G2<T extends A & B & C> extends A<T> implements X<T> {}
+trait H<T extends A & B & C> extends A implements X, Y {}
+trait I<T extends A & B & C> extends A implements X, Y, Z {}
+public trait J<T extends A & B & C> extends A implements X, Y, Z {}
+@Test2 public trait K<T extends A & B & C> extends A implements X, Y, Z {}
+@Test2 @Test3 public trait L<T extends A & B & C> extends A implements X, Y, Z {}
+
+@Test2
+@Test3
+public
+trait M
+<
+        T extends
+        A &
+        B &
+        C
+>
+extends
+A
+implements
+X,
+Y,
+Z
+        {
+
+        }
+
+trait t {}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_02.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_02.groovy b/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_02.groovy
new file mode 100644
index 0000000..6820b1f
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_02.groovy
@@ -0,0 +1,58 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+trait AA {
+    {
+        println 123
+    }
+}
+
+trait BB {
+    static {
+        println '123'
+    }
+}
+
+trait CC {
+    static
+    {
+        println '123'
+    }
+}
+
+trait DD {
+    static {
+        println '123'
+    }
+
+    {
+        println 'abc'
+    }
+
+    static {
+        println '234'
+    }
+
+    {
+        println 'bcd'
+    }
+}
+
+trait EE {{}}
+trait FF {static {}}
+trait GG {static {};{}}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_03.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_03.groovy b/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_03.groovy
new file mode 100644
index 0000000..2a68103
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_03.groovy
@@ -0,0 +1,66 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import java.sql.SQLException
+
+trait AAA {
+    public AAA() {
+
+    }
+
+    public AAA(String name) {
+
+    }
+
+    @Test2
+    public AAA(String name, int age) throws Exception {
+
+    }
+
+    AAA(String name, int age, String title) throws Exception {
+
+    }
+
+    private AAA(String name, int age, String title, double income) throws Exception {
+
+    }
+
+    @Test2
+    public String sayHello(String name) {
+        return "Hello, $name";
+    }
+
+    @Test2
+    public <T> T sayHello2(T name) throws IOException, SQLException {
+        return "Hello, $name";
+    }
+
+    public static privateStaticMethod(){}
+
+    public void m(final int param) {}
+    public void m2(def param) {}
+    public void m3(final int param1, long param2, final String param3) {}
+
+    def "hello world"(p1, p2) {
+        println "$p1, $p2"
+    }
+
+    def run() {
+        this."hello world"('ab', 'bc')
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_04.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_04.groovy b/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_04.groovy
new file mode 100644
index 0000000..7cd679c
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_04.groovy
@@ -0,0 +1,46 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+public trait Person {
+    public static final SOME_CONSTANT = 'SOME_CONSTANT';
+    private String name = 'Daniel';
+    private int age;
+    @Test2
+    private String country = 'China',
+            location = 'Shanghai';
+
+    private String field, field2 = 'field2';
+    String someProperty;
+    String someProperty2 = 'someProperty2';
+    String someProperty3 = 'someProperty3',
+            someProperty4 = 'someProperty4';
+    String someProperty5, someProperty6 = 'someProperty6';
+    final String someProperty7 = 'someProperty7';
+    static final String someProperty8 = 'someProperty8';
+
+    @Test3
+    static final String someProperty9 = 'someProperty9';
+
+    protected static def protectedStaticDefField;
+}
+
+trait xx {
+    class yy {
+        enum zz {}
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_05.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_05.groovy b/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_05.groovy
new file mode 100644
index 0000000..625074e
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/TraitDeclaration_05.groovy
@@ -0,0 +1,41 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+trait SwimmingAbility {
+    def swim() {
+        prt("swimming..")
+    }
+
+    abstract String prt(String msg);
+}
+
+trait FlyingAbility {
+    def fly() {
+        println "flying.."
+    }
+}
+
+class Duck implements SwimmingAbility, FlyingAbility {
+    String prt(String msg) {
+        println msg + " happily";
+    }
+}
+
+def duck = new Duck()
+duck.swim()
+duck.fly()

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/TryCatch_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/TryCatch_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/TryCatch_01.groovy
new file mode 100644
index 0000000..d09e1c3
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/TryCatch_01.groovy
@@ -0,0 +1,130 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import java.sql.SQLException
+
+try {
+    assert true;
+} finally {
+    return 0;
+}
+
+try {
+    assert true;
+} catch(Exception e) {
+    assert false;
+}
+
+try {
+    assert true;
+} catch(Exception
+            e) {
+    assert false;
+}
+
+try {
+    assert true;
+} catch(e) {
+    assert false;
+}
+
+try {
+    assert true;
+} catch(e) {
+    assert false;
+} catch(t) {
+    assert false;
+}
+
+try {
+    assert true;
+} catch(final e) {
+    assert false;
+}
+
+try {
+    assert true;
+} catch(final Exception e) {
+    assert false;
+}
+
+try {
+    assert true;
+} catch(IOException e) {
+    assert false;
+} catch(Exception e) {
+    assert false;
+}
+
+try {
+    assert true;
+} catch(IOException e) {
+    assert false;
+} catch(Exception e) {
+    assert false;
+} finally {
+    return 0;
+}
+
+try
+{
+    assert true;
+}
+catch(IOException e)
+{
+    assert false;
+}
+catch(Exception e)
+{
+    assert false;
+}
+finally
+{
+    return 0;
+}
+
+try {
+    assert true;
+} catch(Exception e) {
+    assert false;
+} finally {
+    return 0;
+}
+
+try {
+    assert true;
+} catch(NullPointerException | IOException e) {
+    assert false;
+} finally {
+    return 0;
+}
+
+try {
+    assert true;
+} catch(NullPointerException | IOException e) {
+    assert false;
+}
+
+try {
+    assert true;
+} catch(NullPointerException |
+        IOException |
+        SQLException
+                e) {
+    assert false;
+}

Reply | Threaded
Open this post in threaded view
|

[03/17] groovy git commit: rename antlr4 parser to remove groovy- prefix since that is by convention for modules

paulk
In reply to this post by paulk
http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_01.groovy
new file mode 100644
index 0000000..ed0f67d
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_01.groovy
@@ -0,0 +1,62 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+enum AAAA {}
+public enum AAAA2 {}
+public enum AAAA3 implements A {}
+@Test2
+public enum AAAA4 implements A,B {}
+enum BBBB {A}
+enum CCCC {A, B}
+enum DDDD {A, B,}
+enum EEEE {
+    A,
+    B}
+enum FFFF {
+    A,
+    B,}
+enum GGGG
+{A,
+B,}
+
+enum E1 {
+    A(111,'aa'), B(222,'bb')
+}
+
+@Test2
+enum E2 {
+    A2,
+    B2,C2,
+    D2
+    private void a() {}
+    def c;
+}
+
+enum E3 {
+    A(1), B(2)
+
+    public static final String SOME_CONSTANT = '123';
+    private String name;
+    private int age = 2;
+    String title = "title"
+    public E9(int x) {}
+}
+
+
+
+enum e {}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_02.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_02.groovy b/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_02.groovy
new file mode 100644
index 0000000..a5768db
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_02.groovy
@@ -0,0 +1,70 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+enum E {
+    A() {}, B(1) {{}},
+    C(1, 2) {
+        public void prt() {
+            println "$x, $y"
+        }
+
+        void prt2() {
+            println "$x, $y"
+        }
+
+        @Test2 prt3() {
+            println "$x, $y"
+        }
+
+        private void prt4() {
+            println "$x, $y"
+        }
+
+        private prt5() {
+            println "$x, $y"
+        }
+    },
+    D {
+        void hello() {}
+    }
+
+    protected int x;
+    protected int y;
+
+    E() {}
+    E(int x) {
+        this.x = x;
+    }
+    E(int x, y) {
+        this(x)
+        this.y = y;
+    }
+
+    void prt() {
+        println "123"
+    }
+}
+
+enum F {
+    @Test2
+    A
+}
+
+enum G implements I<T> {
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_03.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_03.groovy b/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_03.groovy
new file mode 100644
index 0000000..27d3621
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_03.groovy
@@ -0,0 +1,24 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+enum H {
+    SOME_ENUM_CONSTANT0(a: "0"),
+    SOME_ENUM_CONSTANT1(a: "0") {},
+    SOME_ENUM_CONSTANT2(a: "1", b: "2"),
+    SOME_ENUM_CONSTANT3(c: "3", d: "4") {}
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_04.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_04.groovy b/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_04.groovy
new file mode 100644
index 0000000..b923828
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_04.groovy
@@ -0,0 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+enum ListEnum1 {
+    ONE([111, 222])
+    ListEnum1(Object listArg){}
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_05.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_05.groovy b/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_05.groovy
new file mode 100644
index 0000000..bdeb296
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/EnumDeclaration_05.groovy
@@ -0,0 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+enum ListEnum1 {
+    ONE([111, 222]) {}
+    ListEnum1(Object listArg){}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_01.groovy
new file mode 100644
index 0000000..575439a
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_01.groovy
@@ -0,0 +1,248 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+-1
+-12
+-123
+
+-1.2
+-1.2f
+-1.2F
+-1.2d
+-1.2D
+-1.2g
+-1.2G
+
+-0x1234567890abcdef
+-0X1234567890ABCDEF
+-0x1234567890abcdefi
+-0x1234567890abcdefl
+-0x1234567890abcdefg
+-0x1234567890abcdefI
+-0x1234567890abcdefL
+-0x1234567890abcdefG
+-0xabcdef
+-0xABCDEF
+-0xABCDEF
+-0xabcdef
+-0xABCDEF
+
+-01234567
+-01234567
+-01234567
+-01234567i
+-01234567l
+-01234567g
+-01234567I
+-01234567L
+-01234567G
+
+-1__2
+-2_12_3
+-2__12__3
+-2__12__3.1__2
+-2__12__3.1__2
+-12e10
+-12e-10
+-12e10
+-12e-10
+-12.12e10
+-12.12e-10
+-12.12e10
+-12.12e-10
+-12.12e-10f
+-12.12e-10d
+-12.12e-10g
+-12e-10F
+-120e-10D
+-11F
+-12D
+-1.1F
+-1.2D
+-12e-10G
+-12.1__2e-10f
+-12.1_2e-10d
+-1__12_2.12e-10g
+-0xab__cdef
+-0xAB__CD_EF
+-012__34567L
+
+-0b010101
+-0B10101011
+
++1
++12
++123
+
++1.2
++1.2f
++1.2F
++1.2d
++1.2D
++1.2g
++1.2G
+
++0x1234567890abcdef
++0X1234567890ABCDEF
++0x1234567890abcdefi
++0x1234567890abcdefl
++0x1234567890abcdefg
++0x1234567890abcdefI
++0x1234567890abcdefL
++0x1234567890abcdefG
++0xabcdef
++0xABCDEF
++0xABCDEF
++0xabcdef
++0xABCDEF
+
++01234567
++01234567
++01234567
++01234567i
++01234567l
++01234567g
++01234567I
++01234567L
++01234567G
+
++1__2
++2_12_3
++2__12__3
++2__12__3.1__2
++2__12__3.1__2
++12e10
++12e-10
++12e10
++12e-10
++12.12e10
++12.12e-10
++12.12e10
++12.12e-10
++12.12e-10f
++12.12e-10d
++12.12e-10g
++12e-10F
++120e-10D
++11F
++12D
++1.1F
++1.2D
++12e-10G
++12.1__2e-10f
++12.1_2e-10d
++1__12_2.12e-10g
++0xab__cdef
++0xAB__CD_EF
++012__34567L
+
++0b010101
++0B10101011
+
+~1
+~12
+~123
+
+~1.2
+~1.2f
+~1.2F
+~1.2d
+~1.2D
+~1.2g
+~1.2G
+
+~0x1234567890abcdef
+~0X1234567890ABCDEF
+~0x1234567890abcdefi
+~0x1234567890abcdefl
+~0x1234567890abcdefg
+~0x1234567890abcdefI
+~0x1234567890abcdefL
+~0x1234567890abcdefG
+~0xabcdef
+~0xABCDEF
+~0xABCDEF
+~0xabcdef
+~0xABCDEF
+
+~01234567
+~01234567
+~01234567
+~01234567i
+~01234567l
+~01234567g
+~01234567I
+~01234567L
+~01234567G
+
+~1__2
+~2_12_3
+~2__12__3
+~2__12__3.1__2
+~2__12__3.1__2
+~12e10
+~12e-10
+~12e10
+~12e-10
+~12.12e10
+~12.12e-10
+~12.12e10
+~12.12e-10
+~12.12e-10f
+~12.12e-10d
+~12.12e-10g
+~12e-10F
+~120e-10D
+~11F
+~12D
+~1.1F
+~1.2D
+~12e-10G
+~12.1__2e-10f
+~12.1_2e-10d
+~1__12_2.12e-10g
+~0xab__cdef
+~0xAB__CD_EF
+~012__34567L
+
+~0b010101
+~0B10101011
+
+!true
+!false
+
++a
+-a
+
+++a
+--a
+
+int[]
+String[]
+String[][]
+
+
+1
+2147483647
+2147483648
+9223372036854775807
+9223372036854775808
+-1
+-2147483648
+-2147483649
+-9223372036854775808

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_02.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_02.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_02.groovy
new file mode 100644
index 0000000..5a65f87
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_02.groovy
@@ -0,0 +1,24 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+assert (1)
+assert (
+        1)
+assert (
+        1
+)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_03.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_03.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_03.groovy
new file mode 100644
index 0000000..f5c3819
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_03.groovy
@@ -0,0 +1,49 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+1 + 2 + 3
+'a' + 'b' + 'c'
+10 - 2 + 3 - 5 + 6 + 7
+++a + 1 - --b - 6 + ++c + 'a' + 2 - 3
+++a +
+        1 -
+        --b -
+        6 +
+        ++c +
+        'a' +
+        2 *
+        3 +
+        a++ -
+        a--
+
+1 * 2 / 3 % 4
+1 *
+        2 /
+        3 %
+        4
+
+
+1 ** 2 ** 3
+1 **
+        2 **
+        3
+
+1 + 2 * 3 - 4 / 5 + 6 % 7 - 8 ** 9
+
+
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_04.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_04.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_04.groovy
new file mode 100644
index 0000000..e8c72e0
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_04.groovy
@@ -0,0 +1,80 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+a = 1
+a = b = 1
+left >>>= 16
+left >>= 8
+left <<= 2
+sum += sup
+cantlive -= you
+times *= me
+times **= me
+slash /= nstore
+your |= me
+here %= sometimes
+water ^= oil
+a &= that
+
+a = e f g h
+a = b *= c += d %= e f g h
+
+obj.name = '123'
+m().result = 123
+map[a] = 1
+map['a'] = 1
+map["$a"] = 1
+map[a.b] = 1
+map[a()] = 1
+map[obj.a()] = 1
+map[a().result] = 1
+map[a + b] = 1
+obj.prop[0][1] = 'a'
+this = someValue;
+super = someValue;
+
+list[0] = 1
+list[1, 2] = [11, 22]
+
+(a)         = [1]
+(a)         = x++
+(a)         = (SomeType)x++
+(a)         = obj.m()
+(a)         = [1]
+(a)         = [1] + [2]
+(a, b)      = [1, 2]
+(a, b, c)   = [1, 2, 3]
+
+(obj) =
+        a =
+              b =
+                left >>>=
+                        left >>=
+                                left <<=
+                                        sum +=
+                                                cantlive -=
+                                                        times *=
+                                                                times **=
+                                                                        slash /=
+                                                                                your |=
+                                                                                        here %=
+                                                                                                water ^=
+                                                                                                        a &=
+                                                                                                                that =
+                                                                                                                        x y z
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_05.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_05.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_05.groovy
new file mode 100644
index 0000000..d195b10
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_05.groovy
@@ -0,0 +1,58 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+true ?: 'a'
+
+true
+?: 'a'
+
+true
+?:
+'a'
+
+true ? 'a' : 'b'
+
+true ?
+        'a'
+        :
+        'b'
+
+true ?
+        'a'
+        :
+        true ?: 'b'
+
+true ?
+        'a'
+        :
+        true ? 'b' : 'c'
+
+true ?: true ?: 'a'
+
+1 == 2 ?: 3
+1 == 2 ? 3 : 4
+
+1 == 2 || 1 != 3 && !(1 == 6)
+    ? 2 > 3 && 3 >= 1
+        ? 4 < 5 && 2 <= 9 ?: 6 ^ 8 | 9 & 10
+        : 8 * 2 / (3 % 4 + 6) - 2
+    : 9
+
+
+bar = 0 ? "moo"         \
+              : "cow"

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_06.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_06.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_06.groovy
new file mode 100644
index 0000000..debea2c
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_06.groovy
@@ -0,0 +1,24 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+true && false || true && false || true
+true &&
+        false ||
+        true &&
+        false ||
+        true

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_07.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_07.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_07.groovy
new file mode 100644
index 0000000..9474f18
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_07.groovy
@@ -0,0 +1,27 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+1 | 2 ^ 3 & 4 | 5 ^ 6 & 7 | 8
+1 |
+        2 ^
+        3 &
+        4 |
+        5 ^
+        6 &
+        7 |
+        8
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_08.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_08.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_08.groovy
new file mode 100644
index 0000000..108e1b0
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_08.groovy
@@ -0,0 +1,24 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+a =~ /abc/
+a =~
+        /abc/
+b ==~ /abc/
+b ==~
+        /abc/

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_09.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_09.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_09.groovy
new file mode 100644
index 0000000..98b7e95
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_09.groovy
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+1 == 1 != 2 == 3 != 4 <=> 5 == 6 != 7
+1 ==
+        1 !=
+        2 ==
+        3 !=
+        4 <=>
+        5 ==
+        6 !=
+        7
+2 == 3 != 4 <=> 5
+
+
+        2 ==
+        3 !=
+        4 <=>
+        5

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_10.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_10.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_10.groovy
new file mode 100644
index 0000000..bdd8c7a
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_10.groovy
@@ -0,0 +1,43 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+1 < 2
+1 <
+        2
+2 <= 2
+2 <=
+        2
+2 >= 2
+2 >=
+        2
+2 > 1
+2 >
+        1
+1 in [1, 2, 3]
+1 in
+        [1, 2, 3]
+
+'abc' instanceof String
+'abc' instanceof
+        String
+'abc' as String
+'abc' as
+        String
+
+
+1 < 2 && 2 <= 2 | 2 >= 2 && (2 > 1 || 1 == 1) & (1 != 2 || 1 ^ 2 && 1 <=> 2) && 1 in [1, 2, 3] && 'abc' as String || 'abc' instanceof String
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_11.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_11.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_11.groovy
new file mode 100644
index 0000000..2030a4a
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_11.groovy
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+1 << 2
+1 <<
+        2
+1 >> 2
+1 >>
+        2
+1 >>> 3
+1 >>>
+        3
+
+1..2
+1..
+        2
+1..<2
+1..<
+        2
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_12.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_12.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_12.groovy
new file mode 100644
index 0000000..d7c4042
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_12.groovy
@@ -0,0 +1,35 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+!true
+!
+        true
+~1
+~
+        1
+(String)'abc'
+(int) obj.someMethod()
+(int) (obj.someMethod())
+(int) 1 / 2
+1 / (int) 2
+(int) a++
+(int) a--
+(int) ++a
+(int) --a
+(int) ~123
+(boolean) !false
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_13.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_13.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_13.groovy
new file mode 100644
index 0000000..b092c64
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_13.groovy
@@ -0,0 +1,63 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+!5
+~5
+-5
++5
+-a
++a
+
+5+5
++(+5)
+-(-5)
++(-5)
+-(+5)
+
+5 + 10
+5 - 10
+5 * 10
+5 / 10
+5 % 10
+5 ** 10
+
+5--
+5++
+--5
+++5
+
+5 >> 10
+5 >>> 10
+5 << 10
+5 > 10
+5 < 10
+
+5 ^ 10
+
+5 | 10
+5 & 10
+
+5 || 10
+5 && 10
+5 ==  10
+5 !=  10
+5 <=>  10
+
+5..10
+5..10
+5..<10 > 1..3

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_14.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_14.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_14.groovy
new file mode 100644
index 0000000..f7f1ef0
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_14.groovy
@@ -0,0 +1,40 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+a = java.lang.Integer
+a = java.lang.Integer.class
+a = Integer
+a = Integer.class
+a = void
+a = void.class
+a = boolean
+a = boolean.class
+a = byte
+a = byte.class
+a = char
+a = char.class
+a = short
+a = short.class
+a = int
+a = int.class
+a = float
+a = float.class
+a = long
+a = long.class
+a = double
+a = double.class
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_15.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_15.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_15.groovy
new file mode 100644
index 0000000..bab67fa
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_15.groovy
@@ -0,0 +1,145 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+person.@name
+person.child.@name
+[hidden email]
+person.&sayHello
+person.child.&sayHello
+person?.child
+person?.@child
+person*.child
+person*.@child
+person.'name'
+person.@'name'
+person?.'name'
+person?.@'name'
+person*.'child'
+person*.@'child'
+person.&'sayHello'
+person.new
+person.@new
+person?.new
+person?.@new
+person*.new
+person*.@new
+person.&new
+person."$name"
+person.@"$name"
+person?."$name"
+person?.@"$name"
+person*."$name"
+person*.@"$name"
+person.&"$methodName"
+person.("$firstname" + "$lastname")
+person.@("$firstname" + "$lastname")
+person?.("$firstname" + "$lastname")
+person?.@("$firstname" + "$lastname")
+person*.("$firstname" + "$lastname")
+person*.@("$firstname" + "$lastname")
+person.&("$method" + "$name")
+
+a.b?.c[1, 2, 3]*.d
+a[1, *[2, 3]]*.b
+a[*[2, 3]]*.b
+
+person
+*.
+child
+*.
+@child
+?.
+child
+?.
+@child
+.
+child
+        .
+@name
+.&
+length
+
+a.b()
+a.'b'()
+a."$b"()
+a?.b()
+a*.b()
+a()
+'a'()
+"$a"()
+
+obj.a
+    .b()
+    ?.c()
+    *.d()
+
+obj.a(1, 2)
+a(1, 2)
+
+obj.a(x: 1, y: 2)
+a(x: 1, y: 2)
+
+a.@b()
+a.@b(1, 2, 3)
+a?.@b()
+a?.@b(1, 2, 3)
+a*.@b()
+a*.@b(1, 2, 3)
+
+a.<Integer>b(1, 2)
+
+a
+        .
+<Integer>b(1, 2)
+
+a.<Integer, String>b(1, '2')
+a?.<Integer, String>b(1, '2')
+a*.<Integer, String>b(1, '2')
+obj?.a*.<
+        Integer,
+        String
+        >b(1, '2')
+
+String[] codes = [
+        className + '.' + propertyName + '.typeMismatch.error',
+        className + '.' + propertyName + '.typeMismatch',
+        classAsPropertyName + '.' + propertyName + '.typeMismatch.error',
+        classAsPropertyName + '.' + propertyName + '.typeMismatch',
+        bindingResult.resolveMessageCodes('typeMismatch', propertyName)
+].flatten() as String[]
+
+
+person*.child[1, 2 + 6, *[3, 4]]*.@child*.@child()?.@child().@child()?.child?.@child.child.getChild().getChild(1, 2).getChild(name: 'a', age: 2).'child'."$child".('chi' + 'ld').@name.class.&equals
+
+
+(obj.x)()
+(obj.@x)()
+
+
+static.unused = { -> }
+
+ResolveOptions resolveOptions = new ResolveOptions()\
+            .setConfs(['default'] as String[])\
+            .setOutputReport(false)\
+            .setValidate(args.containsKey('validate') ? args.validate : false)
+
+new A("b") C.d()
+
+m()()
+
+a = {a,b-> }()

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_16.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_16.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_16.groovy
new file mode 100644
index 0000000..58e7b0a
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_16.groovy
@@ -0,0 +1,40 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+this
+super
+this.name
+super.name
+
+
+def x = {->}()
+x = {a, b -> a + b }(1, 2)
+
+void()
+void(1, 2)
+void(1, 2) {
+
+}
+void(x: 1, y: 2)
+void(x: 1, y: 2) {
+
+}
+
+use(String) {
+}
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_17.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_17.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_17.groovy
new file mode 100644
index 0000000..89309fb
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_17.groovy
@@ -0,0 +1,159 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+a.m(x: 1, y: 2) {
+    println('named arguments');
+}
+
+a.m(x: 1, y: 2, z: 3) {
+    println('named arguments');
+} {
+    println('named arguments');
+}
+
+
+a.m(x: 1, y: 2, z: 3)
+
+{
+    println('named arguments');
+}
+
+{
+    println('named arguments');
+}
+
+
+
+a.m(1, 2) {
+    println('normal arguments');
+}
+
+a.m(1, 2, 3) {
+    println('normal arguments');
+} {
+    println('normal arguments');
+}
+
+a.m(1, 2, 3)
+
+{
+    println('normal arguments');
+}
+
+
+{
+    println('normal arguments');
+}
+
+
+
+
+m {
+    println('closure arguments');
+}
+
+m {
+    println('closure arguments');
+} {
+    println('closure arguments');
+}
+
+m {
+    println('closure arguments');
+} {
+    println('closure arguments');
+} {
+    println('closure arguments');
+}
+
+
+m
+
+{
+    println('closure arguments');
+}
+
+{
+    println('closure arguments');
+}
+
+{
+    println('closure arguments');
+}
+
+'m' {
+    println('closure arguments');
+}
+
+
+1 {
+
+}
+1.1 {
+
+}
+
+-1 {
+
+}
+
+-1.1 {
+
+}
+
+1()
+1.1()
+1(1, 2, 3)
+1.1(1, 2, 3)
+-1()
+-1.1()
+-1(1, 2, 3)
+-1.1(1, 2, 3)
+
+1(1, 2) {
+
+}
+
+1.1(1, 2) {
+
+}
+
+-1(1, 2) {
+
+}
+
+-1.1(1, 2) {
+
+}
+
+hello(x: 1, y: 2, z: 3)
+hello('a', 'b')
+hello(x: 1, 'a', y: 2, 'b', z: 3)
+hello('c', x: 1, 'a', y: 2, 'b', z: 3)
+
+
+A[x: 1, y: 2]
+A[*: someMap]
+A[*: someMap, z: 3]
+A[w: 0, *: someMap]
+A[*: [x: 1, y: 2]]
+A[*: [x: 1, y: 2], z: 3]
+A[w: 0, *: [x: 1, y: 2]]
+
+SomeMethod(a, b)
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_18.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_18.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_18.groovy
new file mode 100644
index 0000000..5a8cc37
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_18.groovy
@@ -0,0 +1,44 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+1 > 2 ? 'y' : 'n'
+1 >= 2 ? 'y' : 'n'
+1 < 2 ? 'y' : 'n'
+1 <= 2 ? 'y' : 'n'
+1 == 2 ? 'y' : 'n'
+1 != 2 ? 'y' : 'n'
+
+p29 = 1 > 2 ? /ab/ : /cd/
+p30=++a == b[2].next()
+p31=a <=> b == a.compareTo(b)
+p32 = 1 in [1, 2, 3] == 1 instanceof Integer
+p33 = 1-2+3
+p34 = 1+2-3
+p35 = 1*2/3
+p36 = 1/2*3
+p37 = 1*2%3
+p38 = 1%2*3
+p39 = 1/2%3
+p40 = 1%2/3
+p41 = 1+2+3
+p42 = 1-2-3
+p43 = 1*2*3
+p44 = 1/2/3
+p45 = 1%2%3
+p46 = 1-2*3+4/5-6%7-8-9+10/11*12-13+14+15-16%17%18/19/20*21*22
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_19.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_19.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_19.groovy
new file mode 100644
index 0000000..3f893a6
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_19.groovy
@@ -0,0 +1,50 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+List list = new ArrayList();
+List list2 = new java.util.ArrayList();
+List<String> list3 = new ArrayList<String>();
+List<String> list4 = new java.util.ArrayList<String>();
+List<String> list5 = new ArrayList<>();
+//List<String> list6 = new java.util.ArrayList<>(); // the old parser can not parse "new java.util.ArrayList<>()"
+def x = new A<EE, TT>();
+int[] a = new int[10];
+int[][] b = new int[length()][2 * 8];
+ArrayList[] c = new ArrayList[10];
+ArrayList[][] cc = new ArrayList[10][size()];
+java.util.ArrayList[] d = new java.util.ArrayList[10];
+ArrayList[] e = new ArrayList<String>[10];
+java.util.ArrayList[] f = new java.util.ArrayList<String>[10];
+java.util.ArrayList[] g = new java.util.ArrayList<String>[size()];
+
+int[][] h = new int[10][];
+int[][][] i = new int[10][][];
+ArrayList[][] j = new ArrayList[10][];
+ArrayList[][] k = new ArrayList<String>[10][];
+
+def bb = new A.B();
+def bb2 = new A.B[0];
+
+new
+    A
+        ('x', 'y');
+
+
+new a();
+new $a();
+new as.def.in.trait.a();

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_20.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_20.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_20.groovy
new file mode 100644
index 0000000..7249e85
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_20.groovy
@@ -0,0 +1,20 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+@Test2(pre={ super(xx);})
+class XX {}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_21x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_21x.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_21x.groovy
new file mode 100644
index 0000000..c983dc9
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_21x.groovy
@@ -0,0 +1,24 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+new int[5]
+new int[5][]
+new int[5][6][]
+new int[5][6][7][]
+new int[5][6][7][][]
+new int[5][6][7][][][]

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_22x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_22x.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_22x.groovy
new file mode 100644
index 0000000..e744a27
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_22x.groovy
@@ -0,0 +1,29 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+int j = 0
+++j++
+assert j == 1
+
+int i = 0
+((i++)++)++
+assert i == 1
+++(++(++i))
+assert i == 2
+++(++(++i++)++)++
+assert i == 3

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Expression_23x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Expression_23x.groovy b/subprojects/parser-antlr4/src/test/resources/core/Expression_23x.groovy
new file mode 100644
index 0000000..2f3007d
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Expression_23x.groovy
@@ -0,0 +1,115 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+def a
+    =
+        1 + 2
+assert 3 == a
+
+a
+    +=
+        2
+assert 5 == a
+
+int b
+    =
+        1,
+    c
+        =
+            2
+assert 1 == b
+assert 2 == c
+
+def (int x, int y)
+    =
+        [1, 2]
+assert 1 == x
+assert 2 == y
+(x)
+    =
+        [3]
+assert 3 == x
+
+@SuppressWarnings(value
+        =
+        "all")
+def m(p1
+        =
+            1,
+      p2
+        =
+            2,
+      int... p3
+                =
+                    [3]) {
+    return p1 + p2 + p3[0]
+}
+assert 6 == m()
+
+def w
+    =
+        1
+            <<
+                2
+assert 4 == w
+assert 'a'
+            instanceof
+                        String
+assert 1
+            <
+                2
+
+assert 1
+            ==
+                1
+
+assert 'a'
+            ==~
+                /a/
+assert true
+            &
+                true
+assert true
+            ^
+                false
+assert true
+            |
+                true
+
+assert true
+            &&
+                true
+
+assert true
+            ||
+                true
+
+
+def z =
+        9
+            /
+                3
+                    *
+                        2
+assert 6 == z
+
+def r =
+         3
+            %
+                2
+assert 1 == r
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/For_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/For_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/For_01.groovy
new file mode 100644
index 0000000..b1cbefb
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/For_01.groovy
@@ -0,0 +1,73 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+for (i in someList) {}
+
+
+for (i in someList) {
+    break;
+}
+
+for (i in someList)
+{
+    break;
+}
+
+for (int i in someList) {
+    break;
+}
+
+for (String i in someList) {
+    break;
+}
+
+for (final String i in someList) {
+    break;
+}
+
+for (@Test2 String i in someList) {
+    break;
+}
+
+
+for (int i : someList) {}
+
+for (int i : someList) {
+    break;
+}
+
+for (int i : someList)
+{
+    break;
+}
+
+for (int i : someList) {
+    break;
+}
+
+for (String i : someList) {
+    break;
+}
+
+for (final String i : someList) {
+    break;
+}
+
+for (@Test2 String i : someList) {
+    break;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/For_02.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/For_02.groovy b/subprojects/parser-antlr4/src/test/resources/core/For_02.groovy
new file mode 100644
index 0000000..5a2b795
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/For_02.groovy
@@ -0,0 +1,54 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+for (int i = 0; true; false) {}
+for (int i = 0; true; false) {
+
+}
+for (int i = 0; true; false)
+{
+}
+for (int i = 0;
+     true;
+     false)
+{
+}
+for(;;) {
+
+}
+for(int i = 0;;) {
+
+}
+for(;true;) {
+
+}
+for(;;false) {
+
+}
+
+for (int i = 0; i < 10; i++) {
+
+}
+
+for (i = 0; i < 10; i++) {
+
+}
+
+for(;;) {
+    continue;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/For_03.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/For_03.groovy b/subprojects/parser-antlr4/src/test/resources/core/For_03.groovy
new file mode 100644
index 0000000..d37aef3
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/For_03.groovy
@@ -0,0 +1,55 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+outer:
+for (def i in [1, 2]) {
+    for (def j in [1, 2, 3, 4, 5]) {
+        if (j == 1) {
+            break outer;
+        } else if (j == 2) {
+            continue outer;
+        }
+
+        if (j == 3) {
+            continue;
+        }
+
+        if (j == 4) {
+            break;
+        }
+    }
+}
+
+
+for (;;)
+    int number = 1
+
+
+int i
+for (i = 0; i < 5; i++);
+
+
+
+
+for (Object child in children()) {
+    if (child instanceof String) {
+        break
+    } else {
+        continue
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/For_04x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/For_04x.groovy b/subprojects/parser-antlr4/src/test/resources/core/For_04x.groovy
new file mode 100644
index 0000000..dcd7b57
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/For_04x.groovy
@@ -0,0 +1,54 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import groovy.transform.CompileStatic
+
+@CompileStatic
+def testCS() {
+    int result = 0
+    for (def (int i, int j) = [0, 0]; i < 5 && j < 5; i = i + 2, j++) {
+        result += i;
+        result += j;
+    }
+    assert 9 == result
+
+    result = 0
+    for (int i = 0, j = 0; i < 5 && j < 5; i = i + 2, j++) {
+        result += i;
+        result += j;
+    }
+    assert 9 == result
+}
+testCS()
+
+def test() {
+    int result = 0
+    for ((i, j) = [0, 0]; i < 5 && j < 5; i = i + 2, j++) {
+        result += i;
+        result += j;
+    }
+    assert 9 == result
+
+    result = 0
+    for (int i = 0, j = 0; i < 5 && j < 5; i = i + 2, j++) {
+        result += i;
+        result += j;
+    }
+    assert 9 == result
+}
+test()

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/For_05x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/For_05x.groovy b/subprojects/parser-antlr4/src/test/resources/core/For_05x.groovy
new file mode 100644
index 0000000..dd63224
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/For_05x.groovy
@@ -0,0 +1,56 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import groovy.transform.CompileStatic
+
+@CompileStatic
+def testCS() {
+    int result = 0
+    for (int i = 0, n = 5; i < n; i++) {
+        result += i
+    }
+    assert 10 == result
+
+    result = 0;
+    int i;
+    int j;
+    for (i = 1, j = 5; i < j; i++, j--) {
+        result += i;
+        result += j;
+    }
+    assert 12 == result
+}
+testCS();
+
+def test() {
+    int result = 0
+    for (int i = 0, n = 5; i < n; i++) {
+        result += i
+    }
+    assert 10 == result
+
+    result = 0;
+    int i;
+    int j;
+    for (i = 1, j = 5; i < j; i++, j--) {
+        result += i;
+        result += j;
+    }
+    assert 12 == result
+}
+test();

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/GString_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/GString_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/GString_01.groovy
new file mode 100644
index 0000000..d233bab
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/GString_01.groovy
@@ -0,0 +1,48 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+"abc${'123'}def"
+"${'123'}def"
+"${'123'}"
+"a:$a"
+"a:$a.b.c"
+"$a.b.c"
+"$a.b.c,d"
+"${12}a${}c${34}"
+"${->12}"
+"${12}${->12}${'12'}"
+"""abc${'123'}def"""
+"""${'123'}def"""
+"""${'123'}"""
+"""a:$a"""
+"""a:$a.b.c"""
+"""$a.b.c"""
+"""$a.b.c,d"""
+"""${12}a${}c${34}"""
+"""${->12}"""
+"""${12}${->12}${'12'}"""
+"""${12}${->12}${'12'}${a=1;return a;}"""
+
+
+"${}"
+"${;}"
+"${;;}"
+"${;;;}"
+
+"${a b}"
+"${obj.a b}"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/GString_02.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/GString_02.groovy b/subprojects/parser-antlr4/src/test/resources/core/GString_02.groovy
new file mode 100644
index 0000000..2e69232
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/GString_02.groovy
@@ -0,0 +1,77 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+/abc${'123'}def $a.b.c,d${->12}/
+$/${-12}abc${'123'}def $a.b.c,d${->12}/$
+
+def p1=/ab/
+def p2=/a${c}b/
+p3=/a${c}b/
+p4=/a${c}b/*2
+p5=!/a${c}b/
+p6= ~/a${c}b/
+p7=~/a${c}b/
+p8==~/a${c}b/
+p9=/a${c}b/ + /a${c}b/
+p10=/ab/
+p11=/ab/*2
+p12=!/ab/
+p13= ~/ab/
+p14=~/ab/
+p15==~/ab/
+p16=/ab/ + /ab/
+p17=/ab/ == /cd/
+p18=/a${c}b/ == /c${f}d/
+p19=/ab/ != /cd/
+p20=/a${c}b/ != /c${f}d/
+p27=1?:/cd/
+p28=1?:/a${c}b/
+p29=1>2?/ab/:/cd/
+p30=1>2?/c${f}d/:/c${f}d/
+p29=true?
+        /ab/:
+        /cd/
+p30=true?
+        /c${f}d/:
+        /c${f}d/
+p31=/A/ && /B/
+p32=/a${b}/ && /c${d}/
+p33=/A/ || /B/
+p34=/a${b}/ || /c${d}/
+p39=/$a/
+p40=/^a+$/
+p41=/$0+/
+p42=/$2a+/
+p43=/$$2a+/
+p44=/^$|$|^$$2a+$/
+p45=/
+    hello, world!
+/
+p46=/hello\
+world/
+p47=/hello\
+    \/
+world/
+p48=/^hello\
+    \/$|^
+world$/
+p49=/ $x $ /
+p50=/$x\
+    $
+/
+p51=/$$/

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/GString_03.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/GString_03.groovy b/subprojects/parser-antlr4/src/test/resources/core/GString_03.groovy
new file mode 100644
index 0000000..731986b
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/GString_03.groovy
@@ -0,0 +1,67 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+def a = """hello${a}
+world
+"""
+
+a = """
+hello
+${a}
+world
+"""
+
+a =~ $/(${123}hello) \/
+            ${a}world\1
+ \u9fa5 \r
+/$
+a =~ $/\
+    x  $
+    $$
+    $/
+/$
+a =~ $/\
+    $x  $
+    $$
+    $/
+/$
+a = $/
+            Hello name,
+            today we're date.
+
+            $ dollar sign
+            $$ escaped dollar sign
+            \ backslash
+            / forward slash
+            $/ escaped forward slash
+            $/$ escaped dollar slashy string delimiter
+        /$
+
+a = $/
+            Hello $name,
+            today we're ${date}.
+
+            $ dollar sign
+            $$ escaped dollar sign
+            \ backslash
+            / forward slash
+            $/ escaped forward slash
+            $/$ escaped dollar slashy string delimiter
+        /$
+a = $/$$VAR/$
+a = $/$$ $VAR/$

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/GString_04.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/GString_04.groovy b/subprojects/parser-antlr4/src/test/resources/core/GString_04.groovy
new file mode 100644
index 0000000..1d7b1c2
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/GString_04.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+"At $date"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/GString_05.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/GString_05.groovy b/subprojects/parser-antlr4/src/test/resources/core/GString_05.groovy
new file mode 100644
index 0000000..e49c060
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/GString_05.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+"""At $date"""
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/GString_06.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/GString_06.groovy b/subprojects/parser-antlr4/src/test/resources/core/GString_06.groovy
new file mode 100644
index 0000000..18d5770
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/GString_06.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+/At $date/
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Groovydoc_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Groovydoc_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/Groovydoc_01x.groovy
new file mode 100644
index 0000000..9bbf9f5
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Groovydoc_01x.groovy
@@ -0,0 +1,70 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+/**
+ * @Groovydoc
+ * class AA
+ */
+class AA {
+    /**
+     * @Groovydoc
+     * field SOME_FIELD
+     */
+    public static final int SOME_FIELD = 1;
+
+    /**
+     * @Groovydoc
+     * constructor AA
+     */
+    public AA() {
+
+    }
+
+    /**
+     * @Groovydoc
+     * method m
+     */
+    public void m() {
+
+    }
+
+    /**
+     * @Groovydoc
+     * class InnerClass
+     */
+    class InnerClass {
+
+    }
+
+
+}
+
+/**
+ * @Groovydoc
+ * annotation BB
+ */
+@interface BB {
+
+}
+
+assert AA.class.getAnnotation(groovy.lang.Groovydoc).value().contains('class AA')
+assert AA.class.getMethod('m', new Class[0]).getAnnotation(groovy.lang.Groovydoc).value().contains('method m')
+assert AA.class.getConstructor().getAnnotation(groovy.lang.Groovydoc).value().contains('constructor AA')
+assert AA.class.getField('SOME_FIELD').getAnnotation(groovy.lang.Groovydoc).value().contains('field SOME_FIELD')
+assert AA.class.getDeclaredClasses().find {it.simpleName.contains('InnerClass')}.getAnnotation(groovy.lang.Groovydoc).value().contains('class InnerClass')
+assert BB.class.getAnnotation(groovy.lang.Groovydoc).value().contains('annotation BB')
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/IdenticalOp_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/IdenticalOp_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/IdenticalOp_01x.groovy
new file mode 100644
index 0000000..9110bb4
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/IdenticalOp_01x.groovy
@@ -0,0 +1,28 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+def x = []
+def y = []
+assert y !== x
+
+assert 'a' === 'a'
+assert 'a' !== new String('a')
+assert null === null
+assert true === true
+assert false === false
+assert 0 == 0 && 'a' === 'a' && 1 != 2 && 'a' !== new String('a') && 1 == 1
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/IfElse_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/IfElse_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/IfElse_01.groovy
new file mode 100644
index 0000000..94687b8
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/IfElse_01.groovy
@@ -0,0 +1,62 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+if (true)
+    assert true, ':('
+
+if (true) assert true, ':('
+
+if (true)
+    assert true, ':('
+else
+    assert false, ':('
+
+if (true) assert true, ':('
+else
+    assert false, ':('
+
+if (true) assert true, ':('
+else assert false, ':('
+
+if (true) assert true, ':(' else assert false, ':('
+
+
+if (false)
+    int number = 1
+
+
+if(true) 1; else 0
+
+if(true) 1 else 0
+
+if(true) 1; else 0;
+
+if(true)
+    1;
+else
+    0
+
+if(true)
+    1
+else
+    0
+
+if(true)
+    1;
+else
+    0;

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_01.groovy
new file mode 100644
index 0000000..f0ed391
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_01.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import java.util.Map
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_02.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_02.groovy b/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_02.groovy
new file mode 100644
index 0000000..f32f0c8
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_02.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import java.util.Map;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_03.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_03.groovy b/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_03.groovy
new file mode 100644
index 0000000..c308f92
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_03.groovy
@@ -0,0 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import java.util.Map
+import java.util.HashMap;
+import java.io.InputStream
+import java.io.BufferedInputStream;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_04.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_04.groovy b/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_04.groovy
new file mode 100644
index 0000000..d54207f
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_04.groovy
@@ -0,0 +1,23 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package core;
+import java.util.Map
+import java.util.HashMap;
+import java.io.InputStream
+import java.io.BufferedInputStream;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_05.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_05.groovy b/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_05.groovy
new file mode 100644
index 0000000..238549a
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_05.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import java.util.*
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_06.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_06.groovy b/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_06.groovy
new file mode 100644
index 0000000..176714c
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/ImportDeclaration_06.groovy
@@ -0,0 +1,21 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import java.util.*
+import java.math.BigDecimal
+import java.io.*
\ No newline at end of file

Reply | Threaded
Open this post in threaded view
|

[04/17] groovy git commit: rename antlr4 parser to remove groovy- prefix since that is by convention for modules

paulk
In reply to this post by paulk
http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Annotation_03.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Annotation_03.groovy b/subprojects/parser-antlr4/src/test/resources/core/Annotation_03.groovy
new file mode 100644
index 0000000..4bea111
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Annotation_03.groovy
@@ -0,0 +1,21 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+@Export
+@Version
+package core

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Annotation_04.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Annotation_04.groovy b/subprojects/parser-antlr4/src/test/resources/core/Annotation_04.groovy
new file mode 100644
index 0000000..a3e7d8c
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Annotation_04.groovy
@@ -0,0 +1,20 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+@Export @Version
+package core

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Annotation_05.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Annotation_05.groovy b/subprojects/parser-antlr4/src/test/resources/core/Annotation_05.groovy
new file mode 100644
index 0000000..855b57f
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Annotation_05.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+@Test1 import java.util.Map

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Annotation_06.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Annotation_06.groovy b/subprojects/parser-antlr4/src/test/resources/core/Annotation_06.groovy
new file mode 100644
index 0000000..b53f38d
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Annotation_06.groovy
@@ -0,0 +1,20 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+@Test1
+import java.util.Map

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Annotation_07.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Annotation_07.groovy b/subprojects/parser-antlr4/src/test/resources/core/Annotation_07.groovy
new file mode 100644
index 0000000..bbb83e3
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Annotation_07.groovy
@@ -0,0 +1,20 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+@Test1 @Test2
+import java.util.Map

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Annotation_08.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Annotation_08.groovy b/subprojects/parser-antlr4/src/test/resources/core/Annotation_08.groovy
new file mode 100644
index 0000000..7a2e4d0
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Annotation_08.groovy
@@ -0,0 +1,28 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+@Test1 @Test2 @Test3
+import java.util.Map
+@Test1 @Test2 @Test3
+import java.util.*
+@Test1 @Test2 @Test3
+import static java.lang.Math
+@Test1 @Test2 @Test3
+import static java.lang.Math.*
+@Test1 @Test2 @Test3
+import static java.lang.Math.pow

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Annotation_09.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Annotation_09.groovy b/subprojects/parser-antlr4/src/test/resources/core/Annotation_09.groovy
new file mode 100644
index 0000000..b5753c4
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Annotation_09.groovy
@@ -0,0 +1,32 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+@Test1(12)
+@Test1(@Test1)
+@Test2(v=6)
+@Test3(v1=6, v2=8, v3=10)
+@Test4([1, 2, 3])
+@Test5(v=[1, 2, 3])
+@Test6(v1=[1, 2, 3], v2=[1], v3=6)
+package core
+
+@Grapes([
+        @Grab('xx:yy:1.0'), // xx
+        @Grab('zz:yy:1.0') /* zz */
+])
+import xx.yy.ZZ;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Annotation_10x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Annotation_10x.groovy b/subprojects/parser-antlr4/src/test/resources/core/Annotation_10x.groovy
new file mode 100644
index 0000000..1ee354b
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Annotation_10x.groovy
@@ -0,0 +1,38 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import java.lang.annotation.RetentionPolicy
+import java.lang.annotation.Retention
+
+def closureClass = NestedAnnotationWithDefault.getAnnotation(AnnWithNestedAnnWithDefault).elem().elem()
+def closure = closureClass.newInstance(null, null)
+assert closure.call() == 3
+
+
+@AnnWithNestedAnnWithDefault(elem = @AnnWithDefaultValue())
+class NestedAnnotationWithDefault {}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface AnnWithDefaultValue {
+    Class elem() default { 1 + 2 }
+}
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface AnnWithNestedAnnWithDefault {
+    AnnWithDefaultValue elem()
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Array_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Array_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/Array_01x.groovy
new file mode 100644
index 0000000..9af7957
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Array_01x.groovy
@@ -0,0 +1,104 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import groovy.transform.CompileStatic
+
+def testArrayInitializer() {
+    def x = new double[] {}
+    assert x.length == 0
+
+    def y = new double[][] {}
+    assert y.length == 0
+
+    def a = new int[] {1, 2}
+    assert a[0] == 1
+    assert a[1] == 2
+    assert a as List == [1, 2]
+
+    def b = new int[][] {
+        new int[] {1, 1.plus(1)},
+        new int[] {2.plus(1), 4}
+    }
+    assert b[0][0] == 1
+    assert b[0][1] == 2
+    assert b[1][0] == 3
+    assert b[1][1] == 4
+
+    def c = new String[] {
+        'a'
+        ,
+        'b'
+        ,
+        'c'
+        ,
+    }
+    assert c[0] == 'a'
+    assert c[1] == 'b'
+    assert c[2] == 'c'
+
+    assert new String[]
+            {
+                'a', 'b'
+            }
+    ==
+            ['a', 'b'] as String[]
+}
+testArrayInitializer();
+
+@CompileStatic
+def testArrayInitializerCS() {
+    def x = new double[] {}
+    assert x.length == 0
+
+    def y = new double[][] {}
+    assert y.length == 0
+
+    def a = new int[] {1, 2}
+    assert a[0] == 1
+    assert a[1] == 2
+    assert a as List == [1, 2]
+
+    def b = new int[][] {
+        new int[] {1, 1.plus(1)},
+        new int[] {2.plus(1), 4}
+    }
+    assert b[0][0] == 1
+    assert b[0][1] == 2
+    assert b[1][0] == 3
+    assert b[1][1] == 4
+
+    def c = new String[] {
+        'a'
+        ,
+        'b'
+        ,
+        'c'
+        ,
+    }
+    assert c[0] == 'a'
+    assert c[1] == 'b'
+    assert c[2] == 'c'
+
+    assert new String[]
+            {
+                'a', 'b'
+            }
+    ==
+    ['a', 'b'] as String[]
+}
+testArrayInitializerCS();
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Assert_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Assert_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/Assert_01.groovy
new file mode 100644
index 0000000..f790083
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Assert_01.groovy
@@ -0,0 +1,46 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+assert true
+assert true;
+assert true : ':(';
+assert true , ':(';
+assert true :
+        ':('
+assert true ,
+        ':(';
+
+assert true:    \
+    'hello, world'
+
+assert true,    \
+    'hello, world'
+
+assert 1 \
+        + 2 * \
+        3 :    \
+        'hello, world'
+
+assert 1 \
+        + 2 * \
+\
+        3 :    \
+\
+\
+'hello, world'
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Assert_02x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Assert_02x.groovy b/subprojects/parser-antlr4/src/test/resources/core/Assert_02x.groovy
new file mode 100644
index 0000000..659232d
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Assert_02x.groovy
@@ -0,0 +1,55 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import org.codehaus.groovy.runtime.powerassert.PowerAssertionError
+
+testBinaryExpression()
+
+/***********************************/
+void testBinaryExpression() {
+    isRendered """
+assert a * b
+       | | |
+       0 0 1
+        """, {
+        def a = 0
+        def b = 1
+        assert a * b
+    }
+
+    isRendered """
+assert a[b]
+       |||
+       ||0
+       |false
+       [false]
+        """, {
+        def a = [false]
+        def b = 0
+        assert a[b]
+    }
+}
+
+static isRendered(String expectedRendering, Closure failingAssertion) {
+    try {
+        failingAssertion.call();
+        assert false, "assertion should have failed but didn't"
+    } catch (PowerAssertionError e) {
+        assert expectedRendering.trim() == e.message.trim()
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Assert_03x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Assert_03x.groovy b/subprojects/parser-antlr4/src/test/resources/core/Assert_03x.groovy
new file mode 100644
index 0000000..71f4540
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Assert_03x.groovy
@@ -0,0 +1,44 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import org.codehaus.groovy.runtime.powerassert.PowerAssertionError
+
+testPostfixExpression()
+
+/***********************************/
+
+void testPostfixExpression() {
+    isRendered """
+assert x++ == null
+       ||  |
+       |0  false
+       0
+        """, {
+        def x = 0
+        assert x++ == null
+    }
+}
+
+static isRendered(String expectedRendering, Closure failingAssertion) {
+    try {
+        failingAssertion.call();
+        assert false, "assertion should have failed but didn't"
+    } catch (PowerAssertionError e) {
+        assert expectedRendering.trim() == e.message.trim()
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/BreakingChange_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/BreakingChange_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/BreakingChange_01x.groovy
new file mode 100644
index 0000000..33bb86d
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/BreakingChange_01x.groovy
@@ -0,0 +1,42 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package core
+
+class a<T> {
+    int x = 1;
+}
+
+a b = new a()
+assert b.x == 1
+
+a<String> b2 = new a<String>()
+assert b2.x == 1
+
+a<String>[] b3 = new a<String>[0]
+assert b3.length == 0
+
+core.a b4 = new a()
+assert b4.x == 1
+
+core.a<String> b5 = new a<String>()
+assert b5.x == 1
+
+core.a<String>[] b6 = new a<String>[0]
+assert b6.length == 0
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/BreakingChange_02x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/BreakingChange_02x.groovy b/subprojects/parser-antlr4/src/test/resources/core/BreakingChange_02x.groovy
new file mode 100644
index 0000000..3c38453
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/BreakingChange_02x.groovy
@@ -0,0 +1,27 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package core
+
+import java.util.concurrent.atomic.AtomicInteger
+
+def inc(AtomicInteger x) { x.incrementAndGet() }
+def a = new AtomicInteger(0)
+
+inc a
+assert 1 == a.get()

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/BreakingChange_03x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/BreakingChange_03x.groovy b/subprojects/parser-antlr4/src/test/resources/core/BreakingChange_03x.groovy
new file mode 100644
index 0000000..4f9e8d7
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/BreakingChange_03x.groovy
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package core
+
+class a {}
+a[] b
+b = new a[0]
+assert 0 == b.length
+
+a[] b2 = new a[0]
+assert 0 == b2.length
+
+core.a[] b3
+b3 = new a[0]
+assert 0 == b3.length
+
+core.a[] b4 = new a[0]
+assert 0 == b4.length
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/BreakingChange_04x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/BreakingChange_04x.groovy b/subprojects/parser-antlr4/src/test/resources/core/BreakingChange_04x.groovy
new file mode 100644
index 0000000..477932b
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/BreakingChange_04x.groovy
@@ -0,0 +1,44 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package core
+
+class B<T> {}
+B b
+b = new B()
+assert b instanceof B
+
+B<String> b2
+b2 = new B<String>()
+assert b2 instanceof B
+
+B<String>[] b3
+b3 = new B<String>[0]
+assert b3 instanceof B[]
+
+core.B b4
+b4 = new B()
+assert b4 instanceof B
+
+core.B<String> b5
+b5 = new B<String>()
+assert b5 instanceof B
+
+core.B<String>[] b6
+b6 = new B<String>[0]
+assert b6 instanceof B[]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_01.groovy
new file mode 100644
index 0000000..05c8bc3
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_01.groovy
@@ -0,0 +1,73 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package core
+
+class A {}
+class B<T> {}
+class C<T extends A> {}
+class D<T extends A & B> {}
+class E<T extends A & B & C> {}
+class F<T extends A & B & C> extends A {}
+class F2 extends A<T> {}
+class G1<T extends A & B & C> extends A implements X {}
+class G2<T extends A & B & C> extends A<T> implements X<T> {}
+class G3                      extends A<T> implements X<T> {}
+class G4                      extends A    implements X<T> {}
+class G5                      extends A    implements X    {}
+class H<T extends A & B & C> extends A implements X, Y {}
+class I<T extends A & B & C> extends A implements X, Y, Z {}
+public class J<T extends A & B & C> extends A implements X, Y, Z {}
+@Test2 public class K<T extends A & B & C> extends A implements X, Y, Z {}
+@Test2 @Test3 public class L<T extends A & B & C> extends A implements X, Y, Z {}
+
+@Test2
+@Test3
+@Test4(value={
+        def a = someMethod()
+        assert a.result() == 'abc'
+})
+@Test5(b=2, a=1)
+@Test6(a=2, b=1)
+public
+class M
+<
+        T extends
+A &
+B &
+C
+>
+        extends
+                A
+        implements
+                X,
+                Y,
+                Z
+{
+
+}
+
+class a {}
+
+class OutputTransforms {
+        final  static localTransforms = loadOutputTransforms()
+}
+
+class OutputTransforms2 {
+        @Lazy  static localTransforms = loadOutputTransforms()
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_02.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_02.groovy b/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_02.groovy
new file mode 100644
index 0000000..a973737
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_02.groovy
@@ -0,0 +1,60 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+class AA {
+    {
+        println 123
+    }
+}
+
+class BB {
+    static {
+        println '123'
+    }
+}
+
+class CC {
+    static
+    {
+        println '123'
+    }
+}
+
+class DD {
+    static {
+        println '123'
+    }
+
+    {
+        println 'abc'
+    }
+
+    static {
+        println '234'
+    }
+
+    {
+        println 'bcd'
+    }
+}
+
+class EE {{}}
+class FF {static {}}
+class GG {static {};{}}
+
+class Iterator implements java.util.Iterator {}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_03.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_03.groovy b/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_03.groovy
new file mode 100644
index 0000000..70ad9a0
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_03.groovy
@@ -0,0 +1,69 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import java.sql.SQLException
+
+class AAA {
+    private volatile XX xx;
+    private transient YY yy;
+
+    public AAA() {
+
+    }
+
+    public AAA(String name) {
+
+    }
+
+    @Test2
+    public AAA(String name, int age) throws Exception {
+
+    }
+
+    AAA(String name, int age, String title) throws Exception {
+
+    }
+
+    private AAA(String name, int age, String title, double income) throws Exception {
+
+    }
+
+    @Test2
+    public synchronized String sayHello(String name) {
+        return "Hello, $name";
+    }
+
+    @Test2
+    public <T> T sayHello2(T name) throws IOException, SQLException {
+        return "Hello, $name";
+    }
+
+    public static privateStaticMethod(){}
+
+    public void m(final int param) {}
+    public void m2(def param) {}
+    public void m3(final int param1, long param2, final String param3) {}
+
+    def "hello world"(p1, p2) {
+        println "$p1, $p2"
+    }
+
+    def run() {
+        this."hello world"('ab', 'bc')
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_04.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_04.groovy b/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_04.groovy
new file mode 100644
index 0000000..78230e8
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_04.groovy
@@ -0,0 +1,40 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+public class Person {
+    public static final SOME_CONSTANT = 'SOME_CONSTANT';
+    private String name = 'Daniel';
+    private int age;
+    @Test2
+    private String country = 'China',
+            location = 'Shanghai';
+
+    private String field, field2 = 'field2';
+    String someProperty;
+    String someProperty2 = 'someProperty2';
+    String someProperty3 = 'someProperty3',
+            someProperty4 = 'someProperty4';
+    String someProperty5, someProperty6 = 'someProperty6';
+    final String someProperty7 = 'someProperty7';
+    static final String someProperty8 = 'someProperty8';
+
+    @Test3
+    static final String someProperty9 = 'someProperty9';
+
+    protected static def protectedStaticDefField;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_05.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_05.groovy b/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_05.groovy
new file mode 100644
index 0000000..25c3701
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_05.groovy
@@ -0,0 +1,38 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+public class A extends B {
+    private int age;
+
+    public A() {
+        super()
+    }
+
+    public A(int age) {
+        this()
+    }
+
+    public A(String name) {
+        super(name);
+    }
+
+    public A(String name, int age) {
+        this(name);
+        this.age = age;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_06.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_06.groovy b/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_06.groovy
new file mode 100644
index 0000000..34a9c2a
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_06.groovy
@@ -0,0 +1,101 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+public class OuterA {
+    class InnerB {}
+}
+
+class OuterClazz {
+    enum InnerEnum implements SomeInterface {
+        A, B
+    }
+}
+
+
+class AA {
+    class Inner {
+        public def innerMethod() {}
+    }
+    private class PrivateInner {}
+    protected final class ProtectedFinalInner {
+        ProtectedFinalInner() {
+
+        }
+
+        ProtectedFinalInner(Integer a) {
+            new A() {
+                public int method() {
+                    1
+                }
+            }
+        }
+    }
+
+    public int method() {
+        0
+    }
+}
+
+
+
+interface A {
+    static enum B {
+        static interface C {
+        }
+    }
+}
+
+interface A2 {
+    static class B2 {
+        static enum C2 {
+        }
+    }
+}
+
+enum A4 {
+    static interface B4 {
+        static class C4 {
+        }
+    }
+}
+
+
+class A3 {
+    static class B3 {
+        static enum C3 {
+        }
+    }
+}
+
+class A5 {
+    static class B5 {
+        static class C5 {
+        }
+    }
+}
+
+interface A1 {
+    static interface B1 {
+        static enum C1 {
+        }
+    }
+}
+
+
+
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_07.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_07.groovy b/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_07.groovy
new file mode 100644
index 0000000..4406289
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/ClassDeclaration_07.groovy
@@ -0,0 +1,45 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+new A() {}
+new A(1, '2') {
+    public void prt() {
+        new B() {}
+        new C() {
+            {
+                new D() {
+                    {
+                        new E() {}
+                        new F() {}
+                    }
+                }
+            }
+        }
+    }
+}
+
+class OuterAA {
+    public void method() {
+        new InnerBB() {}
+        new InnerCC() {{
+            new InnerDD() {}
+            new InnerEE() {}
+        }}
+        new InnerFF() {}
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Closure_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Closure_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/Closure_01.groovy
new file mode 100644
index 0000000..ba93142
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Closure_01.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+{->}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Closure_02.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Closure_02.groovy b/subprojects/parser-antlr4/src/test/resources/core/Closure_02.groovy
new file mode 100644
index 0000000..92fdd1c
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Closure_02.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+{->12}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Closure_03.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Closure_03.groovy b/subprojects/parser-antlr4/src/test/resources/core/Closure_03.groovy
new file mode 100644
index 0000000..3e91329
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Closure_03.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+{-> {->12}}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Closure_04.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Closure_04.groovy b/subprojects/parser-antlr4/src/test/resources/core/Closure_04.groovy
new file mode 100644
index 0000000..25e391b
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Closure_04.groovy
@@ -0,0 +1,21 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+{->
+    12
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Closure_05.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Closure_05.groovy b/subprojects/parser-antlr4/src/test/resources/core/Closure_05.groovy
new file mode 100644
index 0000000..3223365
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Closure_05.groovy
@@ -0,0 +1,21 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+{int a ->
+    a
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Closure_06.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Closure_06.groovy b/subprojects/parser-antlr4/src/test/resources/core/Closure_06.groovy
new file mode 100644
index 0000000..5c7062b
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Closure_06.groovy
@@ -0,0 +1,27 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+{int a,
+ long b, float[] c,
+ double[][] d, String e, Object[] f,
+ Object[][] g, Object[][][] h,
+ Object[]... i
+    ->
+
+    a
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Closure_07.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Closure_07.groovy b/subprojects/parser-antlr4/src/test/resources/core/Closure_07.groovy
new file mode 100644
index 0000000..c6f6c9f
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Closure_07.groovy
@@ -0,0 +1,21 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+{Object... i ->
+    i
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Closure_08.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Closure_08.groovy b/subprojects/parser-antlr4/src/test/resources/core/Closure_08.groovy
new file mode 100644
index 0000000..9a98f35
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Closure_08.groovy
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+{ List<String> i, List<List<String>> j, List<List<List<String>>> k,
+  List<?> l, List<? extends Map> m, List<? super Map> n,
+  List<? extends Map<String, Object>> o, List<? super Map<String, Object>> p,
+  List<String>[] q,  List<? extends Map<String, Object>>[][] r,
+
+  List<
+        ? super
+                Map,
+        ? extends
+        Set,
+        List
+        > s,
+
+  List<? extends Map<String, Object>>[][]... t ->
+    i
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Closure_09.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Closure_09.groovy b/subprojects/parser-antlr4/src/test/resources/core/Closure_09.groovy
new file mode 100644
index 0000000..919a8a9
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Closure_09.groovy
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+{ String i,
+  final String j, final def String k,
+  @Test2 final def String l,
+  @Test2
+  final
+
+  def
+          String m,
+        final n,
+        def
+          o,
+        p, q,
+        r, s,
+  @Test2 final def String... z ->
+    i
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Closure_10.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Closure_10.groovy b/subprojects/parser-antlr4/src/test/resources/core/Closure_10.groovy
new file mode 100644
index 0000000..024b334
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Closure_10.groovy
@@ -0,0 +1,22 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+{ java.lang.Integer t, Integer u, int v, int[] w, int[][] x,
+    String y = 'y', long... z = 123 ->
+    i
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/CodeBlock_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/CodeBlock_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/CodeBlock_01x.groovy
new file mode 100644
index 0000000..d9dd10d
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/CodeBlock_01x.groovy
@@ -0,0 +1,42 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+def m() {
+    int result = 0;
+    {
+        int i = 1;
+        result += i;
+    }
+    {
+        int i = 2;
+        result += i;
+
+        {
+            int j = 3;
+            result += j;
+        }
+        {
+            int j = 4;
+            result += j;
+        }
+
+    }
+    return { result }
+}
+
+assert m()() == 10
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Command_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Command_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/Command_01.groovy
new file mode 100644
index 0000000..beadc8a
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Command_01.groovy
@@ -0,0 +1,36 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+a 1
+a 1, 2
+a x: 1, y: 2
+a.b 1, 2
+z.a b(1), c(2)
+a.b x: 1, y: 2
+z.a x: b(1), y: c(2)
+a b(1), c(2)
+a x: b(1), y: c(2)
+z.a x: b(1, 3), y: c(2, 4)
+a b(1, 3), c(2, 4)
+obj.<Integer, Double>a b(1, 3), c(2, 4), d(3, 5)
+println a
+// println a = 1  // breaking change
+println a == 1
+
+result.addAll allElements()
+task someTask() {}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Command_02.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Command_02.groovy b/subprojects/parser-antlr4/src/test/resources/core/Command_02.groovy
new file mode 100644
index 0000000..a68c6d3
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Command_02.groovy
@@ -0,0 +1,29 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+x y
+x y a b
+x y a.b
+x y a
+a b c() d e
+a b c()() d e
+a b c[x] d e
+a b c[x][y] d e
+a b c {x} d e
+(1 + 2).plus 3 plus 4
+[1, 2].subList 0, 1 plus 2

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Command_03.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Command_03.groovy b/subprojects/parser-antlr4/src/test/resources/core/Command_03.groovy
new file mode 100644
index 0000000..313fd8b
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Command_03.groovy
@@ -0,0 +1,84 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+println withPool {
+}
+
+println aa("bb", "cc") {
+}
+
+println this.aa("bb", "cc") {
+}
+
+println aa("bb", {println 123;}, "cc") {
+}
+
+aa("bb", "cc") {
+    println 1
+} { println 2 }
+
+cc  {
+    println 1
+} {
+    println 2
+}
+
+dd {
+    println 3
+}
+
+obj.cc  {
+    println 1
+} {
+    println 2
+}
+
+bb 1, 2, {println 123;}
+
+obj."some method" (groovy.xml.dom.DOMCategory) {
+}
+
+obj."some ${'method'}" (groovy.xml.dom.DOMCategory) {
+}
+obj.someMethod (groovy.xml.dom.DOMCategory) {
+}
+
+use (groovy.xml.dom.DOMCategory) {
+}
+
+['a','b','c'].inject('x') {
+    result, item -> item + result + item
+}
+
+println a."${hello}"('world') {
+}
+
+println a."${"$hello"}"('world') {
+}
+
+a."${"$hello"}" 'world', {
+}
+
+a.<String, Object>someMethod 'hello', 'world';
+
+a[x] b
+a[x] b c
+a[x] b c d
+
+"$x"(1, 2) a
+"$x" 1, 2  a

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Command_04.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Command_04.groovy b/subprojects/parser-antlr4/src/test/resources/core/Command_04.groovy
new file mode 100644
index 0000000..ba3b2c3
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Command_04.groovy
@@ -0,0 +1,25 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+promise = promise.then { it * 2 } then { it * 3 } then { it + 6 }
+promise = promise.then { it * 2 } then { it * 3 } then { it + 6 } someProperty
+promise = promise.then { it * 2 } then { it * 3 } then { it + 6 } 'someProperty'
+promise = promise.then { it * 2 } then { it * 3 } then { it + 6 } "someProperty"
+promise = promise.then { it * 2 } then { it * 3 } then { it + 6 } "somePropert${'y'}"
+result = [1, 2, 3].size().plus 1 plus 2
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Command_05.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Command_05.groovy b/subprojects/parser-antlr4/src/test/resources/core/Command_05.groovy
new file mode 100644
index 0000000..06205a7
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Command_05.groovy
@@ -0,0 +1,77 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+((int) 1 / 2)(1, 2) {} {} (2, 3, 4) {}
+(((int) 1 / 2))(1, 2) {} {} (2, 3, 4) {}
+(m())()
+((Integer)m())()
+
+((int) 1 / 2) 1, 2 {} {} (2, 3, 4) {}
+
+'m'() + /aa/() + $/bb/$() + "$m"() + /a${'x'}a/() + $/b${'x'}b/$() + 1.2('b') + 1('a') + 2() + null() + true() + false() + a() + {a,b->}(1, 2) + [1, 2]() + [a:1, b:2]() + new int[0]() + new Integer(1)()
+
+// cast expressions
+(int)(1 / 2)
+(Integer)(1 / 2)
+(java.lang.Integer)(1 / 2)
+
+
+
+1 + 1.("a" + "1")()
+1 + 1.(m())()
+1.("a" + "1")()
+1.("a" + "1")(123)
+1.("a" + "1") 123
+1.(m())()
+1.(m())(123)
+1.(m()) 123
+(1+1).("a"+1)()
+(1+1).("a"+1) a b c
+1+1.("a"+1)()
+
+x = a(1, 2)(3, 4) {} {} (5, 6) {} (7, 8)
+x = a(1, 2) {} (3, 4) {} {} (5, 6) {} (7, 8) {} {}
+x = obj.a(1, 2)(3, 4) {} {} (5, 6) {} (7, 8)
+x = obj.a(1, 2) {} (3, 4) {} {} (5, 6) {} (7, 8) {} {}
+x = {a, b -> }(1, 2)(3, 4) {} {} (5, 6) {} (7, 8)
+x = {a, b -> }(1, 2) {} (3, 4) {} {} (5, 6) {} (7, 8) {}
+x = {a, b -> }(1, 2) {} {} (3, 4) {} {} (5, 6) {} (7, 8) {} {}
+
+
+
+m 1, 2
+"m" 1, 2
+"$m" 1, 2
+
+("m") 1, 2
+("$m") 1, 2
+
+find x:
+        1 confirm right
+
+
+find x:
+        1,
+        y:
+                2 confirm right
+
+a b 1 2
+
+
+(obj.m1(1, 2)) m2(3, 4)
+obj.m1(1, 2) m2(3, 4)

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Command_06x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Command_06x.groovy b/subprojects/parser-antlr4/src/test/resources/core/Command_06x.groovy
new file mode 100644
index 0000000..64c94bb
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Command_06x.groovy
@@ -0,0 +1,26 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+assert 11 == (1.plus 2 plus 3) + (2.plus 3) * (1.multiply 1) - ((1 - 1).intdiv 1 multiply 1) / (2.power 10)
+assert (Long)(1.plus 2 plus 3) instanceof Long
+assert [1, 2, 3] == [(1.plus 0), (1.plus 1), (1.plus 1 plus 1)]
+
+def m(a, b) {
+    return a + b
+}
+assert m((1.plus 2 plus 3), (1.multiply 1)) == 7

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Comments_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Comments_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/Comments_01.groovy
new file mode 100644
index 0000000..b01ee37
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Comments_01.groovy
@@ -0,0 +1,46 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+#!/usr/bin/env groovy
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * Created by Daniel.Sun on 2016/08/16.
+ */
+
+// this is a line comment
+
+println /* method name */ 1 /* one */ /* followed by plus */ + /* plus */ 2 /* two */
++3
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Comments_02.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Comments_02.groovy b/subprojects/parser-antlr4/src/test/resources/core/Comments_02.groovy
new file mode 100644
index 0000000..dcb4b76
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Comments_02.groovy
@@ -0,0 +1,135 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+/**
+ * test class Comments
+ */
+public class Comments {
+    /**
+     * test Comments.SOME_VAR
+     */
+    public static final String SOME_VAR = 'SOME_VAR';
+    /**
+     * test Comments.SOME_VAR2
+     */
+    public static final String SOME_VAR2 = 'SOME_VAR2';
+
+    public static final String SOME_VAR3 = 'SOME_VAR3';
+
+    /**
+     * test Comments.SOME_VAR4
+     */
+    // no groovydoc for SOME_VAR4
+    public static final String SOME_VAR4 = 'SOME_VAR4';
+
+
+    /**
+     * test Comments.constructor1
+     */
+    public Comments() {
+
+    }
+
+    /**
+     * test Comments.m1
+     */
+    def m1() {
+        // executing m1
+    }
+
+    /*
+     * test Comments.m2
+     */
+    private m2() {
+        // executing m2
+    }
+
+    /**
+     * test Comments.m3
+     */
+    public void m3() {
+        // executing m3
+    }
+
+    /**
+     * test class InnerClazz
+     */
+    static class InnerClazz {
+        /**
+         * test InnerClazz.SOME_VAR3
+         */
+        public static final String SOME_VAR3 = 'SOME_VAR3';
+        /**
+         * test InnerClazz.SOME_VAR4
+         */
+        public static final String SOME_VAR4 = 'SOME_VAR4';
+
+        /**
+         * test Comments.m4
+         */
+        public void m4() {
+            // executing m4
+        }
+
+        /**
+         * test Comments.m5
+         */
+        public void m5() {
+            // executing m5
+        }
+    }
+
+    /**
+     * test class InnerEnum
+     */
+    static enum InnerEnum {
+        /**
+         * InnerEnum.NEW
+         */
+        NEW,
+
+        /**
+         * InnerEnum.OLD
+         */
+        OLD
+    }
+
+    static enum InnerEnum2 {}
+}
+
+/**
+ * test class Comments2
+ */
+class Comments2 {
+    /*
+     * test Comments.SOME_VAR
+     */
+    public static final String SOME_VAR = 'SOME_VAR';
+}
+
+class Comments3 {}
+
+/**
+ * test someScriptMethod1
+ */
+void someScriptMethod1() {}
+
+/*
+ * test someScriptMethod2
+ */
+void someScriptMethod2() {}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/DefaultMethod_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/DefaultMethod_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/DefaultMethod_01x.groovy
new file mode 100644
index 0000000..7f0c2b0
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/DefaultMethod_01x.groovy
@@ -0,0 +1,39 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+interface Greetable {
+    String name();
+    default String hello() {
+        return 'hello'
+    }
+    default public String sayHello() {
+        return this.hello() + ', ' + this.name()
+    }
+}
+
+class Person implements Greetable {
+    @Override
+    public String name() {
+        return 'Daniel'
+    }
+}
+
+def p = new Person()
+assert 'hello, Daniel' == "${p.hello()}, ${p.name()}"
+assert 'hello, Daniel' == p.sayHello()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/DefaultMethod_02x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/DefaultMethod_02x.groovy b/subprojects/parser-antlr4/src/test/resources/core/DefaultMethod_02x.groovy
new file mode 100644
index 0000000..18e564b
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/DefaultMethod_02x.groovy
@@ -0,0 +1,54 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+interface A {
+    default String hello() {
+        return 'hello'
+    }
+    default String a() {
+        return 'a'
+    }
+    String b();
+}
+
+interface B extends A {
+    public String world();
+}
+
+class C implements B {
+    public static String haha() { return 'haha' }
+
+    public String world() {
+        return 'world'
+    }
+
+    public String name() {
+        return 'c'
+    }
+
+    public String a() {
+        return 'a1';
+    }
+
+    public String b() {
+        return 'b'
+    }
+}
+
+def c = new C()
+assert 'hello, world, c, a1, b, haha' == "${c.hello()}, ${c.world()}, ${c.name()}, ${c.a()}, ${c.b()}, ${C.haha()}"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/DoWhile_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/DoWhile_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/DoWhile_01x.groovy
new file mode 100644
index 0000000..ffdda82
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/DoWhile_01x.groovy
@@ -0,0 +1,25 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+int i = 0;
+
+do {
+    i++
+} while (i < 5)
+
+assert i == 5

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/DoWhile_02x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/DoWhile_02x.groovy b/subprojects/parser-antlr4/src/test/resources/core/DoWhile_02x.groovy
new file mode 100644
index 0000000..5cec460
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/DoWhile_02x.groovy
@@ -0,0 +1,26 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+int i = 0;
+
+do {
+    i++
+    if (i == 3) break;
+} while (i < 5)
+
+assert i == 3

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/DoWhile_03x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/DoWhile_03x.groovy b/subprojects/parser-antlr4/src/test/resources/core/DoWhile_03x.groovy
new file mode 100644
index 0000000..abddd24
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/DoWhile_03x.groovy
@@ -0,0 +1,29 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+int i, j = 0;
+
+do {
+    i++
+    if (i == 4) break;
+
+    if (j == 3) continue;
+    j++
+} while (true)
+
+assert j == 3

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/DoWhile_04x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/DoWhile_04x.groovy b/subprojects/parser-antlr4/src/test/resources/core/DoWhile_04x.groovy
new file mode 100644
index 0000000..f32e88b
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/DoWhile_04x.groovy
@@ -0,0 +1,32 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import groovy.transform.CompileStatic
+
+@CompileStatic
+def a() {
+    int i = 0;
+    int result = 0;
+   do {
+        result += 2
+    } while(i++ < 2)
+        result += 3
+
+    return result;
+}
+assert 9 == a()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/ElvisAssignment_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/ElvisAssignment_01x.groovy b/subprojects/parser-antlr4/src/test/resources/core/ElvisAssignment_01x.groovy
new file mode 100644
index 0000000..17d1bab
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/ElvisAssignment_01x.groovy
@@ -0,0 +1,56 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import groovy.transform.CompileStatic
+
+def elvisAssignment() {
+    def a = 2
+    a ?= 1
+    assert a == 2
+
+    a = null
+    a ?= 1
+    assert a == 1
+
+    a = null
+    a ?= a ?= 1
+    assert a == 1
+
+    a = null
+    assert (a ?= '2') == '2'
+}
+elvisAssignment();
+
+@CompileStatic
+def csElvisAssignment() {
+    def a = 2
+    a ?= 1
+    assert a == 2
+
+    a = null
+    a ?= 1
+    assert a == 1
+
+    a = null
+    a ?= a ?= 1
+    assert a == 1
+
+    a = null
+    assert (a ?= '2') == '2'
+}
+csElvisAssignment();

Reply | Threaded
Open this post in threaded view
|

[05/17] groovy git commit: rename antlr4 parser to remove groovy- prefix since that is by convention for modules

paulk
In reply to this post by paulk
http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy
new file mode 100644
index 0000000..67a68f8
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/SyntaxErrorTest.groovy
@@ -0,0 +1,181 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.parser.antlr4
+
+import org.apache.groovy.parser.antlr4.util.ASTComparatorCategory
+
+/**
+ * Some syntax error test cases for the new parser
+ *
+ * @author  <a href="mailto:[hidden email]">Daniel.Sun</a>
+ * Created on    2016/09/02
+ */
+class SyntaxErrorTest extends GroovyTestCase {
+    public static final String RESOURCES_PATH = 'src/test/resources';
+
+    void setUp() {}
+
+    void tearDown() {}
+
+    void "test groovy core - List"() {
+        TestUtils.shouldFail('fail/List_01.groovy');
+    }
+
+    void "test groovy core - Expression"() {
+        TestUtils.shouldFail('fail/Expression_01.groovy');
+        TestUtils.shouldFail('fail/Expression_02.groovy');
+        TestUtils.shouldFail('fail/Expression_03.groovy');
+//        shouldFail('fail/Expression_04.groovy', true);
+//        shouldFail('fail/Expression_05.groovy', true);
+        TestUtils.shouldFail('fail/Expression_06.groovy');
+        TestUtils.shouldFail('fail/Expression_07.groovy');
+        TestUtils.shouldFail('fail/Expression_08.groovy');
+        TestUtils.shouldFail('fail/Expression_09.groovy');
+    }
+
+    void "test groovy core - Switch"() {
+        TestUtils.shouldFail('fail/Switch_01.groovy');
+    }
+
+    void "test groovy core - LocalVariableDeclaration"() {
+        TestUtils.shouldFail('fail/LocalVariableDeclaration_01.groovy');
+    }
+
+    void "test groovy core - Continue"() {
+        TestUtils.doRunAndShouldFail('fail/Continue_01x.groovy');
+        TestUtils.doRunAndShouldFail('fail/Continue_02x.groovy');
+    }
+
+    void "test groovy core - Break"() {
+        TestUtils.doRunAndShouldFail('fail/Break_01x.groovy');
+        TestUtils.doRunAndShouldFail('fail/Break_02x.groovy');
+    }
+
+    void "test groovy core - UnexpectedCharacter"() {
+        TestUtils.doRunAndShouldFail('fail/UnexpectedCharacter_01x.groovy');
+    }
+
+//    void "test CompilerErrorTest_001.groovy"() {
+//        unzipScriptAndShouldFail("scripts/CompilerErrorTest_001.groovy", [])
+//    }
+
+//    void "test CompilerErrorTest_002.groovy"() {
+//        unzipScriptAndShouldFail("scripts/CompilerErrorTest_002.groovy", [])
+//    }
+
+//    void "test DifferencesFromJavaTest_002.groovy"() {
+//        unzipScriptAndShouldFail("scripts/DifferencesFromJavaTest_002.groovy", [])
+//    }
+
+//    void "test Groovy5212Bug_001.groovy"() {
+//        unzipScriptAndShouldFail("scripts/Groovy5212Bug_001.groovy", [])
+//    }
+
+//    void "test GStringEndTest_001.groovy"() {
+//        unzipScriptAndShouldFail("scripts/GStringEndTest_001.groovy", [])
+//    }
+
+    void "test groovy core - ParExpression"() {
+        TestUtils.doRunAndShouldFail('fail/ParExpression_01x.groovy');
+        TestUtils.doRunAndShouldFail('fail/ParExpression_02x.groovy');
+        TestUtils.doRunAndShouldFail('fail/ParExpression_03x.groovy');
+    }
+
+    void "test groovy core - Parentheses"() {
+        TestUtils.shouldFail('fail/Parentheses_01.groovy');
+    }
+
+    void "test groovy core - This"() {
+        TestUtils.doRunAndShouldFail('fail/This_01x.groovy');
+    }
+
+    void "test groovy core - Super"() {
+        TestUtils.doRunAndShouldFail('fail/Super_01x.groovy');
+    }
+
+    void "test groovy core - AbstractMethod"() {
+        TestUtils.doRunAndShouldFail('fail/AbstractMethod_01x.groovy');
+        TestUtils.doRunAndShouldFail('fail/AbstractMethod_02x.groovy');
+        TestUtils.doRunAndShouldFail('fail/AbstractMethod_03x.groovy');
+        TestUtils.doRunAndShouldFail('fail/AbstractMethod_04x.groovy');
+        TestUtils.doRunAndShouldFail('fail/AbstractMethod_05x.groovy');
+        TestUtils.doRunAndShouldFail('fail/AbstractMethod_06x.groovy');
+    }
+
+    void "test groovy core - BUGs"() {
+        TestUtils.doRunAndShouldFail('bugs/BUG-GROOVY-5318.groovy');
+        TestUtils.doRunAndShouldFail('bugs/BUG-GROOVY-8150.groovy');
+    }
+
+    void "test groovy core - DoWhile"() {
+        TestUtils.doRunAndShouldFail('fail/DoWhile_01x.groovy');
+    }
+
+    void "test groovy core - For"() {
+        TestUtils.shouldFail('fail/For_01.groovy');
+        TestUtils.shouldFail('fail/For_02.groovy');
+    }
+
+    void "test groovy core - Modifier"() {
+        TestUtils.doRunAndShouldFail('fail/Modifier_01x.groovy');
+        TestUtils.doRunAndShouldFail('fail/Modifier_02x.groovy');
+        TestUtils.doRunAndShouldFail('fail/Modifier_03x.groovy');
+        TestUtils.doRunAndShouldFail('fail/Modifier_04x.groovy');
+        TestUtils.doRunAndShouldFail('fail/Modifier_05x.groovy');
+        TestUtils.shouldFail('fail/Modifier_07.groovy');
+    }
+
+    void "test groovy core - ClassDeclaration"() {
+        TestUtils.doRunAndShouldFail('fail/ClassDeclaration_01x.groovy');
+    }
+
+    void "test groovy core - MethodDeclaration"() {
+        TestUtils.shouldFail('fail/MethodDeclaration_01.groovy');
+    }
+
+    void "test groovy core - ConstructorDeclaration"() {
+        TestUtils.shouldFail('fail/ConstructorDeclaration_01.groovy');
+    }
+
+    void "test groovy core - ClosureListExpression"() {
+        TestUtils.shouldFail('fail/ClosureListExpression_01.groovy');
+        TestUtils.shouldFail('fail/ClosureListExpression_02.groovy');
+        TestUtils.shouldFail('fail/ClosureListExpression_03.groovy');
+        TestUtils.shouldFail('fail/ClosureListExpression_04.groovy');
+    }
+
+    void "test groovy core - InterfaceDeclaration"() {
+        TestUtils.shouldFail('fail/InterfaceDeclaration_01.groovy');
+    }
+
+    void "test groovy core - void"() {
+        TestUtils.doRunAndShouldFail('fail/Void_01x.groovy');
+        TestUtils.doRunAndShouldFail('fail/Void_02x.groovy');
+    }
+
+
+    /**************************************/
+    static unzipScriptAndShouldFail(String entryName, List ignoreClazzList, Map<String, String> replacementsMap=[:], boolean toCheckNewParserOnly = false) {
+        ignoreClazzList.addAll(TestUtils.COMMON_IGNORE_CLASS_LIST)
+
+        TestUtils.unzipAndFail(SCRIPT_ZIP_PATH, entryName, TestUtils.addIgnore(ignoreClazzList, ASTComparatorCategory.LOCATION_IGNORE_LIST), replacementsMap, toCheckNewParserOnly)
+    }
+
+    public static final String SCRIPT_ZIP_PATH = "$TestUtils.RESOURCES_PATH/groovy-2.5.0/groovy-2.5.0-SNAPSHOT-20160921-allscripts.zip";
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/TestUtils.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/TestUtils.groovy b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/TestUtils.groovy
new file mode 100644
index 0000000..a82966f
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/TestUtils.groovy
@@ -0,0 +1,259 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.parser.antlr4
+
+import groovy.util.logging.Log
+import org.apache.groovy.parser.AbstractParser
+import org.apache.groovy.parser.Antlr2Parser
+import org.apache.groovy.parser.Antlr4Parser
+import org.apache.groovy.parser.antlr4.util.ASTComparatorCategory
+import org.apache.groovy.parser.antlr4.util.AstDumper
+import org.codehaus.groovy.ast.*
+import org.codehaus.groovy.ast.stmt.*
+import org.codehaus.groovy.control.CompilerConfiguration
+import org.codehaus.groovy.syntax.Token
+
+import java.util.zip.ZipEntry
+import java.util.zip.ZipFile
+
+/**
+ * Utilities for test
+ *
+ * @author  <a href="mailto:[hidden email]">Daniel.Sun</a>
+ * Created on    2016/09/21
+ */
+
+@Log
+class TestUtils {
+    public static final String DEFAULT_RESOURCES_PATH = 'subprojects/parser-antlr4/src/test/resources';
+    public static final String RESOURCES_PATH = new File(DEFAULT_RESOURCES_PATH).exists() ? DEFAULT_RESOURCES_PATH : 'src/test/resources';
+
+    static doTest(String path) {
+        return doTest(path, ASTComparatorCategory.DEFAULT_CONFIGURATION)
+    }
+
+    static doTest(String path, List ignoreClazzList) {
+        return doTest(path, addIgnore(ignoreClazzList, ASTComparatorCategory.LOCATION_IGNORE_LIST))
+    }
+
+    static doTest(String path, conf) {
+        AbstractParser antlr4Parser = new Antlr4Parser()
+        AbstractParser antlr2Parser = new Antlr2Parser()
+
+        File file = new File("$RESOURCES_PATH/$path");
+        def (newAST, newElapsedTime) = profile { antlr4Parser.parse(file) }
+        def (oldAST, oldElapsedTime) = profile { antlr2Parser.parse(file) }
+
+
+        assertAST(newAST, oldAST, conf);
+
+        long diffInMillis = newElapsedTime - oldElapsedTime;
+
+        if (diffInMillis >= 500) {
+            log.warning "${path}\t\t\t\t\tdiff:${diffInMillis / 1000}s,\tnew:${newElapsedTime / 1000}s,\told:${oldElapsedTime / 1000}s."
+        }
+
+        return [newAST, oldAST]
+    }
+
+    /*
+    static unzipAndTest(String path, String entryName) {
+        unzipAndTest(path, entryName, ASTComparatorCategory.DEFAULT_CONFIGURATION)
+    }
+    */
+
+    /*
+    static unzipAndTest(String path, String entryName, List ignoreClazzList) {
+        unzipAndTest(path, entryName, addIgnore(ignoreClazzList, ASTComparatorCategory.LOCATION_IGNORE_LIST))
+    }
+    */
+
+    static unzipAndTest(String path, String entryName, conf, Map<String, String> replacementsMap=[:]) {
+        AbstractParser antlr4Parser = new Antlr4Parser()
+        AbstractParser antlr2Parser = new Antlr2Parser()
+
+        String name = "$path!$entryName";
+        String text = readZipEntry(path, entryName);
+
+        replacementsMap?.each {k, v ->
+            text = text.replace(k, v);
+        }
+
+        def (newAST, newElapsedTime) = profile { antlr4Parser.parse(name, text) }
+        def (oldAST, oldElapsedTime) = profile { antlr2Parser.parse(name, text) }
+
+
+        assertAST(newAST, oldAST, conf);
+
+        long diffInMillis = newElapsedTime - oldElapsedTime;
+
+        if (diffInMillis >= 500) {
+            log.warning "${path}!${entryName}\t\t\t\t\tdiff:${diffInMillis / 1000}s,\tnew:${newElapsedTime / 1000}s,\told:${oldElapsedTime / 1000}s."
+        }
+    }
+
+
+    static shouldFail(String path, boolean toCheckNewParserOnly = false) {
+        shouldFail(path, ASTComparatorCategory.DEFAULT_CONFIGURATION, toCheckNewParserOnly)
+    }
+
+    static shouldFail(String path, List ignoreClazzList, boolean toCheckNewParserOnly = false) {
+        shouldFail(path, addIgnore(ignoreClazzList, ASTComparatorCategory.LOCATION_IGNORE_LIST), toCheckNewParserOnly)
+    }
+
+    static shouldFail(String path, conf, boolean toCheckNewParserOnly = false) {
+        AbstractParser antlr4Parser = new Antlr4Parser()
+        AbstractParser antlr2Parser = new Antlr2Parser()
+
+        File file = new File("$RESOURCES_PATH/$path");
+        def (newAST, newElapsedTime) = profile { antlr4Parser.parse(file) }
+        def (oldAST, oldElapsedTime) = profile { antlr2Parser.parse(file) }
+
+        if (toCheckNewParserOnly) {
+            assert (newAST == null || newAST.context.errorCollector.hasErrors())
+        } else {
+            assert (newAST == null || newAST.context.errorCollector.hasErrors()) &&
+                    (oldAST == null || oldAST.context.errorCollector.hasErrors())
+        }
+
+        long diffInMillis = newElapsedTime - oldElapsedTime;
+
+        if (diffInMillis >= 500) {
+            log.warning "${path}\t\t\t\t\tdiff:${diffInMillis / 1000}s,\tnew:${newElapsedTime / 1000}s,\told:${oldElapsedTime / 1000}s."
+        }
+    }
+
+    static unzipAndFail(String path, String entryName, conf, Map<String, String> replacementsMap=[:], boolean toCheckNewParserOnly = false) {
+        AbstractParser antlr4Parser = new Antlr4Parser()
+        AbstractParser antlr2Parser = new Antlr2Parser()
+
+        String name = "$path!$entryName";
+        String text = readZipEntry(path, entryName);
+
+        replacementsMap?.each {k, v ->
+            text = text.replace(k, v);
+        }
+
+        def (newAST, newElapsedTime) = profile { antlr4Parser.parse(name, text) }
+        def (oldAST, oldElapsedTime) = profile { antlr2Parser.parse(name, text) }
+
+        if (toCheckNewParserOnly) {
+            assert (newAST == null || newAST.context.errorCollector.hasErrors())
+        } else {
+            assert (newAST == null || newAST.context.errorCollector.hasErrors()) &&
+                    (oldAST == null || oldAST.context.errorCollector.hasErrors())
+        }
+
+        long diffInMillis = newElapsedTime - oldElapsedTime;
+
+        if (diffInMillis >= 500) {
+            log.warning "${path}!${entryName}\t\t\t\t\tdiff:${diffInMillis / 1000}s,\tnew:${newElapsedTime / 1000}s,\told:${oldElapsedTime / 1000}s."
+        }
+    }
+
+
+    static assertAST(ast1, ast2, conf) {
+        assert null != ast1 && null != ast2
+
+        ASTComparatorCategory.apply(conf) {
+            assert ast1 == ast2
+        }
+
+        assert genSrc(ast1) == genSrc(ast2)
+    }
+
+    static genSrc(ModuleNode ast) {
+        return new AstDumper(ast).gen();
+    }
+
+    static profile(Closure c) {
+        long begin = System.currentTimeMillis()
+        def result = c.call()
+        long end = System.currentTimeMillis()
+
+        return [result, end - begin];
+    }
+
+    static addIgnore(Class aClass, ArrayList<String> ignore, Map<Class, List<String>> c = null) {
+        c = c ?: ASTComparatorCategory.DEFAULT_CONFIGURATION.clone() as Map<Class, List<String>>;
+        c[aClass].addAll(ignore)
+        return c
+    }
+
+    static addIgnore(Collection<Class> aClass, ArrayList<String> ignore, Map<Class, List<String>> c = null) {
+        c = c ?: ASTComparatorCategory.DEFAULT_CONFIGURATION.clone() as Map<Class, List<String>>;
+        aClass.each { c[it].addAll(ignore) }
+        return c
+    }
+
+    static readZipEntry(String path, String entryName) {
+        String result = "";
+
+        def zf = new ZipFile(new File(path));
+        try {
+            def is = new BufferedInputStream(zf.getInputStream(new ZipEntry(entryName)));
+            result = is.getText("UTF-8");
+        } catch (Exception e) {
+            log.severe(e.message);
+        } finally {
+            try {
+                zf.close();
+            } catch(Exception e) {
+                // IGNORED
+            }
+        }
+
+        return result;
+    }
+
+    static doRunAndShouldFail(String path) {
+        assert !executeScript(path);
+    }
+
+    static doRunAndTest(String path) {
+        assert executeScript(path);
+    }
+
+    static executeScript(String path) {
+        executeScript(createAntlr4Shell(), "$RESOURCES_PATH/$path")
+    }
+
+    static executeScript(gsh, String path) {
+        def file = new File(path);
+        def content = file.text;
+
+        try {
+            gsh.evaluate(content);
+//            log.info("Evaluated $file")
+            return true;
+        } catch (Throwable t) {
+            log.severe("Failed $file: ${t.getMessage()}");
+            return false;
+        }
+    }
+
+    static createAntlr4Shell() {
+        CompilerConfiguration configuration = new CompilerConfiguration(CompilerConfiguration.DEFAULT)
+        configuration.pluginFactory = new Antlr4PluginFactory()
+
+        return new GroovyShell(configuration);
+    }
+
+    public static final List COMMON_IGNORE_CLASS_LIST = Collections.unmodifiableList([AssertStatement, BreakStatement, ConstructorNode, ContinueStatement, ExpressionStatement, FieldNode, ForStatement, GenericsType, IfStatement, MethodNode, PackageNode, Parameter, PropertyNode, ReturnStatement, ThrowStatement, Token, WhileStatement]);
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/util/ASTComparatorCategory.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/util/ASTComparatorCategory.groovy b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/util/ASTComparatorCategory.groovy
new file mode 100644
index 0000000..47b9507
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/util/ASTComparatorCategory.groovy
@@ -0,0 +1,526 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.parser.antlr4.util
+
+import groovy.util.logging.Log
+import org.codehaus.groovy.ast.*
+import org.codehaus.groovy.ast.expr.*
+import org.codehaus.groovy.ast.stmt.*
+import org.codehaus.groovy.syntax.Token
+
+import java.util.logging.Level
+
+@Log @SuppressWarnings("GroovyUnusedDeclaration")
+class ASTComparatorCategory {
+    static { log.level = Level.WARNING }
+    static List<String> LOCATION_IGNORE_LIST = ["columnNumber", "lineNumber", "lastColumnNumber", "lastLineNumber", "startLine"]
+    static private List<String> EXPRESSION_IGNORE_LIST = ["text"] + LOCATION_IGNORE_LIST
+
+    /**
+     *  Keeps all checked object pairs and their comparison result.
+     *  Will be cleared at {@link #apply(groovy.lang.Closure)} method }
+     */
+    static objects = [:] as Map<List<Object>, Boolean>
+    static String lastName
+
+    static Map<Class, List<String>> DEFAULT_CONFIGURATION = [
+            (ClassNode): (['module', "declaredMethodsMap", "plainNodeReference", "typeClass", "allInterfaces", "orAddStaticConstructorNode", "allDeclaredMethods", "unresolvedSuperClass", "innerClasses" ] + LOCATION_IGNORE_LIST) as List<String>,
+            (ConstructorNode): ['declaringClass'],
+            (DynamicVariable): [],
+            (EnumConstantClassNode): ["typeClass"],
+            (FieldNode): ["owner", "declaringClass", "initialValueExpression", "assignToken"],
+            (GenericsType): [],
+            (ImportNode): LOCATION_IGNORE_LIST,
+            (InnerClassNode): (['module', "declaredMethodsMap", "plainNodeReference", "typeClass", "allInterfaces", "orAddStaticConstructorNode", "allDeclaredMethods", "unresolvedSuperClass", "innerClasses" ] + LOCATION_IGNORE_LIST) as List<String>,
+            (InterfaceHelperClassNode): [],
+            (MethodNode): ["text", "declaringClass"],
+            (MixinNode): [],
+            (ModuleNode): ["context"],
+            (PackageNode): [],
+            (Parameter): [],
+            (PropertyNode): ['declaringClass', 'initialValueExpression', "assignToken"],
+            (Variable): [],
+            (VariableScope): ["clazzScope", "parent", "declaredVariablesIterator"],
+            (Token): ["root", "startColumn"],
+            (AnnotationNode): (["text"] + LOCATION_IGNORE_LIST) as List<String>,
+            (AssertStatement): ["text"],
+            (BlockStatement): ["columnNumber", "lineNumber", "lastColumnNumber", "lastLineNumber", "text"],
+            (BreakStatement): ["text"],
+            (CaseStatement): ["text"],
+            (CatchStatement): (["text"] + LOCATION_IGNORE_LIST) as List<String>,
+            (ContinueStatement): ["text"],
+            (DoWhileStatement): ["text"],
+            (EmptyStatement): ["text"],
+            (ExpressionStatement): ["text"],
+            (ForStatement): ["text"],
+            (IfStatement): ["text"],
+            (LoopingStatement): ["text"],
+            (ReturnStatement): ["text"],
+            (SwitchStatement): ["columnNumber", "lineNumber", "lastColumnNumber", "lastLineNumber", "text"],
+            (SynchronizedStatement): ["text"],
+            (ThrowStatement): ["text"],
+            (TryCatchStatement): (["text"] + LOCATION_IGNORE_LIST) as List<String>,
+            (WhileStatement): ["text"],
+            (AnnotationConstantExpression): EXPRESSION_IGNORE_LIST,
+            (ArgumentListExpression): EXPRESSION_IGNORE_LIST,
+            (ArrayExpression): EXPRESSION_IGNORE_LIST,
+            (AttributeExpression): EXPRESSION_IGNORE_LIST,
+            (BinaryExpression): EXPRESSION_IGNORE_LIST,
+            (BitwiseNegationExpression): EXPRESSION_IGNORE_LIST,
+            (BooleanExpression): EXPRESSION_IGNORE_LIST,
+            (CastExpression): EXPRESSION_IGNORE_LIST,
+            (ClassExpression): EXPRESSION_IGNORE_LIST,
+            (ClosureExpression): EXPRESSION_IGNORE_LIST,
+            (ClosureListExpression): EXPRESSION_IGNORE_LIST,
+            (ConstantExpression): EXPRESSION_IGNORE_LIST,
+            (ConstructorCallExpression): EXPRESSION_IGNORE_LIST,
+            (DeclarationExpression): ["text", "columnNumber", "lineNumber", "lastColumnNumber", "lastLineNumber"],
+            (ElvisOperatorExpression): EXPRESSION_IGNORE_LIST,
+            (EmptyExpression): EXPRESSION_IGNORE_LIST,
+            (ExpressionTransformer): EXPRESSION_IGNORE_LIST,
+            (FieldExpression): EXPRESSION_IGNORE_LIST,
+            (GStringExpression): EXPRESSION_IGNORE_LIST,
+            (ListExpression): EXPRESSION_IGNORE_LIST,
+            (MapEntryExpression): EXPRESSION_IGNORE_LIST,
+            (MapExpression): EXPRESSION_IGNORE_LIST,
+            (MethodCall): EXPRESSION_IGNORE_LIST,
+            (MethodCallExpression): EXPRESSION_IGNORE_LIST,
+            (MethodPointerExpression): EXPRESSION_IGNORE_LIST,
+            (NamedArgumentListExpression): EXPRESSION_IGNORE_LIST,
+            (NotExpression): EXPRESSION_IGNORE_LIST,
+            (PostfixExpression): EXPRESSION_IGNORE_LIST,
+            (PrefixExpression): EXPRESSION_IGNORE_LIST,
+            (PropertyExpression): EXPRESSION_IGNORE_LIST,
+            (RangeExpression): EXPRESSION_IGNORE_LIST,
+            (SpreadExpression): EXPRESSION_IGNORE_LIST,
+            (SpreadMapExpression): EXPRESSION_IGNORE_LIST,
+            (StaticMethodCallExpression): EXPRESSION_IGNORE_LIST,
+            (TernaryExpression): EXPRESSION_IGNORE_LIST,
+            (TupleExpression): EXPRESSION_IGNORE_LIST,
+            (UnaryMinusExpression): EXPRESSION_IGNORE_LIST,
+            (UnaryPlusExpression): EXPRESSION_IGNORE_LIST,
+            (VariableExpression): EXPRESSION_IGNORE_LIST,
+    ];
+
+    static Map<Class, List<String>> COLLECTION_PROPERTY_CONFIGURATION = [
+            (ModuleNode): ["classes", "name"]
+    ]
+
+    static Map<Class, List<String>> configuration = DEFAULT_CONFIGURATION;
+
+    static void apply(config = DEFAULT_CONFIGURATION, Closure cl) {
+        configuration = config
+        objects.clear()
+        use(ASTComparatorCategory, cl)
+        configuration = DEFAULT_CONFIGURATION
+    }
+
+    /**
+     * Main method that makes the magic. Compares all properties for object a and object b.
+     * There is a lot of problems in this code, like omitted class checking and so on. Just belive, it will be used properly.
+     * @param a
+     * @param b
+     * @return
+     */
+    static reflexiveEquals(a, b, ignore = []) {
+
+        if (a.getClass() != b.getClass()) {
+            log.warning(" !!!! DIFFERENCE WAS FOUND! ${a.getClass()} != ${b.getClass()}")
+            return false;
+        }
+
+        def objects = [a, b]
+        Boolean res = this.objects[objects]
+        if (res != null) {
+            log.info("Skipping [$a, $b] comparison as they are ${ res ? "" : "un" }equal.")
+            return res;
+        }
+        else if (this.objects.containsKey(objects)) {
+            log.info("Skipping as they are processed at higher levels.")
+            return true
+        }
+
+        this.objects[objects] = null
+        log.info("Equals was called for ${ a.getClass() } ${ a.hashCode() }, $lastName")
+        if (a.is(b))
+            return true
+
+        def difference = a.metaClass.properties.find { MetaBeanProperty p ->
+            if (!p.getter)
+                return false
+
+            def name = p.name
+            lastName = "$name :::: ${ a.getClass() } ${ a.hashCode() }"
+
+
+            for (Map.Entry<Class, List<String>> me : COLLECTION_PROPERTY_CONFIGURATION) {
+                if (!(me.key.isCase(a) && me.key.isCase(b))) {
+                    continue;
+                }
+
+                String propName = me.value[0];
+
+                if (name != propName) {
+                    continue;
+                }
+
+                def aValue = a."${propName}"; // FIXME when the propName is "classes", a classNode will be added to moduleNode.classes
+                def bValue = b."${propName}";
+
+                String orderName = me.value[1];
+
+                return new LinkedList(aValue?.getClass()?.isArray() ? Arrays.asList(aValue) : (aValue ?: [])).sort {c1, c2 -> c1."${orderName}" <=> c2."${orderName}"} !=
+                        new LinkedList(bValue?.getClass()?.isArray() ? Arrays.asList(bValue) : (bValue ?: [])).sort {c1, c2 -> c1."${orderName}" <=> c2."${orderName}"}
+            }
+
+
+            !(name in ignore) && (name != 'nodeMetaData' && name != 'metaDataMap') && a."$name" != b."$name"
+        }
+
+        if (difference)
+            log.warning(" !!!! DIFFERENCE WAS FOUND! [${a.metaClass.hasProperty(a, 'text') ? a.text : '<NO TEXT>'}][${a.class}][${difference.name}]:: ${ a."$difference.name" } != ${ b."$difference.name" }")
+        else
+            log.info(" ==== Exit ${ a.getClass() } ${ a.hashCode() } ====== ")
+
+        res = difference == null
+        this.objects[objects] = res
+        this.objects[objects.reverse(false)] = res
+        res
+    }
+
+    ////////////////////////////////////////////////////////////////////////////////////////////////////
+    // Just a bunch of copypasted methods. Maybe will wrote AST transformation for them.
+    ////////////////////////////////////////////////////////////////////////////////////////////////////
+
+    static equals(ClassNode a, ClassNode b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(ConstructorNode a, ConstructorNode b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(DynamicVariable a, DynamicVariable b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(EnumConstantClassNode a, EnumConstantClassNode b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(FieldNode a, FieldNode b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(GenericsType a, GenericsType b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(ImportNode a, ImportNode b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(InnerClassNode a, InnerClassNode b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(InterfaceHelperClassNode a, InterfaceHelperClassNode b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(MethodNode a, MethodNode b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(MixinNode a, MixinNode b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(ModuleNode a, ModuleNode b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(PackageNode a, PackageNode b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(Parameter a, Parameter b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(PropertyNode a, PropertyNode b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(Variable a, Variable b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(VariableScope a, VariableScope b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(Token a, Token b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(CompileUnit a, CompileUnit b) {
+        true
+    }
+
+    static equals(AnnotationNode a, AnnotationNode b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    ////////////////////////////////////////////////////////////////////////////////////////////////////
+    // Statements
+    ////////////////////////////////////////////////////////////////////////////////////////////////////
+
+    static equals(AssertStatement a, AssertStatement b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(BlockStatement a, BlockStatement b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(BreakStatement a, BreakStatement b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(CaseStatement a, CaseStatement b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(CatchStatement a, CatchStatement b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(ContinueStatement a, ContinueStatement b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(DoWhileStatement a, DoWhileStatement b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(EmptyStatement a, EmptyStatement b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(ExpressionStatement a, ExpressionStatement b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(ForStatement a, ForStatement b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(IfStatement a, IfStatement b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(LoopingStatement a, LoopingStatement b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(ReturnStatement a, ReturnStatement b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(SwitchStatement a, SwitchStatement b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(SynchronizedStatement a, SynchronizedStatement b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(ThrowStatement a, ThrowStatement b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(TryCatchStatement a, TryCatchStatement b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(WhileStatement a, WhileStatement b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    /////////////////////////////////////////////////////////////////////////////////////////////
+    // Expressions
+    /////////////////////////////////////////////////////////////////////////////////////////////
+
+    static equals(AnnotationConstantExpression a, AnnotationConstantExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(ArgumentListExpression a, ArgumentListExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(ArrayExpression a, ArrayExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(AttributeExpression a, AttributeExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(BinaryExpression a, BinaryExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(BitwiseNegationExpression a, BitwiseNegationExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(BooleanExpression a, BooleanExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(CastExpression a, CastExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(ClassExpression a, ClassExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(ClosureExpression a, ClosureExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(ClosureListExpression a, ClosureListExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(ConstantExpression a, ConstantExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(ConstructorCallExpression a, ConstructorCallExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(DeclarationExpression a, DeclarationExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(ElvisOperatorExpression a, ElvisOperatorExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(EmptyExpression a, EmptyExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(ExpressionTransformer a, ExpressionTransformer b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(FieldExpression a, FieldExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(GStringExpression a, GStringExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(ListExpression a, ListExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(MapEntryExpression a, MapEntryExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(MapExpression a, MapExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(MethodCall a, MethodCall b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(MethodCallExpression a, MethodCallExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(MethodPointerExpression a, MethodPointerExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(NamedArgumentListExpression a, NamedArgumentListExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(NotExpression a, NotExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(PostfixExpression a, PostfixExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(PrefixExpression a, PrefixExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(PropertyExpression a, PropertyExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(RangeExpression a, RangeExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(SpreadExpression a, SpreadExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(SpreadMapExpression a, SpreadMapExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(StaticMethodCallExpression a, StaticMethodCallExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(TernaryExpression a, TernaryExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(TupleExpression a, TupleExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(UnaryMinusExpression a, UnaryMinusExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(UnaryPlusExpression a, UnaryPlusExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+
+    static equals(VariableExpression a, VariableExpression b) {
+        reflexiveEquals(a, b, configuration[a.class])
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/util/AstDumper.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/util/AstDumper.groovy b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/util/AstDumper.groovy
new file mode 100644
index 0000000..72a64e5
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/util/AstDumper.groovy
@@ -0,0 +1,1025 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.parser.antlr4.util
+
+import org.codehaus.groovy.ast.*
+import org.codehaus.groovy.ast.expr.*
+import org.codehaus.groovy.ast.stmt.*
+import org.codehaus.groovy.classgen.BytecodeExpression
+import org.codehaus.groovy.classgen.GeneratorContext
+import org.codehaus.groovy.classgen.Verifier
+import org.codehaus.groovy.control.CompilationUnit
+import org.codehaus.groovy.control.SourceUnit
+import org.codehaus.groovy.control.io.ReaderSource
+
+import java.lang.reflect.Modifier
+
+/**
+ * Generate the groovy source according to the AST.
+ * It is useful to verify the equality of new and old parser.
+ *
+ * @author  <a href="mailto:[hidden email]">Daniel.Sun</a>
+ * Created on    2016/08/16
+ */
+class AstDumper {
+    private ModuleNode ast;
+
+    public AstDumper(ModuleNode ast) {
+        this.ast = ast;
+    }
+
+    /**
+     * Generate the groovy source code according the AST
+     *
+     * @return the groovy source code
+     */
+    public String gen() {
+        StringWriter out = new StringWriter();
+
+        try {
+            AstNodeToScriptVisitor visitor = new AstNodeToScriptVisitor(out, true, true);
+
+            new LinkedList<ClassNode>(this.ast?.classes ?: []).sort { c1, c2 -> c1.name <=> c2.name }?.each {
+                visitor.call(new SourceUnit((String) null, (ReaderSource) null, null, null, null) {
+                    @Override
+                    public ModuleNode getAST() {
+                        return AstDumper.this.ast;
+                    }
+                }, null, it)
+            }
+
+            return out.toString().replaceAll(/([\w_$]+)@[0-9a-z]+/, '$1@<hashcode>');
+        } finally {
+            out.close();
+        }
+    }
+}
+
+/**
+ * *****************************************************
+ * In order to solve the "Egg & Chicken" problem,
+ * we have to copy the source code(instead of invoking it): subprojects/groovy-console/src/main/groovy/groovy/inspect/swingui/AstNodeToScriptAdapter.groovy
+ * *****************************************************
+ *
+ *
+ * An adapter from ASTNode tree to source code.
+ *
+ * @author Hamlet D'Arcy
+ */
+class AstNodeToScriptVisitor extends CompilationUnit.PrimaryClassNodeOperation implements GroovyCodeVisitor, GroovyClassVisitor {
+
+    private final Writer _out
+    Stack<String> classNameStack = new Stack<String>()
+    String _indent = ''
+    boolean readyToIndent = true
+    boolean showScriptFreeForm
+    boolean showScriptClass
+    boolean scriptHasBeenVisited
+
+    def AstNodeToScriptVisitor(Writer writer, boolean showScriptFreeForm = true, boolean showScriptClass = true) {
+        this._out = writer
+        this.showScriptFreeForm = showScriptFreeForm
+        this.showScriptClass = showScriptClass
+        this.scriptHasBeenVisited = false
+    }
+
+    void call(SourceUnit source, GeneratorContext context, ClassNode classNode) {
+
+        visitPackage(source?.getAST()?.getPackage())
+
+        visitAllImports(source)
+
+        if (showScriptFreeForm && !scriptHasBeenVisited) {
+            scriptHasBeenVisited = true
+            source?.getAST()?.getStatementBlock()?.visit(this)
+        }
+        if (showScriptClass || !classNode.isScript()) {
+            visitClass classNode
+        }
+    }
+
+    private def visitAllImports(SourceUnit source) {
+        boolean staticImportsPresent = false
+        boolean importsPresent = false
+
+        source?.getAST()?.getStaticImports()?.values()?.each {
+            visitImport(it)
+            staticImportsPresent = true
+        }
+        source?.getAST()?.getStaticStarImports()?.values()?.each {
+            visitImport(it)
+            staticImportsPresent = true
+        }
+
+        if (staticImportsPresent) {
+            printDoubleBreak()
+        }
+
+        source?.getAST()?.getImports()?.each {
+            visitImport(it)
+            importsPresent = true
+        }
+        source?.getAST()?.getStarImports()?.each {
+            visitImport(it)
+            importsPresent = true
+        }
+        if (importsPresent) {
+            printDoubleBreak()
+        }
+    }
+
+
+    void print(parameter) {
+        def output = parameter.toString()
+
+        if (readyToIndent) {
+            _out.print _indent
+            readyToIndent = false
+            while (output.startsWith(' ')) {
+                output = output[1..-1]  // trim left
+            }
+        }
+        if (_out.toString().endsWith(' ')) {
+            if (output.startsWith(' ')) {
+                output = output[1..-1]
+            }
+        }
+        _out.print output
+    }
+
+    def println(parameter) {
+        throw new UnsupportedOperationException('Wrong API')
+    }
+
+    def indented(Closure block) {
+        String startingIndent = _indent
+        _indent = _indent + '    '
+        block()
+        _indent = startingIndent
+    }
+
+    def printLineBreak() {
+        if (!_out.toString().endsWith('\n')) {
+            _out.print '\n'
+        }
+        readyToIndent = true
+    }
+
+    def printDoubleBreak() {
+        if (_out.toString().endsWith('\n\n')) {
+            // do nothing
+        } else if (_out.toString().endsWith('\n')) {
+            _out.print '\n'
+        } else {
+            _out.print '\n'
+            _out.print '\n'
+        }
+        readyToIndent = true
+    }
+
+    void visitPackage(PackageNode packageNode) {
+
+        if (packageNode) {
+
+            packageNode.annotations?.each {
+                visitAnnotationNode(it)
+                printLineBreak()
+            }
+
+            if (packageNode.text.endsWith('.')) {
+                print packageNode.text[0..-2]
+            } else {
+                print packageNode.text
+            }
+            printDoubleBreak()
+        }
+    }
+
+    void visitImport(ImportNode node) {
+        if (node) {
+            node.annotations?.each {
+                visitAnnotationNode(it)
+                printLineBreak()
+            }
+            print node.text
+            printLineBreak()
+        }
+    }
+
+    @Override
+    void visitClass(ClassNode node) {
+
+        classNameStack.push(node.name)
+
+        node?.annotations?.each {
+            visitAnnotationNode(it)
+            printLineBreak()
+        }
+
+        visitModifiers(node.modifiers)
+        print "class $node.name"
+        visitGenerics node?.genericsTypes
+        boolean first = true
+        node.unresolvedInterfaces?.each {
+            if (!first) {
+                print ', '
+            } else {
+                print ' implements '
+            }
+            first = false
+            visitType it
+        }
+        print ' extends '
+        visitType node.unresolvedSuperClass
+        print ' { '
+        printDoubleBreak()
+
+        indented {
+            node?.properties?.each { visitProperty(it) }
+            printLineBreak()
+            node?.fields?.each { visitField(it) }
+            printDoubleBreak()
+            node?.declaredConstructors?.each { visitConstructor(it) }
+            printLineBreak()
+            node?.methods?.each { visitMethod(it) }
+        }
+        print '}'
+        printLineBreak()
+        classNameStack.pop()
+    }
+
+    private void visitGenerics(GenericsType[] generics) {
+
+        if (generics) {
+            print '<'
+            boolean first = true
+            generics.each { GenericsType it ->
+                if (!first) {
+                    print ', '
+                }
+                first = false
+                print it.name
+                if (it.upperBounds) {
+                    print ' extends '
+                    boolean innerFirst = true
+                    it.upperBounds.each { ClassNode upperBound ->
+                        if (!innerFirst) {
+                            print ' & '
+                        }
+                        innerFirst = false
+                        visitType upperBound
+                    }
+                }
+                if (it.lowerBound) {
+                    print ' super '
+                    visitType it.lowerBound
+                }
+            }
+            print '>'
+        }
+    }
+
+    @Override
+    void visitConstructor(ConstructorNode node) {
+        visitMethod(node)
+    }
+
+    private String visitParameters(parameters) {
+        boolean first = true
+
+        parameters.each { Parameter it ->
+            if (!first) {
+                print ', '
+            }
+            first = false
+
+            it.annotations?.each {
+                visitAnnotationNode(it)
+                print(' ')
+            }
+
+            visitModifiers(it.modifiers)
+            visitType it.type
+            print ' ' + it.name
+            if (it.initialExpression && !(it.initialExpression instanceof EmptyExpression)) {
+                print ' = '
+                it.initialExpression.visit this
+            }
+        }
+    }
+
+    @Override
+    void visitMethod(MethodNode node) {
+        node?.annotations?.each {
+            visitAnnotationNode(it)
+            printLineBreak()
+        }
+
+        visitModifiers(node.modifiers)
+        if (node.name == '<init>') {
+            print "${classNameStack.peek()}("
+            visitParameters(node.parameters)
+            print ') {'
+            printLineBreak()
+        } else if (node.name == '<clinit>') {
+            print '{ ' // will already have 'static' from modifiers
+            printLineBreak()
+        } else {
+            visitType node.returnType
+            print " $node.name("
+            visitParameters(node.parameters)
+            print ')'
+            if (node.exceptions) {
+                boolean first = true
+                print ' throws '
+                node.exceptions.each {
+                    if (!first) {
+                        print ', '
+                    }
+                    first = false
+                    visitType it
+                }
+            }
+            print ' {'
+            printLineBreak()
+        }
+
+        indented {
+            node?.code?.visit(this)
+        }
+        printLineBreak()
+        print '}'
+        printDoubleBreak()
+    }
+
+    private def visitModifiers(int modifiers) {
+        if (Modifier.isAbstract(modifiers)) {
+            print 'abstract '
+        }
+        if (Modifier.isFinal(modifiers)) {
+            print 'final '
+        }
+        if (Modifier.isInterface(modifiers)) {
+            print 'interface '
+        }
+        if (Modifier.isNative(modifiers)) {
+            print 'native '
+        }
+        if (Modifier.isPrivate(modifiers)) {
+            print 'private '
+        }
+        if (Modifier.isProtected(modifiers)) {
+            print 'protected '
+        }
+        if (Modifier.isPublic(modifiers)) {
+            print 'public '
+        }
+        if (Modifier.isStatic(modifiers)) {
+            print 'static '
+        }
+        if (Modifier.isSynchronized(modifiers)) {
+            print 'synchronized '
+        }
+        if (Modifier.isTransient(modifiers)) {
+            print 'transient '
+        }
+        if (Modifier.isVolatile(modifiers)) {
+            print 'volatile '
+        }
+    }
+
+    @Override
+    void visitField(FieldNode node) {
+        node?.annotations?.each {
+            visitAnnotationNode(it)
+            printLineBreak()
+        }
+        visitModifiers(node.modifiers)
+        visitType node.type
+        print " $node.name "
+        // do not print initial expression, as this is executed as part of the constructor, unless on static constant
+        Expression exp = node.initialValueExpression
+        if (exp instanceof ConstantExpression) exp = Verifier.transformToPrimitiveConstantIfPossible(exp)
+        ClassNode type = exp?.type
+        if (Modifier.isStatic(node.modifiers) && Modifier.isFinal(node.getModifiers())
+                && exp instanceof ConstantExpression
+                && type == node.type
+                && ClassHelper.isStaticConstantInitializerType(type)) {
+            // GROOVY-5150: final constants may be initialized directly
+            print ' = '
+            if (ClassHelper.STRING_TYPE == type) {
+                print "'"+node.initialValueExpression.text.replaceAll("'", "\\\\'")+"'"
+            } else if (ClassHelper.char_TYPE == type) {
+                print "'${node.initialValueExpression.text}'"
+            } else {
+                print node.initialValueExpression.text
+            }
+        }
+        printLineBreak()
+    }
+
+    void visitAnnotationNode(AnnotationNode node) {
+        print '@' + node?.classNode?.name
+        if (node?.members) {
+            print '('
+            boolean first = true
+            node.members.each { String name, Expression value ->
+                if (first) {
+                    first = false
+                } else {
+                    print ', '
+                }
+                print name + ' = '
+                value.visit(this)
+            }
+            print ')'
+        }
+
+    }
+
+    @Override
+    void visitProperty(PropertyNode node) {
+        // is a FieldNode, avoid double dispatch
+    }
+
+    @Override
+    void visitBlockStatement(BlockStatement block) {
+        block?.statements?.each {
+            it.visit(this)
+            printLineBreak()
+        }
+        if (!_out.toString().endsWith('\n')) {
+            printLineBreak()
+        }
+    }
+
+    @Override
+    void visitForLoop(ForStatement statement) {
+
+        print 'for ('
+        if (statement?.variable != ForStatement.FOR_LOOP_DUMMY) {
+            visitParameters([statement.variable])
+            print ' : '
+        }
+
+        if (statement?.collectionExpression instanceof ListExpression) {
+            statement?.collectionExpression?.visit this
+        } else {
+            statement?.collectionExpression?.visit this
+        }
+        print ') {'
+        printLineBreak()
+        indented {
+            statement?.loopBlock?.visit this
+        }
+        print '}'
+        printLineBreak()
+    }
+
+    @Override
+    void visitIfElse(IfStatement ifElse) {
+        print 'if ('
+        ifElse?.booleanExpression?.visit this
+        print ') {'
+        printLineBreak()
+        indented {
+            ifElse?.ifBlock?.visit this
+        }
+        printLineBreak()
+        if (ifElse?.elseBlock && !(ifElse.elseBlock instanceof EmptyStatement)) {
+            print '} else {'
+            printLineBreak()
+            indented {
+                ifElse?.elseBlock?.visit this
+            }
+            printLineBreak()
+        }
+        print '}'
+        printLineBreak()
+    }
+
+    @Override
+    void visitExpressionStatement(ExpressionStatement statement) {
+        statement.expression.visit this
+    }
+
+    @Override
+    void visitReturnStatement(ReturnStatement statement) {
+        printLineBreak()
+        print 'return '
+        statement.getExpression().visit(this)
+        printLineBreak()
+    }
+
+    @Override
+    void visitSwitch(SwitchStatement statement) {
+        print 'switch ('
+        statement?.expression?.visit this
+        print ') {'
+        printLineBreak()
+        indented {
+            statement?.caseStatements?.each {
+                visitCaseStatement it
+            }
+            if (statement?.defaultStatement) {
+                print 'default: '
+                printLineBreak()
+                statement?.defaultStatement?.visit this
+            }
+        }
+        print '}'
+        printLineBreak()
+    }
+
+    @Override
+    void visitCaseStatement(CaseStatement statement) {
+        print 'case '
+        statement?.expression?.visit this
+        print ':'
+        printLineBreak()
+        indented {
+            statement?.code?.visit this
+        }
+    }
+
+    @Override
+    void visitBreakStatement(BreakStatement statement) {
+        print 'break'
+        printLineBreak()
+    }
+
+    @Override
+    void visitContinueStatement(ContinueStatement statement) {
+        print 'continue'
+        printLineBreak()
+    }
+
+    @Override
+    void visitMethodCallExpression(MethodCallExpression expression) {
+
+        Expression objectExp = expression.getObjectExpression()
+        if (objectExp instanceof VariableExpression) {
+            visitVariableExpression(objectExp, false)
+        } else {
+            objectExp.visit(this)
+        }
+        if (expression.spreadSafe) {
+            print '*'
+        }
+        if (expression.safe) {
+            print '?'
+        }
+        print '.'
+        Expression method = expression.getMethod()
+        if (method instanceof ConstantExpression) {
+            visitConstantExpression(method, true)
+        } else {
+            method.visit(this)
+        }
+        expression.getArguments().visit(this)
+    }
+
+    @Override
+    void visitStaticMethodCallExpression(StaticMethodCallExpression expression) {
+        print expression?.ownerType?.name + '.' + expression?.method
+        if (expression?.arguments instanceof VariableExpression || expression?.arguments instanceof MethodCallExpression) {
+            print '('
+            expression?.arguments?.visit this
+            print ')'
+        } else {
+            expression?.arguments?.visit this
+        }
+    }
+
+    @Override
+    void visitConstructorCallExpression(ConstructorCallExpression expression) {
+        if (expression?.isSuperCall()) {
+            print 'super'
+        } else if (expression?.isThisCall()) {
+            print 'this '
+        } else {
+            print 'new '
+            visitType expression?.type
+        }
+        expression?.arguments?.visit this
+    }
+
+    @Override
+    void visitBinaryExpression(BinaryExpression expression) {
+        expression?.leftExpression?.visit this
+        print " $expression.operation.text "
+        expression.rightExpression.visit this
+
+        if (expression?.operation?.text == '[') {
+            print ']'
+        }
+    }
+
+    @Override
+    void visitPostfixExpression(PostfixExpression expression) {
+        print '('
+        expression?.expression?.visit this
+        print ')'
+        print expression?.operation?.text
+    }
+
+    @Override
+    void visitPrefixExpression(PrefixExpression expression) {
+        print expression?.operation?.text
+        print '('
+        expression?.expression?.visit this
+        print ')'
+    }
+
+
+    @Override
+    void visitClosureExpression(ClosureExpression expression) {
+        print '{ '
+        if (expression?.parameters) {
+            visitParameters(expression?.parameters)
+            print ' ->'
+        }
+        printLineBreak()
+        indented {
+            expression?.code?.visit this
+        }
+        print '}'
+    }
+
+    @Override
+    void visitTupleExpression(TupleExpression expression) {
+        print '('
+        visitExpressionsAndCommaSeparate(expression?.expressions)
+        print ')'
+    }
+
+    @Override
+    void visitRangeExpression(RangeExpression expression) {
+        print '('
+        expression?.from?.visit this
+        print '..'
+        expression?.to?.visit this
+        print ')'
+    }
+
+    @Override
+    void visitPropertyExpression(PropertyExpression expression) {
+        expression?.objectExpression?.visit this
+        if (expression?.spreadSafe) {
+            print '*'
+        } else if (expression?.isSafe()) {
+            print '?'
+        }
+        print '.'
+        if (expression?.property instanceof ConstantExpression) {
+            visitConstantExpression(expression?.property, true)
+        } else {
+            expression?.property?.visit this
+        }
+    }
+
+    @Override
+    void visitAttributeExpression(AttributeExpression attributeExpression) {
+        visitPropertyExpression attributeExpression
+    }
+
+    @Override
+    void visitFieldExpression(FieldExpression expression) {
+        print expression?.field?.name
+    }
+
+    void visitConstantExpression(ConstantExpression expression, boolean unwrapQuotes = false) {
+        if (expression.value instanceof String && !unwrapQuotes) {
+            // string reverse escaping is very naive
+            def escaped = ((String) expression.value).replaceAll('\n', '\\\\n').replaceAll("'", "\\\\'")
+            print "'$escaped'"
+        } else {
+            print expression.value
+        }
+    }
+
+    @Override
+    void visitClassExpression(ClassExpression expression) {
+        print expression.text
+    }
+
+    void visitVariableExpression(VariableExpression expression, boolean spacePad = true) {
+
+        if (spacePad) {
+            print ' ' + expression.name + ' '
+        } else {
+            print expression.name
+        }
+    }
+
+    @Override
+    void visitDeclarationExpression(DeclarationExpression expression) {
+        // handle multiple assignment expressions
+        if (expression?.leftExpression instanceof ArgumentListExpression) {
+            print 'def '
+            visitArgumentlistExpression expression?.leftExpression, true
+            print " $expression.operation.text "
+            expression.rightExpression.visit this
+
+            if (expression?.operation?.text == '[') {
+                print ']'
+            }
+        } else {
+            visitType expression?.leftExpression?.type
+            visitBinaryExpression expression // is a BinaryExpression
+        }
+    }
+
+    @Override
+    void visitGStringExpression(GStringExpression expression) {
+        print '"' + expression.text + '"'
+    }
+
+    @Override
+    void visitSpreadExpression(SpreadExpression expression) {
+        print '*'
+        expression?.expression?.visit this
+    }
+
+    @Override
+    void visitNotExpression(NotExpression expression) {
+        print '!('
+        expression?.expression?.visit this
+        print ')'
+    }
+
+    @Override
+    void visitUnaryMinusExpression(UnaryMinusExpression expression) {
+        print '-('
+        expression?.expression?.visit this
+        print ')'
+    }
+
+    @Override
+    void visitUnaryPlusExpression(UnaryPlusExpression expression) {
+        print '+('
+        expression?.expression?.visit this
+        print ')'
+    }
+
+    @Override
+    void visitCastExpression(CastExpression expression) {
+        print '(('
+        expression?.expression?.visit this
+        print ') as '
+        visitType(expression?.type)
+        print ')'
+
+    }
+
+    /**
+     * Prints out the type, safely handling arrays.
+     * @param classNode
+     *      classnode
+     */
+    void visitType(ClassNode classNode) {
+        def name = classNode.name
+        if (name =~ /^\[+L/ && name.endsWith(';')) {
+            int numDimensions = name.indexOf('L')
+            print "${classNode.name[(numDimensions + 1)..-2]}" + ('[]' * numDimensions)
+        } else {
+            print name
+        }
+        visitGenerics classNode?.genericsTypes
+    }
+
+    void visitArgumentlistExpression(ArgumentListExpression expression, boolean showTypes = false) {
+        print '('
+        int count = expression?.expressions?.size()
+        expression.expressions.each {
+            if (showTypes) {
+                visitType it.type
+                print ' '
+            }
+            if (it instanceof VariableExpression) {
+                visitVariableExpression it, false
+            } else if (it instanceof ConstantExpression) {
+                visitConstantExpression it, false
+            } else {
+                it.visit this
+            }
+            count--
+            if (count) print ', '
+        }
+        print ')'
+    }
+
+    @Override
+    void visitBytecodeExpression(BytecodeExpression expression) {
+        print '/*BytecodeExpression*/'
+        printLineBreak()
+    }
+
+
+
+    @Override
+    void visitMapExpression(MapExpression expression) {
+        print '['
+        if (expression?.mapEntryExpressions?.size() == 0) {
+            print ':'
+        } else {
+            visitExpressionsAndCommaSeparate(expression?.mapEntryExpressions)
+        }
+        print ']'
+    }
+
+    @Override
+    void visitMapEntryExpression(MapEntryExpression expression) {
+        if (expression?.keyExpression instanceof SpreadMapExpression) {
+            print '*'            // is this correct?
+        } else {
+            expression?.keyExpression?.visit this
+        }
+        print ': '
+        expression?.valueExpression?.visit this
+    }
+
+    @Override
+    void visitListExpression(ListExpression expression) {
+        print '['
+        visitExpressionsAndCommaSeparate(expression?.expressions)
+        print ']'
+    }
+
+    @Override
+    void visitTryCatchFinally(TryCatchStatement statement) {
+        print 'try {'
+        printLineBreak()
+        indented {
+            statement?.tryStatement?.visit this
+        }
+        printLineBreak()
+        print '} '
+        printLineBreak()
+        statement?.catchStatements?.each { CatchStatement catchStatement ->
+            visitCatchStatement(catchStatement)
+        }
+        print 'finally { '
+        printLineBreak()
+        indented {
+            statement?.finallyStatement?.visit this
+        }
+        print '} '
+        printLineBreak()
+    }
+
+    @Override
+    void visitThrowStatement(ThrowStatement statement) {
+        print 'throw '
+        statement?.expression?.visit this
+        printLineBreak()
+    }
+
+    @Override
+    void visitSynchronizedStatement(SynchronizedStatement statement) {
+        print 'synchronized ('
+        statement?.expression?.visit this
+        print ') {'
+        printLineBreak()
+        indented {
+            statement?.code?.visit this
+        }
+        print '}'
+    }
+
+    @Override
+    void visitTernaryExpression(TernaryExpression expression) {
+        expression?.booleanExpression?.visit this
+        print ' ? '
+        expression?.trueExpression?.visit this
+        print ' : '
+        expression?.falseExpression?.visit this
+    }
+
+    @Override
+    void visitShortTernaryExpression(ElvisOperatorExpression expression) {
+        visitTernaryExpression(expression)
+    }
+
+    @Override
+    void visitBooleanExpression(BooleanExpression expression) {
+        expression?.expression?.visit this
+    }
+
+    @Override
+    void visitWhileLoop(WhileStatement statement) {
+        print 'while ('
+        statement?.booleanExpression?.visit this
+        print ') {'
+        printLineBreak()
+        indented {
+            statement?.loopBlock?.visit this
+        }
+        printLineBreak()
+        print '}'
+        printLineBreak()
+    }
+
+    @Override
+    void visitDoWhileLoop(DoWhileStatement statement) {
+        print 'do {'
+        printLineBreak()
+        indented {
+            statement?.loopBlock?.visit this
+        }
+        print '} while ('
+        statement?.booleanExpression?.visit this
+        print ')'
+        printLineBreak()
+    }
+
+    @Override
+    void visitCatchStatement(CatchStatement statement) {
+        print 'catch ('
+        visitParameters([statement.variable])
+        print ') {'
+        printLineBreak()
+        indented {
+            statement.code?.visit this
+        }
+        print '} '
+        printLineBreak()
+    }
+
+    @Override
+    void visitBitwiseNegationExpression(BitwiseNegationExpression expression) {
+        print '~('
+        expression?.expression?.visit this
+        print ') '
+    }
+
+    @Override
+    void visitAssertStatement(AssertStatement statement) {
+        print 'assert '
+        statement?.booleanExpression?.visit this
+        print ' : '
+        statement?.messageExpression?.visit this
+    }
+
+    @Override
+    void visitClosureListExpression(ClosureListExpression expression) {
+        boolean first = true
+        expression?.expressions?.each {
+            if (!first) {
+                print ';'
+            }
+            first = false
+            it.visit this
+        }
+    }
+
+    @Override
+    void visitMethodPointerExpression(MethodPointerExpression expression) {
+        expression?.expression?.visit this
+        print '.&'
+        expression?.methodName?.visit this
+    }
+
+    @Override
+    void visitArrayExpression(ArrayExpression expression) {
+        print 'new '
+        visitType expression?.elementType
+        print '['
+        visitExpressionsAndCommaSeparate(expression?.sizeExpression)
+        print ']'
+    }
+
+    private void visitExpressionsAndCommaSeparate(List<? super Expression> expressions) {
+        boolean first = true
+        expressions?.each {
+            if (!first) {
+                print ', '
+            }
+            first = false
+            it.visit this
+        }
+    }
+
+    @Override
+    void visitSpreadMapExpression(SpreadMapExpression expression) {
+        print '*:'
+        expression?.expression?.visit this
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-2324.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-2324.groovy b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-2324.groovy
new file mode 100644
index 0000000..30e2f30
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-2324.groovy
@@ -0,0 +1,23 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+class Foo {}
+
+Foo bar
+bar = new Foo()
+assert bar instanceof Foo

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-4438.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-4438.groovy b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-4438.groovy
new file mode 100644
index 0000000..41ee327
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-4438.groovy
@@ -0,0 +1,26 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+enum Outer {
+    A, B
+    enum Inner{X, Y}
+}
+assert Outer.A instanceof Outer
+assert Outer.B instanceof Outer
+assert Outer.Inner.X instanceof Outer.Inner
+assert Outer.Inner.Y instanceof Outer.Inner
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-4757.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-4757.groovy b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-4757.groovy
new file mode 100644
index 0000000..1a7d2e5
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-4757.groovy
@@ -0,0 +1,27 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package bugs
+
+class Foo {
+    <T extends Object> T foo(T t) {
+        return t
+    }
+}
+
+assert 'abc' == new Foo().foo('abc')
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-4762.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-4762.groovy b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-4762.groovy
new file mode 100644
index 0000000..235f6a5
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-4762.groovy
@@ -0,0 +1,27 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package bugs
+
+def get123() {2}
+def foo(i) {this}
+
+def a = foo(2).'123'
+def b = foo 2   123
+
+assert a == b
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-5318.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-5318.groovy b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-5318.groovy
new file mode 100644
index 0000000..13cb623
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-5318.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+def a= new java.util<Integer>.ArrayList<ArrayList<Integer>>()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-5652.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-5652.groovy b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-5652.groovy
new file mode 100644
index 0000000..e7c6b3f
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-5652.groovy
@@ -0,0 +1,24 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package bugs
+
+def list = [[1,2],[3,4]] as List<List<Integer>>
+println list
+println 'bye'
+assert [[1,2],[3,4]] == list

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-6038.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-6038.groovy b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-6038.groovy
new file mode 100644
index 0000000..f41c5e9
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-6038.groovy
@@ -0,0 +1,37 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import java.lang.annotation.*
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+@interface Upper {
+    @Retention(RetentionPolicy.RUNTIME)
+    @Target(ElementType.METHOD)
+    @interface Inner {
+        String testInner()
+    }
+}
+
+class X {
+    @Upper.Inner(testInner='abc')
+    def m() {}
+}
+
+def m = X.class.declaredMethods.find { it.name == 'm' }
+assert m.declaredAnnotations[0].testInner() == 'abc'

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8150.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8150.groovy b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8150.groovy
new file mode 100644
index 0000000..ac0cc9d
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8150.groovy
@@ -0,0 +1,21 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+def a
+def b = [1]
+((a)) = b
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8161.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8161.groovy b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8161.groovy
new file mode 100644
index 0000000..0b54cda
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/bugs/BUG-GROOVY-8161.groovy
@@ -0,0 +1,20 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+for (foo in []) {;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/bugs/GROOVY-3898.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/bugs/GROOVY-3898.groovy b/subprojects/parser-antlr4/src/test/resources/bugs/GROOVY-3898.groovy
new file mode 100644
index 0000000..146b5e6
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/bugs/GROOVY-3898.groovy
@@ -0,0 +1,26 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package bugs
+
+int result = 1
+for((i, j) = [0,0]; i < 3; {i++; j++}()){
+    result = result * i + j
+}
+assert 4 == result
+

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/AnnotationDeclaration_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/AnnotationDeclaration_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/AnnotationDeclaration_01.groovy
new file mode 100644
index 0000000..88f3a3d
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/AnnotationDeclaration_01.groovy
@@ -0,0 +1,57 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+import org.codehaus.groovy.transform.GroovyASTTransformationClass
+
+import java.lang.annotation.Documented
+import java.lang.annotation.ElementType
+import java.lang.annotation.Retention
+import java.lang.annotation.RetentionPolicy
+import java.lang.annotation.Target
+
+@Canonical(
+        includes = ['a', 'b'], excludes = ['c']
+)
+@Documented
+@Retention(RetentionPolicy.SOURCE)
+@Target(ElementType.FIELD)
+@GroovyASTTransformationClass('Lulz')
+@interface FunnyAnnotation {
+    public static final String SOME_CONSTANT2 = 'SOME_CONSTANT2';
+    String SOME_CONSTANT = 'SOME_CONSTANT';
+
+    /* This is a comment
+    */
+    String name() default ""
+
+    /**
+     * This has a default, too
+     */
+    boolean synchronize() default false
+
+    boolean synchronize2() default
+            false
+}
+
+@interface a {
+
+}
+
+@interface b {
+    String name()
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Annotation_01.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Annotation_01.groovy b/subprojects/parser-antlr4/src/test/resources/core/Annotation_01.groovy
new file mode 100644
index 0000000..c86b156
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Annotation_01.groovy
@@ -0,0 +1,19 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+@Export package core

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/test/resources/core/Annotation_02.groovy
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/test/resources/core/Annotation_02.groovy b/subprojects/parser-antlr4/src/test/resources/core/Annotation_02.groovy
new file mode 100644
index 0000000..8d624ae
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/resources/core/Annotation_02.groovy
@@ -0,0 +1,20 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+@Export
+package core

Reply | Threaded
Open this post in threaded view
|

[06/17] groovy git commit: rename antlr4 parser to remove groovy- prefix since that is by convention for modules

paulk
In reply to this post by paulk
http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovyLangLexer.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovyLangLexer.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovyLangLexer.java
new file mode 100644
index 0000000..d3b7538
--- /dev/null
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovyLangLexer.java
@@ -0,0 +1,63 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.parser.antlr4;
+
+import org.antlr.v4.runtime.CharStream;
+import org.antlr.v4.runtime.Lexer;
+import org.antlr.v4.runtime.LexerNoViableAltException;
+import org.antlr.v4.runtime.atn.ATN;
+import org.antlr.v4.runtime.atn.LexerATNSimulator;
+import org.apache.groovy.parser.antlr4.internal.AtnManager;
+
+/**
+ * The lexer for Groovy programming language, which is based on the lexer generated by Antlr4
+ *
+ * @author <a href="mailto:[hidden email]">Daniel.Sun</a>
+ * Created on 2016/08/14
+ */
+public class GroovyLangLexer extends GroovyLexer {
+    public GroovyLangLexer(CharStream input) {
+        super(input);
+
+        this.setInterpreter(new PositionAdjustingLexerATNSimulator(this, new AtnManager(this).getATN()));
+    }
+
+    @Override
+    public void recover(LexerNoViableAltException e) {
+        throw e; // if some lexical error occurred, stop parsing!
+    }
+
+    @Override
+    protected void rollbackOneChar() {
+        ((PositionAdjustingLexerATNSimulator) getInterpreter()).resetAcceptPosition(getInputStream(), _tokenStartCharIndex - 1, _tokenStartLine, _tokenStartCharPositionInLine - 1);
+    }
+
+    private static class PositionAdjustingLexerATNSimulator extends LexerATNSimulator {
+        public PositionAdjustingLexerATNSimulator(Lexer recog, ATN atn) {
+            super(recog, atn);
+        }
+
+        protected void resetAcceptPosition(CharStream input, int index, int line, int charPositionInLine) {
+            input.seek(index);
+            this.line = line;
+            this.charPositionInLine = charPositionInLine;
+            this.consume(input);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovyLangParser.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovyLangParser.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovyLangParser.java
new file mode 100644
index 0000000..fa33c6e
--- /dev/null
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovyLangParser.java
@@ -0,0 +1,38 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.groovy.parser.antlr4;
+
+import org.antlr.v4.runtime.TokenStream;
+import org.antlr.v4.runtime.atn.ParserATNSimulator;
+import org.apache.groovy.parser.antlr4.internal.AtnManager;
+
+/**
+ * The parser for Groovy programming language, which is based on the parser generated by Antlr4
+ *
+ * @author  <a href="mailto:[hidden email]">Daniel.Sun</a>
+ * Created on    2016/08/14
+ */
+public class GroovyLangParser extends GroovyParser {
+    public GroovyLangParser(TokenStream input) {
+        super(input);
+
+        this.setInterpreter(new ParserATNSimulator(this, new AtnManager(this).getATN()));
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovySyntaxError.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovySyntaxError.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovySyntaxError.java
new file mode 100644
index 0000000..7ca8bba
--- /dev/null
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovySyntaxError.java
@@ -0,0 +1,53 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.parser.antlr4;
+
+/**
+ * Represents a syntax error of groovy program
+ */
+public class GroovySyntaxError extends AssertionError {
+    public static final int LEXER = 0;
+    public static final int PARSER = 1;
+    private int source;
+    private int line;
+    private int column;
+
+    public GroovySyntaxError(String message, int source, int line, int column) {
+        super(message, null);
+
+        if (source != LEXER && source != PARSER) {
+            throw new IllegalArgumentException("Invalid syntax error source: " + source);
+        }
+
+        this.source = source;
+        this.line = line;
+        this.column = column;
+    }
+
+    public int getSource() {
+        return source;
+    }
+    public int getLine() {
+        return line;
+    }
+
+    public int getColumn() {
+        return column;
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java
new file mode 100644
index 0000000..449b2e7
--- /dev/null
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/GroovydocManager.java
@@ -0,0 +1,183 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.parser.antlr4;
+
+import groovy.lang.Groovydoc;
+import org.antlr.v4.runtime.ParserRuleContext;
+import org.antlr.v4.runtime.tree.ParseTree;
+import org.antlr.v4.runtime.tree.TerminalNode;
+import org.codehaus.groovy.GroovyBugError;
+import org.codehaus.groovy.ast.ASTNode;
+import org.codehaus.groovy.ast.AnnotatedNode;
+import org.codehaus.groovy.ast.AnnotationNode;
+import org.codehaus.groovy.ast.ClassHelper;
+import org.codehaus.groovy.ast.expr.ConstantExpression;
+
+import java.util.List;
+
+import static org.codehaus.groovy.runtime.DefaultGroovyMethods.asBoolean;
+
+/**
+ * A utilities for managing groovydoc, e.g.
+ * 1) extracting groovydoc from groovy AST;
+ * 2) TODO extracting tags from groovydoc;
+ * 3) attach groovydoc to AST node as metadata
+ */
+public class GroovydocManager {
+    public static final String DOC_COMMENT = "_DOC_COMMENT"; // keys for meta data
+    private static final String DOC_COMMENT_PREFIX = "/**";
+    private static final String EXTRACT_DOC_COMMENT = "groovy.extract.doc.comment";
+    private static final String TRUE_STR = "true";
+    private static final boolean EXTRACTING_DOC_COMMENT_ENABLED;
+    private static final String VALUE = "value";
+    private static final String RUNTIME_GROOVYDOC_PATTERN = "(?s)/[*][*]\\s+(\\s+[*]\\s*)*@Groovydoc\\b.+?[*]/";
+    private AstBuilder astBuilder;
+
+    static {
+        boolean edce;
+        try {
+            edce = TRUE_STR.equals(System.getProperty(EXTRACT_DOC_COMMENT));
+        } catch (Exception e) {
+            edce = false;
+        }
+
+        EXTRACTING_DOC_COMMENT_ENABLED = edce;
+    }
+
+    public GroovydocManager(AstBuilder astBuilder) {
+        this.astBuilder = astBuilder;
+    }
+
+    /**
+     * Attach doc comment to member node as meta data
+     *
+     */
+    public void handle(ASTNode node, GroovyParser.GroovyParserRuleContext ctx) {
+        if (!asBoolean(node) || !asBoolean(ctx)) {
+            return;
+        }
+
+        String docCommentNodeText = this.findDocCommentByNode(ctx);
+        if (null == docCommentNodeText) {
+            return;
+        }
+
+        attachDocCommentAsMetaData(node, docCommentNodeText);
+        attachGroovydocAnnotation(node, docCommentNodeText);
+    }
+
+    /*
+     * Attach doc comment to member node as meta data
+     */
+    private void attachDocCommentAsMetaData(ASTNode node, String docCommentNodeText) {
+        if (!EXTRACTING_DOC_COMMENT_ENABLED) {
+            return;
+        }
+
+        node.putNodeMetaData(DOC_COMMENT, docCommentNodeText);
+    }
+
+    /*
+     * Attach Groovydoc annotation to the target element
+     */
+    private void attachGroovydocAnnotation(ASTNode node, String docCommentNodeText) {
+        if (!(node instanceof AnnotatedNode)) {
+            return;
+        }
+
+        if (!docCommentNodeText.matches(RUNTIME_GROOVYDOC_PATTERN)) {
+            return;
+        }
+
+        AnnotatedNode annotatedNode = (AnnotatedNode) node;
+        AnnotationNode annotationNode = new AnnotationNode(ClassHelper.make(Groovydoc.class));
+        annotationNode.addMember(VALUE, new ConstantExpression(docCommentNodeText));
+        annotatedNode.addAnnotation(annotationNode);
+    }
+
+    private String findDocCommentByNode(ParserRuleContext node) {
+        if (!asBoolean(node)) {
+            return null;
+        }
+
+        if (node instanceof GroovyParser.ClassBodyContext) {
+            return null;
+        }
+
+        ParserRuleContext parentContext = node.getParent();
+
+        if (!asBoolean(parentContext)) {
+            return null;
+        }
+
+        String docCommentNodeText = null;
+        boolean sameTypeNodeBefore = false;
+        for (ParseTree child : parentContext.children) {
+
+            if (node == child) {
+                // if no doc comment node found and no siblings of same type before the node,
+                // try to find doc comment node of its parent
+                if (!asBoolean((Object) docCommentNodeText) && !sameTypeNodeBefore) {
+                    return findDocCommentByNode(parentContext);
+                }
+
+                return docCommentNodeText;
+            }
+
+            if (node.getClass() == child.getClass()) { // e.g. ClassBodyDeclarationContext == ClassBodyDeclarationContext
+                docCommentNodeText = null;
+                sameTypeNodeBefore = true;
+                continue;
+            }
+
+            if (!(child instanceof GroovyParser.NlsContext || child instanceof GroovyParser.SepContext)) {
+                continue;
+            }
+
+            // doc comments are treated as NL
+            List<? extends TerminalNode> nlList =
+                    child instanceof GroovyParser.NlsContext
+                            ? ((GroovyParser.NlsContext) child).NL()
+                            : ((GroovyParser.SepContext) child).NL();
+
+            int nlListSize = nlList.size();
+            if (0 == nlListSize) {
+                continue;
+            }
+
+            for (int i = nlListSize - 1; i >= 0; i--) {
+                String text = nlList.get(i).getText();
+
+                if (text.matches("\\s+")) {
+                    continue;
+                }
+
+                if (text.startsWith(DOC_COMMENT_PREFIX)) {
+                    docCommentNodeText = text;
+                } else {
+                    docCommentNodeText = null;
+                }
+
+                break;
+            }
+        }
+
+        throw new GroovyBugError("node can not be found: " + node.getText()); // The exception should never be thrown!
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/ModifierManager.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/ModifierManager.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/ModifierManager.java
new file mode 100644
index 0000000..a45e36c
--- /dev/null
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/ModifierManager.java
@@ -0,0 +1,198 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.parser.antlr4;
+
+import org.codehaus.groovy.ast.AnnotatedNode;
+import org.codehaus.groovy.ast.AnnotationNode;
+import org.codehaus.groovy.ast.ConstructorNode;
+import org.codehaus.groovy.ast.MethodNode;
+import org.codehaus.groovy.ast.Parameter;
+import org.codehaus.groovy.ast.expr.VariableExpression;
+import org.objectweb.asm.Opcodes;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import static org.apache.groovy.parser.antlr4.GroovyParser.*;
+import static org.codehaus.groovy.runtime.DefaultGroovyMethods.asBoolean;
+
+/**
+ * Process modifiers for AST nodes
+ * <p>
+ * Created by Daniel.Sun on 2016/08/27.
+ */
+class ModifierManager {
+    private static final Map<Class, List<Integer>> INVALID_MODIFIERS_MAP = Collections.unmodifiableMap(new HashMap<Class, List<Integer>>() {
+        {
+            put(ConstructorNode.class, Arrays.asList(STATIC, FINAL, ABSTRACT, NATIVE));
+            put(MethodNode.class, Arrays.asList(VOLATILE/*, TRANSIENT*/));
+        }
+    });
+    private AstBuilder astBuilder;
+    private List<ModifierNode> modifierNodeList;
+
+    public ModifierManager(AstBuilder astBuilder, List<ModifierNode> modifierNodeList) {
+        this.astBuilder = astBuilder;
+        this.validate(modifierNodeList);
+        this.modifierNodeList = Collections.unmodifiableList(asBoolean((Object) modifierNodeList) ? modifierNodeList : Collections.emptyList());
+    }
+
+    private void validate(List<ModifierNode> modifierNodeList) {
+        Map<ModifierNode, Integer> modifierNodeCounter = new LinkedHashMap<>(modifierNodeList.size());
+        int visibilityModifierCnt = 0;
+
+        for (ModifierNode modifierNode : modifierNodeList) {
+            Integer cnt = modifierNodeCounter.get(modifierNode);
+
+            if (null == cnt) {
+                modifierNodeCounter.put(modifierNode, 1);
+            } else if (1 == cnt && !modifierNode.isRepeatable()) {
+                throw astBuilder.createParsingFailedException("Cannot repeat modifier[" + modifierNode.getText() + "]", modifierNode);
+            }
+
+            if (modifierNode.isVisibilityModifier()) {
+                visibilityModifierCnt++;
+
+                if (visibilityModifierCnt > 1) {
+                    throw astBuilder.createParsingFailedException("Cannot specify modifier[" + modifierNode.getText() + "] when access scope has already been defined", modifierNode);
+                }
+            }
+        }
+    }
+
+    public void validate(MethodNode methodNode) {
+        validate(INVALID_MODIFIERS_MAP.get(MethodNode.class), methodNode);
+    }
+
+    public void validate(ConstructorNode constructorNode) {
+        validate(INVALID_MODIFIERS_MAP.get(ConstructorNode.class), constructorNode);
+    }
+
+    private void validate(List<Integer> invalidModifierList, MethodNode methodNode) {
+        modifierNodeList.forEach(e -> {
+            if (invalidModifierList.contains(e.getType())) {
+                throw astBuilder.createParsingFailedException(methodNode.getClass().getSimpleName().replace("Node", "") + " has an incorrect modifier '" + e + "'.", methodNode);
+            }
+        });
+    }
+
+    // t    1: class modifiers value; 2: class member modifiers value
+    private int calcModifiersOpValue(int t) {
+        int result = 0;
+
+        for (ModifierNode modifierNode : modifierNodeList) {
+            result |= modifierNode.getOpcode();
+        }
+
+        if (!this.containsVisibilityModifier()) {
+            if (1 == t) {
+                result |= Opcodes.ACC_SYNTHETIC | Opcodes.ACC_PUBLIC;
+            } else if (2 == t) {
+                result |= Opcodes.ACC_PUBLIC;
+            }
+        }
+
+        return result;
+    }
+
+    public int getClassModifiersOpValue() {
+        return this.calcModifiersOpValue(1);
+    }
+
+    public int getClassMemberModifiersOpValue() {
+        return this.calcModifiersOpValue(2);
+    }
+
+    public List<AnnotationNode> getAnnotations() {
+        return modifierNodeList.stream()
+                .filter(ModifierNode::isAnnotation)
+                .map(ModifierNode::getAnnotationNode)
+                .collect(Collectors.toList());
+    }
+
+    public boolean contains(int modifierType) {
+        return modifierNodeList.stream().anyMatch(e -> modifierType == e.getType());
+    }
+
+    public Optional<ModifierNode> get(int modifierType) {
+        return modifierNodeList.stream().filter(e -> modifierType == e.getType()).findFirst();
+    }
+
+    public boolean containsAnnotations() {
+        return modifierNodeList.stream().anyMatch(ModifierNode::isAnnotation);
+    }
+
+    public boolean containsVisibilityModifier() {
+        return modifierNodeList.stream().anyMatch(ModifierNode::isVisibilityModifier);
+    }
+
+    public boolean containsNonVisibilityModifier() {
+        return modifierNodeList.stream().anyMatch(ModifierNode::isNonVisibilityModifier);
+    }
+
+    public Parameter processParameter(Parameter parameter) {
+        modifierNodeList.forEach(e -> {
+            parameter.setModifiers(parameter.getModifiers() | e.getOpcode());
+
+            if (e.isAnnotation()) {
+                parameter.addAnnotation(e.getAnnotationNode());
+            }
+        });
+
+        return parameter;
+    }
+
+    public int clearVisibilityModifiers(int modifiers) {
+        return modifiers & ~Opcodes.ACC_PUBLIC & ~Opcodes.ACC_PROTECTED & ~Opcodes.ACC_PRIVATE;
+    }
+
+    public MethodNode processMethodNode(MethodNode mn) {
+        modifierNodeList.forEach(e -> {
+            mn.setModifiers((e.isVisibilityModifier() ? clearVisibilityModifiers(mn.getModifiers()) : mn.getModifiers()) | e.getOpcode());
+
+            if (e.isAnnotation()) {
+                mn.addAnnotation(e.getAnnotationNode());
+            }
+        });
+
+        return mn;
+    }
+
+    public VariableExpression processVariableExpression(VariableExpression ve) {
+        modifierNodeList.forEach(e -> {
+            ve.setModifiers(ve.getModifiers() | e.getOpcode());
+
+            // local variable does not attach annotations
+        });
+
+        return ve;
+    }
+
+    public <T extends AnnotatedNode> T attachAnnotations(T node) {
+        this.getAnnotations().forEach(node::addAnnotation);
+
+        return node;
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/ModifierNode.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/ModifierNode.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/ModifierNode.java
new file mode 100644
index 0000000..5d1007b
--- /dev/null
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/ModifierNode.java
@@ -0,0 +1,164 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.parser.antlr4;
+
+import org.codehaus.groovy.ast.ASTNode;
+import org.codehaus.groovy.ast.AnnotationNode;
+import org.objectweb.asm.Opcodes;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+
+import static org.apache.groovy.parser.antlr4.GroovyParser.*;
+import static org.codehaus.groovy.runtime.DefaultGroovyMethods.asBoolean;
+
+/**
+ * Represents a modifier, which is better to place in the package org.codehaus.groovy.ast
+ * <p>
+ * Created by Daniel.Sun on 2016/08/23.
+ */
+public class ModifierNode extends ASTNode {
+    private Integer type;
+    private Integer opcode; // ASM opcode
+    private String text;
+    private AnnotationNode annotationNode;
+    private boolean repeatable;
+
+    public static final int ANNOTATION_TYPE = -999;
+    public static final Map<Integer, Integer> MODIFIER_OPCODE_MAP = Collections.unmodifiableMap(new HashMap<Integer, Integer>() {
+        {
+            put(ANNOTATION_TYPE, 0);
+            put(DEF, 0);
+
+            put(NATIVE, Opcodes.ACC_NATIVE);
+            put(SYNCHRONIZED, Opcodes.ACC_SYNCHRONIZED);
+            put(TRANSIENT, Opcodes.ACC_TRANSIENT);
+            put(VOLATILE, Opcodes.ACC_VOLATILE);
+
+            put(PUBLIC, Opcodes.ACC_PUBLIC);
+            put(PROTECTED, Opcodes.ACC_PROTECTED);
+            put(PRIVATE, Opcodes.ACC_PRIVATE);
+            put(STATIC, Opcodes.ACC_STATIC);
+            put(ABSTRACT, Opcodes.ACC_ABSTRACT);
+            put(FINAL, Opcodes.ACC_FINAL);
+            put(STRICTFP, Opcodes.ACC_STRICT);
+            put(DEFAULT, 0); // no flag for specifying a default method in the JVM spec, hence no ACC_DEFAULT flag in ASM
+        }
+    });
+
+    public ModifierNode(Integer type) {
+        this.type = type;
+        this.opcode = MODIFIER_OPCODE_MAP.get(type);
+        this.repeatable = ANNOTATION_TYPE == type; // Only annotations are repeatable
+
+        if (!asBoolean((Object) this.opcode)) {
+            throw new IllegalArgumentException("Unsupported modifier type: " + type);
+        }
+    }
+
+    /**
+     * @param type the modifier type, which is same as the token type
+     * @param text text of the ast node
+     */
+    public ModifierNode(Integer type, String text) {
+        this(type);
+        this.text = text;
+    }
+
+    /**
+     * @param annotationNode the annotation node
+     * @param text           text of the ast node
+     */
+    public ModifierNode(AnnotationNode annotationNode, String text) {
+        this(ModifierNode.ANNOTATION_TYPE, text);
+        this.annotationNode = annotationNode;
+
+        if (!asBoolean(annotationNode)) {
+            throw new IllegalArgumentException("annotationNode can not be null");
+        }
+    }
+
+    /**
+     * Check whether the modifier is not an imagined modifier(annotation, def)
+     */
+    public boolean isModifier() {
+        return !this.isAnnotation() && !this.isDef();
+    }
+
+    public boolean isVisibilityModifier() {
+        return Objects.equals(PUBLIC, this.type)
+                || Objects.equals(PROTECTED, this.type)
+                || Objects.equals(PRIVATE, this.type);
+    }
+
+    public boolean isNonVisibilityModifier() {
+        return this.isModifier() && !this.isVisibilityModifier();
+    }
+
+    public boolean isAnnotation() {
+        return Objects.equals(ANNOTATION_TYPE, this.type);
+    }
+
+    public boolean isDef() {
+        return Objects.equals(DEF, this.type);
+    }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public Integer getOpcode() {
+        return opcode;
+    }
+
+    public boolean isRepeatable() {
+        return repeatable;
+    }
+
+    @Override
+    public String getText() {
+        return text;
+    }
+
+    public AnnotationNode getAnnotationNode() {
+        return annotationNode;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        ModifierNode that = (ModifierNode) o;
+        return Objects.equals(type, that.type) &&
+                Objects.equals(text, that.text) &&
+                Objects.equals(annotationNode, that.annotationNode);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(type, text, annotationNode);
+    }
+
+    @Override
+    public String toString() {
+        return this.text;
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/PositionInfo.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/PositionInfo.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/PositionInfo.java
new file mode 100644
index 0000000..b59aabb
--- /dev/null
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/PositionInfo.java
@@ -0,0 +1,73 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.parser.antlr4;
+
+import java.util.Objects;
+
+/**
+ * Created by Daniel on 2017/4/22.
+ */
+public class PositionInfo {
+    private int line;
+    private int column;
+
+    public PositionInfo(int line, int column) {
+        this.line = line;
+        this.column = column;
+    }
+
+    public int getLine() {
+        return line;
+    }
+
+    public void setLine(int line) {
+        this.line = line;
+    }
+
+    public int getColumn() {
+        return column;
+    }
+
+    public void setColumn(int column) {
+        this.column = column;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+        PositionInfo that = (PositionInfo) o;
+        return line == that.line &&
+                column == that.column;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(line, column);
+    }
+
+    @Override
+    public String toString() {
+        if (-1 == line || -1 == column) {
+            return "";
+        }
+
+        return " @ line " + line + ", column " + column;
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/SemanticPredicates.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/SemanticPredicates.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/SemanticPredicates.java
new file mode 100644
index 0000000..eb3dbd9
--- /dev/null
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/SemanticPredicates.java
@@ -0,0 +1,152 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.parser.antlr4;
+
+import org.antlr.v4.runtime.CharStream;
+import org.antlr.v4.runtime.Token;
+import org.antlr.v4.runtime.TokenStream;
+
+import java.util.Collections;
+import java.util.Set;
+
+import static org.apache.groovy.parser.antlr4.GroovyParser.*;
+
+/**
+ * Some semantic predicates for altering the behaviour of the lexer and parser
+ *
+ * @author  <a href="mailto:[hidden email]">Daniel.Sun</a>
+ * Created on    2016/08/20
+ */
+public class SemanticPredicates {
+    public static boolean isFollowedByWhiteSpaces(CharStream cs) {
+        for (int index = 1, c = cs.LA(index); !('\r' == c || '\n' == c || CharStream.EOF == c); index++, c = cs.LA(index)) {
+            if (String.valueOf((char) c).matches("\\S+?")) {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    public static boolean isFollowedBy(CharStream cs, char... chars) {
+        int c1 = cs.LA(1);
+
+        for (char c : chars) {
+            if (c1 == c) {
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    public static boolean isFollowedByJavaLetterInGString(CharStream cs) {
+        int c1 = cs.LA(1);
+
+        if ('$' == c1) { // single $ is not a valid identifier
+            return false;
+        }
+
+        String str1 = String.valueOf((char) c1);
+
+        if (str1.matches("[a-zA-Z_{]")) {
+            return true;
+        }
+
+        if (str1.matches("[^\u0000-\u007F\uD800-\uDBFF]")
+                && Character.isJavaIdentifierPart(c1)) {
+            return true;
+        }
+
+        int c2 = cs.LA(2);
+        String str2 = String.valueOf((char) c2);
+
+        if (str1.matches("[\uD800-\uDBFF]")
+                && str2.matches("[\uDC00-\uDFFF]")
+                && Character.isJavaIdentifierPart(Character.toCodePoint((char) c1, (char) c2))) {
+
+            return true;
+        }
+
+        return false;
+    }
+
+    /**
+     * Check whether following a method name of command expression.
+     * Method name should not end with "2: arguments" and "3: closure"
+     *
+     * @param t the type of pathExpression
+     * @return
+     */
+    public static boolean isFollowingMethodName(int t) {
+        return !(2 == t || 3 == t);
+    }
+
+    /**
+     * Distinguish between method declaration and method call/constructor declaration
+     */
+    public static boolean isInvalidMethodDeclaration(TokenStream ts) {
+        int tokenType = ts.LT(1).getType();
+
+        return (Identifier == tokenType || CapitalizedIdentifier == tokenType || StringLiteral == tokenType)
+                && LPAREN == (ts.LT(2).getType());
+    }
+
+    private static final Set<Integer> MODIFIER_SET =
+            Collections.unmodifiableSet(ModifierNode.MODIFIER_OPCODE_MAP.keySet());
+    /**
+     * Distinguish between local variable declaration and method call, e.g. `a b`
+     */
+    public static boolean isInvalidLocalVariableDeclaration(TokenStream ts) {
+        int index = 2;
+        Token token;
+        int tokenType;
+        int tokenType2 = ts.LT(index).getType();
+        int tokenType3;
+
+        if (DOT == tokenType2) {
+            int tokeTypeN = tokenType2;
+
+            do {
+                index = index + 2;
+                tokeTypeN = ts.LT(index).getType();
+            } while (DOT == tokeTypeN);
+
+            if (LT == tokeTypeN || LBRACK == tokeTypeN) {
+                return false;
+            }
+
+            index = index - 1;
+            tokenType2 = ts.LT(index + 1).getType();
+        } else {
+            index = 1;
+        }
+
+        token = ts.LT(index);
+        tokenType = token.getType();
+        tokenType3 = ts.LT(index + 2).getType();
+
+        return //VOID == tokenType ||
+                !(BuiltInPrimitiveType == tokenType || MODIFIER_SET.contains(tokenType))
+                    && Character.isLowerCase(token.getText().codePointAt(0))
+                    && !(ASSIGN == tokenType3 || (LT == tokenType2 || LBRACK == tokenType2));
+
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/SyntaxErrorReportable.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/SyntaxErrorReportable.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/SyntaxErrorReportable.java
new file mode 100644
index 0000000..021e2f5
--- /dev/null
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/SyntaxErrorReportable.java
@@ -0,0 +1,58 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.parser.antlr4;
+
+/**
+ * A SyntaxErrorReportable is a recognizer that can report syntax error
+ */
+public interface SyntaxErrorReportable {
+    default void require(boolean condition, String msg, int offset, boolean toAttachPositionInfo) {
+        if (condition) {
+            return;
+        }
+
+        this.throwSyntaxError(msg, offset, toAttachPositionInfo);
+    }
+    default void require(boolean condition, String msg, boolean toAttachPositionInfo) {
+        require(condition, msg, 0, toAttachPositionInfo);
+    }
+    default void require(boolean condition, String msg, int offset) {
+        require(condition, msg, offset,false);
+    }
+    default void require(boolean condition, String msg) {
+        require(condition, msg, false);
+    }
+
+    default void throwSyntaxError(String msg, int offset, boolean toAttachPositionInfo) {
+        PositionInfo positionInfo = this.genPositionInfo(offset);
+        throw new GroovySyntaxError(msg + (toAttachPositionInfo ? positionInfo.toString() : ""),
+                this.getSyntaxErrorSource(),
+                positionInfo.getLine(),
+                positionInfo.getColumn()
+        );
+    }
+
+    int getSyntaxErrorSource();
+    default PositionInfo genPositionInfo(int offset) {
+        return new PositionInfo(getErrorLine(), getErrorColumn() + offset);
+    }
+
+    int getErrorLine();
+    int getErrorColumn();
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/TryWithResourcesASTTransformation.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/TryWithResourcesASTTransformation.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/TryWithResourcesASTTransformation.java
new file mode 100644
index 0000000..cbe3697
--- /dev/null
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/TryWithResourcesASTTransformation.java
@@ -0,0 +1,370 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.parser.antlr4;
+
+import org.codehaus.groovy.ast.ClassHelper;
+import org.codehaus.groovy.ast.Parameter;
+import org.codehaus.groovy.ast.expr.ArgumentListExpression;
+import org.codehaus.groovy.ast.expr.BinaryExpression;
+import org.codehaus.groovy.ast.expr.BooleanExpression;
+import org.codehaus.groovy.ast.expr.ConstantExpression;
+import org.codehaus.groovy.ast.expr.DeclarationExpression;
+import org.codehaus.groovy.ast.expr.MethodCallExpression;
+import org.codehaus.groovy.ast.expr.VariableExpression;
+import org.codehaus.groovy.ast.stmt.BlockStatement;
+import org.codehaus.groovy.ast.stmt.CatchStatement;
+import org.codehaus.groovy.ast.stmt.EmptyStatement;
+import org.codehaus.groovy.ast.stmt.ExpressionStatement;
+import org.codehaus.groovy.ast.stmt.IfStatement;
+import org.codehaus.groovy.ast.stmt.Statement;
+import org.codehaus.groovy.ast.stmt.ThrowStatement;
+import org.codehaus.groovy.ast.stmt.TryCatchStatement;
+import org.codehaus.groovy.syntax.Types;
+import org.objectweb.asm.Opcodes;
+
+import java.util.Collections;
+import java.util.List;
+
+import static org.codehaus.groovy.runtime.DefaultGroovyMethods.asBoolean;
+
+/**
+ * Transform try-with-resources to try-catch-finally
+ * Reference JLS "14.20.3. try-with-resources"(https://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html)
+ *
+ * @author <a href="mailto:[hidden email]">Daniel.Sun</a>
+ *         Created on 2016/11/04
+ */
+public class TryWithResourcesASTTransformation {
+    private AstBuilder astBuilder;
+
+    public TryWithResourcesASTTransformation(AstBuilder astBuilder) {
+        this.astBuilder = astBuilder;
+    }
+
+    /**
+     * Reference JLS "14.20.3. try-with-resources"(https://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html)
+     *
+     * @param tryCatchStatement the try-with-resources statement to transform
+     * @return try-catch-finally statement, which contains no resources clause
+     */
+    public Statement transform(TryCatchStatement tryCatchStatement) {
+        if (!asBoolean(tryCatchStatement.getResourceStatements())) {
+            return tryCatchStatement;
+        }
+
+        if (this.isBasicTryWithResourcesStatement(tryCatchStatement)) {
+            return this.transformBasicTryWithResourcesStatement(tryCatchStatement);
+        } else {
+            return this.transformExtendedTryWithResourcesStatement(tryCatchStatement);
+        }
+    }
+
+    private boolean isBasicTryWithResourcesStatement(TryCatchStatement tryCatchStatement) {
+        if (EmptyStatement.INSTANCE.equals(tryCatchStatement.getFinallyStatement())
+                && !asBoolean(tryCatchStatement.getCatchStatements())) {
+            return true;
+        }
+
+        return false;
+    }
+
+    private ExpressionStatement makeVariableDeclarationFinal(ExpressionStatement variableDeclaration) {
+        if (!asBoolean(variableDeclaration)) {
+            return variableDeclaration;
+        }
+
+        if (!(variableDeclaration.getExpression() instanceof DeclarationExpression)) {
+            throw new IllegalArgumentException("variableDeclaration is not a declaration statement");
+        }
+
+        DeclarationExpression declarationExpression = (DeclarationExpression) variableDeclaration.getExpression();
+        if (!(declarationExpression.getLeftExpression() instanceof VariableExpression)) {
+            throw astBuilder.createParsingFailedException("The expression statement is not a variable delcaration statement", variableDeclaration);
+        }
+
+        VariableExpression variableExpression = (VariableExpression) declarationExpression.getLeftExpression();
+        variableExpression.setModifiers(variableExpression.getModifiers() | Opcodes.ACC_FINAL);
+
+        return variableDeclaration;
+    }
+
+    private int primaryExcCnt = 0;
+    private String genPrimaryExcName() {
+        return "__$$primaryExc" + primaryExcCnt++;
+    }
+
+    /*
+     *   try ResourceSpecification
+     *       Block
+     *   Catchesopt
+     *   Finallyopt
+     *
+     *   **The above AST should be transformed to the following AST**
+     *
+     *   try {
+     *       try ResourceSpecification
+     *           Block
+     *   }
+     *   Catchesopt
+     *   Finallyopt
+     */
+    private Statement transformExtendedTryWithResourcesStatement(TryCatchStatement tryCatchStatement) {
+        /*
+         *  try ResourceSpecification
+         *      Block
+         */
+        TryCatchStatement newTryWithResourcesStatement =
+                new TryCatchStatement(
+                        tryCatchStatement.getTryStatement(),
+                        EmptyStatement.INSTANCE);
+        tryCatchStatement.getResourceStatements().forEach(newTryWithResourcesStatement::addResource);
+
+
+        /*
+         *   try {
+         *       << the following try-with-resources has been transformed >>
+         *       try ResourceSpecification
+         *           Block
+         *   }
+         *   Catchesopt
+         *   Finallyopt
+         */
+        TryCatchStatement newTryCatchStatement =
+                new TryCatchStatement(
+                        astBuilder.createBlockStatement(this.transform(newTryWithResourcesStatement)),
+                        tryCatchStatement.getFinallyStatement());
+
+        tryCatchStatement.getCatchStatements().forEach(newTryCatchStatement::addCatch);
+
+        return newTryCatchStatement;
+    }
+
+    /*
+     *   try (VariableModifiersopt R Identifier = Expression ...)
+     *      Block
+     *
+     *  **The above AST should be transformed to the following AST**
+     *
+     *   {
+     *       final VariableModifiers_minus_final R Identifier = Expression;
+     *       Throwable #primaryExc = null;
+     *
+     *       try ResourceSpecification_tail
+     *           Block
+     *       catch (Throwable #t) {
+     *           #primaryExc = #t;
+     *           throw #t;
+     *       } finally {
+     *           if (Identifier != null) {
+     *               if (#primaryExc != null) {
+     *                   try {
+     *                       Identifier.close();
+     *                   } catch (Throwable #suppressedExc) {
+     *                       #primaryExc.addSuppressed(#suppressedExc);
+     *                   }
+     *               } else {
+     *                   Identifier.close();
+     *               }
+     *           }
+     *       }
+     *   }
+     *
+     */
+    private Statement transformBasicTryWithResourcesStatement(TryCatchStatement tryCatchStatement) {
+        // { ... }
+        BlockStatement blockStatement = new BlockStatement();
+
+        // final VariableModifiers_minus_final R Identifier = Expression;
+        ExpressionStatement firstResourceStatement =
+                this.makeVariableDeclarationFinal(
+                        tryCatchStatement.getResourceStatement(0));
+        astBuilder.appendStatementsToBlockStatement(blockStatement, firstResourceStatement);
+
+        // Throwable #primaryExc = null;
+        String primaryExcName = this.genPrimaryExcName();
+        ExpressionStatement primaryExcDeclarationStatement =
+                new ExpressionStatement(
+                        new DeclarationExpression(
+                                new VariableExpression(primaryExcName, ClassHelper.make(Throwable.class)),
+                                org.codehaus.groovy.syntax.Token.newSymbol(Types.ASSIGN, -1, -1),
+                                new ConstantExpression(null)
+                        )
+                );
+        astBuilder.appendStatementsToBlockStatement(blockStatement, primaryExcDeclarationStatement);
+
+
+        // The generated try-catch-finally statement
+        String firstResourceIdentifierName =
+                ((DeclarationExpression) tryCatchStatement.getResourceStatement(0).getExpression()).getLeftExpression().getText();
+
+        TryCatchStatement newTryCatchStatement =
+                new TryCatchStatement(
+                        tryCatchStatement.getTryStatement(),
+                        this.createFinallyBlockForNewTryCatchStatement(primaryExcName, firstResourceIdentifierName));
+
+        List<ExpressionStatement> resourceStatements = tryCatchStatement.getResourceStatements();
+        // 2nd, 3rd, ..., n'th resources declared in resources
+        List<ExpressionStatement> tailResourceStatements = resourceStatements.subList(1, resourceStatements.size());
+        tailResourceStatements.stream().forEach(newTryCatchStatement::addResource);
+
+        newTryCatchStatement.addCatch(this.createCatchBlockForOuterNewTryCatchStatement(primaryExcName));
+        astBuilder.appendStatementsToBlockStatement(blockStatement, this.transform(newTryCatchStatement));
+
+        return blockStatement;
+    }
+
+    /*
+     *   catch (Throwable #t) {
+     *       #primaryExc = #t;
+     *       throw #t;
+     *   }
+     *
+     */
+    private CatchStatement createCatchBlockForOuterNewTryCatchStatement(String primaryExcName) {
+        // { ... }
+        BlockStatement blockStatement = new BlockStatement();
+        String tExcName = this.genTExcName();
+
+        // #primaryExc = #t;
+        ExpressionStatement primaryExcAssignStatement =
+                new ExpressionStatement(
+                        new BinaryExpression(
+                                new VariableExpression(primaryExcName),
+                                org.codehaus.groovy.syntax.Token.newSymbol(Types.ASSIGN, -1, -1),
+                                new VariableExpression(tExcName)));
+        astBuilder.appendStatementsToBlockStatement(blockStatement, primaryExcAssignStatement);
+
+        // throw #t;
+        ThrowStatement throwTExcStatement = new ThrowStatement(new VariableExpression(tExcName));
+        astBuilder.appendStatementsToBlockStatement(blockStatement, throwTExcStatement);
+
+        // Throwable #t
+        Parameter tExcParameter = new Parameter(ClassHelper.make(Throwable.class), tExcName);
+
+        return new CatchStatement(tExcParameter, blockStatement);
+    }
+
+    private int tExcCnt = 0;
+    private String genTExcName() {
+        return "__$$t" + tExcCnt++;
+    }
+
+    /*
+     *   finally {
+     *       if (Identifier != null) {
+     *           if (#primaryExc != null) {
+     *              try {
+     *                  Identifier.close();
+     *              } catch (Throwable #suppressedExc) {
+     *                  #primaryExc.addSuppressed(#suppressedExc);
+     *              }
+     *           } else {
+     *               Identifier.close();
+     *           }
+     *       }
+     *   }
+     *
+     * We can simplify the above code to a Groovy version as follows:
+     *
+     *   finally {
+     *      if (#primaryExc != null)
+     *         try {
+     *             Identifier?.close();
+     *         } catch (Throwable #suppressedExc) {
+     *             #primaryExc.addSuppressed(#suppressedExc);
+     *         }
+     *      else
+     *          Identifier?.close();
+     *
+     *   }
+     *
+     */
+    private BlockStatement createFinallyBlockForNewTryCatchStatement(String primaryExcName, String firstResourceIdentifierName) {
+        BlockStatement finallyBlock = new BlockStatement();
+
+        // primaryExc != null
+        BooleanExpression conditionExpression =
+                new BooleanExpression(
+                        new BinaryExpression(
+                                new VariableExpression(primaryExcName),
+                                org.codehaus.groovy.syntax.Token.newSymbol(Types.COMPARE_NOT_EQUAL, -1, -1),
+                                new ConstantExpression(null)));
+
+        // try-catch statement
+        TryCatchStatement newTryCatchStatement =
+                new TryCatchStatement(
+                        astBuilder.createBlockStatement(this.createCloseResourceStatement(firstResourceIdentifierName)), // { Identifier?.close(); }
+                        EmptyStatement.INSTANCE);
+
+
+        String suppressedExcName = this.genSuppressedExcName();
+        newTryCatchStatement.addCatch(
+                // catch (Throwable #suppressedExc) { .. }
+                new CatchStatement(
+                        new Parameter(ClassHelper.make(Throwable.class), suppressedExcName),
+                        astBuilder.createBlockStatement(this.createAddSuppressedStatement(primaryExcName, suppressedExcName)) // #primaryExc.addSuppressed(#suppressedExc);
+                )
+        );
+
+        // if (#primaryExc != null) { ... }
+        IfStatement ifStatement =
+                new IfStatement(
+                        conditionExpression,
+                        newTryCatchStatement,
+                        this.createCloseResourceStatement(firstResourceIdentifierName) // Identifier?.close();
+                );
+        astBuilder.appendStatementsToBlockStatement(finallyBlock, ifStatement);
+
+        return astBuilder.createBlockStatement(finallyBlock);
+    }
+
+    private int suppressedExcCnt = 0;
+    private String genSuppressedExcName() {
+        return "__$$suppressedExc" + suppressedExcCnt++;
+    }
+
+    /*
+     *  Identifier?.close();
+     */
+    private ExpressionStatement createCloseResourceStatement(String firstResourceIdentifierName) {
+        MethodCallExpression closeMethodCallExpression =
+                new MethodCallExpression(new VariableExpression(firstResourceIdentifierName), "close", new ArgumentListExpression());
+
+        closeMethodCallExpression.setImplicitThis(false);
+        closeMethodCallExpression.setSafe(true);
+
+        return new ExpressionStatement(closeMethodCallExpression);
+    }
+
+    /*
+     *  #primaryExc.addSuppressed(#suppressedExc);
+     */
+    private ExpressionStatement createAddSuppressedStatement(String primaryExcName, String suppressedExcName) {
+        MethodCallExpression addSuppressedMethodCallExpression =
+                new MethodCallExpression(
+                        new VariableExpression(primaryExcName),
+                        "addSuppressed",
+                        new ArgumentListExpression(Collections.singletonList(new VariableExpression(suppressedExcName))));
+        addSuppressedMethodCallExpression.setImplicitThis(false);
+        addSuppressedMethodCallExpression.setSafe(true);
+
+        return new ExpressionStatement(addSuppressedMethodCallExpression);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/internal/AtnManager.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/internal/AtnManager.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/internal/AtnManager.java
new file mode 100644
index 0000000..02cc152
--- /dev/null
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/internal/AtnManager.java
@@ -0,0 +1,107 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.parser.antlr4.internal;
+
+import org.antlr.v4.runtime.atn.ATN;
+import org.apache.groovy.parser.antlr4.GroovyLangLexer;
+import org.apache.groovy.parser.antlr4.GroovyLangParser;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+/**
+ * Manage ATN for lexer and parser to avoid memory leak
+ *
+ * @author <a href="mailto:[hidden email]">Daniel.Sun</a>
+ * Created on 2016/08/14
+ */
+public class AtnManager {
+    public static final ReentrantReadWriteLock RRWL = new ReentrantReadWriteLock(true);
+    private static final String CACHE_THRESHOLD_NAME = "groovy.antlr4.cache.threshold";
+    private static final int CACHE_THRESHOLD;
+    private final Class ownerClass;
+    private final ATN atn;
+    private static final Map<Class, AtnWrapper> ATN_MAP =
+            Collections.unmodifiableMap(new HashMap<Class, AtnWrapper>() {
+                {
+                    put(GroovyLangLexer.class, new AtnWrapper(GroovyLangLexer._ATN));
+                    put(GroovyLangParser.class, new AtnWrapper(GroovyLangParser._ATN));
+                }
+            });
+
+    static {
+        int t = 50;
+
+        try {
+            t = Integer.parseInt(System.getProperty(CACHE_THRESHOLD_NAME));
+
+            // cache threshold should be at least 50 for better performance
+            t = t < 50 ? 50 : t;
+        } catch (Exception e) {
+            // ignored
+        }
+
+        CACHE_THRESHOLD = t;
+    }
+
+    public AtnManager(GroovyLangLexer lexer) {
+        this.ownerClass = lexer.getClass();
+        this.atn = GroovyLangLexer._ATN; //getAtnWrapper(this.ownerClass).checkAndClear();
+    }
+
+    public AtnManager(GroovyLangParser parser) {
+        this.ownerClass = parser.getClass();
+        this.atn = getAtnWrapper(this.ownerClass).checkAndClear();
+    }
+
+    public ATN getATN() {
+        return this.atn;
+    }
+
+    private AtnWrapper getAtnWrapper(Class ownerClass) {
+        return ATN_MAP.get(ownerClass);
+    }
+
+    private static class AtnWrapper {
+        private final ATN atn;
+        private final AtomicLong counter = new AtomicLong(0);
+
+        public AtnWrapper(ATN atn) {
+            this.atn = atn;
+        }
+
+        public ATN checkAndClear() {
+            if (0 != counter.incrementAndGet() % CACHE_THRESHOLD) {
+                return atn;
+            }
+
+            RRWL.writeLock().lock();
+            try {
+                atn.clearDFA();
+            } finally {
+                RRWL.writeLock().unlock();
+            }
+
+            return atn;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/internal/DescriptiveErrorStrategy.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/internal/DescriptiveErrorStrategy.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/internal/DescriptiveErrorStrategy.java
new file mode 100644
index 0000000..12081ed
--- /dev/null
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/internal/DescriptiveErrorStrategy.java
@@ -0,0 +1,110 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.parser.antlr4.internal;
+
+import org.antlr.v4.runtime.BailErrorStrategy;
+import org.antlr.v4.runtime.FailedPredicateException;
+import org.antlr.v4.runtime.InputMismatchException;
+import org.antlr.v4.runtime.NoViableAltException;
+import org.antlr.v4.runtime.Parser;
+import org.antlr.v4.runtime.ParserRuleContext;
+import org.antlr.v4.runtime.RecognitionException;
+import org.antlr.v4.runtime.Token;
+import org.antlr.v4.runtime.TokenStream;
+import org.antlr.v4.runtime.atn.PredictionMode;
+import org.antlr.v4.runtime.misc.NotNull;
+import org.antlr.v4.runtime.misc.ParseCancellationException;
+
+/**
+ * Provide friendly error messages when parsing errors occurred.
+ *
+ * @author <a href="mailto:[hidden email]">Daniel.Sun</a>
+ *         Created on 2016/10/19
+ */
+public class DescriptiveErrorStrategy extends BailErrorStrategy {
+    @Override
+    public void recover(Parser recognizer, RecognitionException e) {
+        for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent()) {
+            context.exception = e;
+        }
+
+        if (PredictionMode.LL.equals(recognizer.getInterpreter().getPredictionMode())) {
+            if (e instanceof NoViableAltException) {
+                this.reportNoViableAlternative(recognizer, (NoViableAltException) e);
+            } else if (e instanceof InputMismatchException) {
+                this.reportInputMismatch(recognizer, (InputMismatchException) e);
+            } else if (e instanceof FailedPredicateException) {
+                this.reportFailedPredicate(recognizer, (FailedPredicateException) e);
+            }
+        }
+
+        throw new ParseCancellationException(e);
+    }
+
+    @Override
+    public Token recoverInline(Parser recognizer)
+            throws RecognitionException {
+
+        this.recover(recognizer, new InputMismatchException(recognizer)); // stop parsing
+        return null;
+    }
+
+    protected String createNoViableAlternativeErrorMessage(Parser recognizer, NoViableAltException e) {
+        TokenStream tokens = recognizer.getInputStream();
+        String input;
+        if (tokens != null) {
+            if (e.getStartToken().getType() == Token.EOF) input = "<EOF>";
+            else input = tokens.getText(e.getStartToken(), e.getOffendingToken());
+        } else {
+            input = "<unknown input>";
+        }
+
+        return "Unexpected input: " + escapeWSAndQuote(input);
+    }
+
+    @Override
+    protected void reportNoViableAlternative(@NotNull Parser recognizer,
+                                             @NotNull NoViableAltException e) {
+
+        notifyErrorListeners(recognizer, this.createNoViableAlternativeErrorMessage(recognizer, e), e);
+    }
+
+    protected String createInputMismatchErrorMessage(@NotNull Parser recognizer,
+                                                     @NotNull InputMismatchException e) {
+        return "Unexpected input: " + getTokenErrorDisplay(e.getOffendingToken(recognizer)) +
+                "; Expecting " + e.getExpectedTokens().toString(recognizer.getVocabulary());
+    }
+
+    protected void reportInputMismatch(@NotNull Parser recognizer,
+                                       @NotNull InputMismatchException e) {
+
+        notifyErrorListeners(recognizer, this.createInputMismatchErrorMessage(recognizer, e), e);
+    }
+
+
+    protected String createFailedPredicateErrorMessage(@NotNull Parser recognizer,
+                                                       @NotNull FailedPredicateException e) {
+        return e.getMessage();
+    }
+
+    protected void reportFailedPredicate(@NotNull Parser recognizer,
+                                         @NotNull FailedPredicateException e) {
+        notifyErrorListeners(recognizer, this.createFailedPredicateErrorMessage(recognizer, e), e);
+    }
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java
new file mode 100644
index 0000000..739a737
--- /dev/null
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java
@@ -0,0 +1,149 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.parser.antlr4.util;
+
+import groovy.lang.Closure;
+import org.codehaus.groovy.runtime.StringGroovyMethods;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+/**
+ * Utilities for handling strings
+ *
+ * @author  <a href="mailto:[hidden email]">Daniel.Sun</a>
+ * Created on    2016/08/20
+ */
+public class StringUtils {
+    public static String replaceHexEscapes(String text) {
+        Pattern p = Pattern.compile("(\\\\*)\\\\u+([0-9abcdefABCDEF]{4})");
+    return StringGroovyMethods.replaceAll((CharSequence) text, p, new Closure<Void>(null, null) {
+    Object doCall(String _0, String _1, String _2) {
+ if (isLengthOdd(_1)) {
+ return _0;
+ }
+
+    return _1 + new String(Character.toChars(Integer.parseInt(_2, 16)));
+    }
+    });
+    }
+
+ public static String replaceOctalEscapes(String text) {
+    Pattern p = Pattern.compile("(\\\\*)\\\\([0-3]?[0-7]?[0-7])");
+    return StringGroovyMethods.replaceAll((CharSequence) text, p, new Closure<Void>(null, null) {
+    Object doCall(String _0, String _1, String _2) {
+ if (isLengthOdd(_1)) {
+ return _0;
+ }
+
+    return _1 + new String(Character.toChars(Integer.parseInt(_2, 8)));
+    }
+    });
+    }
+
+    private static Map<Character, Character> STANDARD_ESCAPES = new HashMap<Character, Character>() {
+ {
+ this.put('b', '\b');
+ this.put('t', '\t');
+ this.put('n', '\n');
+ this.put('f', '\f');
+ this.put('r', '\r');
+ }
+ };
+
+ public static String replaceStandardEscapes(String text) {
+    Pattern p = Pattern.compile("(\\\\*)\\\\([btnfr\"'])");
+
+    String result = StringGroovyMethods.replaceAll((CharSequence) text, p, new Closure<Void>(null, null) {
+ Object doCall(String _0, String _1, String _2) {
+ if (isLengthOdd(_1)) {
+ return _0;
+ }
+
+ Character character = STANDARD_ESCAPES.get(_2.charAt(0));
+ return _1 + (character != null ? character : _2);
+ }
+ });
+
+ return result.replace("\\\\", "\\");
+    }
+
+ public static final int NONE_SLASHY = 0;
+ public static final int SLASHY = 1;
+ public static final int DOLLAR_SLASHY = 2;
+
+ public static String replaceEscapes(String text, int slashyType) {
+ if (slashyType == SLASHY || slashyType == DOLLAR_SLASHY) {
+ text = StringUtils.replaceHexEscapes(text);
+ text = StringUtils.replaceLineEscape(text);
+
+ if (slashyType == SLASHY) {
+ text = text.replace("\\/", "/");
+ }
+
+ if (slashyType == DOLLAR_SLASHY) {
+ text = text.replace("$$", "$");
+ text = text.replace("$/", "/");
+ }
+
+ } else if (slashyType == NONE_SLASHY) {
+ text = StringUtils.replaceEscapes(text);
+ } else {
+ throw new IllegalArgumentException("Invalid slashyType: " + slashyType);
+ }
+
+ return text;
+ }
+
+ private static String replaceEscapes(String text) {
+ text = text.replace("\\$", "$");
+
+ text = StringUtils.replaceLineEscape(text);
+
+        return StringUtils.replaceStandardEscapes(replaceHexEscapes(replaceOctalEscapes(text)));
+    }
+
+ private static String replaceLineEscape(String text) {
+ Pattern p = Pattern.compile("(\\\\*)\\\\\r?\n");
+ text = StringGroovyMethods.replaceAll((CharSequence) text, p, new Closure<Void>(null, null) {
+ Object doCall(String _0, String _1) {
+ if (isLengthOdd(_1)) {
+ return _0;
+ }
+
+ return _1;
+ }
+ });
+
+ return text;
+ }
+
+ private static boolean isLengthOdd(String str) {
+ return null != str && str.length() % 2 == 1;
+ }
+
+ public static String removeCR(String text) {
+        return text.replace("\r\n", "\n");
+    }
+
+ public static long countChar(String text, char c) {
+ return text.chars().filter(e -> c == e).count();
+ }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/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
new file mode 100644
index 0000000..480d2ab
--- /dev/null
+++ b/subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
@@ -0,0 +1,368 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.parser.antlr4
+
+import org.codehaus.groovy.ast.ClassNode
+import org.codehaus.groovy.ast.FieldNode
+import org.codehaus.groovy.ast.MethodNode
+import org.codehaus.groovy.ast.Parameter
+import org.codehaus.groovy.ast.PropertyNode
+import org.codehaus.groovy.ast.stmt.AssertStatement
+import org.codehaus.groovy.ast.stmt.ExpressionStatement
+import org.codehaus.groovy.syntax.Token
+
+import static org.apache.groovy.parser.antlr4.TestUtils.doTest
+import static org.apache.groovy.parser.antlr4.TestUtils.doRunAndTest
+
+/**
+ * Some basic test cases for the new parser
+ *
+ * @author  <a href="mailto:[hidden email]">Daniel.Sun</a>
+ * Created on    2016/08/14
+ */
+class GroovyParserTest extends GroovyTestCase {
+
+    void setUp() {}
+
+    void tearDown() {}
+
+    void "test groovy core - Comments"() {
+        doTest('core/Comments_01.groovy', [ExpressionStatement]);
+        doTestAttachedComments();
+    }
+
+    private static doTestAttachedComments() {
+        def (newAST, oldAST) = doTest('core/Comments_02.groovy');
+        List<ClassNode> classes = new ArrayList<>(newAST.classes).sort { c1, c2 -> c1.name <=> c2.name };
+        List<MethodNode> methods = new ArrayList<>(newAST.methods).sort { m1, m2 -> m1.name <=> m2.name };
+
+        assert classes[0].nodeMetaData[GroovydocManager.DOC_COMMENT].replaceAll(/\r?\n/, '')            == '/** * test class Comments */'
+        assert classes[0].fields[0].nodeMetaData[GroovydocManager.DOC_COMMENT].replaceAll(/\r?\n/, '')  == '/**     * test Comments.SOME_VAR     */'
+        assert classes[0].fields[1].nodeMetaData[GroovydocManager.DOC_COMMENT].replaceAll(/\r?\n/, '')  == '/**     * test Comments.SOME_VAR2     */'
+        assert classes[0].fields[2].nodeMetaData[GroovydocManager.DOC_COMMENT] == null
+        assert classes[0].fields[3].nodeMetaData[GroovydocManager.DOC_COMMENT] == null
+        assert classes[0].declaredConstructors[0].nodeMetaData[GroovydocManager.DOC_COMMENT].replaceAll(/\r?\n/, '') == '/**     * test Comments.constructor1     */'
+        assert classes[0].methods[0].nodeMetaData[GroovydocManager.DOC_COMMENT].replaceAll(/\r?\n/, '') == '/**     * test Comments.m1     */'
+        assert classes[0].methods[1].nodeMetaData[GroovydocManager.DOC_COMMENT] == null
+        assert classes[0].methods[2].nodeMetaData[GroovydocManager.DOC_COMMENT].replaceAll(/\r?\n/, '') == '/**     * test Comments.m3     */'
+
+        assert classes[1].nodeMetaData[GroovydocManager.DOC_COMMENT].replaceAll(/\r?\n/, '')            == '/**     * test class InnerClazz     */'
+        assert classes[1].fields[0].nodeMetaData[GroovydocManager.DOC_COMMENT].replaceAll(/\r?\n/, '')  == '/**         * test InnerClazz.SOME_VAR3         */'
+        assert classes[1].fields[1].nodeMetaData[GroovydocManager.DOC_COMMENT].replaceAll(/\r?\n/, '')  == '/**         * test InnerClazz.SOME_VAR4         */'
+        assert classes[1].methods[0].nodeMetaData[GroovydocManager.DOC_COMMENT].replaceAll(/\r?\n/, '') == '/**         * test Comments.m4         */'
+        assert classes[1].methods[1].nodeMetaData[GroovydocManager.DOC_COMMENT].replaceAll(/\r?\n/, '') == '/**         * test Comments.m5         */'
+
+        assert classes[2].nodeMetaData[GroovydocManager.DOC_COMMENT].replaceAll(/\r?\n/, '')            == '/**     * test class InnerEnum     */'
+        assert classes[2].fields[0].nodeMetaData[GroovydocManager.DOC_COMMENT].replaceAll(/\r?\n/, '')  == '/**         * InnerEnum.NEW         */'
+        assert classes[2].fields[1].nodeMetaData[GroovydocManager.DOC_COMMENT].replaceAll(/\r?\n/, '')  == '/**         * InnerEnum.OLD         */'
+
+        assert classes[3].nodeMetaData[GroovydocManager.DOC_COMMENT] == null
+
+        assert classes[4].fields[0].nodeMetaData[GroovydocManager.DOC_COMMENT] == null
+
+        assert classes[5].nodeMetaData[GroovydocManager.DOC_COMMENT] == null
+
+        assert methods[0].nodeMetaData[GroovydocManager.DOC_COMMENT].replaceAll(/\r?\n/, '') == '/** * test someScriptMethod1 */'
+        assert methods[1].nodeMetaData[GroovydocManager.DOC_COMMENT] == null
+    }
+
+    void "test groovy core - PackageDeclaration"() {
+        doTest('core/PackageDeclaration_01.groovy');
+        doTest('core/PackageDeclaration_02.groovy');
+        doTest('core/PackageDeclaration_03.groovy');
+        doTest('core/PackageDeclaration_04.groovy');
+        doTest('core/PackageDeclaration_05.groovy');
+        doTest('core/PackageDeclaration_06.groovy');
+    }
+
+    void "test groovy core - ImportDeclaration"() {
+        doTest('core/ImportDeclaration_01.groovy');
+        doTest('core/ImportDeclaration_02.groovy');
+        doTest('core/ImportDeclaration_03.groovy');
+        doTest('core/ImportDeclaration_04.groovy');
+        doTest('core/ImportDeclaration_05.groovy');
+        doTest('core/ImportDeclaration_06.groovy');
+        doTest('core/ImportDeclaration_07.groovy');
+        doTest('core/ImportDeclaration_08.groovy');
+    }
+
+    void "test groovy core - Annotation"() {
+        doTest('core/Annotation_01.groovy');
+        doTest('core/Annotation_02.groovy');
+        doTest('core/Annotation_03.groovy');
+        doTest('core/Annotation_04.groovy');
+        doTest('core/Annotation_05.groovy');
+        doTest('core/Annotation_06.groovy');
+        doTest('core/Annotation_07.groovy');
+        doTest('core/Annotation_08.groovy');
+        doTest('core/Annotation_09.groovy');
+        doRunAndTest('core/Annotation_10x.groovy');
+    }
+
+    void "test groovy core - Literal"() {
+        doTest('core/Literal_01.groovy');
+        doTest('core/Literal_02.groovy', [ExpressionStatement]);
+        doTest('core/Literal_03.groovy');
+    }
+
+    void "test groovy core - GString"() {
+        doTest('core/GString_01.groovy');
+        doTest('core/GString_02.groovy');
+        doTest('core/GString_03.groovy');
+        doTest('core/GString_04.groovy');
+        doTest('core/GString_05.groovy');
+        doTest('core/GString_06.groovy');
+    }
+
+    void "test groovy core - Closure"() {
+        doTest('core/Closure_01.groovy');
+        doTest('core/Closure_02.groovy');
+        doTest('core/Closure_03.groovy');
+        doTest('core/Closure_04.groovy');
+        doTest('core/Closure_05.groovy', [Parameter]);
+        doTest('core/Closure_06.groovy', [Parameter]);
+        doTest('core/Closure_07.groovy', [Parameter]);
+        doTest('core/Closure_08.groovy', [Parameter]);
+        doTest('core/Closure_09.groovy', [Parameter]);
+        doTest('core/Closure_10.groovy', [Parameter]);
+    }
+
+    void "test groovy core - Lambda"() {
+        doRunAndTest('core/Lambda_01x.groovy');
+    }
+
+    void "test groovy core - MethodReference"() {
+        doRunAndTest('core/MethodReference_01x.groovy');
+    }
+
+    void "test groovy core - MethodPointer"() {
+        doRunAndTest('core/MethodPointer_01x.groovy');
+    }
+
+    void "test groovy core - ElvisAssignment"() {
+        doRunAndTest('core/ElvisAssignment_01x.groovy');
+    }
+
+    void "test groovy core - List"() {
+        doTest('core/List_01.groovy');
+    }
+
+    void "test groovy core - Map"() {
+        doTest('core/Map_01.groovy');
+    }
+
+    void "test groovy core - Expression"() {
+        doTest('core/Expression_01.groovy');
+        doTest('core/Expression_02.groovy');
+        doTest('core/Expression_03.groovy');
+        doTest('core/Expression_04.groovy');
+        doTest('core/Expression_05.groovy');
+        doTest('core/Expression_06.groovy');
+        doTest('core/Expression_07.groovy');
+        doTest('core/Expression_08.groovy');
+        doTest('core/Expression_09.groovy');
+        doTest('core/Expression_10.groovy');
+        doTest('core/Expression_11.groovy');
+        doTest('core/Expression_12.groovy');
+        doTest('core/Expression_13.groovy');
+        doTest('core/Expression_14.groovy');
+        doTest('core/Expression_15.groovy');
+        doTest('core/Expression_16.groovy', [Parameter, ExpressionStatement]);
+        doTest('core/Expression_17.groovy');
+        doTest('core/Expression_18.groovy');
+        doTest('core/Expression_19.groovy');
+        doTest('core/Expression_20.groovy');
+        doRunAndTest('core/Expression_21x.groovy');
+        doTest('core/Expression_22x.groovy');
+        doRunAndTest('core/Expression_22x.groovy');
+        doRunAndTest('core/Expression_23x.groovy');
+    }
+
+    void "test groovy core - IdenticalOp"() {
+        doRunAndTest('core/IdenticalOp_01x.groovy');
+    }
+
+    void "test groovy core - Assert"() {
+        doTest('core/Assert_01.groovy');
+        doRunAndTest('core/Assert_02x.groovy');
+        doRunAndTest('core/Assert_03x.groovy');
+    }
+
+    void "test groovy core - IfElse"() {
+        doTest('core/IfElse_01.groovy', [AssertStatement]);
+    }
+
+    void "test groovy core - For"() {
+        doTest('core/For_01.groovy', [AssertStatement]);
+        doTest('core/For_02.groovy');
+        doTest('core/For_03.groovy');
+        doRunAndTest('core/For_04x.groovy');
+        doRunAndTest('core/For_05x.groovy');
+    }
+
+    void "test groovy core - While"() {
+        doTest('core/While_01.groovy');
+        doRunAndTest('core/While_02x.groovy');
+    }
+
+    void "test groovy core - CodeBlock"() {
+        doRunAndTest('core/CodeBlock_01x.groovy');
+    }
+
+    void "test groovy core - DoWhile"() {
+        doRunAndTest('core/DoWhile_01x.groovy');
+        doRunAndTest('core/DoWhile_02x.groovy');
+        doRunAndTest('core/DoWhile_03x.groovy');
+        doRunAndTest('core/DoWhile_04x.groovy');
+    }
+
+
+    void "test groovy core - TryCatch"() {
+        doTest('core/TryCatch_01.groovy');
+    }
+
+    void "test groovy core - TryWithResources"() {
+        doRunAndTest('core/TryWithResources_01x.groovy');
+    }
+
+    void "test groovy core - SafeIndex"() {
+        doRunAndTest('core/SafeIndex_01x.groovy');
+        doRunAndTest('core/SafeIndex_02x.groovy');
+        doRunAndTest('core/SafeIndex_03x.groovy');
+    }
+
+    void "test groovy core - NegativeRelationalOperators"() {
+        doRunAndTest('core/NegativeRelationalOperators_01x.groovy');
+        doRunAndTest('core/NegativeRelationalOperators_02x.groovy');
+    }
+
+    void "test groovy core - DefaultMethod"() {
+        doRunAndTest('core/DefaultMethod_01x.groovy');
+        doRunAndTest('core/DefaultMethod_02x.groovy');
+    }
+
+
+    void "test groovy core - Switch"() {
+        doTest('core/Switch_01.groovy');
+    }
+
+    void "test groovy core - Synchronized"() {
+        doTest('core/Synchronized_01.groovy');
+    }
+
+    void "test groovy core - Return"() {
+        doTest('core/Return_01.groovy');
+    }
+
+    void "test groovy core - Throw"() {
+        doTest('core/Throw_01.groovy');
+    }
+
+    void "test groovy core - Label"() {
+        doTest('core/Label_01.groovy');
+    }
+
+    void "test groovy core - LocalVariableDeclaration"() {
+        doTest('core/LocalVariableDeclaration_01.groovy', [Token]); // [class org.codehaus.groovy.syntax.Token][startLine]:: 9 != 8
+    }
+
+    void "test groovy core - MethodDeclaration"() {
+        doTest('core/MethodDeclaration_01.groovy');
+        doTest('core/MethodDeclaration_02.groovy');
+    }
+
+    void "test groovy core - ClassDeclaration"() {
+        doTest('core/ClassDeclaration_01.groovy');
+        doTest('core/ClassDeclaration_02.groovy');
+        doTest('core/ClassDeclaration_03.groovy');
+        doTest('core/ClassDeclaration_04.groovy', [PropertyNode, FieldNode]);
+        doTest('core/ClassDeclaration_05.groovy', [ExpressionStatement]);
+        doTest('core/ClassDeclaration_06.groovy');
+        doTest('core/ClassDeclaration_07.groovy');
+    }
+
+    void "test groovy core - InterfaceDeclaration"() {
+        doTest('core/InterfaceDeclaration_01.groovy');
+        doTest('core/InterfaceDeclaration_02.groovy');
+        doTest('core/InterfaceDeclaration_03.groovy');
+    }
+
+    void "test groovy core - EnumDeclaration"() {
+        doTest('core/EnumDeclaration_01.groovy');
+        doTest('core/EnumDeclaration_02.groovy', [ExpressionStatement]);
+        doTest('core/EnumDeclaration_03.groovy');
+        doTest('core/EnumDeclaration_04.groovy');
+        doTest('core/EnumDeclaration_05.groovy');
+    }
+
+    void "test groovy core - TraitDeclaration"() {
+        doTest('core/TraitDeclaration_01.groovy');
+        doTest('core/TraitDeclaration_02.groovy');
+        doTest('core/TraitDeclaration_03.groovy');
+        doTest('core/TraitDeclaration_04.groovy', [PropertyNode, FieldNode]);
+        doTest('core/TraitDeclaration_05.groovy');
+    }
+
+    void "test groovy core - AnnotationDeclaration"() {
+        doTest('core/AnnotationDeclaration_01.groovy');
+    }
+
+    void "test groovy core - Command"() {
+        doTest('core/Command_01.groovy');
+        doTest('core/Command_02.groovy');
+        doTest('core/Command_03.groovy', [ExpressionStatement, Parameter]);
+        doTest('core/Command_04.groovy', [ExpressionStatement]);
+        doTest('core/Command_05.groovy');
+        doRunAndTest('core/Command_06x.groovy')
+    }
+
+    void "test groovy core - Unicode"() {
+        doTest('core/Unicode_01.groovy');
+    }
+
+    void "test groovy core - BreakingChanges"() {
+        doRunAndTest('core/BreakingChange_01x.groovy');
+        doRunAndTest('core/BreakingChange_02x.groovy');
+        doRunAndTest('core/BreakingChange_03x.groovy');
+        doRunAndTest('core/BreakingChange_04x.groovy');
+    }
+
+    void "test groovy core - Array"() {
+        doRunAndTest('core/Array_01x.groovy');
+    }
+
+    void "test groovy core - Groovydoc"() {
+        doRunAndTest('core/Groovydoc_01x.groovy');
+    }
+
+    void "test groovy core - Script"() {
+        doRunAndTest('core/Script_01x.groovy');
+    }
+
+    void "test groovy core - BUG"() {
+        doRunAndTest('bugs/BUG-GROOVY-4757.groovy');
+        doRunAndTest('bugs/GROOVY-3898.groovy');
+        doRunAndTest('bugs/BUG-GROOVY-5652.groovy');
+        doRunAndTest('bugs/BUG-GROOVY-4762.groovy');
+        doRunAndTest('bugs/BUG-GROOVY-4438.groovy');
+        doRunAndTest('bugs/BUG-GROOVY-6038.groovy');
+        doRunAndTest('bugs/BUG-GROOVY-2324.groovy');
+        doTest('bugs/BUG-GROOVY-8161.groovy');
+    }
+}

Reply | Threaded
Open this post in threaded view
|

[07/17] groovy git commit: rename antlr4 parser to remove groovy- prefix since that is by convention for modules

paulk
In reply to this post by paulk
http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/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
new file mode 100644
index 0000000..e0708f7
--- /dev/null
+++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
@@ -0,0 +1,4317 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.groovy.parser.antlr4;
+
+import groovy.lang.IntRange;
+import org.antlr.v4.runtime.ANTLRErrorListener;
+import org.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.CommonTokenStream;
+import org.antlr.v4.runtime.RecognitionException;
+import org.antlr.v4.runtime.Recognizer;
+import org.antlr.v4.runtime.Token;
+import org.antlr.v4.runtime.atn.PredictionMode;
+import org.antlr.v4.runtime.misc.ParseCancellationException;
+import org.antlr.v4.runtime.tree.ParseTree;
+import org.antlr.v4.runtime.tree.TerminalNode;
+import org.apache.groovy.parser.antlr4.internal.AtnManager;
+import org.apache.groovy.parser.antlr4.internal.DescriptiveErrorStrategy;
+import org.apache.groovy.parser.antlr4.util.StringUtils;
+import org.codehaus.groovy.GroovyBugError;
+import org.codehaus.groovy.antlr.EnumHelper;
+import org.codehaus.groovy.ast.ASTNode;
+import org.codehaus.groovy.ast.AnnotationNode;
+import org.codehaus.groovy.ast.ClassHelper;
+import org.codehaus.groovy.ast.ClassNode;
+import org.codehaus.groovy.ast.ConstructorNode;
+import org.codehaus.groovy.ast.EnumConstantClassNode;
+import org.codehaus.groovy.ast.FieldNode;
+import org.codehaus.groovy.ast.GenericsType;
+import org.codehaus.groovy.ast.ImportNode;
+import org.codehaus.groovy.ast.InnerClassNode;
+import org.codehaus.groovy.ast.MethodNode;
+import org.codehaus.groovy.ast.ModuleNode;
+import org.codehaus.groovy.ast.PackageNode;
+import org.codehaus.groovy.ast.Parameter;
+import org.codehaus.groovy.ast.PropertyNode;
+import org.codehaus.groovy.ast.expr.AnnotationConstantExpression;
+import org.codehaus.groovy.ast.expr.ArgumentListExpression;
+import org.codehaus.groovy.ast.expr.ArrayExpression;
+import org.codehaus.groovy.ast.expr.AttributeExpression;
+import org.codehaus.groovy.ast.expr.BinaryExpression;
+import org.codehaus.groovy.ast.expr.BitwiseNegationExpression;
+import org.codehaus.groovy.ast.expr.BooleanExpression;
+import org.codehaus.groovy.ast.expr.CastExpression;
+import org.codehaus.groovy.ast.expr.ClassExpression;
+import org.codehaus.groovy.ast.expr.ClosureExpression;
+import org.codehaus.groovy.ast.expr.ClosureListExpression;
+import org.codehaus.groovy.ast.expr.ConstantExpression;
+import org.codehaus.groovy.ast.expr.ConstructorCallExpression;
+import org.codehaus.groovy.ast.expr.DeclarationExpression;
+import org.codehaus.groovy.ast.expr.ElvisOperatorExpression;
+import org.codehaus.groovy.ast.expr.EmptyExpression;
+import org.codehaus.groovy.ast.expr.Expression;
+import org.codehaus.groovy.ast.expr.GStringExpression;
+import org.codehaus.groovy.ast.expr.LambdaExpression;
+import org.codehaus.groovy.ast.expr.ListExpression;
+import org.codehaus.groovy.ast.expr.MapEntryExpression;
+import org.codehaus.groovy.ast.expr.MapExpression;
+import org.codehaus.groovy.ast.expr.MethodCallExpression;
+import org.codehaus.groovy.ast.expr.MethodPointerExpression;
+import org.codehaus.groovy.ast.expr.MethodReferenceExpression;
+import org.codehaus.groovy.ast.expr.NamedArgumentListExpression;
+import org.codehaus.groovy.ast.expr.NotExpression;
+import org.codehaus.groovy.ast.expr.PostfixExpression;
+import org.codehaus.groovy.ast.expr.PrefixExpression;
+import org.codehaus.groovy.ast.expr.PropertyExpression;
+import org.codehaus.groovy.ast.expr.RangeExpression;
+import org.codehaus.groovy.ast.expr.SpreadExpression;
+import org.codehaus.groovy.ast.expr.SpreadMapExpression;
+import org.codehaus.groovy.ast.expr.TernaryExpression;
+import org.codehaus.groovy.ast.expr.TupleExpression;
+import org.codehaus.groovy.ast.expr.UnaryMinusExpression;
+import org.codehaus.groovy.ast.expr.UnaryPlusExpression;
+import org.codehaus.groovy.ast.expr.VariableExpression;
+import org.codehaus.groovy.ast.stmt.AssertStatement;
+import org.codehaus.groovy.ast.stmt.BlockStatement;
+import org.codehaus.groovy.ast.stmt.BreakStatement;
+import org.codehaus.groovy.ast.stmt.CaseStatement;
+import org.codehaus.groovy.ast.stmt.CatchStatement;
+import org.codehaus.groovy.ast.stmt.ContinueStatement;
+import org.codehaus.groovy.ast.stmt.DoWhileStatement;
+import org.codehaus.groovy.ast.stmt.EmptyStatement;
+import org.codehaus.groovy.ast.stmt.ExpressionStatement;
+import org.codehaus.groovy.ast.stmt.ForStatement;
+import org.codehaus.groovy.ast.stmt.IfStatement;
+import org.codehaus.groovy.ast.stmt.ReturnStatement;
+import org.codehaus.groovy.ast.stmt.Statement;
+import org.codehaus.groovy.ast.stmt.SwitchStatement;
+import org.codehaus.groovy.ast.stmt.SynchronizedStatement;
+import org.codehaus.groovy.ast.stmt.ThrowStatement;
+import org.codehaus.groovy.ast.stmt.TryCatchStatement;
+import org.codehaus.groovy.ast.stmt.WhileStatement;
+import org.codehaus.groovy.control.CompilationFailedException;
+import org.codehaus.groovy.control.CompilePhase;
+import org.codehaus.groovy.control.SourceUnit;
+import org.codehaus.groovy.control.messages.SyntaxErrorMessage;
+import org.codehaus.groovy.runtime.IOGroovyMethods;
+import org.codehaus.groovy.runtime.StringGroovyMethods;
+import org.codehaus.groovy.syntax.Numbers;
+import org.codehaus.groovy.syntax.SyntaxException;
+import org.codehaus.groovy.syntax.Types;
+import org.objectweb.asm.Opcodes;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Field;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static org.apache.groovy.parser.antlr4.GroovyLangParser.*;
+import static org.codehaus.groovy.runtime.DefaultGroovyMethods.asBoolean;
+import static org.codehaus.groovy.runtime.DefaultGroovyMethods.last;
+
+/**
+ * Building the AST from the parse tree generated by Antlr4
+ *
+ * @author <a href="mailto:[hidden email]">Daniel.Sun</a>
+ *         Created on 2016/08/14
+ */
+public class AstBuilder extends GroovyParserBaseVisitor<Object> implements GroovyParserVisitor<Object> {
+
+    public AstBuilder(SourceUnit sourceUnit, ClassLoader classLoader) {
+        this.sourceUnit = sourceUnit;
+        this.moduleNode = new ModuleNode(sourceUnit);
+        this.classLoader = classLoader; // unused for the time being
+
+        this.lexer = new GroovyLangLexer(
+                new ANTLRInputStream(
+                        this.readSourceCode(sourceUnit)));
+        this.parser = new GroovyLangParser(
+                new CommonTokenStream(this.lexer));
+
+        this.parser.setErrorHandler(new DescriptiveErrorStrategy());
+
+        this.tryWithResourcesASTTransformation = new TryWithResourcesASTTransformation(this);
+        this.groovydocManager = new GroovydocManager(this);
+    }
+
+    private GroovyParserRuleContext buildCST() {
+        GroovyParserRuleContext result;
+
+        // parsing have to wait util clearing is complete.
+        AtnManager.RRWL.readLock().lock();
+        try {
+            result = buildCST(PredictionMode.SLL);
+        } catch (Throwable t) {
+            // if some syntax error occurred in the lexer, no need to retry the powerful LL mode
+            if (t instanceof GroovySyntaxError && GroovySyntaxError.LEXER == ((GroovySyntaxError) t).getSource()) {
+                throw t;
+            }
+
+            result = buildCST(PredictionMode.LL);
+        } finally {
+            AtnManager.RRWL.readLock().unlock();
+        }
+
+        return result;
+    }
+
+    private GroovyParserRuleContext buildCST(PredictionMode predictionMode) {
+        parser.getInterpreter().setPredictionMode(predictionMode);
+
+        if (PredictionMode.SLL.equals(predictionMode)) {
+            this.removeErrorListeners();
+        } else {
+            ((CommonTokenStream) parser.getInputStream()).reset();
+            this.addErrorListeners();
+        }
+
+        return parser.compilationUnit();
+    }
+
+    public ModuleNode buildAST() {
+        try {
+            return (ModuleNode) this.visit(this.buildCST());
+        } catch (Throwable t) {
+            CompilationFailedException cfe;
+
+            if (t instanceof CompilationFailedException) {
+                cfe = (CompilationFailedException) t;
+            } else if (t instanceof ParseCancellationException) {
+                cfe = createParsingFailedException(t.getCause());
+            } else {
+                cfe = createParsingFailedException(t);
+            }
+
+//            LOGGER.log(Level.SEVERE, "Failed to build AST", cfe);
+
+            throw cfe;
+        }
+    }
+
+    @Override
+    public ModuleNode visitCompilationUnit(CompilationUnitContext ctx) {
+        this.visit(ctx.packageDeclaration());
+
+        ctx.statement().stream()
+                .map(this::visit)
+//                .filter(e -> e instanceof Statement)
+                .forEach(e -> {
+                    if (e instanceof DeclarationListStatement) { // local variable declaration
+                        ((DeclarationListStatement) e).getDeclarationStatements().forEach(moduleNode::addStatement);
+                    } else if (e instanceof Statement) {
+                        moduleNode.addStatement((Statement) e);
+                    } else if (e instanceof MethodNode) { // script method
+                        moduleNode.addMethod((MethodNode) e);
+                    }
+                });
+
+        this.classNodeList.forEach(moduleNode::addClass);
+
+        if (this.isPackageInfoDeclaration()) {
+            this.addPackageInfoClassNode();
+        } else {
+            // if groovy source file only contains blank(including EOF), add "return null" to the AST
+            if (this.isBlankScript(ctx)) {
+                this.addEmptyReturnStatement();
+            }
+        }
+
+        this.configureScriptClassNode();
+
+        return moduleNode;
+    }
+
+    @Override
+    public PackageNode visitPackageDeclaration(PackageDeclarationContext ctx) {
+        String packageName = this.visitQualifiedName(ctx.qualifiedName());
+        moduleNode.setPackageName(packageName + DOT_STR);
+
+        PackageNode packageNode = moduleNode.getPackage();
+
+        this.visitAnnotationsOpt(ctx.annotationsOpt()).forEach(packageNode::addAnnotation);
+
+        return this.configureAST(packageNode, ctx);
+    }
+
+    @Override
+    public ImportNode visitImportDeclaration(ImportDeclarationContext ctx) {
+        ImportNode importNode;
+
+        boolean hasStatic = asBoolean(ctx.STATIC());
+        boolean hasStar = asBoolean(ctx.MUL());
+        boolean hasAlias = asBoolean(ctx.alias);
+
+        List<AnnotationNode> annotationNodeList = this.visitAnnotationsOpt(ctx.annotationsOpt());
+
+        if (hasStatic) {
+            if (hasStar) { // e.g. import static java.lang.Math.*
+                String qualifiedName = this.visitQualifiedName(ctx.qualifiedName());
+                ClassNode type = ClassHelper.make(qualifiedName);
+
+
+                moduleNode.addStaticStarImport(type.getText(), type, annotationNodeList);
+
+                importNode = last(moduleNode.getStaticStarImports().values());
+            } else { // e.g. import static java.lang.Math.pow
+                List<GroovyParserRuleContext> identifierList = new LinkedList<>(ctx.qualifiedName().qualifiedNameElement());
+                int identifierListSize = identifierList.size();
+                String name = identifierList.get(identifierListSize - 1).getText();
+                ClassNode classNode =
+                        ClassHelper.make(
+                                identifierList.stream()
+                                        .limit(identifierListSize - 1)
+                                        .map(ParseTree::getText)
+                                        .collect(Collectors.joining(DOT_STR)));
+                String alias = hasAlias
+                        ? ctx.alias.getText()
+                        : name;
+
+                moduleNode.addStaticImport(classNode, name, alias, annotationNodeList);
+
+                importNode = last(moduleNode.getStaticImports().values());
+            }
+        } else {
+            if (hasStar) { // e.g. import java.util.*
+                String qualifiedName = this.visitQualifiedName(ctx.qualifiedName());
+
+                moduleNode.addStarImport(qualifiedName + DOT_STR, annotationNodeList);
+
+                importNode = last(moduleNode.getStarImports());
+            } else { // e.g. import java.util.Map
+                String qualifiedName = this.visitQualifiedName(ctx.qualifiedName());
+                String name = last(ctx.qualifiedName().qualifiedNameElement()).getText();
+                ClassNode classNode = ClassHelper.make(qualifiedName);
+                String alias = hasAlias
+                        ? ctx.alias.getText()
+                        : name;
+
+                moduleNode.addImport(alias, classNode, annotationNodeList);
+
+                importNode = last(moduleNode.getImports());
+            }
+        }
+
+        return this.configureAST(importNode, ctx);
+    }
+
+    // statement {    --------------------------------------------------------------------
+    @Override
+    public AssertStatement visitAssertStatement(AssertStatementContext ctx) {
+        Expression conditionExpression = (Expression) this.visit(ctx.ce);
+        BooleanExpression booleanExpression =
+                this.configureAST(
+                        new BooleanExpression(conditionExpression), conditionExpression);
+
+        if (!asBoolean(ctx.me)) {
+            return this.configureAST(
+                    new AssertStatement(booleanExpression), ctx);
+        }
+
+        return this.configureAST(new AssertStatement(booleanExpression,
+                        (Expression) this.visit(ctx.me)),
+                ctx);
+    }
+
+    @Override
+    public AssertStatement visitAssertStmtAlt(AssertStmtAltContext ctx) {
+        return this.configureAST(this.visitAssertStatement(ctx.assertStatement()), ctx);
+    }
+
+    @Override
+    public IfStatement visitIfElseStmtAlt(IfElseStmtAltContext ctx) {
+        Expression conditionExpression = this.visitParExpression(ctx.parExpression());
+        BooleanExpression booleanExpression =
+                this.configureAST(
+                        new BooleanExpression(conditionExpression), conditionExpression);
+
+        Statement ifBlock =
+                this.unpackStatement(
+                        (Statement) this.visit(ctx.tb));
+        Statement elseBlock =
+                this.unpackStatement(
+                        asBoolean(ctx.ELSE())
+                                ? (Statement) this.visit(ctx.fb)
+                                : EmptyStatement.INSTANCE);
+
+        return this.configureAST(new IfStatement(booleanExpression, ifBlock, elseBlock), ctx);
+    }
+
+    @Override
+    public Statement visitLoopStmtAlt(LoopStmtAltContext ctx) {
+        return this.configureAST((Statement) this.visit(ctx.loopStatement()), ctx);
+    }
+
+    @Override
+    public ForStatement visitForStmtAlt(ForStmtAltContext ctx) {
+        Pair<Parameter, Expression> controlPair = this.visitForControl(ctx.forControl());
+
+        Statement loopBlock = this.unpackStatement((Statement) this.visit(ctx.statement()));
+
+        return this.configureAST(
+                new ForStatement(controlPair.getKey(), controlPair.getValue(), asBoolean(loopBlock) ? loopBlock : EmptyStatement.INSTANCE),
+                ctx);
+    }
+
+    @Override
+    public Pair<Parameter, Expression> visitForControl(ForControlContext ctx) {
+        if (asBoolean(ctx.enhancedForControl())) { // e.g. for(int i in 0..<10) {}
+            return this.visitEnhancedForControl(ctx.enhancedForControl());
+        }
+
+        if (asBoolean(ctx.classicalForControl())) { // e.g. for(int i = 0; i < 10; i++) {}
+            return this.visitClassicalForControl(ctx.classicalForControl());
+        }
+
+        throw createParsingFailedException("Unsupported for control: " + ctx.getText(), ctx);
+    }
+
+    @Override
+    public Expression visitForInit(ForInitContext ctx) {
+        if (!asBoolean(ctx)) {
+            return EmptyExpression.INSTANCE;
+        }
+
+        if (asBoolean(ctx.localVariableDeclaration())) {
+            DeclarationListStatement declarationListStatement = this.visitLocalVariableDeclaration(ctx.localVariableDeclaration());
+            List<?> declarationExpressionList = declarationListStatement.getDeclarationExpressions();
+
+            if (declarationExpressionList.size() == 1) {
+                return this.configureAST((Expression) declarationExpressionList.get(0), ctx);
+            } else {
+                return this.configureAST(new ClosureListExpression((List<Expression>) declarationExpressionList), ctx);
+            }
+        }
+
+        if (asBoolean(ctx.expressionList())) {
+            return this.translateExpressionList(ctx.expressionList());
+        }
+
+        throw createParsingFailedException("Unsupported for init: " + ctx.getText(), ctx);
+    }
+
+    @Override
+    public Expression visitForUpdate(ForUpdateContext ctx) {
+        if (!asBoolean(ctx)) {
+            return EmptyExpression.INSTANCE;
+        }
+
+        return this.translateExpressionList(ctx.expressionList());
+    }
+
+    private Expression translateExpressionList(ExpressionListContext ctx) {
+        List<Expression> expressionList = this.visitExpressionList(ctx);
+
+        if (expressionList.size() == 1) {
+            return this.configureAST(expressionList.get(0), ctx);
+        } else {
+            return this.configureAST(new ClosureListExpression(expressionList), ctx);
+        }
+    }
+
+    @Override
+    public Pair<Parameter, Expression> visitEnhancedForControl(EnhancedForControlContext ctx) {
+        Parameter parameter = this.configureAST(
+                new Parameter(this.visitType(ctx.type()), this.visitVariableDeclaratorId(ctx.variableDeclaratorId()).getName()),
+                ctx.variableDeclaratorId());
+
+        // FIXME Groovy will ignore variableModifier of parameter in the for control
+        // In order to make the new parser behave same with the old one, we do not process variableModifier*
+
+        return new Pair<>(parameter, (Expression) this.visit(ctx.expression()));
+    }
+
+    @Override
+    public Pair<Parameter, Expression> visitClassicalForControl(ClassicalForControlContext ctx) {
+        ClosureListExpression closureListExpression = new ClosureListExpression();
+
+        closureListExpression.addExpression(this.visitForInit(ctx.forInit()));
+        closureListExpression.addExpression(asBoolean(ctx.expression()) ? (Expression) this.visit(ctx.expression()) : EmptyExpression.INSTANCE);
+        closureListExpression.addExpression(this.visitForUpdate(ctx.forUpdate()));
+
+        return new Pair<>(ForStatement.FOR_LOOP_DUMMY, closureListExpression);
+    }
+
+    @Override
+    public WhileStatement visitWhileStmtAlt(WhileStmtAltContext ctx) {
+        Expression conditionExpression = this.visitParExpression(ctx.parExpression());
+        BooleanExpression booleanExpression =
+                this.configureAST(
+                        new BooleanExpression(conditionExpression), conditionExpression);
+
+        Statement loopBlock = this.unpackStatement((Statement) this.visit(ctx.statement()));
+
+        return this.configureAST(
+                new WhileStatement(booleanExpression, asBoolean(loopBlock) ? loopBlock : EmptyStatement.INSTANCE),
+                ctx);
+    }
+
+    @Override
+    public DoWhileStatement visitDoWhileStmtAlt(DoWhileStmtAltContext ctx) {
+        Expression conditionExpression = this.visitParExpression(ctx.parExpression());
+
+        BooleanExpression booleanExpression =
+                this.configureAST(
+                        new BooleanExpression(conditionExpression),
+                        conditionExpression
+                );
+
+        Statement loopBlock = this.unpackStatement((Statement) this.visit(ctx.statement()));
+
+        return this.configureAST(
+                new DoWhileStatement(booleanExpression, asBoolean(loopBlock) ? loopBlock : EmptyStatement.INSTANCE),
+                ctx);
+    }
+
+    @Override
+    public Statement visitTryCatchStmtAlt(TryCatchStmtAltContext ctx) {
+        return this.configureAST(this.visitTryCatchStatement(ctx.tryCatchStatement()), ctx);
+    }
+
+    @Override
+    public Statement visitTryCatchStatement(TryCatchStatementContext ctx) {
+        TryCatchStatement tryCatchStatement =
+                new TryCatchStatement((Statement) this.visit(ctx.block()),
+                        this.visitFinallyBlock(ctx.finallyBlock()));
+
+        if (asBoolean(ctx.resources())) {
+            this.visitResources(ctx.resources()).forEach(tryCatchStatement::addResource);
+        }
+
+        ctx.catchClause().stream().map(this::visitCatchClause)
+                .reduce(new LinkedList<CatchStatement>(), (r, e) -> {
+                    r.addAll(e); // merge several LinkedList<CatchStatement> instances into one LinkedList<CatchStatement> instance
+                    return r;
+                })
+                .forEach(tryCatchStatement::addCatch);
+
+        return this.configureAST(
+                tryWithResourcesASTTransformation.transform(
+                        this.configureAST(tryCatchStatement, ctx)),
+                ctx);
+    }
+
+
+    @Override
+    public List<ExpressionStatement> visitResources(ResourcesContext ctx) {
+        return this.visitResourceList(ctx.resourceList());
+    }
+
+    @Override
+    public List<ExpressionStatement> visitResourceList(ResourceListContext ctx) {
+        return ctx.resource().stream().map(this::visitResource).collect(Collectors.toList());
+    }
+
+    @Override
+    public ExpressionStatement visitResource(ResourceContext ctx) {
+        if (asBoolean(ctx.localVariableDeclaration())) {
+            List<ExpressionStatement> declarationStatements = this.visitLocalVariableDeclaration(ctx.localVariableDeclaration()).getDeclarationStatements();
+
+            if (declarationStatements.size() > 1) {
+                throw createParsingFailedException("Multi resources can not be declared in one statement", ctx);
+            }
+
+            return declarationStatements.get(0);
+        } else if (asBoolean(ctx.expression())) {
+            Expression expression = (Expression) this.visit(ctx.expression());
+            if (!(expression instanceof BinaryExpression
+                    && Types.ASSIGN == ((BinaryExpression) expression).getOperation().getType()
+                    && ((BinaryExpression) expression).getLeftExpression() instanceof VariableExpression)) {
+
+                throw createParsingFailedException("Only variable declarations are allowed to declare resource", ctx);
+            }
+
+            BinaryExpression assignmentExpression = (BinaryExpression) expression;
+
+            return this.configureAST(
+                    new ExpressionStatement(
+                            this.configureAST(
+                                    new DeclarationExpression(
+                                            this.configureAST(
+                                                    new VariableExpression(assignmentExpression.getLeftExpression().getText()),
+                                                    assignmentExpression.getLeftExpression()
+                                            ),
+                                            assignmentExpression.getOperation(),
+                                            assignmentExpression.getRightExpression()
+                                    ), ctx)
+                    ), ctx);
+        }
+
+        throw createParsingFailedException("Unsupported resource declaration: " + ctx.getText(), ctx);
+    }
+
+    /**
+     * Multi-catch(1..*) clause will be unpacked to several normal catch clauses, so the return type is List
+     *
+     * @param ctx the parse tree
+     * @return
+     */
+    @Override
+    public List<CatchStatement> visitCatchClause(CatchClauseContext ctx) {
+        // FIXME Groovy will ignore variableModifier of parameter in the catch clause
+        // In order to make the new parser behave same with the old one, we do not process variableModifier*
+
+        return this.visitCatchType(ctx.catchType()).stream()
+                .map(e -> this.configureAST(
+                        new CatchStatement(
+                                // FIXME The old parser does not set location info for the parameter of the catch clause.
+                                // we could make it better
+                                //this.configureAST(new Parameter(e, this.visitIdentifier(ctx.identifier())), ctx.Identifier()),
+
+                                new Parameter(e, this.visitIdentifier(ctx.identifier())),
+                                this.visitBlock(ctx.block())),
+                        ctx.block()))
+                .collect(Collectors.toList());
+    }
+
+    @Override
+    public List<ClassNode> visitCatchType(CatchTypeContext ctx) {
+        if (!asBoolean(ctx)) {
+            return Collections.singletonList(ClassHelper.OBJECT_TYPE);
+        }
+
+        return ctx.qualifiedClassName().stream()
+                .map(this::visitQualifiedClassName)
+                .collect(Collectors.toList());
+    }
+
+
+    @Override
+    public Statement visitFinallyBlock(FinallyBlockContext ctx) {
+        if (!asBoolean(ctx)) {
+            return EmptyStatement.INSTANCE;
+        }
+
+        return this.configureAST(
+                this.createBlockStatement((Statement) this.visit(ctx.block())),
+                ctx);
+    }
+
+    @Override
+    public SwitchStatement visitSwitchStmtAlt(SwitchStmtAltContext ctx) {
+        return this.configureAST(this.visitSwitchStatement(ctx.switchStatement()), ctx);
+    }
+
+    public SwitchStatement visitSwitchStatement(SwitchStatementContext ctx) {
+        List<Statement> statementList =
+                ctx.switchBlockStatementGroup().stream()
+                        .map(this::visitSwitchBlockStatementGroup)
+                        .reduce(new LinkedList<>(), (r, e) -> {
+                            r.addAll(e);
+                            return r;
+                        });
+
+        List<CaseStatement> caseStatementList = new LinkedList<>();
+        List<Statement> defaultStatementList = new LinkedList<>();
+
+        statementList.forEach(e -> {
+            if (e instanceof CaseStatement) {
+                caseStatementList.add((CaseStatement) e);
+            } else if (isTrue(e, IS_SWITCH_DEFAULT)) {
+                defaultStatementList.add(e);
+            }
+        });
+
+        int defaultStatementListSize = defaultStatementList.size();
+        if (defaultStatementListSize > 1) {
+            throw createParsingFailedException("switch statement should have only one default case, which should appear at last", defaultStatementList.get(0));
+        }
+
+        if (defaultStatementListSize > 0 && last(statementList) instanceof CaseStatement) {
+            throw createParsingFailedException("default case should appear at last", defaultStatementList.get(0));
+        }
+
+        return this.configureAST(
+                new SwitchStatement(
+                        this.visitParExpression(ctx.parExpression()),
+                        caseStatementList,
+                        defaultStatementListSize == 0 ? EmptyStatement.INSTANCE : defaultStatementList.get(0)
+                ),
+                ctx);
+
+    }
+
+
+    @Override
+    @SuppressWarnings({"unchecked"})
+    public List<Statement> visitSwitchBlockStatementGroup(SwitchBlockStatementGroupContext ctx) {
+        int labelCnt = ctx.switchLabel().size();
+        List<Token> firstLabelHolder = new ArrayList<>(1);
+
+        return (List<Statement>) ctx.switchLabel().stream()
+                .map(e -> (Object) this.visitSwitchLabel(e))
+                .reduce(new ArrayList<Statement>(4), (r, e) -> {
+                    List<Statement> statementList = (List<Statement>) r;
+                    Pair<Token, Expression> pair = (Pair<Token, Expression>) e;
+
+                    boolean isLast = labelCnt - 1 == statementList.size();
+
+                    switch (pair.getKey().getType()) {
+                        case CASE: {
+                            if (!asBoolean(statementList)) {
+                                firstLabelHolder.add(pair.getKey());
+                            }
+
+                            statementList.add(
+                                    this.configureAST(
+                                            new CaseStatement(
+                                                    pair.getValue(),
+
+                                                    // check whether processing the last label. if yes, block statement should be attached.
+                                                    isLast ? this.visitBlockStatements(ctx.blockStatements())
+                                                            : EmptyStatement.INSTANCE
+                                            ),
+                                            firstLabelHolder.get(0)));
+
+                            break;
+                        }
+                        case DEFAULT: {
+
+                            BlockStatement blockStatement = this.visitBlockStatements(ctx.blockStatements());
+                            blockStatement.putNodeMetaData(IS_SWITCH_DEFAULT, true);
+
+                            statementList.add(
+                                    // this.configureAST(blockStatement, pair.getKey())
+                                    blockStatement
+                            );
+
+                            break;
+                        }
+                    }
+
+                    return statementList;
+                });
+
+    }
+
+    @Override
+    public Pair<Token, Expression> visitSwitchLabel(SwitchLabelContext ctx) {
+        if (asBoolean(ctx.CASE())) {
+            return new Pair<>(ctx.CASE().getSymbol(), (Expression) this.visit(ctx.expression()));
+        } else if (asBoolean(ctx.DEFAULT())) {
+            return new Pair<>(ctx.DEFAULT().getSymbol(), EmptyExpression.INSTANCE);
+        }
+
+        throw createParsingFailedException("Unsupported switch label: " + ctx.getText(), ctx);
+    }
+
+
+    @Override
+    public SynchronizedStatement visitSynchronizedStmtAlt(SynchronizedStmtAltContext ctx) {
+        return this.configureAST(
+                new SynchronizedStatement(this.visitParExpression(ctx.parExpression()), this.visitBlock(ctx.block())),
+                ctx);
+    }
+
+
+    @Override
+    public ExpressionStatement visitExpressionStmtAlt(ExpressionStmtAltContext ctx) {
+        return (ExpressionStatement) this.visit(ctx.statementExpression());
+    }
+
+    @Override
+    public ReturnStatement visitReturnStmtAlt(ReturnStmtAltContext ctx) {
+        return this.configureAST(new ReturnStatement(asBoolean(ctx.expression())
+                        ? (Expression) this.visit(ctx.expression())
+                        : ConstantExpression.EMPTY_EXPRESSION),
+                ctx);
+    }
+
+    @Override
+    public ThrowStatement visitThrowStmtAlt(ThrowStmtAltContext ctx) {
+        return this.configureAST(
+                new ThrowStatement((Expression) this.visit(ctx.expression())),
+                ctx);
+    }
+
+    @Override
+    public Statement visitLabeledStmtAlt(LabeledStmtAltContext ctx) {
+        Statement statement = (Statement) this.visit(ctx.statement());
+
+        statement.addStatementLabel(this.visitIdentifier(ctx.identifier()));
+
+        return statement; // this.configureAST(statement, ctx);
+    }
+
+    @Override
+    public BreakStatement visitBreakStatement(BreakStatementContext ctx) {
+        String label = asBoolean(ctx.identifier())
+                ? this.visitIdentifier(ctx.identifier())
+                : null;
+
+        return this.configureAST(new BreakStatement(label), ctx);
+    }
+
+    @Override
+    public BreakStatement visitBreakStmtAlt(BreakStmtAltContext ctx) {
+        return this.configureAST(this.visitBreakStatement(ctx.breakStatement()), ctx);
+    }
+
+    @Override
+    public ContinueStatement visitContinueStatement(ContinueStatementContext ctx) {
+        String label = asBoolean(ctx.identifier())
+                ? this.visitIdentifier(ctx.identifier())
+                : null;
+
+        return this.configureAST(new ContinueStatement(label), ctx);
+
+    }
+
+    @Override
+    public ContinueStatement visitContinueStmtAlt(ContinueStmtAltContext ctx) {
+        return this.configureAST(this.visitContinueStatement(ctx.continueStatement()), ctx);
+    }
+
+    @Override
+    public ImportNode visitImportStmtAlt(ImportStmtAltContext ctx) {
+        return this.configureAST(this.visitImportDeclaration(ctx.importDeclaration()), ctx);
+    }
+
+    @Override
+    public ClassNode visitTypeDeclarationStmtAlt(TypeDeclarationStmtAltContext ctx) {
+        return this.configureAST(this.visitTypeDeclaration(ctx.typeDeclaration()), ctx);
+    }
+
+
+    @Override
+    public Statement visitLocalVariableDeclarationStmtAlt(LocalVariableDeclarationStmtAltContext ctx) {
+        return this.configureAST(this.visitLocalVariableDeclaration(ctx.localVariableDeclaration()), ctx);
+    }
+
+    @Override
+    public MethodNode visitMethodDeclarationStmtAlt(MethodDeclarationStmtAltContext ctx) {
+        return this.configureAST(this.visitMethodDeclaration(ctx.methodDeclaration()), ctx);
+    }
+
+    // } statement    --------------------------------------------------------------------
+
+    @Override
+    public ClassNode visitTypeDeclaration(TypeDeclarationContext ctx) {
+        if (asBoolean(ctx.classDeclaration())) { // e.g. class A {}
+            ctx.classDeclaration().putNodeMetaData(TYPE_DECLARATION_MODIFIERS, this.visitClassOrInterfaceModifiersOpt(ctx.classOrInterfaceModifiersOpt()));
+            return this.configureAST(this.visitClassDeclaration(ctx.classDeclaration()), ctx);
+        }
+
+        throw createParsingFailedException("Unsupported type declaration: " + ctx.getText(), ctx);
+    }
+
+    private void initUsingGenerics(ClassNode classNode) {
+        if (classNode.isUsingGenerics()) {
+            return;
+        }
+
+        if (!classNode.isEnum()) {
+            classNode.setUsingGenerics(classNode.getSuperClass().isUsingGenerics());
+        }
+
+        if (!classNode.isUsingGenerics() && asBoolean((Object) classNode.getInterfaces())) {
+            for (ClassNode anInterface : classNode.getInterfaces()) {
+                classNode.setUsingGenerics(classNode.isUsingGenerics() || anInterface.isUsingGenerics());
+
+                if (classNode.isUsingGenerics())
+                    break;
+            }
+        }
+    }
+
+    @Override
+    public ClassNode visitClassDeclaration(ClassDeclarationContext ctx) {
+        String packageName = moduleNode.getPackageName();
+        packageName = asBoolean((Object) packageName) ? packageName : "";
+
+        List<ModifierNode> modifierNodeList = ctx.getNodeMetaData(TYPE_DECLARATION_MODIFIERS);
+        Objects.requireNonNull(modifierNodeList, "modifierNodeList should not be null");
+
+        ModifierManager modifierManager = new ModifierManager(this, modifierNodeList);
+        int modifiers = modifierManager.getClassModifiersOpValue();
+
+        boolean syntheticPublic = ((modifiers & Opcodes.ACC_SYNTHETIC) != 0);
+        modifiers &= ~Opcodes.ACC_SYNTHETIC;
+
+        final ClassNode outerClass = classNodeStack.peek();
+        ClassNode classNode;
+        String className = this.visitIdentifier(ctx.identifier());
+        if (asBoolean(ctx.ENUM())) {
+            classNode =
+                    EnumHelper.makeEnumNode(
+                            asBoolean(outerClass) ? className : packageName + className,
+                            modifiers, null, outerClass);
+        } else {
+            if (asBoolean(outerClass)) {
+                classNode =
+                        new InnerClassNode(
+                                outerClass,
+                                outerClass.getName() + "$" + className,
+                                modifiers | (outerClass.isInterface() ? Opcodes.ACC_STATIC : 0),
+                                ClassHelper.OBJECT_TYPE);
+            } else {
+                classNode =
+                        new ClassNode(
+                                packageName + className,
+                                modifiers,
+                                ClassHelper.OBJECT_TYPE);
+            }
+
+        }
+
+        this.configureAST(classNode, ctx);
+        classNode.putNodeMetaData(CLASS_NAME, className);
+        classNode.setSyntheticPublic(syntheticPublic);
+
+        if (asBoolean(ctx.TRAIT())) {
+            classNode.addAnnotation(new AnnotationNode(ClassHelper.make(GROOVY_TRANSFORM_TRAIT)));
+        }
+        classNode.addAnnotations(modifierManager.getAnnotations());
+        classNode.setGenericsTypes(this.visitTypeParameters(ctx.typeParameters()));
+
+        boolean isInterface = asBoolean(ctx.INTERFACE()) && !asBoolean(ctx.AT());
+        boolean isInterfaceWithDefaultMethods = false;
+
+        // declaring interface with default method
+        if (isInterface && this.containsDefaultMethods(ctx)) {
+            isInterfaceWithDefaultMethods = true;
+            classNode.addAnnotation(new AnnotationNode(ClassHelper.make(GROOVY_TRANSFORM_TRAIT)));
+            classNode.putNodeMetaData(IS_INTERFACE_WITH_DEFAULT_METHODS, true);
+        }
+
+        if (asBoolean(ctx.CLASS()) || asBoolean(ctx.TRAIT()) || isInterfaceWithDefaultMethods) { // class OR trait OR interface with default methods
+            classNode.setSuperClass(this.visitType(ctx.sc));
+            classNode.setInterfaces(this.visitTypeList(ctx.is));
+
+            this.initUsingGenerics(classNode);
+        } else if (isInterface) { // interface(NOT annotation)
+            classNode.setModifiers(classNode.getModifiers() | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT);
+
+            classNode.setSuperClass(ClassHelper.OBJECT_TYPE);
+            classNode.setInterfaces(this.visitTypeList(ctx.scs));
+
+            this.initUsingGenerics(classNode);
+
+            this.hackMixins(classNode);
+        } else if (asBoolean(ctx.ENUM())) { // enum
+            classNode.setModifiers(classNode.getModifiers() | Opcodes.ACC_ENUM | Opcodes.ACC_FINAL);
+
+            classNode.setInterfaces(this.visitTypeList(ctx.is));
+
+            this.initUsingGenerics(classNode);
+        } else if (asBoolean(ctx.AT())) { // annotation
+            classNode.setModifiers(classNode.getModifiers() | Opcodes.ACC_INTERFACE | Opcodes.ACC_ABSTRACT | Opcodes.ACC_ANNOTATION);
+
+            classNode.addInterface(ClassHelper.Annotation_TYPE);
+
+            this.hackMixins(classNode);
+        } else {
+            throw createParsingFailedException("Unsupported class declaration: " + ctx.getText(), ctx);
+        }
+
+        // we put the class already in output to avoid the most inner classes
+        // will be used as first class later in the loader. The first class
+        // there determines what GCL#parseClass for example will return, so we
+        // have here to ensure it won't be the inner class
+        if (asBoolean(ctx.CLASS()) || asBoolean(ctx.TRAIT())) {
+            classNodeList.add(classNode);
+        }
+
+        int oldAnonymousInnerClassCounter = this.anonymousInnerClassCounter;
+        classNodeStack.push(classNode);
+        ctx.classBody().putNodeMetaData(CLASS_DECLARATION_CLASS_NODE, classNode);
+        this.visitClassBody(ctx.classBody());
+        classNodeStack.pop();
+        this.anonymousInnerClassCounter = oldAnonymousInnerClassCounter;
+
+        if (!(asBoolean(ctx.CLASS()) || asBoolean(ctx.TRAIT()))) {
+            classNodeList.add(classNode);
+        }
+
+        groovydocManager.handle(classNode, ctx);
+
+        return classNode;
+    }
+
+    @SuppressWarnings({"unchecked"})
+    private boolean containsDefaultMethods(ClassDeclarationContext ctx) {
+        List<MethodDeclarationContext> methodDeclarationContextList =
+                (List<MethodDeclarationContext>) ctx.classBody().classBodyDeclaration().stream()
+                .map(ClassBodyDeclarationContext::memberDeclaration)
+                .filter(Objects::nonNull)
+                .map(e -> (Object) e.methodDeclaration())
+                .filter(Objects::nonNull).reduce(new LinkedList<MethodDeclarationContext>(), (r, e) -> {
+                    MethodDeclarationContext methodDeclarationContext = (MethodDeclarationContext) e;
+
+                    if (createModifierManager(methodDeclarationContext).contains(DEFAULT)) {
+                        ((List) r).add(methodDeclarationContext);
+                    }
+
+                    return r;
+        });
+
+        return !methodDeclarationContextList.isEmpty();
+    }
+
+    @Override
+    public Void visitClassBody(ClassBodyContext ctx) {
+        ClassNode classNode = ctx.getNodeMetaData(CLASS_DECLARATION_CLASS_NODE);
+        Objects.requireNonNull(classNode, "classNode should not be null");
+
+        if (asBoolean(ctx.enumConstants())) {
+            ctx.enumConstants().putNodeMetaData(CLASS_DECLARATION_CLASS_NODE, classNode);
+            this.visitEnumConstants(ctx.enumConstants());
+        }
+
+        ctx.classBodyDeclaration().forEach(e -> {
+            e.putNodeMetaData(CLASS_DECLARATION_CLASS_NODE, classNode);
+            this.visitClassBodyDeclaration(e);
+        });
+
+        return null;
+    }
+
+    @Override
+    public List<FieldNode> visitEnumConstants(EnumConstantsContext ctx) {
+        ClassNode classNode = ctx.getNodeMetaData(CLASS_DECLARATION_CLASS_NODE);
+        Objects.requireNonNull(classNode, "classNode should not be null");
+
+        return ctx.enumConstant().stream()
+                .map(e -> {
+                    e.putNodeMetaData(CLASS_DECLARATION_CLASS_NODE, classNode);
+                    return this.visitEnumConstant(e);
+                })
+                .collect(Collectors.toList());
+    }
+
+    @Override
+    public FieldNode visitEnumConstant(EnumConstantContext ctx) {
+        ClassNode classNode = ctx.getNodeMetaData(CLASS_DECLARATION_CLASS_NODE);
+        Objects.requireNonNull(classNode, "classNode should not be null");
+
+        InnerClassNode anonymousInnerClassNode = null;
+        if (asBoolean(ctx.anonymousInnerClassDeclaration())) {
+            ctx.anonymousInnerClassDeclaration().putNodeMetaData(ANONYMOUS_INNER_CLASS_SUPER_CLASS, classNode);
+            anonymousInnerClassNode = this.visitAnonymousInnerClassDeclaration(ctx.anonymousInnerClassDeclaration());
+        }
+
+        FieldNode enumConstant =
+                EnumHelper.addEnumConstant(
+                        classNode,
+                        this.visitIdentifier(ctx.identifier()),
+                        createEnumConstantInitExpression(ctx.arguments(), anonymousInnerClassNode));
+
+        this.visitAnnotationsOpt(ctx.annotationsOpt()).forEach(enumConstant::addAnnotation);
+
+        groovydocManager.handle(enumConstant, ctx);
+
+        return this.configureAST(enumConstant, ctx);
+    }
+
+    private Expression createEnumConstantInitExpression(ArgumentsContext ctx, InnerClassNode anonymousInnerClassNode) {
+        if (!asBoolean(ctx) && !asBoolean(anonymousInnerClassNode)) {
+            return null;
+        }
+
+        TupleExpression argumentListExpression = (TupleExpression) this.visitArguments(ctx);
+        List<Expression> expressions = argumentListExpression.getExpressions();
+
+        if (expressions.size() == 1) {
+            Expression expression = expressions.get(0);
+
+            if (expression instanceof NamedArgumentListExpression) { // e.g. SOME_ENUM_CONSTANT(a: "1", b: "2")
+                List<MapEntryExpression> mapEntryExpressionList = ((NamedArgumentListExpression) expression).getMapEntryExpressions();
+                ListExpression listExpression =
+                        new ListExpression(
+                                mapEntryExpressionList.stream()
+                                        .map(e -> (Expression) e)
+                                        .collect(Collectors.toList()));
+
+                if (asBoolean(anonymousInnerClassNode)) {
+                    listExpression.addExpression(
+                            this.configureAST(
+                                    new ClassExpression(anonymousInnerClassNode),
+                                    anonymousInnerClassNode));
+                }
+
+                if (mapEntryExpressionList.size() > 1) {
+                    listExpression.setWrapped(true);
+                }
+
+                return this.configureAST(listExpression, ctx);
+            }
+
+            if (!asBoolean(anonymousInnerClassNode)) {
+                if (expression instanceof ListExpression) {
+                    ListExpression listExpression = new ListExpression();
+                    listExpression.addExpression(expression);
+
+                    return this.configureAST(listExpression, ctx);
+                }
+
+                return expression;
+            }
+
+            ListExpression listExpression = new ListExpression();
+
+            if (expression instanceof ListExpression) {
+                ((ListExpression) expression).getExpressions().forEach(listExpression::addExpression);
+            } else {
+                listExpression.addExpression(expression);
+            }
+
+            listExpression.addExpression(
+                    this.configureAST(
+                            new ClassExpression(anonymousInnerClassNode),
+                            anonymousInnerClassNode));
+
+            return this.configureAST(listExpression, ctx);
+        }
+
+        ListExpression listExpression = new ListExpression(expressions);
+        if (asBoolean(anonymousInnerClassNode)) {
+            listExpression.addExpression(
+                    this.configureAST(
+                            new ClassExpression(anonymousInnerClassNode),
+                            anonymousInnerClassNode));
+        }
+
+        if (asBoolean(ctx)) {
+            listExpression.setWrapped(true);
+        }
+
+        return asBoolean(ctx)
+                ? this.configureAST(listExpression, ctx)
+                : this.configureAST(listExpression, anonymousInnerClassNode);
+    }
+
+
+    @Override
+    public Void visitClassBodyDeclaration(ClassBodyDeclarationContext ctx) {
+        ClassNode classNode = ctx.getNodeMetaData(CLASS_DECLARATION_CLASS_NODE);
+        Objects.requireNonNull(classNode, "classNode should not be null");
+
+        if (asBoolean(ctx.memberDeclaration())) {
+            ctx.memberDeclaration().putNodeMetaData(CLASS_DECLARATION_CLASS_NODE, classNode);
+            this.visitMemberDeclaration(ctx.memberDeclaration());
+        } else if (asBoolean(ctx.block())) {
+            Statement statement = this.visitBlock(ctx.block());
+
+            if (asBoolean(ctx.STATIC())) { // e.g. static { }
+                classNode.addStaticInitializerStatements(Collections.singletonList(statement), false);
+            } else { // e.g.  { }
+                classNode.addObjectInitializerStatements(
+                        this.configureAST(
+                                this.createBlockStatement(statement),
+                                statement));
+            }
+        }
+
+        return null;
+    }
+
+    @Override
+    public Void visitMemberDeclaration(MemberDeclarationContext ctx) {
+        ClassNode classNode = ctx.getNodeMetaData(CLASS_DECLARATION_CLASS_NODE);
+        Objects.requireNonNull(classNode, "classNode should not be null");
+
+        if (asBoolean(ctx.methodDeclaration())) {
+            ctx.methodDeclaration().putNodeMetaData(CLASS_DECLARATION_CLASS_NODE, classNode);
+            this.visitMethodDeclaration(ctx.methodDeclaration());
+        } else if (asBoolean(ctx.fieldDeclaration())) {
+            ctx.fieldDeclaration().putNodeMetaData(CLASS_DECLARATION_CLASS_NODE, classNode);
+            this.visitFieldDeclaration(ctx.fieldDeclaration());
+        } else if (asBoolean(ctx.classDeclaration())) {
+            ctx.classDeclaration().putNodeMetaData(TYPE_DECLARATION_MODIFIERS, this.visitModifiersOpt(ctx.modifiersOpt()));
+            ctx.classDeclaration().putNodeMetaData(CLASS_DECLARATION_CLASS_NODE, classNode);
+            this.visitClassDeclaration(ctx.classDeclaration());
+        }
+
+        return null;
+    }
+
+    @Override
+    public GenericsType[] visitTypeParameters(TypeParametersContext ctx) {
+        if (!asBoolean(ctx)) {
+            return null;
+        }
+
+        return ctx.typeParameter().stream()
+                .map(this::visitTypeParameter)
+                .toArray(GenericsType[]::new);
+    }
+
+    @Override
+    public GenericsType visitTypeParameter(TypeParameterContext ctx) {
+        return this.configureAST(
+                new GenericsType(
+                        ClassHelper.make(this.visitClassName(ctx.className())),
+                        this.visitTypeBound(ctx.typeBound()),
+                        null
+                ),
+                ctx);
+    }
+
+    @Override
+    public ClassNode[] visitTypeBound(TypeBoundContext ctx) {
+        if (!asBoolean(ctx)) {
+            return null;
+        }
+
+        return ctx.type().stream()
+                .map(this::visitType)
+                .toArray(ClassNode[]::new);
+    }
+
+    @Override
+    public Void visitFieldDeclaration(FieldDeclarationContext ctx) {
+        ClassNode classNode = ctx.getNodeMetaData(CLASS_DECLARATION_CLASS_NODE);
+        Objects.requireNonNull(classNode, "classNode should not be null");
+
+        ctx.variableDeclaration().putNodeMetaData(CLASS_DECLARATION_CLASS_NODE, classNode);
+        this.visitVariableDeclaration(ctx.variableDeclaration());
+
+        return null;
+    }
+
+    private ConstructorCallExpression checkThisAndSuperConstructorCall(Statement statement) {
+        if (!(statement instanceof BlockStatement)) { // method code must be a BlockStatement
+            return null;
+        }
+
+        BlockStatement blockStatement = (BlockStatement) statement;
+        List<Statement> statementList = blockStatement.getStatements();
+
+        for (int i = 0, n = statementList.size(); i < n; i++) {
+            Statement s = statementList.get(i);
+            if (s instanceof ExpressionStatement) {
+                Expression expression = ((ExpressionStatement) s).getExpression();
+                if ((expression instanceof ConstructorCallExpression) && 0 != i) {
+                    return (ConstructorCallExpression) expression;
+                }
+            }
+        }
+
+        return null;
+    }
+
+    private ModifierManager createModifierManager(MethodDeclarationContext ctx) {
+        List<ModifierNode> modifierNodeList = Collections.emptyList();
+
+        if (asBoolean(ctx.modifiers())) {
+            modifierNodeList = this.visitModifiers(ctx.modifiers());
+        } else if (asBoolean(ctx.modifiersOpt())) {
+            modifierNodeList = this.visitModifiersOpt(ctx.modifiersOpt());
+        }
+
+        return new ModifierManager(this, modifierNodeList);
+    }
+
+    private void validateParametersOfMethodDeclaration(Parameter[] parameters, ClassNode classNode) {
+        if (!classNode.isInterface()) {
+            return;
+        }
+
+        Arrays.stream(parameters).forEach(e -> {
+            if (e.hasInitialExpression()) {
+                throw createParsingFailedException("Cannot specify default value for method parameter '" + e.getName() + " = " + e.getInitialExpression().getText() + "' inside an interface", e);
+            }
+        });
+    }
+
+    @Override
+    public MethodNode visitMethodDeclaration(MethodDeclarationContext ctx) {
+        ModifierManager modifierManager = createModifierManager(ctx);
+        String methodName = this.visitMethodName(ctx.methodName());
+        ClassNode returnType = this.visitReturnType(ctx.returnType());
+        Parameter[] parameters = this.visitFormalParameters(ctx.formalParameters());
+        ClassNode[] exceptions = this.visitQualifiedClassNameList(ctx.qualifiedClassNameList());
+
+        anonymousInnerClassesDefinedInMethodStack.push(new LinkedList<>());
+        Statement code = this.visitMethodBody(ctx.methodBody());
+        List<InnerClassNode> anonymousInnerClassList = anonymousInnerClassesDefinedInMethodStack.pop();
+
+        MethodNode methodNode;
+        // if classNode is not null, the method declaration is for class declaration
+        ClassNode classNode = ctx.getNodeMetaData(CLASS_DECLARATION_CLASS_NODE);
+        if (asBoolean(classNode)) {
+            validateParametersOfMethodDeclaration(parameters, classNode);
+
+            methodNode = createConstructorOrMethodNodeForClass(ctx, modifierManager, methodName, returnType, parameters, exceptions, code, classNode);
+        } else { // script method declaration
+            methodNode = createScriptMethodNode(modifierManager, methodName, returnType, parameters, exceptions, code);
+        }
+        anonymousInnerClassList.forEach(e -> e.setEnclosingMethod(methodNode));
+
+        methodNode.setGenericsTypes(this.visitTypeParameters(ctx.typeParameters()));
+        methodNode.setSyntheticPublic(
+                this.isSyntheticPublic(
+                        this.isAnnotationDeclaration(classNode),
+                        classNode instanceof EnumConstantClassNode,
+                        asBoolean(ctx.returnType()),
+                        modifierManager));
+
+        if (modifierManager.contains(STATIC)) {
+            Arrays.stream(methodNode.getParameters()).forEach(e -> e.setInStaticContext(true));
+            methodNode.getVariableScope().setInStaticContext(true);
+        }
+
+        this.configureAST(methodNode, ctx);
+
+        validateMethodDeclaration(ctx, methodNode, modifierManager, classNode);
+
+        groovydocManager.handle(methodNode, ctx);
+
+        return methodNode;
+    }
+
+    private void validateMethodDeclaration(MethodDeclarationContext ctx, MethodNode methodNode, ModifierManager modifierManager, ClassNode classNode) {
+        boolean isAbstractMethod = methodNode.isAbstract();
+        boolean hasMethodBody = asBoolean(methodNode.getCode());
+
+        if (9 == ctx.ct) { // script
+            if (isAbstractMethod || !hasMethodBody) { // method should not be declared abstract in the script
+                throw createParsingFailedException("You can not define a " + (isAbstractMethod ? "abstract" : "") + " method[" + methodNode.getName() + "] " + (!hasMethodBody ? "without method body" : "") + " in the script. Try " + (isAbstractMethod ? "removing the 'abstract'" : "") + (isAbstractMethod && !hasMethodBody ? " and" : "") + (!hasMethodBody ? " adding a method body" : ""), methodNode);
+            }
+        } else {
+            if (!isAbstractMethod && !hasMethodBody) { // non-abstract method without body in the non-script(e.g. class, enum, trait) is not allowed!
+                throw createParsingFailedException("You defined a method[" + methodNode.getName() + "] without body. Try adding a method body, or declare it abstract", methodNode);
+            }
+
+            boolean isInterfaceOrAbstractClass = asBoolean(classNode) && classNode.isAbstract() && !classNode.isAnnotationDefinition();
+            if (isInterfaceOrAbstractClass && !modifierManager.contains(DEFAULT) && isAbstractMethod && hasMethodBody) {
+                throw createParsingFailedException("You defined an abstract method[" + methodNode.getName() + "] with body. Try removing the method body" + (classNode.isInterface() ? ", or declare it default" : ""), methodNode);
+            }
+        }
+
+        modifierManager.validate(methodNode);
+
+        if (methodNode instanceof ConstructorNode) {
+            modifierManager.validate((ConstructorNode) methodNode);
+        }
+    }
+
+    private MethodNode createScriptMethodNode(ModifierManager modifierManager, String methodName, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code) {
+        MethodNode methodNode;
+        methodNode =
+                new MethodNode(
+                        methodName,
+                        modifierManager.contains(PRIVATE) ? Opcodes.ACC_PRIVATE : Opcodes.ACC_PUBLIC,
+                        returnType,
+                        parameters,
+                        exceptions,
+                        code);
+
+        modifierManager.processMethodNode(methodNode);
+        return methodNode;
+    }
+
+    private MethodNode createConstructorOrMethodNodeForClass(MethodDeclarationContext ctx, ModifierManager modifierManager, String methodName, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code, ClassNode classNode) {
+        MethodNode methodNode;
+        String className = classNode.getNodeMetaData(CLASS_NAME);
+        int modifiers = modifierManager.getClassMemberModifiersOpValue();
+
+        if (!asBoolean(ctx.returnType())
+                && asBoolean(ctx.methodBody())
+                && methodName.equals(className)) { // constructor declaration
+
+            methodNode = createConstructorNodeForClass(methodName, parameters, exceptions, code, classNode, modifiers);
+        } else { // class memeber method declaration
+            methodNode = createMethodNodeForClass(ctx, modifierManager, methodName, returnType, parameters, exceptions, code, classNode, modifiers);
+        }
+
+        modifierManager.attachAnnotations(methodNode);
+        return methodNode;
+    }
+
+    private MethodNode createMethodNodeForClass(MethodDeclarationContext ctx, ModifierManager modifierManager, String methodName, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code, ClassNode classNode, int modifiers) {
+        MethodNode methodNode;
+        if (asBoolean(ctx.elementValue())) { // the code of annotation method
+            code = this.configureAST(
+                    new ExpressionStatement(
+                            this.visitElementValue(ctx.elementValue())),
+                    ctx.elementValue());
+
+        }
+
+        modifiers |= !modifierManager.contains(STATIC) && (classNode.isInterface() || (isTrue(classNode, IS_INTERFACE_WITH_DEFAULT_METHODS) && !modifierManager.contains(DEFAULT))) ? Opcodes.ACC_ABSTRACT : 0;
+
+        checkWhetherMethodNodeWithSameSignatureExists(classNode, methodName, parameters, ctx);
+
+        methodNode = classNode.addMethod(methodName, modifiers, returnType, parameters, exceptions, code);
+
+        methodNode.setAnnotationDefault(asBoolean(ctx.elementValue()));
+        return methodNode;
+    }
+
+    private void checkWhetherMethodNodeWithSameSignatureExists(ClassNode classNode, String methodName, Parameter[] parameters, MethodDeclarationContext ctx) {
+        MethodNode sameSigMethodNode = classNode.getDeclaredMethod(methodName, parameters);
+
+        if (null == sameSigMethodNode) {
+            return;
+        }
+
+        throw createParsingFailedException("The method " +  sameSigMethodNode.getText() + " duplicates another method of the same signature", ctx);
+    }
+
+    private ConstructorNode createConstructorNodeForClass(String methodName, Parameter[] parameters, ClassNode[] exceptions, Statement code, ClassNode classNode, int modifiers) {
+        ConstructorCallExpression thisOrSuperConstructorCallExpression = this.checkThisAndSuperConstructorCall(code);
+        if (asBoolean(thisOrSuperConstructorCallExpression)) {
+            throw createParsingFailedException(thisOrSuperConstructorCallExpression.getText() + " should be the first statement in the constructor[" + methodName + "]", thisOrSuperConstructorCallExpression);
+        }
+
+        return classNode.addConstructor(
+                modifiers,
+                parameters,
+                exceptions,
+                code);
+    }
+
+    @Override
+    public String visitMethodName(MethodNameContext ctx) {
+        if (asBoolean(ctx.identifier())) {
+            return this.visitIdentifier(ctx.identifier());
+        }
+
+        if (asBoolean(ctx.stringLiteral())) {
+            return this.visitStringLiteral(ctx.stringLiteral()).getText();
+        }
+
+        throw createParsingFailedException("Unsupported method name: " + ctx.getText(), ctx);
+    }
+
+    @Override
+    public ClassNode visitReturnType(ReturnTypeContext ctx) {
+        if (!asBoolean(ctx)) {
+            return ClassHelper.OBJECT_TYPE;
+        }
+
+        if (asBoolean(ctx.type())) {
+            return this.visitType(ctx.type());
+        }
+
+        if (asBoolean(ctx.VOID())) {
+            return ClassHelper.VOID_TYPE;
+        }
+
+        throw createParsingFailedException("Unsupported return type: " + ctx.getText(), ctx);
+    }
+
+    @Override
+    public Statement visitMethodBody(MethodBodyContext ctx) {
+        if (!asBoolean(ctx)) {
+            return null;
+        }
+
+        return this.configureAST(this.visitBlock(ctx.block()), ctx);
+    }
+
+    @Override
+    public DeclarationListStatement visitLocalVariableDeclaration(LocalVariableDeclarationContext ctx) {
+        return this.configureAST(this.visitVariableDeclaration(ctx.variableDeclaration()), ctx);
+    }
+
+    private ModifierManager createModifierManager(VariableDeclarationContext ctx) {
+        List<ModifierNode> modifierNodeList = Collections.emptyList();
+
+        if (asBoolean(ctx.variableModifiers())) {
+            modifierNodeList = this.visitVariableModifiers(ctx.variableModifiers());
+        } else if (asBoolean(ctx.variableModifiersOpt())) {
+            modifierNodeList = this.visitVariableModifiersOpt(ctx.variableModifiersOpt());
+        } else if (asBoolean(ctx.modifiers())) {
+            modifierNodeList = this.visitModifiers(ctx.modifiers());
+        } else if (asBoolean(ctx.modifiersOpt())) {
+            modifierNodeList = this.visitModifiersOpt(ctx.modifiersOpt());
+        }
+
+        return new ModifierManager(this, modifierNodeList);
+    }
+
+    private DeclarationListStatement createMultiAssignmentDeclarationListStatement(VariableDeclarationContext ctx, ModifierManager modifierManager) {
+        if (!modifierManager.contains(DEF)) {
+            throw createParsingFailedException("keyword def is required to declare tuple, e.g. def (int a, int b) = [1, 2]", ctx);
+        }
+
+        return this.configureAST(
+                new DeclarationListStatement(
+                        this.configureAST(
+                                modifierManager.attachAnnotations(
+                                        new DeclarationExpression(
+                                                new ArgumentListExpression(
+                                                        this.visitTypeNamePairs(ctx.typeNamePairs()).stream()
+                                                                .peek(e -> modifierManager.processVariableExpression((VariableExpression) e))
+                                                                .collect(Collectors.toList())
+                                                ),
+                                                this.createGroovyTokenByType(ctx.ASSIGN().getSymbol(), Types.ASSIGN),
+                                                this.visitVariableInitializer(ctx.variableInitializer())
+                                        )
+                                ),
+                                ctx
+                        )
+                ),
+                ctx
+        );
+    }
+
+    @Override
+    public DeclarationListStatement visitVariableDeclaration(VariableDeclarationContext ctx) {
+        ModifierManager modifierManager = this.createModifierManager(ctx);
+
+        if (asBoolean(ctx.typeNamePairs())) { // e.g. def (int a, int b) = [1, 2]
+            return this.createMultiAssignmentDeclarationListStatement(ctx, modifierManager);
+        }
+
+        ClassNode variableType = this.visitType(ctx.type());
+        ctx.variableDeclarators().putNodeMetaData(VARIABLE_DECLARATION_VARIABLE_TYPE, variableType);
+        List<DeclarationExpression> declarationExpressionList = this.visitVariableDeclarators(ctx.variableDeclarators());
+
+        // if classNode is not null, the variable declaration is for class declaration. In other words, it is a field declaration
+        ClassNode classNode = ctx.getNodeMetaData(CLASS_DECLARATION_CLASS_NODE);
+
+        if (asBoolean(classNode)) {
+            return createFieldDeclarationListStatement(ctx, modifierManager, variableType, declarationExpressionList, classNode);
+        }
+
+        declarationExpressionList.forEach(e -> {
+            VariableExpression variableExpression = (VariableExpression) e.getLeftExpression();
+
+            modifierManager.processVariableExpression(variableExpression);
+            modifierManager.attachAnnotations(e);
+        });
+
+        int size = declarationExpressionList.size();
+        if (size > 0) {
+            DeclarationExpression declarationExpression = declarationExpressionList.get(0);
+
+            if (1 == size) {
+                this.configureAST(declarationExpression, ctx);
+            } else {
+                // Tweak start of first declaration
+                declarationExpression.setLineNumber(ctx.getStart().getLine());
+                declarationExpression.setColumnNumber(ctx.getStart().getCharPositionInLine() + 1);
+            }
+        }
+
+        return this.configureAST(new DeclarationListStatement(declarationExpressionList), ctx);
+    }
+
+    private DeclarationListStatement createFieldDeclarationListStatement(VariableDeclarationContext ctx, ModifierManager modifierManager, ClassNode variableType, List<DeclarationExpression> declarationExpressionList, ClassNode classNode) {
+        declarationExpressionList.forEach(e -> {
+            VariableExpression variableExpression = (VariableExpression) e.getLeftExpression();
+
+            int modifiers = modifierManager.getClassMemberModifiersOpValue();
+
+            Expression initialValue = EmptyExpression.INSTANCE.equals(e.getRightExpression()) ? null : e.getRightExpression();
+            Object defaultValue = findDefaultValueByType(variableType);
+
+            if (classNode.isInterface()) {
+                if (!asBoolean(initialValue)) {
+                    initialValue = !asBoolean(defaultValue) ? null : new ConstantExpression(defaultValue);
+                }
+
+                modifiers |= Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_FINAL;
+            }
+
+            if (classNode.isInterface() || modifierManager.containsVisibilityModifier()) {
+                FieldNode fieldNode =
+                        classNode.addField(
+                                variableExpression.getName(),
+                                modifiers,
+                                variableType,
+                                initialValue);
+                modifierManager.attachAnnotations(fieldNode);
+
+                groovydocManager.handle(fieldNode, ctx);
+
+                this.configureAST(fieldNode, ctx);
+            } else {
+                PropertyNode propertyNode =
+                        classNode.addProperty(
+                                variableExpression.getName(),
+                                modifiers | Opcodes.ACC_PUBLIC,
+                                variableType,
+                                initialValue,
+                                null,
+                                null);
+
+                FieldNode fieldNode = propertyNode.getField();
+                fieldNode.setModifiers(modifiers & ~Opcodes.ACC_PUBLIC | Opcodes.ACC_PRIVATE);
+                fieldNode.setSynthetic(!classNode.isInterface());
+                modifierManager.attachAnnotations(fieldNode);
+
+                groovydocManager.handle(fieldNode, ctx);
+                groovydocManager.handle(propertyNode, ctx);
+
+                this.configureAST(fieldNode, ctx);
+                this.configureAST(propertyNode, ctx);
+            }
+
+        });
+
+        return null;
+    }
+
+    @Override
+    public List<Expression> visitTypeNamePairs(TypeNamePairsContext ctx) {
+        return ctx.typeNamePair().stream().map(this::visitTypeNamePair).collect(Collectors.toList());
+    }
+
+    @Override
+    public VariableExpression visitTypeNamePair(TypeNamePairContext ctx) {
+        return this.configureAST(
+                new VariableExpression(
+                        this.visitVariableDeclaratorId(ctx.variableDeclaratorId()).getName(),
+                        this.visitType(ctx.type())),
+                ctx);
+    }
+
+    @Override
+    public List<DeclarationExpression> visitVariableDeclarators(VariableDeclaratorsContext ctx) {
+        ClassNode variableType = ctx.getNodeMetaData(VARIABLE_DECLARATION_VARIABLE_TYPE);
+        Objects.requireNonNull(variableType, "variableType should not be null");
+
+        return ctx.variableDeclarator().stream()
+                .map(e -> {
+                    e.putNodeMetaData(VARIABLE_DECLARATION_VARIABLE_TYPE, variableType);
+                    return this.visitVariableDeclarator(e);
+//                    return this.configureAST(this.visitVariableDeclarator(e), ctx);
+                })
+                .collect(Collectors.toList());
+    }
+
+    @Override
+    public DeclarationExpression visitVariableDeclarator(VariableDeclaratorContext ctx) {
+        ClassNode variableType = ctx.getNodeMetaData(VARIABLE_DECLARATION_VARIABLE_TYPE);
+        Objects.requireNonNull(variableType, "variableType should not be null");
+
+        org.codehaus.groovy.syntax.Token token;
+        if (asBoolean(ctx.ASSIGN())) {
+            token = createGroovyTokenByType(ctx.ASSIGN().getSymbol(), Types.ASSIGN);
+        } else {
+            token = new org.codehaus.groovy.syntax.Token(Types.ASSIGN, ASSIGN_STR, ctx.start.getLine(), 1);
+        }
+
+        return this.configureAST(
+                new DeclarationExpression(
+                        this.configureAST(
+                                new VariableExpression(
+                                        this.visitVariableDeclaratorId(ctx.variableDeclaratorId()).getName(),
+                                        variableType
+                                ),
+                                ctx.variableDeclaratorId()),
+                        token,
+                        this.visitVariableInitializer(ctx.variableInitializer())),
+                ctx);
+    }
+
+    @Override
+    public Expression visitVariableInitializer(VariableInitializerContext ctx) {
+        if (!asBoolean(ctx)) {
+            return EmptyExpression.INSTANCE;
+        }
+
+        if (asBoolean(ctx.statementExpression())) {
+            return this.configureAST(
+                    ((ExpressionStatement) this.visit(ctx.statementExpression())).getExpression(),
+                    ctx);
+        }
+
+        if (asBoolean(ctx.standardLambda())) {
+            return this.configureAST(this.visitStandardLambda(ctx.standardLambda()), ctx);
+        }
+
+        throw createParsingFailedException("Unsupported variable initializer: " + ctx.getText(), ctx);
+    }
+
+    @Override
+    public List<Expression> visitVariableInitializers(VariableInitializersContext ctx) {
+        if (!asBoolean(ctx)) {
+            return Collections.emptyList();
+        }
+
+        return ctx.variableInitializer().stream()
+                        .map(this::visitVariableInitializer)
+                        .collect(Collectors.toList());
+    }
+
+    @Override
+    public List<Expression> visitArrayInitializer(ArrayInitializerContext ctx) {
+        if (!asBoolean(ctx)) {
+            return Collections.emptyList();
+        }
+
+        return this.visitVariableInitializers(ctx.variableInitializers());
+    }
+
+    @Override
+    public Statement visitBlock(BlockContext ctx) {
+        if (!asBoolean(ctx)) {
+            return this.createBlockStatement();
+        }
+
+        return this.configureAST(
+                this.visitBlockStatementsOpt(ctx.blockStatementsOpt()),
+                ctx);
+    }
+
+
+    @Override
+    public ExpressionStatement visitNormalExprAlt(NormalExprAltContext ctx) {
+        return this.configureAST(new ExpressionStatement((Expression) this.visit(ctx.expression())), ctx);
+    }
+
+    @Override
+    public ExpressionStatement visitCommandExprAlt(CommandExprAltContext ctx) {
+        return this.configureAST(new ExpressionStatement(this.visitCommandExpression(ctx.commandExpression())), ctx);
+    }
+
+    @Override
+    public Expression visitCommandExpression(CommandExpressionContext ctx) {
+        Expression baseExpr = this.visitPathExpression(ctx.pathExpression());
+        Expression arguments = this.visitEnhancedArgumentList(ctx.enhancedArgumentList());
+
+        MethodCallExpression methodCallExpression;
+        if (baseExpr instanceof PropertyExpression) { // e.g. obj.a 1, 2
+            methodCallExpression =
+                    this.configureAST(
+                            this.createMethodCallExpression(
+                                    (PropertyExpression) baseExpr, arguments),
+                            arguments);
+
+        } else if (baseExpr instanceof MethodCallExpression && !isTrue(baseExpr, IS_INSIDE_PARENTHESES)) { // e.g. m {} a, b  OR  m(...) a, b
+            if (asBoolean(arguments)) {
+                // The error should never be thrown.
+                throw new GroovyBugError("When baseExpr is a instance of MethodCallExpression, which should follow NO argumentList");
+            }
+
+            methodCallExpression = (MethodCallExpression) baseExpr;
+        } else if (
+                !isTrue(baseExpr, IS_INSIDE_PARENTHESES)
+                        && (baseExpr instanceof VariableExpression /* e.g. m 1, 2 */
+                        || baseExpr instanceof GStringExpression /* e.g. "$m" 1, 2 */
+                        || (baseExpr instanceof ConstantExpression && isTrue(baseExpr, IS_STRING)) /* e.g. "m" 1, 2 */)
+                ) {
+            methodCallExpression =
+                    this.configureAST(
+                            this.createMethodCallExpression(baseExpr, arguments),
+                            arguments);
+        } else { // e.g. a[x] b, new A() b, etc.
+            methodCallExpression =
+                    this.configureAST(
+                            new MethodCallExpression(
+                                    baseExpr,
+                                    CALL_STR,
+                                    arguments
+                            ),
+                            arguments
+                    );
+
+            methodCallExpression.setImplicitThis(false);
+        }
+
+        if (!asBoolean(ctx.commandArgument())) {
+            return this.configureAST(methodCallExpression, ctx);
+        }
+
+        return this.configureAST(
+                (Expression) ctx.commandArgument().stream()
+                        .map(e -> (Object) e)
+                        .reduce(methodCallExpression,
+                                (r, e) -> {
+                                    CommandArgumentContext commandArgumentContext = (CommandArgumentContext) e;
+                                    commandArgumentContext.putNodeMetaData(CMD_EXPRESSION_BASE_EXPR, r);
+
+                                    return this.visitCommandArgument(commandArgumentContext);
+                                }
+                        ),
+                ctx);
+    }
+
+    @Override
+    public Expression visitCommandArgument(CommandArgumentContext ctx) {
+        // e.g. x y a b     we call "x y" as the base expression
+        Expression baseExpr = ctx.getNodeMetaData(CMD_EXPRESSION_BASE_EXPR);
+
+        Expression primaryExpr = (Expression) this.visit(ctx.primary());
+
+        if (asBoolean(ctx.enhancedArgumentList())) { // e.g. x y a b
+            if (baseExpr instanceof PropertyExpression) { // the branch should never reach, because a.b.c will be parsed as a path expression, not a method call
+                throw createParsingFailedException("Unsupported command argument: " + ctx.getText(), ctx);
+            }
+
+            // the following code will process "a b" of "x y a b"
+            MethodCallExpression methodCallExpression =
+                    new MethodCallExpression(
+                            baseExpr,
+                            this.createConstantExpression(primaryExpr),
+                            this.visitEnhancedArgumentList(ctx.enhancedArgumentList())
+                    );
+            methodCallExpression.setImplicitThis(false);
+
+            return this.configureAST(methodCallExpression, ctx);
+        } else if (asBoolean(ctx.pathElement())) { // e.g. x y a.b
+            Expression pathExpression =
+                    this.createPathExpression(
+                            this.configureAST(
+                                    new PropertyExpression(baseExpr, this.createConstantExpression(primaryExpr)),
+                                    primaryExpr
+                            ),
+                            ctx.pathElement()
+                    );
+
+            return this.configureAST(pathExpression, ctx);
+        }
+
+        // e.g. x y a
+        return this.configureAST(
+                new PropertyExpression(
+                        baseExpr,
+                        primaryExpr instanceof VariableExpression
+                                ? this.createConstantExpression(primaryExpr)
+                                : primaryExpr
+                ),
+                primaryExpr
+        );
+    }
+
+
+    // expression {    --------------------------------------------------------------------
+
+    @Override
+    public ClassNode visitCastParExpression(CastParExpressionContext ctx) {
+        return this.visitType(ctx.type());
+    }
+
+    @Override
+    public Expression visitParExpression(ParExpressionContext ctx) {
+        Expression expression;
+
+        if (asBoolean(ctx.statementExpression())) {
+            expression = ((ExpressionStatement) this.visit(ctx.statementExpression())).getExpression();
+        } else if (asBoolean(ctx.standardLambda())) {
+            expression = this.visitStandardLambda(ctx.standardLambda());
+        } else {
+            throw createParsingFailedException("Unsupported parentheses expression: " + ctx.getText(), ctx);
+        }
+
+        expression.putNodeMetaData(IS_INSIDE_PARENTHESES, true);
+
+        Integer insideParenLevel = expression.getNodeMetaData(INSIDE_PARENTHESES_LEVEL);
+        if (asBoolean((Object) insideParenLevel)) {
+            insideParenLevel++;
+        } else {
+            insideParenLevel = 1;
+        }
+        expression.putNodeMetaData(INSIDE_PARENTHESES_LEVEL, insideParenLevel);
+
+        return this.configureAST(expression, ctx);
+    }
+
+    @Override
+    public Expression visitPathExpression(PathExpressionContext ctx) {
+        return this.configureAST(
+                this.createPathExpression((Expression) this.visit(ctx.primary()), ctx.pathElement()),
+                ctx);
+    }
+
+    @Override
+    public Expression visitPathElement(PathElementContext ctx) {
+        Expression baseExpr = ctx.getNodeMetaData(PATH_EXPRESSION_BASE_EXPR);
+        Objects.requireNonNull(baseExpr, "baseExpr is required!");
+
+        if (asBoolean(ctx.namePart())) {
+            Expression namePartExpr = this.visitNamePart(ctx.namePart());
+            GenericsType[] genericsTypes = this.visitNonWildcardTypeArguments(ctx.nonWildcardTypeArguments());
+
+
+            if (asBoolean(ctx.DOT())) {
+                if (asBoolean(ctx.AT())) { // e.g. obj.@a
+                    return this.configureAST(new AttributeExpression(baseExpr, namePartExpr), ctx);
+                } else { // e.g. obj.p
+                    PropertyExpression propertyExpression = new PropertyExpression(baseExpr, namePartExpr);
+                    propertyExpression.putNodeMetaData(PATH_EXPRESSION_BASE_EXPR_GENERICS_TYPES, genericsTypes);
+
+                    return this.configureAST(propertyExpression, ctx);
+                }
+            } else if (asBoolean(ctx.SAFE_DOT())) {
+                if (asBoolean(ctx.AT())) { // e.g. obj?.@a
+                    return this.configureAST(new AttributeExpression(baseExpr, namePartExpr, true), ctx);
+                } else { // e.g. obj?.p
+                    PropertyExpression propertyExpression = new PropertyExpression(baseExpr, namePartExpr, true);
+                    propertyExpression.putNodeMetaData(PATH_EXPRESSION_BASE_EXPR_GENERICS_TYPES, genericsTypes);
+
+                    return this.configureAST(propertyExpression, ctx);
+                }
+            } else if (asBoolean(ctx.METHOD_POINTER())) { // e.g. obj.&m
+                return this.configureAST(new MethodPointerExpression(baseExpr, namePartExpr), ctx);
+            } else if (asBoolean(ctx.METHOD_REFERENCE())) { // e.g. obj::m
+                return this.configureAST(new MethodReferenceExpression(baseExpr, namePartExpr), ctx);
+            } else if (asBoolean(ctx.SPREAD_DOT())) {
+                if (asBoolean(ctx.AT())) { // e.g. obj*.@a
+                    AttributeExpression attributeExpression = new AttributeExpression(baseExpr, namePartExpr, true);
+
+                    attributeExpression.setSpreadSafe(true);
+
+                    return this.configureAST(attributeExpression, ctx);
+                } else { // e.g. obj*.p
+                    PropertyExpression propertyExpression = new PropertyExpression(baseExpr, namePartExpr, true);
+                    propertyExpression.putNodeMetaData(PATH_EXPRESSION_BASE_EXPR_GENERICS_TYPES, genericsTypes);
+
+                    propertyExpression.setSpreadSafe(true);
+
+                    return this.configureAST(propertyExpression, ctx);
+                }
+            }
+        }
+
+        if (asBoolean(ctx.indexPropertyArgs())) { // e.g. list[1, 3, 5]
+            Pair<Token, Expression> pair = this.visitIndexPropertyArgs(ctx.indexPropertyArgs());
+
+            return this.configureAST(
+                    new BinaryExpression(baseExpr, createGroovyToken(pair.getKey()), pair.getValue(), asBoolean(ctx.indexPropertyArgs().QUESTION())),
+                    ctx);
+        }
+
+        if (asBoolean(ctx.namedPropertyArgs())) { // this is a special way to new instance, e.g. Person(name: 'Daniel.Sun', location: 'Shanghai')
+            List<MapEntryExpression> mapEntryExpressionList =
+                    this.visitNamedPropertyArgs(ctx.namedPropertyArgs());
+
+            Expression right;
+            if (mapEntryExpressionList.size() == 1) {
+                MapEntryExpression mapEntryExpression = mapEntryExpressionList.get(0);
+
+                if (mapEntryExpression.getKeyExpression() instanceof SpreadMapExpression) {
+                    right = mapEntryExpression.getKeyExpression();
+                } else {
+                    right = mapEntryExpression;
+                }
+            } else {
+                ListExpression listExpression =
+                        this.configureAST(
+                                new ListExpression(
+                                        mapEntryExpressionList.stream()
+                                                .map(
+                                                        e -> {
+                                                            if (e.getKeyExpression() instanceof SpreadMapExpression) {
+                                                                return e.getKeyExpression();
+                                                            }
+
+                                                            return e;
+                                                        }
+                                                )
+                                                .collect(Collectors.toList())),
+                                ctx.namedPropertyArgs()
+                        );
+                listExpression.setWrapped(true);
+                right = listExpression;
+            }
+
+            return this.configureAST(
+                    new BinaryExpression(baseExpr, createGroovyToken(ctx.namedPropertyArgs().LBRACK().getSymbol()), right),
+                    ctx);
+        }
+
+        if (asBoolean(ctx.arguments())) {
+            Expression argumentsExpr = this.visitArguments(ctx.arguments());
+
+            if (isTrue(baseExpr, IS_INSIDE_PARENTHESES)) { // e.g. (obj.x)(), (obj.@x)()
+                MethodCallExpression methodCallExpression =
+                        new MethodCallExpression(
+                                baseExpr,
+                                CALL_STR,
+                                argumentsExpr
+                        );
+
+                methodCallExpression.setImplicitThis(false);
+
+                return this.configureAST(methodCallExpression, ctx);
+            }
+
+            if (baseExpr instanceof AttributeExpression) { // e.g. obj.@a(1, 2)
+                AttributeExpression attributeExpression = (AttributeExpression) baseExpr;
+                attributeExpression.setSpreadSafe(false); // whether attributeExpression is spread safe or not, we must reset it as false
+
+                MethodCallExpression methodCallExpression =
+                        new MethodCallExpression(
+                                attributeExpression,
+                                CALL_STR,
+                                argumentsExpr
+                        );
+
+                return this.configureAST(methodCallExpression, ctx);
+            }
+
+            if (baseExpr instanceof PropertyExpression) { // e.g. obj.a(1, 2)
+                MethodCallExpression methodCallExpression =
+                        this.createMethodCallExpression((PropertyExpression) baseExpr, argumentsExpr);
+
+                return this.configureAST(methodCallExpression, ctx);
+            }
+
+            if (baseExpr instanceof VariableExpression) { // void and primitive type AST node must be an instance of VariableExpression
+                String baseExprText = baseExpr.getText();
+                if (VOID_STR.equals(baseExprText)) { // e.g. void()
+                    MethodCallExpression methodCallExpression =
+                            new MethodCallExpression(
+                                    this.createConstantExpression(baseExpr),
+                                    CALL_STR,
+                                    argumentsExpr
+                            );
+
+                    methodCallExpression.setImplicitThis(false);
+
+                    return this.configureAST(methodCallExpression, ctx);
+                } else if (PRIMITIVE_TYPE_SET.contains(baseExprText)) { // e.g. int(), long(), float(), etc.
+                    throw createParsingFailedException("Primitive type literal: " + baseExprText + " cannot be used as a method name", ctx);
+                }
+            }
+
+            if (baseExpr instanceof VariableExpression
+                    || baseExpr instanceof GStringExpression
+                    || (baseExpr instanceof ConstantExpression && isTrue(baseExpr, IS_STRING))) { // e.g. m(), "$m"(), "m"()
+
+                String baseExprText = base

<TRUNCATED>
Reply | Threaded
Open this post in threaded view
|

[08/17] groovy git commit: rename antlr4 parser to remove groovy- prefix since that is by convention for modules

paulk
In reply to this post by paulk
http://git-wip-us.apache.org/repos/asf/groovy/blob/73acbcfe/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyLexer.g4
----------------------------------------------------------------------
diff --git a/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyLexer.g4 b/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyLexer.g4
new file mode 100644
index 0000000..7bcec42
--- /dev/null
+++ b/subprojects/parser-antlr4/src/main/antlr4/org/apache/groovy/parser/antlr4/GroovyLexer.g4
@@ -0,0 +1,882 @@
+/*
+ * This file is adapted from the Antlr4 Java grammar which has the following license
+ *
+ *  Copyright (c) 2013 Terence Parr, Sam Harwell
+ *  All rights reserved.
+ *  [The "BSD licence"]
+ *
+ *    http://www.opensource.org/licenses/bsd-license.php
+ *
+ * Subsequent modifications by the Groovy community have been done under the Apache License v2:
+ *
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+/**
+ * The Groovy grammar is based on the official grammar for Java:
+ * https://github.com/antlr/grammars-v4/blob/master/java/Java.g4
+ */
+lexer grammar GroovyLexer;
+
+options {
+    superClass = AbstractLexer;
+}
+
+@header {
+    import static org.apache.groovy.parser.antlr4.SemanticPredicates.*;
+    import java.util.Deque;
+    import java.util.ArrayDeque;
+    import java.util.Map;
+    import java.util.HashMap;
+    import java.util.Set;
+    import java.util.HashSet;
+    import java.util.Collections;
+    import java.util.Arrays;
+}
+
+@members {
+    private long tokenIndex     = 0;
+    private int  lastTokenType  = 0;
+
+    /**
+     * Record the index and token type of the current token while emitting tokens.
+     */
+    @Override
+    public void emit(Token token) {
+        this.tokenIndex++;
+
+        int tokenType = token.getType();
+        if (Token.DEFAULT_CHANNEL == token.getChannel()) {
+            this.lastTokenType = tokenType;
+        }
+
+        if (RollBackOne == tokenType) {
+            this.rollbackOneChar();
+        }
+
+        super.emit(token);
+    }
+
+    private static final Set<Integer> REGEX_CHECK_SET =
+                                            Collections.unmodifiableSet(
+                                                new HashSet<>(Arrays.asList(Identifier, CapitalizedIdentifier, NullLiteral, BooleanLiteral, THIS, RPAREN, RBRACK, RBRACE, IntegerLiteral, FloatingPointLiteral, StringLiteral, GStringEnd, INC, DEC)));
+    private boolean isRegexAllowed() {
+        if (REGEX_CHECK_SET.contains(this.lastTokenType)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    /**
+     * just a hook, which will be overrided by GroovyLangLexer
+     */
+    protected void rollbackOneChar() {}
+
+    private static class Paren {
+        private String text;
+        private int lastTokenType;
+        private int line;
+        private int column;
+
+        public Paren(String text, int lastTokenType, int line, int column) {
+            this.text = text;
+            this.lastTokenType = lastTokenType;
+            this.line = line;
+            this.column = column;
+        }
+
+        public String getText() {
+            return this.text;
+        }
+
+        public int getLastTokenType() {
+            return this.lastTokenType;
+        }
+
+        public int getLine() {
+            return line;
+        }
+
+        public int getColumn() {
+            return column;
+        }
+
+        @Override
+        public int hashCode() {
+            return (int) (text.hashCode() * line + column);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (!(obj instanceof Paren)) {
+                return false;
+            }
+
+            Paren other = (Paren) obj;
+
+            return this.text.equals(other.text) && (this.line == other.line && this.column == other.column);
+        }
+    }
+
+    private static final Map<String, String> PAREN_MAP = Collections.unmodifiableMap(new HashMap<String, String>() {
+        {
+            put("(", ")");
+            put("[", "]");
+            put("{", "}");
+        }
+    });
+
+    private final Deque<Paren> parenStack = new ArrayDeque<>(32);
+    private void enterParen() {
+        parenStack.push(new Paren(getText(), this.lastTokenType, getLine(), getCharPositionInLine() + 1));
+    }
+    private void exitParen() {
+        Paren paren = parenStack.peek();
+        String text = getText();
+
+        require(null != paren, "Too many '" + text + "'");
+        require(text.equals(PAREN_MAP.get(paren.getText())),
+                "'" + paren.getText() + "'" + new PositionInfo(paren.getLine(), paren.getColumn()) + " can not match '" + text + "'");
+
+        parenStack.pop();
+    }
+    private boolean isInsideParens() {
+        Paren paren = parenStack.peek();
+
+        // We just care about "(" and "[", inside which the new lines will be ignored.
+        // Notice: the new lines between "{" and "}" can not be ignored.
+        if (null == paren) {
+            return false;
+        }
+        return ("(".equals(paren.getText()) && TRY != paren.getLastTokenType()) // we don't treat try-paren(i.e. try (....)) as parenthesis
+                    || "[".equals(paren.getText());
+    }
+    private void ignoreTokenInsideParens() {
+        if (!this.isInsideParens()) {
+            return;
+        }
+
+        this.setChannel(Token.HIDDEN_CHANNEL);
+    }
+    private void ignoreMultiLineCommentConditionally() {
+        if (!this.isInsideParens() && isFollowedByWhiteSpaces(_input)) {
+            return;
+        }
+
+        this.setChannel(Token.HIDDEN_CHANNEL);
+    }
+
+    @Override
+    public int getSyntaxErrorSource() {
+        return GroovySyntaxError.LEXER;
+    }
+
+    @Override
+    public int getErrorLine() {
+        return getLine();
+    }
+
+    @Override
+    public int getErrorColumn() {
+        return getCharPositionInLine() + 1;
+    }
+}
+
+
+// §3.10.5 String Literals
+
+StringLiteral
+    :   '"'      DqStringCharacter*?           '"'
+    |   '\''     SqStringCharacter*?           '\''
+
+    |   '/'      { this.isRegexAllowed() && _input.LA(1) != '*' }?
+                 SlashyStringCharacter+?       '/'
+
+    |   '"""'    TdqStringCharacter*?          '"""'
+    |   '\'\'\'' TsqStringCharacter*?          '\'\'\''
+    |   '$/'     DollarSlashyStringCharacter+? '/$'
+    ;
+
+// Groovy gstring
+GStringBegin
+    :   '"' DqStringCharacter*? DOLLAR -> pushMode(DQ_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE)
+    ;
+TdqGStringBegin
+    :   '"""'   TdqStringCharacter*? DOLLAR -> type(GStringBegin), pushMode(TDQ_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE)
+    ;
+SlashyGStringBegin
+    :   '/' { this.isRegexAllowed() && _input.LA(1) != '*' }? SlashyStringCharacter*? DOLLAR { isFollowedByJavaLetterInGString(_input) }? -> type(GStringBegin), pushMode(SLASHY_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE)
+    ;
+DollarSlashyGStringBegin
+    :   '$/' DollarSlashyStringCharacter*? DOLLAR { isFollowedByJavaLetterInGString(_input) }? -> type(GStringBegin), pushMode(DOLLAR_SLASHY_GSTRING_MODE), pushMode(GSTRING_TYPE_SELECTOR_MODE)
+    ;
+
+mode DQ_GSTRING_MODE;
+GStringEnd
+    :   '"'     -> popMode
+    ;
+GStringPart
+    :   DOLLAR  -> pushMode(GSTRING_TYPE_SELECTOR_MODE)
+    ;
+GStringCharacter
+    :   DqStringCharacter -> more
+    ;
+
+mode TDQ_GSTRING_MODE;
+TdqGStringEnd
+    :   '"""'    -> type(GStringEnd), popMode
+    ;
+TdqGStringPart
+    :   DOLLAR   -> type(GStringPart), pushMode(GSTRING_TYPE_SELECTOR_MODE)
+    ;
+TdqGStringCharacter
+    :   TdqStringCharacter -> more
+    ;
+
+mode SLASHY_GSTRING_MODE;
+SlashyGStringEnd
+    :   '$'? '/'  -> type(GStringEnd), popMode
+    ;
+SlashyGStringPart
+    :   DOLLAR { isFollowedByJavaLetterInGString(_input) }?   -> type(GStringPart), pushMode(GSTRING_TYPE_SELECTOR_MODE)
+    ;
+SlashyGStringCharacter
+    :   SlashyStringCharacter -> more
+    ;
+
+mode DOLLAR_SLASHY_GSTRING_MODE;
+DollarSlashyGStringEnd
+    :   '/$'      -> type(GStringEnd), popMode
+    ;
+DollarSlashyGStringPart
+    :   DOLLAR { isFollowedByJavaLetterInGString(_input) }?   -> type(GStringPart), pushMode(GSTRING_TYPE_SELECTOR_MODE)
+    ;
+DollarSlashyGStringCharacter
+    :   DollarSlashyStringCharacter -> more
+    ;
+
+mode GSTRING_TYPE_SELECTOR_MODE;
+GStringLBrace
+    :   '{' { this.enterParen();  } -> type(LBRACE), popMode, pushMode(DEFAULT_MODE)
+    ;
+GStringIdentifier
+    :   IdentifierInGString -> type(Identifier), popMode, pushMode(GSTRING_PATH_MODE)
+    ;
+
+
+mode GSTRING_PATH_MODE;
+GStringPathPart
+    :   '.' IdentifierInGString
+    ;
+RollBackOne
+    :   . {
+            // a trick to handle GStrings followed by EOF properly
+            if (EOF == _input.LA(1) && ('"' == _input.LA(-1) || '/' == _input.LA(-1))) {
+                setType(GStringEnd);
+            } else {
+                setChannel(HIDDEN);
+            }
+