Date: Thu, 28 Nov 1996 09:57:45 GMT From: rb@gid.co.uk (Bob Bishop) To: Terry Lambert <terry@lambert.org> Cc: Andrew Stesin <stesin@gu.net>, Chuck Robey <chuckr@glue.umd.edu>, hackers@FreeBSD.org Subject: Re: Lex/Yacc question Message-ID: <v01540b0caec30fb3ed73@[194.32.164.2]>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?v01540b0caec30fb3ed73>
