Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!cwruecmp!hal!ncoast!allbery From: allbery@ncoast.UUCP Newsgroups: comp.unix.questions Subject: Re: Any LEX gurus? Message-ID: <4162@ncoast.UUCP> Date: Thu, 13-Aug-87 13:43:42 EDT Article-I.D.: ncoast.4162 Posted: Thu Aug 13 13:43:42 1987 Date-Received: Sat, 15-Aug-87 16:04:58 EDT References: <716@umnd-cs.D.UMN.EDU> Reply-To: allbery@ncoast.UUCP (Brandon Allbery) Followup-To: comp.unix.questions Organization: Cleveland Public Access UN*X, Cleveland, Oh Lines: 36 As quoted from <716@umnd-cs.D.UMN.EDU> by jwabik@cs.D.UMN.EDU (Jeff Wabik): +--------------- | ^{WS}*"??"(.|{WS})*"??" | | { Where {WS} is defined as whitespace (i.e. \n, \t, ' ') } | | Which, of course, doesn't work since the (.|{WS})* eats everything to the | end of the file and LEX segment faults.. I've also tried things like: | | ^{WS}*"??"[^"??"]"??" +--------------- Don't try to do it -- I have done it, but lex-generated parsers which try to do this will overflow buffers and dump core. The best way to do it is something like: ^[ \t]*"??" { int ch, lastch; lastch = '\0'; while ((ch = input()) != '?' || lastch == '?') { if (ch == 0) { yyerror("unexpected end of file"); return 0; } lastch = ch; } } -- Brandon S. Allbery, moderator of comp.sources.misc and comp.binaries.ibm.pc {{harvard,mit-eddie}!necntc,well!hoptoad,sun!mandrill!hal}!ncoast!allbery ARPA: necntc!ncoast!allbery@harvard.harvard.edu Fido: 157/502 MCI: BALLBERY <> ** Site "cwruecmp" is changing its name to "mandrill". Please re-address ** *** all mail to ncoast to pass through "mandrill" instead of "cwruecmp". ***