checkpoint

This commit is contained in:
2025-10-10 04:59:32 +01:00
parent 244d0ce26d
commit 5a43954aef

View File

@@ -112,8 +112,8 @@ struct
fun addFromList (lst, tree) = fun addFromList (lst, tree) =
case lst of case lst of
[] => tree [] => tree
| (k, v) :: tl => | k :: tl =>
let val tree = insertOrReplace (k, v, tree) let val tree = insertOrReplace (k, (), tree)
in addFromList (tl, tree) in addFromList (tl, tree)
end end
@@ -820,7 +820,7 @@ struct
let let
val currentFollows = Set.getOrDefault (hd, followSet, []) val currentFollows = Set.getOrDefault (hd, followSet, [])
val updatedFollows = Set.addFromList (currentFollows, addSet) val updatedFollows = Set.addFromList (currentFollows, addSet)
val updatedFollows = Set.keysToList updatedFollows val updatedFollows: int list = Set.keysToList updatedFollows
val followSet = Set.insertOrReplace (hd, updatedFollows, followSet) val followSet = Set.insertOrReplace (hd, updatedFollows, followSet)
in in
addKeysToFollowSet (tl, addSet, followSet) addKeysToFollowSet (tl, addSet, followSet)
@@ -852,14 +852,24 @@ struct
let let
val lp = lastpos (child, []) val lp = lastpos (child, [])
val fp = firstpos (child, []) val fp = firstpos (child, [])
val fp = Set.addToFollowSet (fp, Set.LEAF) val fp = Set.addFromList (fp, Set.LEAF)
in in
addToFollowSet (lp, fp, followSet) addKeysToFollowSet (lp, fp, followSet)
end end
| _ => raise Fail "dfa-gen.sml 816: unimplemented" | ONE_OR_MORE child =>
let
val lp = lastpos (child, [])
val fp = firstpos (child, [])
val fp = Set.addFromList (fp, Set.LEAF)
in
addKeysToFollowSet (lp, fp, followSet)
end
| ZERO_OR_ONE child => addToFollowSet (child, followSet)
| GROUP child => addToFollowSet (child, followSet)
fun convert (regex, numStates) = fun convert (regex, numStates) =
let let
val fs = addToFollowSet (regex, Set.LEAF)
val first = List.rev (firstpos (regex, [])) val first = List.rev (firstpos (regex, []))
val dstates = Vector.fromList [{transitions = first, marked = false}] val dstates = Vector.fromList [{transitions = first, marked = false}]
in in