Re: Pretty printer for yacc

Tanguy Gilmont <gilmont@sci3>
9 Feb 1996 14:15:10 -0500

          From comp.compilers

Related articles
Pretty printer for yacc charlie@halcyon.com (1996-01-29)
Re: Pretty printer for yacc the_tick@access.digex.com (Scott Stanchfield) (1996-02-04)
Re: Pretty printer for yacc gilmont@sci3 (Tanguy Gilmont) (1996-02-09)
| List of all articles for this month |

From: Tanguy Gilmont <gilmont@sci3>
Newsgroups: comp.compilers
Date: 9 Feb 1996 14:15:10 -0500
Organization: Universite Catholique de Louvain, Louvain-la-Neuve, Belgium
References: 96-01-120
Keywords: yacc, tools

charlie@halcyon.com (Charles Castellow) wrote:
>Does anyone have/know of a pretty printer for yacc? ...
>
>Clearly this is sort of a superset of C/C++, so if worse comes to
>worse, I'll start with a pretty printer for C/C++, but I was just
>wondering if there's anything out there that would format the yacc
>productions and the C/C++ actions at the same time.


It's difficult indeed to read both C and Yacc source in a same file !
That's why I modified somewhat a a2ps-like program to get a
pretty-print on a PS printer. Unfortunately, I'm not an Postscript
expert, and found that greyscaling wasn't worth of it on paper, so I
opted for the following styles:


bold for the grammar node defined
italic for C code and comments
normal for other text


However, it must be quite simple to improve, and if someone does, I
would be glad to hear about it.


I also modified the emacs hilit19.el code and created a yacc-mode to
support color enhancement of yacc code, and I think this one is really
helpfull. You can find those files at


ftp://ftp.dice.ucl.ac.be/pub/Incoming/yacc2ps.tar.gz


The programs expect the yacc file to be of the form:




expression
: expression '+' expression
{ $$ = $1 + $2 }
| expression '/' expression
{
if ($2 == 0)
{
yyerror ("division by zero");
return 1;
}
$$ = $1 / $2;
}
;




Because hilit19 does the jobs by regular expression matching, the C
source will be recognized up to a 3-level bracket, but not any
further...


Regards
_________________________________________________________________________


Tanguy GILMONT
Universite Catholique de Louvain-la-Neuve
Maxwell-DICE
Place du Levant, 3
B-1348 Louvain-la-Neuve, Belgium
Bureau: a-104
e-mail: gilmont@dice.ucl.ac.be
Phone: 32-10-47.80.62
Fax: 32-10-47.86.67
--


Post a followup to this message

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