Compare commits

..

No commits in common. "d4cc24239d337de2cae7e16db26c309e18e71633" and "abc4e3ff7018335f8643cc390e704040fbc5b493" have entirely different histories.

View File

@ -3,7 +3,10 @@ package astGenerator;
import abstractSyntaxTree.Class.FieldDecl; import abstractSyntaxTree.Class.FieldDecl;
import abstractSyntaxTree.Class.MethodDecl; import abstractSyntaxTree.Class.MethodDecl;
import abstractSyntaxTree.Class.RefType; import abstractSyntaxTree.Class.RefType;
import abstractSyntaxTree.Expression.*; import abstractSyntaxTree.Expression.BinaryExpression;
import abstractSyntaxTree.Expression.IExpression;
import abstractSyntaxTree.Expression.IntConstantExpression;
import abstractSyntaxTree.Expression.LocalVarIdentifier;
import abstractSyntaxTree.Node; import abstractSyntaxTree.Node;
import abstractSyntaxTree.Parameter.Parameter; import abstractSyntaxTree.Parameter.Parameter;
import abstractSyntaxTree.Parameter.ParameterList; import abstractSyntaxTree.Parameter.ParameterList;
@ -173,12 +176,9 @@ public class ASTGenerator extends DecafBaseVisitor<Node> {
@Override @Override
public Node visitAssign(DecafParser.AssignContext ctx) { public Node visitAssign(DecafParser.AssignContext ctx) {
Node right = visitExpression(ctx.expression()); return new AssignStatementExpression("", null, null);
Node left = visitAssignableExpr(ctx.assignableExpr());
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);
@ -240,14 +240,13 @@ public class ASTGenerator extends DecafBaseVisitor<Node> {
//todo //todo
@Override @Override
public Node visitDotSubExpr(DecafParser.DotSubExprContext ctx) { public Node visitDotSubExpr(DecafParser.DotSubExprContext ctx) {
if (ctx.IntValue() != null) { // if (ctx.IntValue() != null) {
int value = Integer.parseInt(ctx.IntValue().getText()); // int value = Integer.parseInt(ctx.IntValue().getText());
return new IntConstantExpression(value); // return new IntConstantExpression(value);
} else if(ctx.Identifier() != null) { // }
if(ctx.Identifier() != null) {
String identifier = ctx.Identifier().getText(); String identifier = ctx.Identifier().getText();
return new LocalVarIdentifier(identifier); return new LocalVarIdentifier(identifier);
} else if(ctx.instVar() != null) {
return visitInstVar(ctx.instVar());
} }
return null; return null;
} }
@ -284,20 +283,4 @@ public class ASTGenerator extends DecafBaseVisitor<Node> {
} }
return null; 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()) {
//
// }
// }
// }
} }