Related articles |
---|
[2 earlier articles] |
Re: Generating Source Code. chase@world.std.com (David Chase) (1999-10-11) |
Re: Generating Source Code. smith@gandalf.uni-trier.de (Craig Smith) (1999-10-11) |
Re: Generating Source Code. cmilner@virginia.edu (Christopher W. Milner) (1999-10-11) |
Re: Generating Source Code. anton@mips.complang.tuwien.ac.at (1999-10-13) |
Re: Generating Source Code. thetick@jguru.com (Scott Stanchfield) (1999-10-13) |
Re: Generating Source Code. ele@freesurf.ch (H. Ellenberger) (1999-10-14) |
Re: Generating Source Code. vadik@siber.com (Vadim Maslov) (1999-10-16) |
Re: Generating Source Code. chstapfer@bluewin.ch (Christian Stapfer) (1999-10-21) |
From: | Vadim Maslov <vadik@siber.com> |
Newsgroups: | comp.compilers |
Date: | 16 Oct 1999 02:04:17 -0400 |
Organization: | RoadRunner - MGFairfax |
References: | 99-10-036 |
Keywords: | translator |
dara_gallagher@my-deja.com wrote:
>
> 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).
Vadim Maslov
Return to the
comp.compilers page.
Search the
comp.compilers archives again.