Open katyo opened 5 years ago
Indeed, serializing AST back to source code would be a nice addition. What do you mean by "line precise"?
I mean keeping line-to-line mapping between parsed source and formatted output. This important is some use-cases.
I think this is sometimes referred to as a concrete syntax tree (CST) or lossless syntax tree.
@katyo We do macro expansion before parsing, so serializing AST would not yield the same text line for line. At best, it would be able to re-create source text after preprocessing. Perhaps for your use case something like tree-sitter would be a better fit?
Hmm, tree-sitter looks interesting. I will try to play with it. Thanks.
I implements so-called transpiler which process C source before sending to real compiler.
I found lang-c much useful for parsing the sources but it seems the formatting the AST back to the source code still not implemented yet.
I think the line-precise formatter may be very useful feature here.