Don't parse hyphens in Chars() unless escaped
This commit is contained in:
parent
161cb77e53
commit
c43616cf3a
@ -181,6 +181,8 @@ func parseMatcher(matcher string) (alphabet string, ranges [][]rune) {
|
||||
}
|
||||
} else if i+1 < len(runes) && runes[i] == '\\' {
|
||||
alphabet += string(runes[i+1])
|
||||
} else if runes[i] == '-' {
|
||||
continue
|
||||
} else {
|
||||
alphabet += string(runes[i])
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ func TestChars(t *testing.T) {
|
||||
t.Run("unescaped hyphen", func(t *testing.T) {
|
||||
node, ps := runParser("19-", Chars("0-9"))
|
||||
require.Equal(t, "19", node.Token)
|
||||
require.Equal(t, 2, ps.Pos)
|
||||
require.Equal(t, "-", ps.Get()) // hyphen shouldn't have been parsed
|
||||
require.False(t, ps.Errored())
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user