Check both beginning-of-text conditions in Regexp

This commit is contained in:
Brandon Dyck 2024-09-10 18:39:54 -06:00
parent 6919e604ad
commit 3e178e74fd

View File

@ -41,7 +41,7 @@ func (rr *RuneReader) Cursor() cursor.Cursor[byte] {
} }
func Regexp(str string) gigaparsec.Parser[byte, []byte] { func Regexp(str string) gigaparsec.Parser[byte, []byte] {
if !strings.HasPrefix(str, "^") { if !strings.HasPrefix(str, "^") && !strings.HasPrefix(str, `\A`) {
str = "^" + str str = "^" + str
} }
re := regexp.MustCompile(str) re := regexp.MustCompile(str)