adjustments to vi-l-dfa: we should accept a single-newline as a final state, but not a double-newline

This commit is contained in:
2025-09-17 02:35:32 +01:00
parent 161caee62a
commit 5174a5b0a4

View File

@@ -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