|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 (Fauzan Mirza)|
|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>
if ( <Expr> ) <Indent> <Statement> <Outdent>
Where Indent and Outdent are special kind of tokens.
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 Mirza Department of Computer Science
firstname.lastname@example.org 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]
Return to the
Search the comp.compilers archives again.