[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Possible flex-2.5.4 bug



Hi all!

Here is a simple lexer which works with flex-2.5.2 but not with
flex-2.5.4.  Is this a bug in flex-2.5.4 or is 2.5.4 stricter,
revealing a bug in my code?

This simple lexer replaces "foo" with "bar" (just to do something) and
strips out comments delimited by '<' and '>'.  (In real life I am
looking for C-style comments, but single character delimiters yield a
simpler example.)  It works with flex-2.5.2 but with flex-2.5.4 it
blows up following the input() call which returns EOF.

There was a similar bug in flex-2.5.3, but the NEWS file that comes
with 2.5.4 says:

************************************************************
Changes between release 2.5.4 (11Sep96) and release 2.5.3:

        - Fixed a bug introduced in 2.5.3 that blew it when a call
          to input() occurred at the end of an input file.
[snip to end]
************************************************************

I have Debian 1.2 installed, giving me flex-2.5.2.  I built flex-2.5.4
directly from the GNU package.  Could someone running bo or hamm
verify that this lexer breaks with the Debain flex-2.5.4 package, and
could someone who knows a little more than I do about flex tell me if
I am screwing something up.  If my code looks OK I will submit a bug
report.

(I discovered this problem on an RS/6000 where I have an immediate need
for a working flex.  I could not locate flex-2.5.2 on the net, but was
happy to find the source on the rex CD in my laptop.)

Kirk Hilliard

************************************************************
$ flex --version
flex version 2.5.2
$ ./flex-2.5.4 --version
./flex-2.5.4 version 2.5.4
$ cat foo.l
%array
%option noyywrap

%%
"<"  { int c;
       while ( (c = input()) != '>' && c != EOF )
         ;    /* eat up text of comment */
       if ( c == EOF ) printf( "\n" "error: EOF in comment\n" );
     }
foo  printf("bar");
%%

void main(int argc, char **argv) {
  YY_BUFFER_STATE ybsInputBuffer;
  while(--argc) {
    ybsInputBuffer = yy_scan_string(*++argv);
    yylex();
    yy_delete_buffer(ybsInputBuffer);
    putchar('\n');
  }
} /* main */
$ flex foo.l
$ gcc lex.yy.c
$ ./a.out "foo<bleh>bar" "foo<bleh" "foo<bleh>bell"
barbar
bar
error: EOF in comment

barbell
$ ./flex-2.5.4 foo.l
$ gcc lex.yy.c
$ ./a.out "foo<bleh>bar" "foo<bleh" "foo<bleh>bell"
barbar
bar
error: EOF in comment
input in flex scanner failed
$
************************************************************


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: