Expand description
Semantic resolution: pre-computed effective transitions and event catalogs. Semantic resolution: pre-computed effective transitions and event catalogs.
resolve() transforms a Statechart into a ResolvedChart where all
implicit semantics are made explicit: inherited transitions from ancestor
states, resolved initial children for compound regions, per-state event
catalogs, and hierarchy metadata.
This is the canonical consumption layer for code generators, runtimes,
AI agents, and static analysis tools. The Statechart is the source-level
representation (parser output); the ResolvedChart is the resolved IR
(compiler frontend output).
use scxml::{parse_xml, resolve};
let chart = parse_xml(r#"
<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initial="idle">
<state id="parent" initial="idle">
<transition event="reset" target="idle"/>
<state id="idle">
<transition event="start" target="running"/>
</state>
<state id="running">
<transition event="stop" target="idle"/>
</state>
</state>
</scxml>
"#).unwrap();
let resolved = resolve(&chart);
// "running" inherits "reset" from its parent
let running = resolved.states.iter().find(|s| s.id == "running").unwrap();
assert_eq!(running.transitions.len(), 2); // own "stop" + inherited "reset"
assert_eq!(running.transitions[0].event.as_deref(), Some("stop"));
assert_eq!(running.transitions[1].event.as_deref(), Some("reset"));
assert_eq!(running.transitions[1].defined_in.as_str(), "parent");Structs§
- Resolved
Chart - A resolved view of a Statechart with pre-computed effective transitions.
- Resolved
State - A state with its effective transitions (own + inherited from ancestors).
- Resolved
Transition - A transition tagged with the state that originally defined it.
Functions§
- resolve
- Resolve a Statechart into a
ResolvedChart.