You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/01/26 22:39:59 UTC
[groovy] branch master updated (4cd3b09 -> fb8d8dc)
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git.
from 4cd3b09 Tweak rules
new 9f9821c Tweak `commandExpression` rule's semantic predicate
new fb8d8dc Tweak `classOrInterfaceModifiersOpt` rule
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/antlr/GroovyParser.g4 | 2 +-
.../groovy/parser/antlr4/SemanticPredicates.java | 22 +++++++++-------------
2 files changed, 10 insertions(+), 14 deletions(-)
[groovy] 02/02: Tweak `classOrInterfaceModifiersOpt` rule
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit fb8d8dcb62d4a79c75494eb28fd5d9b5372e02a3
Author: Sam Harwell <sa...@tunnelvisionlabs.com>
AuthorDate: Mon Jan 27 06:10:16 2020 +0800
Tweak `classOrInterfaceModifiersOpt` rule
---
src/antlr/GroovyParser.g4 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/antlr/GroovyParser.g4 b/src/antlr/GroovyParser.g4
index 3107f1c..01dee0a 100644
--- a/src/antlr/GroovyParser.g4
+++ b/src/antlr/GroovyParser.g4
@@ -144,7 +144,7 @@ modifiers
;
classOrInterfaceModifiersOpt
- : (classOrInterfaceModifiers nls)?
+ : (classOrInterfaceModifiers NL*)?
;
classOrInterfaceModifiers
[groovy] 01/02: Tweak `commandExpression` rule's semantic predicate
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 9f9821c541bf92555d4b58515134cde65659b4c3
Author: Daniel Sun <su...@apache.org>
AuthorDate: Mon Jan 27 05:22:05 2020 +0800
Tweak `commandExpression` rule's semantic predicate
---
.../groovy/parser/antlr4/SemanticPredicates.java | 22 +++++++++-------------
1 file changed, 9 insertions(+), 13 deletions(-)
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
index 5eb20a4..508dcd7 100644
--- 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
@@ -22,6 +22,7 @@ import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.Token;
import org.antlr.v4.runtime.TokenStream;
import org.antlr.v4.runtime.tree.ParseTree;
+import org.codehaus.groovy.GroovyBugError;
import org.codehaus.groovy.ast.ModifierNode;
import java.util.Arrays;
@@ -116,23 +117,18 @@ public class SemanticPredicates {
if (context instanceof PostfixExprAltContext) {
List<ParseTree> peacChildren = ((PostfixExprAltContext) context).children;
- if (1 == peacChildren.size()) {
+ try {
ParseTree peacChild = peacChildren.get(0);
+ List<ParseTree> pecChildren = ((PostfixExpressionContext) peacChild).children;
- if (peacChild instanceof PostfixExpressionContext) {
- List<ParseTree> pecChildren = ((PostfixExpressionContext) peacChild).children;
+ ParseTree pecChild = pecChildren.get(0);
+ PathExpressionContext pec = (PathExpressionContext) pecChild;
- if (1 == pecChildren.size()) {
- ParseTree pecChild = pecChildren.get(0);
+ int t = pec.t;
- if (pecChild instanceof PathExpressionContext) {
- PathExpressionContext pec = (PathExpressionContext) pecChild;
- int t = pec.t;
-
- return (2 == t || 3 == t);
- }
- }
- }
+ return (2 == t || 3 == t);
+ } catch (IndexOutOfBoundsException | ClassCastException e) {
+ throw new GroovyBugError("Unexpected structure of expression context: " + context, e);
}
}