Path: utzoo!mnetor!uunet!husc6!bloom-beacon!gatech!purdue!decwrl!ucbvax!ucsd!nosc!humu!uhccux!lee
From: lee@uhccux.UUCP (Greg Lee)
Newsgroups: comp.sources.bugs
Subject: flex reject bug
Message-ID: <1825@uhccux.UUCP>
Date: 6 May 88 18:14:26 GMT
Organization: U. of Hawaii, Manoa (Honolulu)
Lines: 61
Keywords: flex



When a flex-created program is asked to reject a string
matched by a pattern ending in $, it appears that one too
few characters is pushed back, in some circumstances.
The following demonstrates the problem -- the program "test"
loops endlessly pushing back and accepting the last character
of a line.
	Greg, lee@uhccux.uhcc.hawaii.edu

---------contents of file test.l-------
%%

.*$	{	printf("%s REJECT\n", yytext);
		REJECT;
	}

.*$	{	printf("%s ACCEPT\n", yytext);
	}

. |
\n	;

%%

main()
{	yylex();
}
----------------eof--------------------

---------contents of file xtext--------
Text ending with X
----------------eof--------------------
(There is a newline after the "X".)

Test program made with flex -r gives following results.

Output of "test