Path: utzoo!censor!geac!torsqnt!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari!aplcen!jhunix!barrett From: barrett@jhunix.HCF.JHU.EDU (Dan Barrett) Newsgroups: comp.lang.c Subject: Re: Re^4: Why nested comments not allowed? Message-ID: <4318@jhunix.HCF.JHU.EDU> Date: 22 Feb 90 23:09:29 GMT References: <1525@wacsvax.OZ> <13771@cbnewsc.ATT.COM> Reply-To: barrett@jhunix.UUCP (Dan Barrett) Organization: The Johns Hopkins University - HCF Lines: 30 In article <13771@cbnewsc.ATT.COM> dalenber@cbnewsc.ATT.COM (Russel Dalenberg) writes: >>> printf("A comment is ended with */"); > >I said: how do you handle the case where the above line of legal C is >commented out. If it's not commented out, there is no problem. > >The "usual" way to comment out such code would be: > >/* printf("A comment is ended with */"); */ > >Since quotes have *NO* significance within comments, the above comment >ends with the first "*/" found; with *both* nested and non-nested comments! It seems there are 2 issues here. The first is "How to parse?" The second is "How to prevent us from tripping ourselves up? The statement: /* printf("A comment is ended with */"); */ is easy to parse -- the comment truly closes at the */ in the string. However, that */ is causing a problem probably unwanted by the programmer. Dan //////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ | Dan Barrett, Department of Computer Science Johns Hopkins University | | INTERNET: barrett@cs.jhu.edu | | | COMPUSERVE: >internet:barrett@cs.jhu.edu | UUCP: barrett@jhunix.UUCP | \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/////////////////////////////////////