fix parameterList in ast
This commit is contained in:
parent
719e19e7f8
commit
ebd4f7ca4e
@ -66,7 +66,10 @@ public class ASTGenerator extends DecafBaseVisitor<Node> {
|
||||
@Override
|
||||
public Node visitConstuctorDecl(DecafParser.ConstuctorDeclContext ctx) {
|
||||
String name = ctx.Identifier().getText();
|
||||
ParameterList parameterList = (ParameterList) visit(ctx.parameterList());
|
||||
ParameterList parameterList = new ParameterList(new ArrayList<>());
|
||||
if (ctx.parameterList() != null) {
|
||||
parameterList = (ParameterList) visit(ctx.parameterList());
|
||||
}
|
||||
BlockStatement block = (BlockStatement) visitBlock(ctx.block());
|
||||
return new MethodDecl("", null, name, parameterList, block);
|
||||
}
|
||||
@ -76,8 +79,11 @@ public class ASTGenerator extends DecafBaseVisitor<Node> {
|
||||
String type;
|
||||
String name = ctx.Identifier().getText();
|
||||
BlockStatement block = (BlockStatement) visitBlock(ctx.block());
|
||||
ParameterList parameterList = (ParameterList) visit(ctx.parameterList());
|
||||
if (ctx.Void() != null) {
|
||||
ParameterList parameterList = new ParameterList(new ArrayList<>());
|
||||
if (ctx.parameterList() != null) {
|
||||
parameterList = (ParameterList) visit(ctx.parameterList());
|
||||
}
|
||||
if (ctx.Void() != null) {
|
||||
type = "void";
|
||||
} else {
|
||||
type = ctx.type().getText();
|
||||
|
Loading…
Reference in New Issue
Block a user