Here is an example that would do this:
First lex file:
%{
#include "grammar.tab.h"
%}
%x REALLYEND
%option noinput nounput
%%
"END" { return END; }
. { return TOK; }
<INITIAL><<EOF>> { BEGIN(REALLYEND); return EOP; }
<REALLYEND><<EOF>> { return 0; }
%%
int yywrap(void)
{
return 1;
}
<INITIAL> EOP. <INITIAL>, <<EOF>> . <REALLYEND>, "" .
:
%token END EOP TOK
%{
#include <stdio.h>
void yyerror(char * msg)
{
fprintf(stderr, "%s\n", msg);
}
extern int yylex(void);
%}
%%
prog : END EOP { printf ("ok\n"); };
%%
int main(void)
{
return yyparse();
}
, bison , EOF, , . , , success, , EOF , . , .