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

This commit is contained in:
2025-10-01 14:06:41 +01:00
parent dddb459d93
commit 61f839641f

View File

@@ -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