Skip to content

regexp: RuneReader functions are hard to use correctly. #5988

@DanielMorsing

Description

@DanielMorsing
The functions taking a RuneReader will read 2 runes past the end of the match. This
means that unless your RuneReader supports seeking, you will lose some of your input.
bufio is the most common RuneReader and it does not support seeking.

We can defer reading the lookahead rune until after we've checked for a match. That gets
gives us one of the Runes. However, we must read one past the final match because that
rune might also match. We could consider using RuneScanner and putting the rune back
after the final match.

Not sure if it's possible to have the property of just reading the match in all cases. I
think it might break when the last op is an alternation or a conditional. Still, I think
it's worth doing.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions