bugfix return

This commit is contained in:
StefanZ3 2024-07-03 15:18:53 +02:00
parent d7016df1ba
commit 6948797001

View File

@ -140,8 +140,12 @@ public class ASTGenerator extends DecafBaseVisitor<Node> {
@Override
public Node visitReturnStmt(DecafParser.ReturnStmtContext ctx) {
Node expression = visitExpression(ctx.expression());
return new ReturnStatement((IExpression) expression);
if (ctx.expression() != null) {
Node expression = visitExpression(ctx.expression());
return new ReturnStatement((IExpression) expression);
} else {
return new ReturnStatement(null);
}
}
@Override