add assign
This commit is contained in:
parent
a147512dcb
commit
25d379876b
@ -3,10 +3,7 @@ package astGenerator;
|
||||
import abstractSyntaxTree.Class.FieldDecl;
|
||||
import abstractSyntaxTree.Class.MethodDecl;
|
||||
import abstractSyntaxTree.Class.RefType;
|
||||
import abstractSyntaxTree.Expression.BinaryExpression;
|
||||
import abstractSyntaxTree.Expression.IExpression;
|
||||
import abstractSyntaxTree.Expression.IntConstantExpression;
|
||||
import abstractSyntaxTree.Expression.LocalVarIdentifier;
|
||||
import abstractSyntaxTree.Expression.*;
|
||||
import abstractSyntaxTree.Node;
|
||||
import abstractSyntaxTree.Parameter.Parameter;
|
||||
import abstractSyntaxTree.Parameter.ParameterList;
|
||||
@ -176,9 +173,12 @@ public class ASTGenerator extends DecafBaseVisitor<Node> {
|
||||
|
||||
@Override
|
||||
public Node visitAssign(DecafParser.AssignContext ctx) {
|
||||
return new AssignStatementExpression("", null, null);
|
||||
Node right = visitExpression(ctx.expression());
|
||||
Node left = visitAssignableExpr(ctx.assignableExpr());
|
||||
return new AssignStatementExpression(ctx.Assign().getText(),(IExpression) left, (IExpression) right);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Node visitMethodCall(DecafParser.MethodCallContext ctx) {
|
||||
return super.visitMethodCall(ctx);
|
||||
@ -240,13 +240,14 @@ public class ASTGenerator extends DecafBaseVisitor<Node> {
|
||||
//todo
|
||||
@Override
|
||||
public Node visitDotSubExpr(DecafParser.DotSubExprContext ctx) {
|
||||
// if (ctx.IntValue() != null) {
|
||||
// int value = Integer.parseInt(ctx.IntValue().getText());
|
||||
// return new IntConstantExpression(value);
|
||||
// }
|
||||
if(ctx.Identifier() != null) {
|
||||
if (ctx.IntValue() != null) {
|
||||
int value = Integer.parseInt(ctx.IntValue().getText());
|
||||
return new IntConstantExpression(value);
|
||||
} else if(ctx.Identifier() != null) {
|
||||
String identifier = ctx.Identifier().getText();
|
||||
return new LocalVarIdentifier(identifier);
|
||||
} else if(ctx.instVar() != null) {
|
||||
return visitInstVar(ctx.instVar());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -283,4 +284,20 @@ public class ASTGenerator extends DecafBaseVisitor<Node> {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node visitInstVar(DecafParser.InstVarContext ctx) {
|
||||
return super.visitInstVar(ctx);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Node visitArgumentList(DecafParser.ArgumentListContext ctx) {
|
||||
// if (ctx.expression().size() == 1) {
|
||||
// return visitExpression(ctx.expression(0));
|
||||
// } else if (ctx.expression().size() >= 2) {
|
||||
// for(DecafParser.ExpressionContext expressionContext: ctx.expression()) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user