The stateDiagram text form (spec/02 §11.3, spec/13 §7.3): a state diagram written as
mermaid writes one, read into a layered diagram's design (Macaw.Frame.TextForms).
stateDiagram
[*] --> Idle
Idle --> Running : start
state "Waiting for work" as Waiting
Running --> Waiting
state Running {
[*] --> Busy
Busy --> [*]
}
Waiting --> [*]- A state is an id (letters, digits,
_), aroundnode labeled by its id;state "label" as IdandId : labellabel it. - A transition is
A --> B, with: labelafter it.[*]is the start pseudo-state as a source and the end as a target:circlenodes with an empty label,[*]startand[*]end, prefixed with their composite state's id inside one (Running/[*]start). - A composite state
state Id {…}is a state and a group of the states first named inside it: a row of thegroupsslot (id,label,parent).
Rows: nodes (id, label, shape, group) with the start pseudo-states first, then
the states in order of first appearance, then the end pseudo-states; edges in order,
each an arrow head on a solid line. Faults, every one at once:
{:expected, :state}, {:expected, :transition}, {:unclosed, "state"},
{:unexpected, "}"}. print/1 writes the states, then the transitions.