diff --git a/src/main/java/astGenerator/ASTGenerator.java b/src/main/java/astGenerator/ASTGenerator.java index c4bb951..3d7d34e 100644 --- a/src/main/java/astGenerator/ASTGenerator.java +++ b/src/main/java/astGenerator/ASTGenerator.java @@ -206,8 +206,12 @@ public class ASTGenerator extends DecafBaseVisitor { for(DecafParser.ReceivingMethodContext receivingMethod: ctx.receivingMethod()) { receivingMethods.add((ReceivingMethod) visit(receivingMethod)); } - Receiver receiver = (Receiver) visit(ctx.receiver()); - return new MethodCallStatementExpression(methodName, receiver, receivingMethods, arguments); + if (ctx.receiver() != null) { + Receiver receiver = (Receiver) visit(ctx.receiver()); + return new MethodCallStatementExpression(methodName, receiver, receivingMethods, arguments); + } else { + return new MethodCallStatementExpression(methodName, null, receivingMethods, arguments); + } } @Override