Skip to content

[Feature] reset doesn't have to close the reader [sf#5] #140

Description

@lsf37

Reported by deadsea on 2002-02-05 21:16 UTC
I would like reset to be a little bit more sophisticated.

If the reader (yy_reader) supports mark and reset, I
would like the contents of the buffer to be pushed back
onto the stream rather than the stream being closed.

This would involve calling mark() an the stream before
reading from it:
if yy_reader.markSupported()
yy_reader.mark(yy_buffer.length-yy_endRead);
int numRead = yy_reader.read(yy_buffer, yy_endRead,
yy_buffer.length-yy_endRead);

Then instead of closing the reader in yyreset, you could
reset it to the mark and then re-read anything that has
been truly consumed:
if yy_reader.markSupported(){
yy_reader.reset();
for (int i=0; i<yy_currentPos; i++){
yy_reader.read();
}
} else {
yyclose();
}

It might be desirable to trigger this behavior with
some special flag in the .lex file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions