Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!milano!mister-curious!loo From: loo@mister-curious.sw.mcc.com (Joel Loo) Newsgroups: comp.lang.c Subject: Re: Want a way to strip comments from a Message-ID: <2131@mister-curious.sw.mcc.com> Date: 17 Mar 89 16:45:17 GMT References: <7150@siemens.UUCP> <9900010@bradley> <4896@cbnews.ATT.COM> <978@philmds.UUCP> Organization: MCC, Austin, TX Lines: 31 In article <978@philmds.UUCP>, leo@philmds.UUCP (Leo de Wit) writes: > In article <4896@cbnews.ATT.COM> smk@cbnews.ATT.COM (Stephen M. Kennedy) writes: > |In article <9900010@bradley> brian@bradley.UUCP writes: > |> The following works in vi: :%s/\/\*.*\*\///g > | > |/* And this */ important_variable = 42 /* doesn't work either! */ > > And how about: > > puts(" A comment /* in here */"); > > And you can give more examples showing it isn't that trivial; a challenge > for the sed adept, perhaps ... > > Leo. [And a lot of previous articles on the same topic] The problem is: sed and vi do not understand C syntax. Solution: write a lex program to strip comments. The program must understand C syntax enough to know what is a comment and what is not. Encouragement: it should not be too difficult. -------------------------------------------------------------------- Joel Loo Peing Ling composed on Fri Mar 17 10:44:52 CST 1989 ---------------------------- Now: ---------------------------------- MCC | Email: loo@sw.mcc.com 3500 West Balcones Centre Dr. | Voice: (512)338-3680 (O) Austin, TX 78759 | (512)343-1780 (H)