Add empty constructor in parser when none is found

This commit is contained in:
Boolean-True 2024-05-10 10:36:23 +02:00
parent b3fc0c5efd
commit a911cc10e1

View File

@ -17,9 +17,12 @@ public class ASTGenerator {
declarations = ctx.field().stream().map(ASTGenerator::generateFieldVariable).toList();
}
List<Constructor> constructors = new ArrayList<>();
if (ctx.constructor() != null) {
if (!ctx.constructor().isEmpty()) {
constructors = ctx.constructor().stream().map(ASTGenerator::generateConstructor).toList();
}
else {
constructors.add(new Constructor(ctx.id().IDENTIFIER().getText(), List.of(), new Block(List.of(), List.of())));
}
List<Method> meths = new ArrayList<>();
if (ctx.meth() != null) {
meths = ctx.meth().stream().map(ASTGenerator::generateMethod).toList();