Regexp: succeed on empty match at end of input

This commit is contained in:
2025-04-02 14:06:12 -06:00
parent 1892a97070
commit 4e157f7a0e
2 changed files with 9 additions and 1 deletions

View File

@ -80,7 +80,7 @@ func Regexp(pattern string) gigaparsec.Parser[byte, string] {
// when searching a RuneReader.
dst := make([]byte, idx[1]-idx[0])
n, _, err := input.Read(dst)
if err != nil {
if err != nil && (!errors.Is(err, io.EOF) || n < uint64(len(dst))) {
return gigaparsec.Result[byte, string]{}, fmt.Errorf("Regexp: unexpected error: %w", err)
}
next := input.At(input.Pos() + n)