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:
@@ -3,17 +3,20 @@ struct
|
|||||||
val startState: Word8.word = 0w0
|
val startState: Word8.word = 0w0
|
||||||
val notNewlineState: Word8.word = 0w1
|
val notNewlineState: Word8.word = 0w1
|
||||||
val oneNewlineState: Word8.word = 0w2
|
val oneNewlineState: Word8.word = 0w2
|
||||||
|
val twoNewlineState: Word8.word = 0w3
|
||||||
|
|
||||||
fun makeStart i =
|
fun makeStart i =
|
||||||
if Char.chr i = #"\n" then oneNewlineState else notNewlineState
|
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 startTable = Vector.tabulate (255, makeStart)
|
||||||
val notNewlineTable = startTable
|
val notNewlineTable = startTable
|
||||||
val oneNewlineTable = Vector.tabulate (255, makeOneNewline)
|
val oneNewlineTable = Vector.tabulate (255, makeOneNewline)
|
||||||
|
val twoNewLineTable = startTable
|
||||||
|
|
||||||
val tables = #[startTable, notNewlineTable, oneNewlineTable]
|
val tables = #[startTable, notNewlineTable, oneNewlineTable, twoNewLineTable]
|
||||||
|
|
||||||
structure ViL =
|
structure ViL =
|
||||||
MakeNextDfaLoop
|
MakeNextDfaLoop
|
||||||
@@ -27,7 +30,9 @@ struct
|
|||||||
val tables = tables
|
val tables = tables
|
||||||
|
|
||||||
fun finish x = x
|
fun finish x = x
|
||||||
fun isFinal currentState = currentState = notNewlineState
|
fun isFinal currentState =
|
||||||
|
currentState = notNewlineState
|
||||||
|
orelse currentState = oneNewlineState
|
||||||
end)
|
end)
|
||||||
|
|
||||||
val fStart = Folder.foldNext
|
val fStart = Folder.foldNext
|
||||||
|
|||||||
Reference in New Issue
Block a user