Re: Source for compiler using yacc/lex wanted

theedge@sun11.rbg.informatik.th-darmstadt.de (felix gaertner)
22 Mar 1996 00:35:57 -0500

          From comp.compilers

Related articles
Source for compiler using yacc/lex wanted platon!fauzan@uunet.uu.net (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 pjj@cs.man.ac.uk (1996-03-08)
Re: Source for compiler using yacc/lex wanted nandu@longs.att.com214) (1996-03-15)
Re: Source for compiler using yacc/lex wanted theedge@sun11.rbg.informatik.th-darmstadt.de (1996-03-22)
Re: pretty-printing with yacc and lex scooter@mccabe.com (Scott Stanchfield) (1996-03-22)
Re: pretty-printing with yacc and lex macrakis@osf.org (1996-03-27)
| List of all articles for this month |

From: theedge@sun11.rbg.informatik.th-darmstadt.de (felix gaertner)
Newsgroups: comp.compilers
Date: 22 Mar 1996 00:35:57 -0500
Organization: Compilers Central
References: 96-03-042 96-03-058
Keywords: yacc, lex

>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:


    http://www.student.informatik.th-darmstadt.de/~theedge/pretzel.html


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
--
________"_________________________________________________
  Felix Gartner (theedge@rbg.informatik.th-darmstadt.de)
  CS Dept., Technical University of Darmstadt, Germany
--


Post a followup to this message

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