Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!mailrus!ncar!boulder!stan!ddv From: ddv@Solbourne.COM (Dan DeVries) Newsgroups: comp.lang.c Subject: Re: c parser wanted Message-ID: <884@stan.Solbourne.COM> Date: 27 Apr 89 01:47:25 GMT References: <7974@june.cs.washington.edu> Reply-To: ddv@Solbourne.com (Dan DeVries) Organization: Solbourne Computer Inc., Longmont, Colorado Lines: 19 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)