From 04978dafe365a5e4e5c9109e872d344a65e93ba3 Mon Sep 17 00:00:00 2001 From: MaarxS Date: Wed, 20 Mar 2024 14:32:26 +0100 Subject: [PATCH] finish ExpressionGenerator --- src/main/java/de/dhbw/horb/ExpressionGenerator.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/dhbw/horb/ExpressionGenerator.java b/src/main/java/de/dhbw/horb/ExpressionGenerator.java index 205eb65..30b33e7 100644 --- a/src/main/java/de/dhbw/horb/ExpressionGenerator.java +++ b/src/main/java/de/dhbw/horb/ExpressionGenerator.java @@ -2,6 +2,9 @@ package de.dhbw.horb; import de.dhbw.horb.ast.*; +import java.util.List; +import java.util.stream.Collectors; + public class ExpressionGenerator extends DecafBaseVisitor { @Override public Expression visitBinaryOperation(DecafParser.BinaryOperationContext ctx) { @@ -10,7 +13,10 @@ public class ExpressionGenerator extends DecafBaseVisitor { @Override public Expression visitFunCallExpression(DecafParser.FunCallExpressionContext ctx) { - throw new RuntimeException("TODO"); + String name = ctx.funcCall().id().getText(); + List expressions = ctx.funcCall().args().expr(); + List args = expressions.stream().map(this::visit).toList(); + return new FunctionCall(name, args); } @Override