Files
sml-projects/dotscape/fcore/parser/int-dfa.sml
Humza Shahid f3a4e15ed5 Add 'dotscape/' from commit 'f306501a68a51b634e895c5fdac70788ae899d75'
git-subtree-dir: dotscape
git-subtree-mainline: 6b91d64fc3
git-subtree-split: f306501a68
2026-04-24 00:30:08 +01:00

28 lines
564 B
Standard ML

structure IntDfa =
struct
val dead = 0
val start = 1
val final = 2
fun makeStart i =
let val chr = Char.chr i
in if Char.isDigit chr then final else dead
end
val deadTable = Vector.tabulate (255, fn _ => dead)
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