Re: Possible flex-2.5.4 bug
Hi,
Each argument is scanned separately, with yy_scan_string. An
end of file is generated, then, at the end of each string (each
argument). There is no yywrap function defined.
So, you call yylex thrice, on three separate, non-wrapped files. The
second file (string, argument, whatever) does end inside a comment,
and since there is no wrapping, the eof is final. The error is as
you asked it to be reported.
This does not seem to be a bug in flex.
manoj
./a.out "foo<bleh>bar" "foo<bleh" "foo<bleh>bell"
"foo<bleh"
file ends inside a comment.
Excerpts from the documentation
======================================================================
File: flex.info, Node: Multiple buffers, Next: End-of-file rules, Prev: Star\
t conditions, Up: Top
Multiple input buffers
======================
[...]
Three routines are available for setting up input buffers for
scanning in-memory strings instead of files. All of them create a new
input buffer for scanning the string, and return a corresponding
`YY_BUFFER_STATE' handle (which you should delete with
`yy_delete_buffer()' when done with it). They also switch to the new
buffer using `yy_switch_to_buffer()', so the next call to `yylex()' will
start scanning the string.
`yy_scan_string(const char *str)'
scans a NUL-terminated string.
`yy_scan_bytes(const char *bytes, int len)'
scans `len' bytes (including possibly NUL's) starting at location
BYTES.
Note that both of these functions create and scan a *copy* of the
string or bytes. (This may be desirable, since `yylex()' modifies the
contents of the buffer it is scanning.)
----------------------------------------------------------------------
File: flex.info, Node: Generated scanner, Next: Start conditions, Prev: Acti\
ons, Up: Top
[...]
When the scanner receives an end-of-file indication from YY_INPUT,
it then checks the `yywrap()' function. If `yywrap()' returns false
(zero), then it is assumed that the function has gone ahead and set up
`yyin' to point to another input file, and scanning continues. If it
returns true (non-zero), then the scanner terminates, returning 0 to
its caller. Note that in either case, the start condition remains
unchanged; it does *not* revert to `INITIAL'.
If you do not supply your own version of `yywrap()', then you must
either use `%option noyywrap' (in which case the scanner behaves as
though `yywrap()' returned 1), or you must link with `-lfl' to obtain
the default version of the routine, which always returns 1.
--
Ripping Yarns "Mind you, not as bad as the night Archie Pettigrew ate
some sheep's testicles for a bet...God, that bloody sheep kicked
him..."
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: