implement pretty print visitor
This commit is contained in:
@@ -61,6 +61,13 @@ public class PrettyPrintVisitor implements Visitor<Void> {
|
||||
ex.nl();
|
||||
ex.nl();
|
||||
}
|
||||
|
||||
for (var structDef: e.structs) {
|
||||
structDef.welcome(this);
|
||||
ex.nl();
|
||||
ex.nl();
|
||||
}
|
||||
|
||||
e.expression.welcome(this);
|
||||
ex.write(";");
|
||||
return null;
|
||||
@@ -378,4 +385,24 @@ public class PrettyPrintVisitor implements Visitor<Void> {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(StructDefinition e) {
|
||||
ex.write("struct " + e.name + " {");
|
||||
ex.addIndent();
|
||||
for(var field: e.fields) {
|
||||
ex.nl();
|
||||
field.welcome(this);
|
||||
}
|
||||
ex.subIndent();
|
||||
ex.nl();
|
||||
ex.write("}");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void visit(StructField e) {
|
||||
ex.write(e.name +": " + e.type.getName() + ";");
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user