implemented ExpressionGenerator
This commit is contained in:
parent
379e622284
commit
8ea08b564d
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user