minor change in ExpressionGenerator

This commit is contained in:
laurenz 2024-05-15 16:58:58 +02:00
parent f74ba50caa
commit 8318defd30

View File

@ -53,10 +53,12 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
}
public static Expression generateConstant(DecafParser.LiteralContext ctx) {
if (ctx.NUMBER() != null)
if (ctx.NUMBER() != null) {
return new IntLiteral(Integer.valueOf(ctx.NUMBER().getText()));
if (ctx.BOOLEANLITERAL() != null)
}
if (ctx.BOOLEANLITERAL() != null) {
return new BoolLiteral(Boolean.valueOf(ctx.BOOLEANLITERAL().getText()));
}
if (ctx.CHARLITERAL() != null) {
if (ctx.CHARLITERAL().getText().length() != 3) {
throw new RuntimeException("Wrong format for Char literal. Good format: 'c' Bad format: " + ctx.CHARLITERAL().getText());