Re: Possible flex-2.5.4 bug
Hi,
On a closer look, I don't like this change in behaviour
either. In fact, I get a worse behaviour:
----------------------------------------------------------------------
__> flex foo.l
__> gcc lex.yy.c
__> ./a.out "foo<bleh>bell"
barbell
yylex() done
*__> ./a.out "foo<bleh"
bar
error: EOF in comment
Segmentation fault
----------------------------------------------------------------------
I _hate_ seg faults ;-). However, adding an explicit return
makes things happier:
----------------------------------------------------------------------
__> cat foo.l
%array
%%
"<" { int c;
while ( (c = input()) != '>' && c != EOF )
; /* eat up text of comment */
if ( c == EOF ) {
printf( "\n" "error: EOF in comment\n" );
return;
}
}
foo printf("bar");
%%
void main(int argc, char **argv) {
YY_BUFFER_STATE ybsInputBuffer;
while(--argc) {
ybsInputBuffer = yy_scan_string(*++argv);
yylex();
printf( "\n" "yylex() done\n" );
yy_delete_buffer(ybsInputBuffer);
}
} /* main */
int yywrap(void) {
return 1;
} /* yywrap */
__> vi foo.l
__> flex foo.l; gcc lex.yy.c
__> ./a.out "foo<bleh"
bar
error: EOF in comment
yylex() done
__> ./a.out "foo<bleh>bellbell"
barbellbell
yylex() done
__> ./a.out "foo<bleh>bellbell" !$
./a.out "foo<bleh>bellbell" "foo<bleh"
barbellbell
yylex() done
bar
error: EOF in comment
yylex() done
__> ./a.out "foo<bleh>bellbell" "foo<bleh" "foo<bleh>bellbell"
barbellbell
yylex() done
bar
error: EOF in comment
yylex() done
barbellbell
yylex() done
----------------------------------------------------------------------
>>"Maarten" == Maarten Boekhold <maartenb@dutepp0.et.tudelft.nl> writes:
Maarten> But, since you have already read EOF in the scanner, and you
Maarten> have not returned from it, yylex will try to get a new
Maarten> character to continue parsing. But EOF has already appaered,
Maarten> so there's nothing in the buffer anymore. I think it's normal
Maarten> that you get an error on this. You either have to unput(EOF),
Maarten> or to 'return' from the scanner after the
Maarten> 'printf("error\n");"....
Bingo.
manoj
ps: I think this is a faster turn around than most support calls.
--
FIELD TESTED: manufacturer lacks test equipment.
Manoj Srivastava <url:mailto:srivasta@acm.org>
Mobile, Alabama USA <url:http://www.datasync.com/%7Esrivasta/>
--
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: