Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/5/84; site steinmetz.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!harvard!talcott!panda!genrad!decvax!mcnc!ncsu!uvacs!edison!steinmetz!hammond From: hammond@steinmetz.UUCP (Steve Hammond) Newsgroups: net.unix Subject: Re: Re: comments in lex Message-ID: <190@steinmetz.UUCP> Date: Mon, 22-Jul-85 18:24:47 EDT Article-I.D.: steinmet.190 Posted: Mon Jul 22 18:24:47 1985 Date-Received: Fri, 26-Jul-85 02:34:02 EDT References: <114@emacs.uucp> <193@jendeh.UUCP> <1614@orca.UUCP> Organization: GE CRD, Schenectady, NY Lines: 21 > >> How do you recognise a PL/1 style comment? > > > > "/*"([^*]|"*"[^/])*"*/" > > Two problems: > > 1) This pattern will incorrectly recognize "/***/ */" as a comment. > > 2) This approach to comment skipping is a bad idea in lex, because the > generated lexer will try to accumulate the entire comment in the > "yytext" buffer, which has a fixed size. (On our system, the size > is 1024 bytes.) If ever a comment with more bytes than the buffer > size is found, the lex driver will merrily overwrite the memory > following the buffer and blow away your compile. > I get around #1 it by switching modes when I encounter a /* and switching back when I encounter a */. To date I have not overflowed the yytext buffer (I hope). -- Steve Hammond arpa: hammond@GE uucp: {...edison!}steinmetz!hammond