Parser bugfix

This commit is contained in:
laurenz 2024-05-20 14:41:16 +02:00
parent fb8bfb719a
commit c3a9dd1f1d
2 changed files with 11 additions and 0 deletions

View File

@ -90,6 +90,11 @@ public class ExpressionGenerator extends DecafBaseVisitor<Expression> {
throw new RuntimeException("No operator found!"); throw new RuntimeException("No operator found!");
} }
@Override
public Expression visitStatementExpressionexpr(DecafParser.StatementExpressionexprContext ctx) {
return ctx.stmtexpr().accept(this);
}
@Override @Override
public Expression visitMethodCall(DecafParser.MethodCallContext ctx) { public Expression visitMethodCall(DecafParser.MethodCallContext ctx) {
boolean isField = ctx.methCall().THIS() != null; boolean isField = ctx.methCall().THIS() != null;

View File

@ -20,6 +20,7 @@ import de.maishai.ast.records.While;
import de.maishai.typedast.Type; import de.maishai.typedast.Type;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
public class StatementGenerator extends DecafBaseVisitor<List<Statement>> { public class StatementGenerator extends DecafBaseVisitor<List<Statement>> {
@ -100,6 +101,11 @@ public class StatementGenerator extends DecafBaseVisitor<List<Statement>> {
null), fieldIdContext.id().IDENTIFIER().getText()); null), fieldIdContext.id().IDENTIFIER().getText());
} }
@Override
public List<Statement> visitStatementExpressionstmt(DecafParser.StatementExpressionstmtContext ctx) {
return ctx.stmtexpr().accept(this);
}
//StatementExpression //StatementExpression
@Override @Override
public List<Statement> visitMethodCall(DecafParser.MethodCallContext ctx) { public List<Statement> visitMethodCall(DecafParser.MethodCallContext ctx) {