finish ExpressionGenerator

This commit is contained in:
MaarxS 2024-03-20 14:32:26 +01:00
parent 2b90f84c1e
commit 04978dafe3

View File

@ -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<Expression> {
@Override
public Expression visitBinaryOperation(DecafParser.BinaryOperationContext ctx) {
@ -10,7 +13,10 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
@Override
public Expression visitFunCallExpression(DecafParser.FunCallExpressionContext ctx) {
throw new RuntimeException("TODO");
String name = ctx.funcCall().id().getText();
List<DecafParser.ExprContext> expressions = ctx.funcCall().args().expr();
List<Expression> args = expressions.stream().map(this::visit).toList();
return new FunctionCall(name, args);
}
@Override