diff --git a/fcore/cursor-dfa/vi-l-dfa.sml b/fcore/cursor-dfa/vi-l-dfa.sml new file mode 100644 index 0000000..32b929d --- /dev/null +++ b/fcore/cursor-dfa/vi-l-dfa.sml @@ -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