add check type
This commit is contained in:
@@ -4,6 +4,7 @@ import TP2.asd.Interface.*;
|
||||
import TP2.asd.Program.*;
|
||||
|
||||
public class PrettyprinterVisitor implements ProgramVisitor<String,String>,
|
||||
PrototypeVisitor<String,String>,
|
||||
FunctionVisitor<String,String>,
|
||||
DeclVisitor<String,String>,
|
||||
InstrVisitor<String,String>,
|
||||
@@ -18,6 +19,11 @@ public class PrettyprinterVisitor implements ProgramVisitor<String,String>,
|
||||
@Override
|
||||
public String visitProgram(ProgramImp prog, String indent) {
|
||||
String str ="";
|
||||
for(int i= 0; i<prog.protos().size();i++){
|
||||
str+=prog.protos().get(i).accept(this, INDENT);
|
||||
if(i<prog.protos().size()-1) str += "\n";
|
||||
}
|
||||
str+="\n";
|
||||
for(int i = 0; i<prog.fonctions().size(); i++){
|
||||
str += prog.fonctions().get(i).accept(this,INDENT);
|
||||
if(i<prog.fonctions().size()-1) str += "\n";
|
||||
@@ -25,8 +31,20 @@ public class PrettyprinterVisitor implements ProgramVisitor<String,String>,
|
||||
return str;
|
||||
}
|
||||
|
||||
//FUNCTION
|
||||
//PROTOTYPE
|
||||
@Override
|
||||
public String visitPrototype(PrototypeImp proto, String indent){
|
||||
String str= indent + "PROTO "+proto.type().accept(this, "")+ " "+ proto.nom() + "(";
|
||||
for(int i=0; i<proto.s().size();i++){
|
||||
str+=proto.s().get(i);
|
||||
if((i<proto.s().size()-1)){
|
||||
str+=", ";
|
||||
}
|
||||
}
|
||||
return str+")";
|
||||
}
|
||||
|
||||
//FUNCTION
|
||||
@Override
|
||||
public String visitFunction(FunctionImp fun, String indent) {
|
||||
String str = indent+"FUNC " + fun.type().accept(this,"")+ " " + fun.nom() +"() ";
|
||||
@@ -35,7 +53,6 @@ public class PrettyprinterVisitor implements ProgramVisitor<String,String>,
|
||||
}
|
||||
|
||||
//DELCARATION
|
||||
|
||||
@Override
|
||||
public String visitDeclaration(DeclarationImp instr, String indent) {
|
||||
String str = indent +instr.t().accept(this,"") + " ";
|
||||
@@ -47,7 +64,6 @@ public class PrettyprinterVisitor implements ProgramVisitor<String,String>,
|
||||
}
|
||||
|
||||
//INSTRUCTION
|
||||
|
||||
@Override
|
||||
public String visitReturn(Return_instrImp instr, String indent) {
|
||||
return indent+"RETURN " + instr.e().accept(this,"");
|
||||
|
||||
Reference in New Issue
Block a user