| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Stateflow |
| Contents | Index |
| Learn more about Stateflow |
| 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 Stateflow chart notation and the action language syntax.
Note The parser does not check for unresolved symbol errors unless you start simulation or update the model diagram. See Resolving Symbols for details. |
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 Stateflow Editor 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 Stateflow chart to the front with the source object highlighted. See Parsing Chart Example for example displays of parsing results in the Stateflow Builder window.
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 Debugging State Inconsistencies in a Chart.
Transition Conflict — Occurs when there are two equally valid transition paths from the same source. See Debugging 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 Debugging Data Range Violations in a Chart.
Cyclical Behavior — Occurs when a step or sequence of steps repeats itself indefinitely. See Debugging 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.
This action selects State A in the upper left corner, and this message appears in the Parser window and the MATLAB Command Window.

In this example, there are two states with the name A. Edit the chart and label the duplicate state with the text B.
The chart should look similar to this figure.

In the Stateflow Editor, select Tools > Parse Diagram to reparse the chart.
This message appears in the Parser window and the MATLAB Command Window.

In this example, 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.
The chart should look similar to this figure.

In the Stateflow Editor, select Tools > Parse Diagram to reparse the chart.
This message appears in the Parser window and the MATLAB Command Window.

In this example, the transition label contains a syntax error, where the closing bracket of the condition is missing. 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.
This message appears in the Parser window and the MATLAB Command Window.

The chart now has no parse errors.
![]() | What Happens During the Target Building Process? | Resolving Event, Data, and Function Symbols in Stateflow Action Language | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |