functorise character folders for vi WORD
This commit is contained in:
@@ -90,64 +90,54 @@ struct
|
|||||||
val fStart = Folder.foldNext
|
val fStart = Folder.foldNext
|
||||||
end)
|
end)
|
||||||
|
|
||||||
fun startOfCurrentWORD (idx, absIdx, str, tl, currentState, counter) =
|
structure StartOfCurrentWORDFolder =
|
||||||
if idx < 0 then
|
MakeCharFolderPrev
|
||||||
case tl of
|
(struct
|
||||||
str :: tl =>
|
val startState = startState
|
||||||
startOfCurrentWORD
|
val tables = tables
|
||||||
(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 = spaceAfterNonBlankState then
|
|
||||||
if counter - 1 = 0 then
|
|
||||||
absIdx + 1
|
|
||||||
else
|
|
||||||
startOfCurrentWORD
|
|
||||||
(idx - 1, absIdx - 1, str, tl, startState, counter - 1)
|
|
||||||
else
|
|
||||||
startOfCurrentWORD (idx - 1, absIdx - 1, str, tl, newState, counter)
|
|
||||||
end
|
|
||||||
|
|
||||||
fun endOfCurrentWORD (idx, absIdx, str, tl, currentState, counter) =
|
fun isFinal currentState = currentState = spaceAfterNonBlankState
|
||||||
if idx = String.size str then
|
fun finish idx = idx + 1
|
||||||
case tl of
|
end)
|
||||||
str :: tl =>
|
|
||||||
endOfCurrentWORD (0, absIdx, str, tl, currentState, counter)
|
|
||||||
| [] => Int.max (0, absIdx - 2)
|
|
||||||
else
|
|
||||||
let
|
|
||||||
val chr = String.sub (str, idx)
|
|
||||||
val newState = next (currentState, chr)
|
|
||||||
in
|
|
||||||
if newState = spaceAfterNonBlankState then
|
|
||||||
if counter - 1 = 0 then
|
|
||||||
Int.max (0, absIdx - 1)
|
|
||||||
else
|
|
||||||
endOfCurrentWORD
|
|
||||||
(idx + 1, absIdx + 1, str, tl, startState, counter - 1)
|
|
||||||
else
|
|
||||||
endOfCurrentWORD (idx + 1, absIdx + 1, str, tl, newState, counter)
|
|
||||||
end
|
|
||||||
|
|
||||||
structure StartOfCurrentWORD =
|
structure StartOfCurrentWORD =
|
||||||
MakePrevDfaLoopMinus1
|
MakePrevDfaLoopMinus1
|
||||||
(struct val startState = startState val fStart = startOfCurrentWORD end)
|
(struct
|
||||||
|
val startState = startState
|
||||||
structure EndOfCurrentWORD =
|
val fStart = StartOfCurrentWORDFolder.foldPrev
|
||||||
MakeNextDfaLoopPlus1
|
end)
|
||||||
(struct val startState = startState val fStart = endOfCurrentWORD end)
|
|
||||||
|
|
||||||
structure StartOfNextWORDStrict =
|
structure StartOfNextWORDStrict =
|
||||||
MakePrevDfaLoop
|
MakePrevDfaLoop
|
||||||
(struct val startState = startState val fStart = startOfCurrentWORD end)
|
(struct
|
||||||
|
val startState = startState
|
||||||
|
val fStart = StartOfCurrentWORDFolder.foldPrev
|
||||||
|
end)
|
||||||
|
|
||||||
|
structure EndOfCurrentWORDFolder =
|
||||||
|
MakeCharFolderNext
|
||||||
|
(struct
|
||||||
|
val startState = startState
|
||||||
|
val tables = tables
|
||||||
|
|
||||||
|
fun isFinal currentState = currentState = spaceAfterNonBlankState
|
||||||
|
fun finish idx =
|
||||||
|
Int.max (0, idx - 1)
|
||||||
|
end)
|
||||||
|
|
||||||
|
structure EndOfCurrentWORD =
|
||||||
|
MakeNextDfaLoopPlus1
|
||||||
|
(struct
|
||||||
|
val startState = startState
|
||||||
|
val fStart = EndOfCurrentWORDFolder.foldNext
|
||||||
|
end)
|
||||||
|
|
||||||
structure EndOfCurrentWORDStrict =
|
structure EndOfCurrentWORDStrict =
|
||||||
MakeNextDfaLoop
|
MakeNextDfaLoop
|
||||||
(struct val startState = startState val fStart = endOfCurrentWORD end)
|
(struct
|
||||||
|
val startState = startState
|
||||||
|
val fStart = EndOfCurrentWORDFolder.foldNext
|
||||||
|
end)
|
||||||
|
|
||||||
(* W *)
|
(* W *)
|
||||||
val startOfNextWORD = StartOfNextWORD.next
|
val startOfNextWORD = StartOfNextWORD.next
|
||||||
|
|||||||
Reference in New Issue
Block a user