Fix multiline RegEx iteration

In `.Multiline` mode:

- `^` is now defined to assert the start of the string or that a "\n" or
  "\r" rune was parsed on last VM dispatch.

- `$` is now defined to consume a newline sequence of "\n", "\r", or
  "\r\n" or to assert the end of the string.
This commit is contained in:
Feoramund
2025-05-26 14:48:45 -04:00
parent 4f7ed35435
commit 35b157ac83
6 changed files with 113 additions and 53 deletions
+1 -4
View File
@@ -282,10 +282,6 @@ create_iterator :: proc(
temporary_allocator := context.temp_allocator,
) -> (result: Match_Iterator, err: Error) {
if .Multiline in flags {
return {}, .Unsupported_Flag
}
result.regex = create(pattern, flags, permanent_allocator, temporary_allocator) or_return
result.capture = preallocate_capture()
result.temp = temporary_allocator
@@ -555,6 +551,7 @@ reset :: proc(it: ^Match_Iterator) {
it.vm.top_thread = 0
it.vm.current_rune = rune(0)
it.vm.current_rune_size = 0
it.vm.last_rune = rune(0)
for i in 0..<it.threads {
it.vm.threads[i] = {}
it.vm.next_threads[i] = {}