From ce19fcb603462e5829b45c20bf39d62ff5c14927 Mon Sep 17 00:00:00 2001 From: laurenz Date: Mon, 20 May 2024 21:50:12 +0200 Subject: [PATCH] bugfix Parser for return; statements --- src/main/java/de/maishai/ASTGenerator.java | 2 +- src/main/java/de/maishai/BlockGenerator.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/maishai/ASTGenerator.java b/src/main/java/de/maishai/ASTGenerator.java index 95c50ce..b639c57 100644 --- a/src/main/java/de/maishai/ASTGenerator.java +++ b/src/main/java/de/maishai/ASTGenerator.java @@ -21,7 +21,7 @@ public class ASTGenerator { declarations = ctx.field().stream().map(ASTGenerator::generateFieldVariable).toList(); } List constructors = new ArrayList<>(); - if (!ctx.constructor().isEmpty()) { + if (ctx.constructor() != null && !ctx.constructor().isEmpty()) { constructors = ctx.constructor().stream().map(ASTGenerator::generateConstructor).toList(); } else { diff --git a/src/main/java/de/maishai/BlockGenerator.java b/src/main/java/de/maishai/BlockGenerator.java index 06eb4a9..c13a0ae 100644 --- a/src/main/java/de/maishai/BlockGenerator.java +++ b/src/main/java/de/maishai/BlockGenerator.java @@ -20,7 +20,7 @@ public class BlockGenerator extends DecafBaseVisitor { } } 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); }