From 5174a5b0a4b6f925897b2642520f67c29cbb23c8 Mon Sep 17 00:00:00 2001 From: Humza Shahid Date: Wed, 17 Sep 2025 02:35:32 +0100 Subject: [PATCH] adjustments to vi-l-dfa: we should accept a single-newline as a final state, but not a double-newline --- fcore/cursor-dfa/vi-l-dfa.sml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fcore/cursor-dfa/vi-l-dfa.sml b/fcore/cursor-dfa/vi-l-dfa.sml index 32b929d..1fe29f1 100644 --- a/fcore/cursor-dfa/vi-l-dfa.sml +++ b/fcore/cursor-dfa/vi-l-dfa.sml @@ -3,17 +3,20 @@ struct val startState: Word8.word = 0w0 val notNewlineState: Word8.word = 0w1 val oneNewlineState: Word8.word = 0w2 + val twoNewlineState: Word8.word = 0w3 fun makeStart i = if Char.chr i = #"\n" then oneNewlineState else notNewlineState - fun makeOneNewline _ = notNewlineState + fun makeOneNewline i = + if Char.chr i = #"\n" then twoNewlineState else notNewlineState val startTable = Vector.tabulate (255, makeStart) val notNewlineTable = startTable val oneNewlineTable = Vector.tabulate (255, makeOneNewline) + val twoNewLineTable = startTable - val tables = #[startTable, notNewlineTable, oneNewlineTable] + val tables = #[startTable, notNewlineTable, oneNewlineTable, twoNewLineTable] structure ViL = MakeNextDfaLoop @@ -27,7 +30,9 @@ struct val tables = tables fun finish x = x - fun isFinal currentState = currentState = notNewlineState + fun isFinal currentState = + currentState = notNewlineState + orelse currentState = oneNewlineState end) val fStart = Folder.foldNext