From d35aadf36c2129ab1409797472d2050be7fa19c3 Mon Sep 17 00:00:00 2001 From: Boolean-True Date: Wed, 8 May 2024 11:16:29 +0200 Subject: [PATCH] Add Exception Messages --- src/main/java/de/maishai/ASTGenerator.java | 4 ++-- src/main/java/de/maishai/ExpressionGenerator.java | 6 +++--- src/main/java/de/maishai/StatementGenerator.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/maishai/ASTGenerator.java b/src/main/java/de/maishai/ASTGenerator.java index 26c253a..ad4681a 100644 --- a/src/main/java/de/maishai/ASTGenerator.java +++ b/src/main/java/de/maishai/ASTGenerator.java @@ -81,7 +81,7 @@ public class ASTGenerator { type.setObjectType(new Id(ctx.id().getText())); return type; } - throw new RuntimeException(); + throw new RuntimeException("No type found!"); } public static ReturnType getReturnType(DecafParser.ReturntypeContext ctx) { @@ -99,6 +99,6 @@ public class ASTGenerator { type.setObjectType(new Id(ctx.type().id().getText())); return type; } - throw new RuntimeException(); + throw new RuntimeException("No return type found!"); } } diff --git a/src/main/java/de/maishai/ExpressionGenerator.java b/src/main/java/de/maishai/ExpressionGenerator.java index 397ce32..7586d84 100644 --- a/src/main/java/de/maishai/ExpressionGenerator.java +++ b/src/main/java/de/maishai/ExpressionGenerator.java @@ -26,7 +26,7 @@ public class ExpressionGenerator extends DecafBaseVisitor { if (ctx.unaryOp().SUB() != null) { return new Unary(UnaryOperator.SUB, expr); } - throw new RuntimeException(); + throw new RuntimeException("No unary operator found."); } @Override @@ -59,7 +59,7 @@ public class ExpressionGenerator extends DecafBaseVisitor { return new BoolLiteral(Boolean.valueOf(ctx.BOOLEANLITERAL().getText())); if (ctx.CHARLITERAL() != null) return new CharLiteral(ctx.CHARLITERAL().getText().charAt(0)); - throw new RuntimeException(); + throw new RuntimeException("No literal found!"); } public static Binary generateBinary(DecafParser.BinaryOperationContext ctx) { @@ -81,7 +81,7 @@ public class ExpressionGenerator extends DecafBaseVisitor { if (ctx.NE() != null) return Operator.NE; if (ctx.AND() != null) return Operator.AND; if (ctx.OR() != null) return Operator.OR; - throw new RuntimeException(); + throw new RuntimeException("No operator found!"); } @Override diff --git a/src/main/java/de/maishai/StatementGenerator.java b/src/main/java/de/maishai/StatementGenerator.java index 62b7800..a91383c 100644 --- a/src/main/java/de/maishai/StatementGenerator.java +++ b/src/main/java/de/maishai/StatementGenerator.java @@ -110,6 +110,6 @@ public class StatementGenerator extends DecafBaseVisitor { return new Binary(id, Operator.SUB, expression); if (ctx.MUL_ASSIGN() != null) return new Binary(id, Operator.MUL, expression); - throw new RuntimeException(); + throw new RuntimeException("No assign sign found!"); } }