From owner-freebsd-hackers Fri Nov 29 13:11:48 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id NAA07215 for hackers-outgoing; Fri, 29 Nov 1996 13:11:48 -0800 (PST) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.211]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id NAA07206 for ; Fri, 29 Nov 1996 13:11:44 -0800 (PST) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id NAA03886; Fri, 29 Nov 1996 13:54:58 -0700 From: Terry Lambert Message-Id: <199611292054.NAA03886@phaeton.artisoft.com> Subject: Re: Lex/Yacc question To: terry@lambert.org (Terry Lambert) Date: Fri, 29 Nov 1996 13:54:57 -0700 (MST) Cc: hackers@freebsd.org In-Reply-To: <199611291847.LAA02669@phaeton.artisoft.com> from "Terry Lambert" at Nov 29, 96 11:47:16 am X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk In case anyone was interested in the answer: rfc821.l: {% #include "y.tab.h" #include %} %x ST_HELO %% helo { BEGIN ST_HELO; return K_HELO; } [\r\n] { BEGIN INITIAL; return HELO_END; } [^\r\n]* { yylval.sval = strdup(yytext); return STR_DOMAIN; } rfc821.y: %union { char *sval; int ival; } /* primary tokens*/ %token HELO /* value tokens*/ %token STR_DOMAIN /* state encapsulation tokens*/ %token HELO_END %start commands %% commands: command | commands command ; command: /* nothing*/ | helo_expr ; helo_expr: HELO HELO_END { if( strict) { printf( "helo requires domain\n"); } else { smtp_hello( ""); } } | HELO STR_DOMAIN HELO_END { smtp_hello( $2); } The use of a "HELO_END" token lets us recognize the end of the statement for a partial statement (HELO STR_DOMAIN HELO_END is otherwise ambiguous). Thanks for all the responses... Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.