diff --git a/fcore/cursor-dfa/vi-word-dfa.sml b/fcore/cursor-dfa/vi-word-dfa.sml index cb226f5..b51fb16 100644 --- a/fcore/cursor-dfa/vi-word-dfa.sml +++ b/fcore/cursor-dfa/vi-word-dfa.sml @@ -109,32 +109,35 @@ struct end) structure EndOfPrevWord = - MakePrevDfaLoop ( - struct - val startState = startState + MakePrevDfaLoop + (struct + val startState = startState - fun fStart (idx, absIdx, str, tl, currentState, counter) = - if idx < 0 then - case tl of - str :: tl => fStart (String.size str - 1, absIdx, str, tl, currentState, counter) - | [] => 0 - else - let - val chr = String.sub (str, idx) - val newState = next (currentState, chr) - in - if newState = alphaToPunct orelse newState = punctToAlpha - orelse newState = spaceToAlpha orelse newState = spaceToPunct - then - if counter - 1 = 0 then - absIdx - else - fStart (idx - 1, absIdx - 1, str, tl, startState, counter - 1) - else - fStart (idx - 1, absIdx - 1, str, tl, newState, counter) - end - end - ) + fun fStart (idx, absIdx, str, tl, currentState, counter) = + if idx < 0 then + case tl of + str :: tl => + fStart + (String.size str - 1, absIdx, str, tl, currentState, counter) + | [] => 0 + else + let + val chr = String.sub (str, idx) + val newState = next (currentState, chr) + in + if + newState = alphaToPunct orelse newState = punctToAlpha + orelse newState = spaceToAlpha orelse newState = spaceToPunct + then + if counter - 1 = 0 then + absIdx + else + fStart + (idx - 1, absIdx - 1, str, tl, startState, counter - 1) + else + fStart (idx - 1, absIdx - 1, str, tl, newState, counter) + end + end) (* w *) val startOfNextWord = StartOfNextWord.next