|[2 earlier articles]|
|Re: Generating Source Code. email@example.com (David Chase) (1999-10-11)|
|Re: Generating Source Code. firstname.lastname@example.org (Craig Smith) (1999-10-11)|
|Re: Generating Source Code. email@example.com (Christopher W. Milner) (1999-10-11)|
|Re: Generating Source Code. firstname.lastname@example.org (1999-10-13)|
|Re: Generating Source Code. email@example.com (Scott Stanchfield) (1999-10-13)|
|Re: Generating Source Code. firstname.lastname@example.org (H. Ellenberger) (1999-10-14)|
|Re: Generating Source Code. email@example.com (Vadim Maslov) (1999-10-16)|
|Re: Generating Source Code. firstname.lastname@example.org (Christian Stapfer) (1999-10-21)|
|From:||Vadim Maslov <email@example.com>|
|Date:||16 Oct 1999 02:04:17 -0400|
|Organization:||RoadRunner - MGFairfax|
> Hi folks,
> I'd appreciate any pointers/references on the subject of generating
> human readable source from an AST. I've looked at some of the source
> code pretty printers which are floating around but all of them seem
> are relatively simple and are based on lexical analysis. I realize
> that "human readable" is a subjective term and that for any particular
> language people will have preferences regarding indentation, line
> splitting etc.
We have a general operation-table-driven PrettyPrinter in
CobolTransformer http://www.siber.com/sct/. It takes the Program Tree
(what you call AST) and turns it back into a beautified program and
most of its intelligence is contained in code generation table (it's
like K&R code generation table on steroids).
Every operation on a tree has a code generation string that specifies
the code layout for the operation. We can do indentation, printing at
fixed positions, printing a list of items starting at the same column.
The approach that we use is language-independent (CodeTransformer),
but so far it was only applied to Cobol (probably because C/C++ is
less likely to be in need of en masse automated conversion).
Return to the
Search the comp.compilers archives again.