From b00979c1a8bc352ad91d4993f0c25b1cd8b71696 Mon Sep 17 00:00:00 2001 From: StefanZ3 Date: Thu, 20 Jun 2024 07:28:31 +0200 Subject: [PATCH 1/2] fix ast --- src/main/java/astGenerator/ASTGenerator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/astGenerator/ASTGenerator.java b/src/main/java/astGenerator/ASTGenerator.java index fdcaf63..123d34b 100644 --- a/src/main/java/astGenerator/ASTGenerator.java +++ b/src/main/java/astGenerator/ASTGenerator.java @@ -282,7 +282,6 @@ public class ASTGenerator extends DecafBaseVisitor { } } - //todo @Override public Node visitDotSubExpr(DecafParser.DotSubExprContext ctx) { if (ctx.IntValue() != null) { @@ -293,6 +292,8 @@ public class ASTGenerator extends DecafBaseVisitor { return new LocalVarIdentifier(identifier); } else if(ctx.instVar() != null) { return visitInstVar(ctx.instVar()); + } else if(ctx.methodCall() != null) { + return visitMethodCall(ctx.methodCall()); } else if(ctx.calcExpr() != null) { return visitCalcExpr(ctx.calcExpr()); } From c96d9fc1a139c779a6425f650c405d7ea97903a5 Mon Sep 17 00:00:00 2001 From: StefanZ3 Date: Thu, 20 Jun 2024 07:37:24 +0200 Subject: [PATCH 2/2] fix block in constructor in ast --- src/main/java/astGenerator/ASTGenerator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/astGenerator/ASTGenerator.java b/src/main/java/astGenerator/ASTGenerator.java index 123d34b..ab192db 100644 --- a/src/main/java/astGenerator/ASTGenerator.java +++ b/src/main/java/astGenerator/ASTGenerator.java @@ -67,7 +67,8 @@ public class ASTGenerator extends DecafBaseVisitor { public Node visitConstuctorDecl(DecafParser.ConstuctorDeclContext ctx) { String name = ctx.Identifier().getText(); ParameterList parameterList = (ParameterList) visit(ctx.parameterList()); - return new MethodDecl("", null, name, parameterList, new BlockStatement(new ArrayList<>(), "void")); + BlockStatement block = (BlockStatement) visitBlock(ctx.block()); + return new MethodDecl("", null, name, parameterList, block); } @Override