Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!eris.berkeley.edu!chapman From: chapman@eris.berkeley.edu (Brent Chapman) Newsgroups: comp.lang.c++ Subject: Re: C++ Comments Message-ID: <24700@agate.BERKELEY.EDU> Date: 22 May 89 17:54:03 GMT References: <6957@brunix.UUCP> Sender: usenet@agate.BERKELEY.EDU Reply-To: chapman@eris.berkeley.edu (Brent Chapman) Organization: UNIXversity of California at Berkeley Lines: 28 In article <6957@brunix.UUCP> sdm@cs.brown.edu (Scott Meyers) writes: >Consider the following C++ source line: > > //********************** > >How should this be treated by the C++ compiler? The GNU g++ compiler >treats this as a comment-to-EOL followed by a bunch of asterisks, but the >AT&T compiler treats it as a slash followed by an open-comment delimiter. >I want the former interpretation, and I can't find anything in Stroustrup's >book which indicates that any other interpretation is to be expected. I'm new to C++, but C has always used a "greedy" parsing algorithm (that is, it always takes the longest possible next token); I don't know why C++ would do otherwise. From K&R, p. 179: If the input stream has been parsed into tokens up to a given character, the next token is taken to include the longest string of characters which could possibly constitute a token. g++ is doing the right thing, and the AT&T compiler is wrong. -Brent -- Brent Chapman Capital Market Technology, Inc. Computer Operations Manager 1995 University Ave., Suite 390 {lll-tis,ucbvax!cogsci}!capmkt!brent Berkeley, CA 94704 capmkt!brent@{lll-tis.arpa,cogsci.berkeley.edu} Phone: 415/540-6400