franz@uw-june (Franz G. Amador) (04/25/89)
I want to do some source-to-source transformations on c programs. Does anyone have or know of source for a parser/pretty-printer for c that reads in the c and just spits it back out? I'd much prefer that it be based upon a nice yacc grammar than it be hand-coded, which is why I'd rather not use the source for Unix's indent command. Franz Amador franz@cs.washington.edu {rutgers,cornell,ucsd,ubc-cs,tektronix}!uw-beaver!june!franz
ddv@Solbourne.COM (Dan DeVries) (04/27/89)
In article <7974@june.cs.washington.edu> franz@cs.washington.edu (Franz G. Amador) writes: >Does anyone have or know of source for a parser/pretty-printer for c >that reads in the c and just spits it back out? I'd much prefer that >it be based upon a nice yacc grammar than it be hand-coded, which is >why I'd rather not use the source for Unix's indent command. > To write a pretty printer that completely syntax checks C is horribly wasteful. Only certain constructs cause indentation and that is all thea a pretty printer should recognize. This is important because a pretty printer is an excellent debug tool when the C parser doesn't help. (i.e. where did I leave out that } ). The last pretty printer I wrote took 4 hours and only recognized { } for while if repeat and a few others. Forget Yacc. The source for yacc would be MUCH more complicated than a simple scanner required for prettyPrint. (I know, flame away. I just think that Yacc has it's place and its not for every job)