pretty printer
This commit is contained in:
@@ -18,7 +18,16 @@ public class ASD_Turtle implements TurtleASD {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
record PhraseImp(EntityImp entity, List<AffectationImp> affs) implements Phrase{}
|
||||
record PhraseImp(EntityImp entity, List<AffectationImp> affs) implements Phrase{
|
||||
public String toString(){
|
||||
String str = "< " + this.entity.toString() + " >";
|
||||
for (AffectationImp affectation : this.affs) {
|
||||
str+= affectation.toString();
|
||||
}
|
||||
str+= ".";
|
||||
return str;
|
||||
}
|
||||
}
|
||||
record AffectationImp(EntityImp entity, List<Complement> complements) implements Affectation{}
|
||||
record Complement_EntityImp(EntityImp entity) implements Complement{}
|
||||
record Complement_TextImp(String string) implements Complement{
|
||||
@@ -27,46 +36,4 @@ public class ASD_Turtle implements TurtleASD {
|
||||
|
||||
}
|
||||
}
|
||||
record EntityImp(String string) implements Entity{
|
||||
public String toString(){
|
||||
return this.string;
|
||||
}
|
||||
}
|
||||
|
||||
public void prettyPrinter(TurtleImp t){
|
||||
for (PhraseImp phrase : t.phrases) {
|
||||
prettyPrinter(phrase);
|
||||
}
|
||||
}
|
||||
|
||||
public void prettyPrinter(PhraseImp phrase){
|
||||
System.out.println("< " + phrase.entity + " >");
|
||||
for (AffectationImp affectation : phrase.affs) {
|
||||
prettyPrinter(affectation);
|
||||
}
|
||||
System.out.println(".");
|
||||
}
|
||||
public void prettyPrinter(AffectationImp affectation){
|
||||
System.out.println("< " + affectation.entity + " >");
|
||||
for (int i =0; i < affectation.complements.size(); i++) {
|
||||
prettyPrinter(affectation.complements.get(i));
|
||||
if (i < affectation.complements.size() - 1) {
|
||||
System.out.print(", ");
|
||||
}
|
||||
}
|
||||
System.out.println(";");
|
||||
}
|
||||
public void prettyPrinter(Complement complement){
|
||||
if( complement instanceof Complement_EntityImp ce){
|
||||
System.out.println(" < " + ce.entity + " >");
|
||||
} else if ( complement instanceof Complement_TextImp ct){
|
||||
System.out.println(" \" " + ct.string + " \"");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public void prettyPrint(EntityImp entity) {
|
||||
System.out.print(entity.string);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user