Library

DFA · Regular

A CSV record with quoted fields

Fields separated by ; — a field is either plain characters (a) or a quoted string in which ; is allowed and a quote is written twice. After a closing quote only a separator or the end may follow, which is where hand-written parsers usually go wrong.

fieldplainquotedcloseda;"a;;, a"";
The machine as drawn — 4 states, 10 transitions.Every word up to length 5, one row per length in shortlex order, inked where it is accepted.

The author’s examples, run

a;a → accept"a;a";a → accept"a""a" → accept;; → accept"a"a → rejecta"a → reject"a → reject"";a → accept