implemented ExpressionGenerator

This commit is contained in:
JonathanFleischmann 2024-03-20 13:06:24 +01:00
parent 379e622284
commit 8ea08b564d

View File

@ -2,6 +2,9 @@ package de.dhbw.horb;
import de.dhbw.horb.ast.*; import de.dhbw.horb.ast.*;
import java.util.ArrayList;
import java.util.List;
public class ExpressionGenerator extends DecafBaseVisitor<Expression> { public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
@Override @Override
public Expression visitBinaryOperation(DecafParser.BinaryOperationContext ctx) { public Expression visitBinaryOperation(DecafParser.BinaryOperationContext ctx) {
@ -10,7 +13,12 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
@Override @Override
public Expression visitFunCallExpression(DecafParser.FunCallExpressionContext ctx) { public Expression visitFunCallExpression(DecafParser.FunCallExpressionContext ctx) {
throw new RuntimeException("TODO"); String functionName = ctx.funcCall().id().getText();
List<Expression> exprList = new ArrayList<>();
for (var expr: ctx.funcCall().args().expr()) {
exprList.add(expr.accept(this));
}
return new FunctionCall(functionName, exprList);
} }
@Override @Override