All work
03 / SYSTEMS · COMPILERS

Abstract states.
Real transitions.

A tiny finite-state machine that makes every character and every transition visible.

Learning experimentFinite automata / Step-by-step execution
A SMALL EXPERIMENT

A machine for a⁺b.

One or more a characters, followed by exactly one b. Try aab, ab, or something else.

q₀Start
a
q₁a loop
b
q₂Accept

Current state: q₀. Choose “Next step” to read the first character.

Undefined transitions lead to a dead state. Input is accepted only after every character is read and the machine ends in q₂.

A state marks a stage

q₀ means that no a has been read. q₁ means at least one a has been read: another a keeps the machine there, while b moves it to q₂. q₂ is the accepting state. Any further character is rejected.

Acceptance depends on the complete input. Passing through an accepting state midway through a longer string does not make the whole string valid.

What this experiment covers

This is a hand-defined deterministic finite automaton. Regular-expression parsing, NFA conversion, and a complete lexer are possible next steps.