Re: Generating Source Code.

Vadim Maslov <>
16 Oct 1999 02:04:17 -0400

          From comp.compilers

Related articles
[2 earlier articles]
Re: Generating Source Code. (David Chase) (1999-10-11)
Re: Generating Source Code. (Craig Smith) (1999-10-11)
Re: Generating Source Code. (Christopher W. Milner) (1999-10-11)
Re: Generating Source Code. (1999-10-13)
Re: Generating Source Code. (Scott Stanchfield) (1999-10-13)
Re: Generating Source Code. (H. Ellenberger) (1999-10-14)
Re: Generating Source Code. (Vadim Maslov) (1999-10-16)
Re: Generating Source Code. (Christian Stapfer) (1999-10-21)
| List of all articles for this month |

From: Vadim Maslov <>
Newsgroups: comp.compilers
Date: 16 Oct 1999 02:04:17 -0400
Organization: RoadRunner - MGFairfax
References: 99-10-036
Keywords: translator 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 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

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.