add newDecl to ASTGenerator
This commit is contained in:
parent
66428159c1
commit
9d9dcfb9b6
@ -10,6 +10,7 @@ import abstractSyntaxTree.Parameter.ParameterList;
|
|||||||
import abstractSyntaxTree.Program;
|
import abstractSyntaxTree.Program;
|
||||||
import abstractSyntaxTree.Statement.*;
|
import abstractSyntaxTree.Statement.*;
|
||||||
import abstractSyntaxTree.StatementExpression.AssignStatementExpression;
|
import abstractSyntaxTree.StatementExpression.AssignStatementExpression;
|
||||||
|
import abstractSyntaxTree.StatementExpression.NewStatementExpression;
|
||||||
import gen.DecafBaseVisitor;
|
import gen.DecafBaseVisitor;
|
||||||
import gen.DecafParser;
|
import gen.DecafParser;
|
||||||
|
|
||||||
@ -184,15 +185,18 @@ public class ASTGenerator extends DecafBaseVisitor<Node> {
|
|||||||
return new AssignStatementExpression(ctx.Assign().getText(),(IExpression) left, (IExpression) right);
|
return new AssignStatementExpression(ctx.Assign().getText(),(IExpression) left, (IExpression) right);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
@Override
|
@Override
|
||||||
public Node visitMethodCall(DecafParser.MethodCallContext ctx) {
|
public Node visitMethodCall(DecafParser.MethodCallContext ctx) {
|
||||||
return super.visitMethodCall(ctx);
|
return super.visitMethodCall(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//add the expression list later to the constructor
|
||||||
@Override
|
@Override
|
||||||
public Node visitNewDecl(DecafParser.NewDeclContext ctx) {
|
public Node visitNewDecl(DecafParser.NewDeclContext ctx) {
|
||||||
return super.visitNewDecl(ctx);
|
String name = ctx.Identifier().getText();
|
||||||
|
List<IExpression> expressions = generateExpressions(ctx.argumentList());
|
||||||
|
return new NewStatementExpression(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -296,14 +300,11 @@ public class ASTGenerator extends DecafBaseVisitor<Node> {
|
|||||||
return super.visitInstVar(ctx);
|
return super.visitInstVar(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Override
|
public List<IExpression> generateExpressions(DecafParser.ArgumentListContext ctx) {
|
||||||
// public Node visitArgumentList(DecafParser.ArgumentListContext ctx) {
|
List<IExpression> expressions = new ArrayList<>();
|
||||||
// if (ctx.expression().size() == 1) {
|
for (DecafParser.ExpressionContext expressionContext : ctx.expression()) {
|
||||||
// return visitExpression(ctx.expression(0));
|
expressions.add((IExpression) visitExpression(expressionContext));
|
||||||
// } else if (ctx.expression().size() >= 2) {
|
}
|
||||||
// for(DecafParser.ExpressionContext expressionContext: ctx.expression()) {
|
return expressions;
|
||||||
//
|
}
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user