[cfe-dev] how to convert AST into source code again????

Douglas Gregor dgregor at apple.com
Mon Jan 17 10:23:39 PST 2011

On Jan 17, 2011, at 7:48 AM, jignesh vasoya wrote:
> in source-to-source translation i want to convert C source into ast.

There are "print" functions for the various kinds of AST nodes. There are bugs that prevent them from always generating compilable source code, and of course they destroy the formatting of the original code, so I don't recommend trying to print an entire AST.

> after making some changes to ast how can i produce C code from modified ast?

Check out the Objective-C rewriter I mentioned elsewhere. It uses limited AST printing along with the rewriter infrastructure to accomplish this.

	- Doug

More information about the cfe-dev mailing list