From 61f839641ff96bda21d136be29ac1c13e524a5e9 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Wed, 1 Oct 2025 14:06:41 +0100 Subject: [PATCH] fix implementation of 'lastpos', which should return the lastpos of the right child in a CONCAT node, if the right child is not nullable, or else should return the union of lastpos for the left and right child both --- fcore/search-list/nfa.sml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fcore/search-list/nfa.sml b/fcore/search-list/nfa.sml index d8f3b57..90a9135 100644 --- a/fcore/search-list/nfa.sml +++ b/fcore/search-list/nfa.sml @@ -187,7 +187,7 @@ struct in lastpos (r2, acc) end else - lastpos (r1, acc) + lastpos (r2, acc) | ALTERNATION (r1, r2) => let val acc = lastpos (r1, acc) in lastpos (r2, acc) @@ -203,4 +203,7 @@ struct case ParseNfa.parse (str, 0) of SOME (ast, _) => SOME ast | NONE => NONE + + fun firstpos regex = ToDfa.firstpos (regex, []) + fun lastpos regex = ToDfa.lastpos (regex, []) end