create DFA for Vi's 'l' motion
This commit is contained in:
37
fcore/cursor-dfa/vi-l-dfa.sml
Normal file
37
fcore/cursor-dfa/vi-l-dfa.sml
Normal file
@@ -0,0 +1,37 @@
|
||||
structure ViLDfa =
|
||||
struct
|
||||
val startState: Word8.word = 0w0
|
||||
val notNewlineState: Word8.word = 0w1
|
||||
val oneNewlineState: Word8.word = 0w2
|
||||
|
||||
fun makeStart i =
|
||||
if Char.chr i = #"\n" then oneNewlineState else notNewlineState
|
||||
|
||||
fun makeOneNewline _ = notNewlineState
|
||||
|
||||
val startTable = Vector.tabulate (255, makeStart)
|
||||
val notNewlineTable = startTable
|
||||
val oneNewlineTable = Vector.tabulate (255, makeOneNewline)
|
||||
|
||||
val tables = #[startTable, notNewlineTable, oneNewlineTable]
|
||||
|
||||
structure ViL =
|
||||
MakeNextDfaLoop
|
||||
(struct
|
||||
val startState = startState
|
||||
|
||||
structure Folder =
|
||||
MakeCharFolderNext
|
||||
(struct
|
||||
val startState = startState
|
||||
val tables = tables
|
||||
|
||||
fun finish x = x
|
||||
fun isFinal currentState = currentState = notNewlineState
|
||||
end)
|
||||
|
||||
val fStart = Folder.foldNext
|
||||
end)
|
||||
|
||||
val next = ViL.next
|
||||
end
|
||||
Reference in New Issue
Block a user