implement pretty print visitor
This commit is contained in:
@@ -61,6 +61,13 @@ public class PrettyPrintVisitor implements Visitor<Void> {
|
|||||||
ex.nl();
|
ex.nl();
|
||||||
ex.nl();
|
ex.nl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (var structDef: e.structs) {
|
||||||
|
structDef.welcome(this);
|
||||||
|
ex.nl();
|
||||||
|
ex.nl();
|
||||||
|
}
|
||||||
|
|
||||||
e.expression.welcome(this);
|
e.expression.welcome(this);
|
||||||
ex.write(";");
|
ex.write(";");
|
||||||
return null;
|
return null;
|
||||||
@@ -378,4 +385,24 @@ public class PrettyPrintVisitor implements Visitor<Void> {
|
|||||||
return null;
|
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