bugfix Parser for return; statements

This commit is contained in:
laurenz 2024-05-20 21:50:12 +02:00
parent ca9f6cc06a
commit ce19fcb603
2 changed files with 2 additions and 2 deletions

View File

@ -21,7 +21,7 @@ public class ASTGenerator {
declarations = ctx.field().stream().map(ASTGenerator::generateFieldVariable).toList();
}
List<Constructor> constructors = new ArrayList<>();
if (!ctx.constructor().isEmpty()) {
if (ctx.constructor() != null && !ctx.constructor().isEmpty()) {
constructors = ctx.constructor().stream().map(ASTGenerator::generateConstructor).toList();
}
else {

View File

@ -20,7 +20,7 @@ public class BlockGenerator extends DecafBaseVisitor<Block> {
}
}
if (ctx.return_() != null){
statements.add(ctx.return_().expr().isEmpty() ? new Return(null) : new Return(new ExpressionGenerator().visit(ctx.return_().expr())));
statements.add(ctx.return_().expr() == null ? new Return(null) : new Return(new ExpressionGenerator().visit(ctx.return_().expr())));
}
return new Block(statements);
}