Source for compiler using yacc/lex wanted

platon!fauzan@uunet.uu.net (Fauzan Mirza)
5 Mar 1996 12:27:15 -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: platon!fauzan@uunet.uu.net (Fauzan Mirza)
Newsgroups: comp.compilers
Date: 5 Mar 1996 12:27:15 -0500
Organization: Royal Holloway, University of London
Keywords: yacc, lex, question, 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.
I have figured out how they work and what inputs they take, but I don't
know enough about the details to be able to write the beautifier.


So far I have got some sample code for a simple C language parser (using
cgram.y and scan.l) but I need to be able to, somehow, convert one stream
of tokens to another. For example:


Convert the token sequence:
if ( <Expr> ) <Statement>
To ...
if ( <Expr> ) <Indent> <Statement> <Outdent>
Where Indent and Outdent are special kind of tokens.


Questions:
1. Can anyone explain how this could be done using yacc or lex?
2. If lex = Tokeniser and yacc = Parser, what is the Code Generator?
3. Does anyone know where I can find a simple compiler built using yacc/lex?


Fauzan


======================================================
Fauzan Mirza Department of Computer Science
fauzan@dcs.rhbnc.ac.uk Royal Holloway, Univ of London
======================================================
[I actually think that lex and yacc are lousy tools to use for a pretty
printer, because they throw too much information away. It's not really
a compiling problem, it's more of a pattern matching problem. -John]
--


Post a followup to this message

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