| Contents | Index |
| On this page… |
|---|
When you begin a build for a target, the parser evaluates the graphical and nongraphical objects in each Stateflow machine against the supported chart notation and the action language syntax.
Apart from building a target, you can call the Stateflow parser to check the syntax of your Stateflow charts in one of these ways:
Parse an individual chart in the Stateflow Editor by selecting Tools > Parse Diagram.
Parse a Stateflow machine (that is, all the charts in a model), by selecting Tools > Parse in the Stateflow Editor.
When you simulate a model, build a target, or generate code for a target, you automatically parse the Stateflow machine.
In all cases, the Stateflow Builder window appears when parsing is complete. If parsing is unsuccessful (that is, an error appears), the chart automatically appears with the highlighted object causing the first parse error. In the Stateflow Builder window, each error appears with a leading red button icon. You can double-click any error in this window to bring its source chart to the front with the source object highlighted.
Using the Debugger, you can detect the following errors during simulation:
State Inconsistency — Most commonly caused by the omission of a default transition to a substate in superstates with exclusive (OR) decomposition. See State Inconsistencies in a Chart.
Transition Conflict — Occurs when there are two equally valid transition paths from the same source. See Conflicting Transitions in a Chart.
Data Range Violation — Occurs when minimum and maximum values specified for a data in its properties dialog box exceed their limits or when fixed-point data overflows its base word size. See Data Range Violations in a Chart.
Cyclic Behavior — Occurs when a step or sequence of steps repeats itself indefinitely. See Cyclic Behavior in a Chart.
You can modify the notation to resolve run-time errors. See Debugging and Testing Stateflow Charts for more information on debugging run-time errors.
For this chart, the steps that follow describe the parsing process and its reported results.

In the Stateflow Editor, select Tools > Parse Diagram to parse the chart.
State A appears highlighted in the chart and a parsing error message indicates that the name A is not unique.
In this example, two states with the name A exist. Edit the chart and label the duplicate state with the text B.

In the Stateflow Editor, select Tools > Parse Diagram to reparse the chart.
State ? appears highlighted in the chart and a parsing error message indicates that the name ? is invalid.
You must label the state with the question mark with at least a state name. Edit the chart and label the state with the text C.

In the Stateflow Editor, select Tools > Parse Diagram to reparse the chart.
The transition for E_one [C_one appears highlighted in the chart and a parsing error message indicates that the transition label contains a syntax error.
The closing bracket of the condition is missing on the transition label. Edit the chart and add the closing bracket so that the label is E_one [C_one].

In the Stateflow Editor, select Tools > Parse Diagram to reparse the chart.
The chart now has no parse errors.
![]() | What Happens During the Target Building Process? | Resolving Undefined Symbols in Your Chart | ![]() |

Learn how engineers use Stateflow to model state machines in their Simulink models.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |