Skip to content

Commit

Permalink
Remove todo and fixme
Browse files Browse the repository at this point in the history
  • Loading branch information
boozec committed Jul 14, 2024
1 parent 7944fd7 commit 1376691
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 33 deletions.
11 changes: 4 additions & 7 deletions src/ast/Python3VisitorImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public Node visitAugassign(AugassignContext ctx) {
}

/**
* Returns a `IfNode`. FIXME: add support for elif statement.
* Returns a `IfNode`.
*
* ``` if_stmt : 'if' expr ':' block ('elif' expr ':' block)* ('else' ':'
* block)? ; ```
Expand Down Expand Up @@ -490,9 +490,7 @@ public Node visitFor_stmt(For_stmtContext ctx) {
int index = ctx.getStart().getTokenIndex();

rewriter.insertAfter(index, " ");
// TODO: generalize this to support multi-definition
// inserting spaces to correctly parse the new input
// `foriinlists` becomes `for i in lists`
// NOTE: works only for one argument
rewriter.insertAfter(index + 1, " ");
rewriter.insertAfter(index + 2, " ");
optimizeWithSecond(block, lineStart, lineStop, index);
Expand Down Expand Up @@ -778,7 +776,7 @@ public Node visitTrailer(TrailerContext ctx) {
}

/**
* Returns a `Node`. FIXME: what to do in case of list??
* Returns a `Node`.
*
* ``` exprlist : expr (',' expr )* ','? ; ```
*/
Expand Down Expand Up @@ -845,12 +843,11 @@ public Node visitComp_for(Comp_forContext ctx) {

/**
* Returns a `CompIterNode`.
* NOTE: We ignore `comp_if`.
*
* ``` comp_iter : comp_for | comp_if ; ;```
*/
public Node visitComp_iter(Comp_iterContext ctx) {
// TODO: Implement comp_if
// Node iter = visit(ctx.comp_if());
Comp_forContext cfc = ctx.comp_for();
Node forNode = null;
if (cfc != null) {
Expand Down
8 changes: 3 additions & 5 deletions src/ast/nodes/ArglistNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting, Fun
String argName = argExpr.getId();
errors.addAll(arg.checkSemantics(ST, _nesting, ft));

// TODO: check IntType for params
if (argName != null) {
if (Arrays.asList(bif).contains(argName)) {
continue;
Expand Down Expand Up @@ -66,7 +65,6 @@ public String codeGeneration() {
return str;
}


@Override
public String printAST(String prefix) {
String str = prefix + "ArglistNode\n";
Expand All @@ -78,12 +76,12 @@ public String printAST(String prefix) {

return str;
}

@Override
public String toPrint(String prefix) {
String str = prefix;
str += arguments.get(0).toPrint("");

if (arguments.size() > 1) {
for (int i = 1; i < arguments.size(); i++) {
str += ", " + arguments.get(i).toPrint("");
Expand All @@ -93,4 +91,4 @@ public String toPrint(String prefix) {
return str;
}

}
}
1 change: 0 additions & 1 deletion src/ast/nodes/AssignmentNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting, Fun

}

// TODO: check it out for this type
@Override
public Type typeCheck() {
return rhr.typeCheck();
Expand Down
4 changes: 1 addition & 3 deletions src/ast/nodes/BlockNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,14 @@ public String printAST(String prefix) {
return str;
}


@Override
public String toPrint(String prefix) {
String str = "";

// TODO: scrivere nella documentazione che diamo per assunto che il blocco sia sempre un blocco su più righe
for (Node child : childs) {
str += child.toPrint(prefix);
}

return str;
}
}
1 change: 0 additions & 1 deletion src/ast/nodes/CompOpNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting, Fun
return new ArrayList<>();
}

// TODO: it should be boolean, right?
@Override
public Type typeCheck() {
return new VoidType();
Expand Down
4 changes: 0 additions & 4 deletions src/ast/nodes/ExprListNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ public class ExprListNode implements Node {

public ExprListNode(List<Node> exprs) {
this.exprs = exprs;

// FIXME: remove this print
// System.out.println(exprs);
}

@Override
Expand Down Expand Up @@ -78,7 +75,6 @@ public String printAST(String prefix) {
@Override
public String toPrint(String prefix) {

// TODO: Diamo per assodato che rimuova le , alla fine
String str = prefix + exprs.get(0).toPrint("");

for (int i = 1; i < exprs.size(); ++i) {
Expand Down
8 changes: 3 additions & 5 deletions src/ast/nodes/ExprNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting, Fun
TrailerNode trailer = (TrailerNode) trailers.get(0);
String funName = atom.getId();

// TODO: it isnt a function, it could be a variable
STentry fun = ST.lookup(funName);

if (fun != null && !(fun.getType() instanceof ImportType)) {
Expand Down Expand Up @@ -132,7 +131,6 @@ public ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting, Fun
return errors;
}

// FIXME: type for the expr
@Override
public Type typeCheck() {
if (this.atom != null) {
Expand Down Expand Up @@ -180,8 +178,8 @@ public String codeGeneration() {
case "+":
case "-":
case "*":
// In real Python `/` is a float division but we'll consider the
// int division here below.
// In real Python `/` is a float division but we'll consider the
// int division here below.
case "/":
return intOpCodeGen(exprs.get(0), exprs.get(1), op);
case "%":
Expand Down Expand Up @@ -241,7 +239,7 @@ public String printAST(String prefix) {
prefix += " ";
if (atom != null) {
str += atom.printAST(prefix);

for (var trailer : trailers) {
str += trailer.printAST(prefix);
}
Expand Down
4 changes: 1 addition & 3 deletions src/ast/nodes/ForStmtNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,11 @@ public String printAST(String prefix) {

@Override
public String toPrint(String prefix) {

// TODO: indicare che diamo per assunto il for su più righe
String str = prefix + "for ";
str += exprList.toPrint("") + ":\n";
str += block.toPrint(prefix + "\t");
return str;
}
}

public Node getBlock() {
return block;
Expand Down
1 change: 0 additions & 1 deletion src/ast/nodes/FuncdefNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting, Fun
return errors;
}

// FIXME: this type must be the same of the return stmt variable
@Override
public Type typeCheck() {
return new VoidType();
Expand Down
1 change: 0 additions & 1 deletion src/ast/nodes/IfNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting, Fun
return errors;
}

// FIXME: fix the if statement
@Override
public Type typeCheck() {
if (guard.typeCheck() instanceof BoolType) {
Expand Down
1 change: 0 additions & 1 deletion src/ast/nodes/ParamdefNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public ArrayList<SemanticError> checkSemantics(SymbolTable ST, int _nesting, Fun
return errors;
}

// FIXME: it should returns the param' type
@Override
public Type typeCheck() {
return new VoidType();
Expand Down
4 changes: 3 additions & 1 deletion src/ast/nodes/WhileStmtNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public Type typeCheck() {
return new VoidType();
}

// TODO: add cgen per while (but it's not requested from the exercise)
/**
* NOTE: It is not a part for this project.
*/
@Override
public String codeGeneration() {
return "";
Expand Down

0 comments on commit 1376691

Please sign in to comment.