For programs that read in source code, transform that source code, and then write back out the transformed source code so that it can be read and edited by humans, what sorts of data structures are typically used for representing source code with all its textual details? Is there a standard "textbook" data structure for this? (e.g. something analogous to the AST for more traditional parsing)
Some examples of the types of programs I have in mind are the many clang-based tools for transforming C and C++, the Python tools for translating Python 2 to Python 3, and the many tools for transforming Go.
I guess the answer could be as simple as an AST with extra-data (e.g. whitespace, parenthesis) on the non-leaf nodes but I'm not sure. It seems like it could be more complicated since the structure needs to negotiate the tension between maintaining textual details and allowing for high-level source code transformations.