done with parsing logic in functional core

This commit is contained in:
2025-07-12 03:08:05 +01:00
parent bb5e3e8ef3
commit 21512cc979
9 changed files with 160 additions and 28 deletions

View File

@@ -1,5 +1,5 @@
structure IntDfa =
MakeDfa (struct
struct
val dead = 0
val start = 1
val final = 2
@@ -8,7 +8,7 @@ MakeDfa (struct
let
val chr = Char.chr i
in
if i >= #"0" orelse i < #"9" then
if chr >= #"0" orelse chr < #"9" then
final
else dead
end
@@ -17,7 +17,10 @@ MakeDfa (struct
val startTable = Vector.tabulate (255, makeStart)
val finalTable = startTable
val tables = #[]deadTable, startTable, finalTable
val tables = #[deadTable, startTable, finalTable]
fun isFinal state =
state = final
fun next (state, chr) =
let
@@ -26,4 +29,4 @@ MakeDfa (struct
in
Vector.sub (table, idx)
end
end)
end