From 8ea08b564dc6f3ea554016666bcceb1318a5f5b3 Mon Sep 17 00:00:00 2001 From: JonathanFleischmann Date: Wed, 20 Mar 2024 13:06:24 +0100 Subject: [PATCH] implemented ExpressionGenerator --- src/main/java/de/dhbw/horb/ExpressionGenerator.java | 10 +++++++++- 1 file changed, 9 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..0e133fe 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.ArrayList; +import java.util.List; + public class ExpressionGenerator extends DecafBaseVisitor { @Override public Expression visitBinaryOperation(DecafParser.BinaryOperationContext ctx) { @@ -10,7 +13,12 @@ public class ExpressionGenerator extends DecafBaseVisitor { @Override public Expression visitFunCallExpression(DecafParser.FunCallExpressionContext ctx) { - throw new RuntimeException("TODO"); + String functionName = ctx.funcCall().id().getText(); + List exprList = new ArrayList<>(); + for (var expr: ctx.funcCall().args().expr()) { + exprList.add(expr.accept(this)); + } + return new FunctionCall(functionName, exprList); } @Override