-
Notifications
You must be signed in to change notification settings - Fork 32
Check Transition Graph
This algorithm constructs and checks the transition graph for a state machine definition.
-
A state machine definition smd.
-
A state machine analysis data structure sma representing the results of analysis so far.
-
sma with the transition graph updated if the check passes; otherwise an error.
-
Construct the transition graph.
-
Check the transition graph for reachability.
-
Check for choice cycles in the transition graph.
-
Construct the reverse transition graph.
-
Let n be the target of the initial transition specifier of the state machine.
-
Let G be the transition graph whose initial node is n and whose node map is empty.
-
For each transition graph node n in the state machine, set G.arcMap(n) to the empty map.
-
For each transition expression e in smd, except for the transition expression in the initial transition of the state machine, do the following:
-
Let n be the start node corresponding to e. This is the state where e appears, if e appears in an initial transition or state transition, or the choice where e appears.
-
Let n' be the end node corresponding to e. This is the state or choice referred to by e.
-
Construct the arc a corresponding to the transition from n to n'.
-
Add a to the set G.arcMap(n).
-
-
Set the transition graph of sma to G.
Algorithm:
-
Let R be an empty set of transition graph nodes.
-
Visit the initial node of the transition graph and update R.
-
Check that R contains all the nodes of the transition graph.
Visiting nodes: To visit a node n of the transition graph T, do the following:
-
If R contains n, then do nothing.
-
Otherwise
-
Add n to R.
-
Visit all the nodes n' such that there is an arc from n to n' in T.
-
Algorithm:
-
Let visited be an empty set of choice definitions.
-
For each choice definition c that is a node in the transition graph
-
Let L be an empty list of transition graph arcs.
-
Let S be an empty set of choice definitions.
-
Visit c with L and S.
-
Visiting choice definitions: To visit a choice definition c with list L and set S, do the following:
-
Check whether c appears in S. If so, then L represents a choice cycle. Throw a semantic error. Use L to construct the error message.
-
Otherwise if c is not in visited, then
-
Add c to S.
-
For each arc a from c to a choice definition c'
-
Add a to L.
-
Visit c'.
-
-
Add c to visited.
-
-
Otherwise we have already visited c; do nothing.
-
Let m be the reverse transition graph of sma. To begin it has the initial node n, and it maps n to the empty set of arcs.
-
Visit each node n in the transition graph. For each arc a from n to n', add a to the set m.arcMap(n').