fix bug in 'Nfa.getMatches' loop function: when we find that this state is valid, continue loop from 'finishIdx + 1'.

This commit is contained in:
2025-09-29 21:07:02 +01:00
parent 665497cf46
commit df78e20cb7

View File

@@ -149,13 +149,18 @@ struct
in
case state of
VALID finishIdx =>
let val acc = PersistentVector.append (pos, finishIdx, acc)
in loop (finishIdx, str, origNfa, origNfa, finishIdx, acc)
let
val acc = PersistentVector.append (startPos, finishIdx, acc)
in
loop
(finishIdx + 1, str, origNfa, origNfa, finishIdx + 1, acc)
end
| INVALID =>
(* backtrack to another position in the string
* to see if the NFA matches that portion of the string *)
loop (startPos + 1, str, origNfa, origNfa, startPos + 1, acc)
let val pos = startPos + 1
in loop (pos, str, origNfa, origNfa, pos, acc)
end
| UNTESTED => loop (pos + 1, str, nfa, origNfa, startPos, acc)
end
in