add function to quad tree to turn items into strings (for later saving to file)

This commit is contained in:
2025-07-12 03:38:20 +01:00
parent 21512cc979
commit 04bb7a18c0
15 changed files with 50 additions and 15 deletions

32
fcore/parser/int-dfa.sml Normal file
View File

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