tiny changes to dfa-gen.sml to make it more presentable when asking for advice

This commit is contained in:
2025-10-03 07:29:28 +01:00
parent 0696d7ed52
commit 7e2021be24
3 changed files with 9 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
structure Nfa = structure DfaGen =
struct struct
datatype regex = datatype regex =
CHAR_LITERAL of {char: char, position: int} CHAR_LITERAL of {char: char, position: int}
@@ -100,7 +100,7 @@ struct
fun toCharsAndPositionsList tree = helpToCharsAndPositionsList (tree, []) fun toCharsAndPositionsList tree = helpToCharsAndPositionsList (tree, [])
end end
structure ParseNfa = structure ParseDfa =
struct struct
(* parsing through precedence climbing algorithm. *) (* parsing through precedence climbing algorithm. *)
val postfixLevel = 1 val postfixLevel = 1
@@ -375,7 +375,7 @@ struct
end end
| _ => | _ =>
raise Fail raise Fail
"nfa.sml 310: should only have loops and concats \ "dfa-gen.sml 310: should only have loops and concats \
\in list to filter") \in list to filter")
| [] => acc | [] => acc
@@ -487,15 +487,10 @@ struct
end end
end end
fun parse str = fun fromString str =
case ParseNfa.parse (str, 0) of case ParseDfa.parse (str, 0) of
SOME (ast, _) => SOME ast SOME (ast, _) => ToDfa.convert ast
| NONE => NONE | NONE => Vector.fromList []
fun firstposWithChar regex = ToDfa.firstposWithChar (regex, [])
fun lastpos regex = ToDfa.lastpos (regex, [])
val test = ToDfa.convert
end end
val SOME nfa = Nfa.parse "(a|b)*abb\^@" val dfa = DfaGen.fromString "(a|b)*abb#"

Binary file not shown.

View File

@@ -14,7 +14,7 @@ ann
in in
fcore/persistent-vector.sml fcore/persistent-vector.sml
end end
fcore/search-list/nfa.sml fcore/search-list/dfa-gen.sml
fcore/search-list.sml fcore/search-list.sml
message-types/input-msg.sml message-types/input-msg.sml