From: Robert Dober Date: 2006-09-14T05:49:39+09:00 Subject: Re: Regular expression question. ------=_Part_52881_19331114.1158180540760 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 9/13/06, Paul Lutus wrote: > > L7 wrote: > > / ... > > > I dont think it applies to this directly. I didnt explicitly mention, > > but the processing is happening on a line-by-line basis. In order to > > remove all commenting in the above manner I would first have to read > > the file as a string, strip, split on newline then parse code. > > Yes, and that may be the best way to approach this problem. There are a > number of problems where reading the entire file and processing it as a > long string is the best (one is tempted to say the only) way to proceed. > > If you don't read the entire file, then you are obliged to carry more > state > information in your algorithm between lines. IMHO, it is much better to > eliminate multiline comments in one go than to construct and maintain > state > flags for this and any other contingencies that may carry over between > lines. > > Obviously this poses practical problems for huge source files, but, again > IMHO, huge source files should not exist anyway -- they should be broken > up > into manageable chunks. > > -- > Paul Lutus > http://www.arachnoid.com > > I am intrigued, I believe that the regular expression to find all comments in C must be very complex and probably not the correct tool, look at these snipplets // /* if(strcmp(x,"*/") // "*/ etc. etc. BTW I cannot find a reason why the job cannot be done by a regular expression but that does not mean it can :( Robert --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_52881_19331114.1158180540760--