generateAst function
Writes the AST represention of root
to sink
.
Implementation
void generateAst(Root root, StringSink sink) {
final Indent indent = Indent(sink);
final String output = root.toString();
bool isFirst = true;
for (final int ch in output.runes) {
final String chStr = String.fromCharCode(ch);
if (chStr == '(') {
if (isFirst) {
isFirst = false;
} else {
indent.inc();
indent.addln('');
indent.write('');
}
} else if (chStr == ')') {
indent.dec();
}
indent.add(chStr);
}
indent.addln('');
}