Finite State Machines in Forth: A 1994 Guide to Cleaner Code

Finite State Machines in Forth (1994)

This 1994 note by J.V. Noble presents methods for building deterministic and nondeterministic finite state automata in Forth, emphasizing a one-to-one mapping between code and state tables. It critiques nested IF clauses for being slow and hard to maintain, and offers three implementations: a brute-force CASE approach, a more factored method, and an elegant table-driven technique using defining words. The note includes a detailed example for parsing fixed-point numbers.

The 'best' method produces a one-to-one relation between the definition and the state table of the automaton.

More from this day

2026-08-13