Re: Source for compiler using yacc/lex wanted

Steve_Kilbane@cegelecproj.co.uk
8 Mar 1996 00:08:29 -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)
| List of all articles for this month |
From: Steve_Kilbane@cegelecproj.co.uk
Newsgroups: comp.compilers
Date: 8 Mar 1996 00:08:29 -0500
Organization: Cegelec Projects Ltd.
References: 96-03-042
Keywords: yacc, lex, comment

> I'm writing a code beautifier program (ie, something similar to
> indent(1)) and thought that the best approach to take would be to
> use yacc and lex.


Ugh, no. The main purpose of a beautifier is to make code easier to
read, by making it follow a common layout. So, what does your lex
scanner do with comments?


C preprocessor statements are a problem too:


#if SOMETHING
if (var1 == var2) {
#else
if (var1 != var2) {
#endif
dosomething();
}


Or even:
#define IF if(
#define THEN ){
#define ENDIF }


IF var1 == var2 THEN
dosomething();
ENDIF




People have written code like this, trust me. :-)


The problem is that your average lex/yacc set up handles a single
grammar, the C one, whereas a pretty printer has to handle that, with
comments and preprocessor grammar munged in.


steve
[Hey, is that last example from the pseudo-algol68 that Steve Bourne used
for the Bourne shell? -John]
--


Post a followup to this message

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