Stateflow | ![]() ![]() |
Parser
The parser evaluates the graphical and nongraphical objects in each Stateflow machine against the supported Stateflow notation and the action language syntax.
Parse the Machine or the Stateflow Diagram
Explicitly parse each Stateflow diagram in the machine by choosing Parse from the graphics editor Tools menu. Explicitly parse the current Stateflow diagram by choosing Parse Diagram from the graphics editor Tools menu. The machine is implicitly parsed when you simulate a model, build a target, or generate code.
In all cases, a pop-up information window is displayed when the parsing is complete. If the parsing is unsuccessful, one error at a time is displayed (in red) in the informational window. The Stateflow diagram automatically selects and pans to the object containing the parse error. Double-click on the error in the information window to bring the Stateflow diagram to the forefront, zoom (fit to view), and select the object containing the parse error. Press the space bar to zoom back out. Fix the error and reparse the Stateflow diagram. Informational messages are also displayed in the MATLAB command window.
These steps describe parsing, assuming this Stateflow diagram.
Choose Parse Diagram from the graphics editor Tools menu to parse the
Stateflow diagram. State A
in the upper left-hand corner is selected and this
message is displayed in the pop-up window and the MATLAB command
window.
In this example, there are two states with the name A
.
Edit the Stateflow
diagram and label the duplicate state with the text B
.
The Stateflow diagram should look similar to this.
Choose Parse Diagram from the graphics editor Tools menu. This message
is displayed in the pop-up menu and the MATLAB command window.
In this example, the state with the question mark needs to be labeled with
at least a state name. Edit the Stateflow diagram and label the state with
the text C
. The Stateflow diagram should look similar to this.
Choose Parse Diagram from the graphics editor Tools menu. This message
is displayed in the pop-up window and the MATLAB command window.
In this example, the transition label contains a syntax error. The closing
bracket of the condition is missing. Edit the Stateflow diagram and add the
closing bracket so that the label is E_one [C_one]
.
Choose Parse Diagram from the graphics editor Tools menu. This message
is displayed in the pop-up window and the MATLAB command window.
The Stateflow diagram has no parse errors.
![]() | Specifying Custom Code Options | Error Messages | ![]() |