Date: Fri, 29 Nov 1996 13:54:57 -0700 (MST) From: Terry Lambert <terry@lambert.org> To: terry@lambert.org (Terry Lambert) Cc: hackers@freebsd.org Subject: Re: Lex/Yacc question Message-ID: <199611292054.NAA03886@phaeton.artisoft.com> In-Reply-To: <199611291847.LAA02669@phaeton.artisoft.com> from "Terry Lambert" at Nov 29, 96 11:47:16 am
next in thread | previous in thread | raw e-mail | index | archive | help
In case anyone was interested in the answer:
rfc821.l:
{%
#include "y.tab.h"
#include <string.h>
%}
%x ST_HELO
%%
helo {
BEGIN ST_HELO;
return K_HELO;
}
<ST_HELO>[\r\n] {
BEGIN INITIAL;
return HELO_END;
}
<ST_HELO>[^\r\n]* {
yylval.sval = strdup(yytext);
return STR_DOMAIN;
}
rfc821.y:
%union {
char *sval;
int ival;
}
/* primary tokens*/
%token HELO
/* value tokens*/
%token <sval> 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199611292054.NAA03886>
