tiny changes to dfa-gen.sml to make it more presentable when asking for advice
This commit is contained in:
@@ -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.
Reference in New Issue
Block a user