Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/antlr/GroovyParser.g4
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,6 @@ originalForControl

forInit
: localVariableDeclaration
| expressionList[false]
;

forUpdate
Expand Down
13 changes: 2 additions & 11 deletions src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,6 @@ public Expression visitForInit(final ForInitContext ctx) {
}
}

if (asBoolean(ctx.expressionList())) {
return this.translateExpressionList(ctx.expressionList());
}

throw createParsingFailedException("Unsupported for init: " + ctx.getText(), ctx);
}

Expand All @@ -558,14 +554,9 @@ public Expression visitForUpdate(final ForUpdateContext ctx) {
return EmptyExpression.INSTANCE;
}

return this.translateExpressionList(ctx.expressionList());
}

private Expression translateExpressionList(final ExpressionListContext ctx) {
List<Expression> expressionList = this.visitExpressionList(ctx);

var expressionList = this.visitExpressionList(ctx.expressionList());
if (expressionList.size() == 1) {
return configureAST(expressionList.get(0), ctx);
return configureAST(expressionList.get(0), ctx); // one Expression
} else {
return configureAST(new ClosureListExpression(expressionList), ctx);
}
Expand Down