From owner-freebsd-hackers Thu Nov 28 02:08:04 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id CAA18183 for hackers-outgoing; Thu, 28 Nov 1996 02:08:04 -0800 (PST) Received: from isbalham (isbalham.ist.co.uk [192.31.26.1]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id CAA18149 for ; Thu, 28 Nov 1996 02:08:00 -0800 (PST) Received: from gid.co.uk (uucp@localhost) by isbalham (8.6.12/8.6.12) with UUCP id KAA23089; Thu, 28 Nov 1996 10:03:52 GMT Date: Thu, 28 Nov 1996 09:57:45 GMT Received: from [194.32.164.2] by seagoon.gid.co.uk; Thu, 28 Nov 1996 09:57:45 GMT X-Sender: rb@194.32.164.1 Message-Id: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: Terry Lambert From: rb@gid.co.uk (Bob Bishop) Subject: Re: Lex/Yacc question Cc: Andrew Stesin , Chuck Robey , hackers@FreeBSD.org Sender: owner-hackers@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk At 10:14 am 28/11/96, Andrew Stesin wrote: >> > echo This is an undelimited yytext[] to my eol to pass to echo() > >lex: > >[^\n]+\n return UNDELIMITED_YYTEXT; > >yacc: > >UNDELIMITED_YYTEXT > { > echo($1); > } > >or something like the above (I used lex+yacc years ago). I think that's right (except that yytext (ie $1) will include the trailing newline which you may want to strip). The main pitfall to watch out for is that `.' in a lex RE will never match newline. IMHO, the original papers are still the best general texts on lex and yacc; they can be found in the 4.4-Lite distribution under /usr/share/doc/psd. Come to think of it, why doesn't /usr/share/doc figure in FreeBSD distributions? -- Bob Bishop (0118) 977 4017 international code +44 118 rb@gid.co.uk fax (0118) 989 4254 between 0800 and 1800 UK