|Source for compiler using yacc/lex wanted email@example.com (1996-03-05)|
|Re: Source for compiler using yacc/lex wanted Steve_Kilbane@cegelecproj.co.uk (1996-03-08)|
|Re: Source for compiler using yacc/lex wanted firstname.lastname@example.org (1996-03-08)|
|Re: Source for compiler using yacc/lex wanted email@example.com) (1996-03-15)|
|Re: Source for compiler using yacc/lex wanted firstname.lastname@example.org (1996-03-22)|
|Re: pretty-printing with yacc and lex email@example.com (Scott Stanchfield) (1996-03-22)|
|Re: pretty-printing with yacc and lex firstname.lastname@example.org (1996-03-27)|
|From:||email@example.com (felix gaertner)|
|Date:||22 Mar 1996 00:35:57 -0500|
>Our moderator writes:
>>[I actually think that lex and yacc are lousy tools to use for a pretty
>>printer, because they throw too much information away.
>If you have some actions in the lex (e.g. doing things with newlines
>and comments) as well as in the yacc (e.g. spotting the ends of
>control structures that don't have an explicit terminating keyword),
>and as long as you are careful about lookahead, then surely you should
>be able to do just about anything you want?
>[Not really, for the reasons outlined in the previous message on this topic.
>C has a two-level grammar, and the techniques you use to parse it don't lend
>themselves to recreating the source code. -John]
I have used lex and yacc (better: flex and bison) to build a multi
purpose prettyprinter and in most cases it works fine. Actually, the
project that I did was to build a prettyprinter generator that would
build a prettyprinter from a formal specification of how a given
language should be prettyprinted. I haven't experimented with a lot
of languages (only Pascal and C), but the results come out nicely
(even with preprocessor commands).
You might want to look at this URL, which gives first information on
the ``pretzel'' project:
Accompanying the pretzel distribution is a 60 page report dealing with
the problems of prettyprinting of source code (using context free
grammars) in a quite detailed fashion.
Felix Gartner (firstname.lastname@example.org)
CS Dept., Technical University of Darmstadt, Germany
Return to the
Search the comp.compilers archives again.