How to pretty print source code when using a AST that is generated from a CST

200 views Asked by At

I'm aware that its fairly trivial to pretty print code with a CST, since information about the grammar is stored in the node.

However, when converted to a AST, much of the initial structure of the source code is lost from de sugaring and other transformations. Thus how can a AST pretty print source code given that it has undergone these major translations? Does it contain references to the AST that was used to generate it (and therefore the grammar/structure necessary to perfectly reproduce the source code)?

0

There are 0 answers