SC.Interpreter (sc v1.0.2)
View SourceCore interpreter for SCXML state charts.
Provides a synchronous, functional API for state chart execution. Documents are automatically validated before interpretation.
Summary
Functions
Check if a specific state is currently active (including ancestors).
Get all currently active states including ancestors.
Get all currently active leaf states (not including ancestors).
Initialize a state chart from a parsed document.
Send an event to the state chart and return the new state (macrostep execution).
Functions
@spec active?(SC.StateChart.t(), String.t()) :: boolean()
Check if a specific state is currently active (including ancestors).
@spec active_ancestors(SC.StateChart.t()) :: MapSet.t(String.t())
Get all currently active states including ancestors.
@spec active_states(SC.StateChart.t()) :: MapSet.t(String.t())
Get all currently active leaf states (not including ancestors).
@spec initialize(SC.Document.t()) :: {:ok, SC.StateChart.t()} | {:error, [String.t()], [String.t()]}
Initialize a state chart from a parsed document.
Automatically validates the document and sets up the initial configuration.
@spec send_event(SC.StateChart.t(), SC.Event.t()) :: {:ok, SC.StateChart.t()}
Send an event to the state chart and return the new state (macrostep execution).
Processes the event according to SCXML semantics:
- Find enabled transitions for the current configuration
- Execute the optimal transition set as a microstep
- Execute any resulting eventless transitions (additional microsteps)
- Return stable configuration (end of macrostep)
Returns the updated state chart. If no transitions match, returns the state chart unchanged (silent handling as discussed).