From df78e20cb744acb234309411457b8063d3166637 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Mon, 29 Sep 2025 21:07:02 +0100 Subject: [PATCH] fix bug in 'Nfa.getMatches' loop function: when we find that this state is valid, continue loop from 'finishIdx + 1'. --- fcore/search-list/nfa.sml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fcore/search-list/nfa.sml b/fcore/search-list/nfa.sml index ef04449..bfd2ea8 100644 --- a/fcore/search-list/nfa.sml +++ b/fcore/search-list/nfa.sml @@ -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