Macaw.Frame.TextForms.State (macaw_frame v0.1.0)

Copy Markdown View Source

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, _), a round node labeled by its id; state "label" as Id and Id : label label it.
  • A transition is A --> B, with : label after it. [*] is the start pseudo-state as a source and the end as a target: circle nodes with an empty label, [*]start and [*]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 the groups slot (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.