Skip to Main Content Skip to Search
Product Documentation

Parsing Stateflow Charts

How the Stateflow Parser Works

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.

Calling the Stateflow Parser

Apart from building a target, you can call the Stateflow parser to check the syntax of your Stateflow charts in one of these ways:

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.

Parser Error Checking

Using the Debugger, you can detect the following errors during simulation:

You can modify the notation to resolve run-time errors. See Debugging and Testing Stateflow Charts for more information on debugging run-time errors.

Parsing Chart Example

For this chart, the steps that follow describe the parsing process and its reported results.

  1. 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.

  2. Fix the parse error.

    In this example, two states with the name A exist. Edit the chart and label the duplicate state with the text B.

  3. 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.

  4. Fix the parse error.

    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.

  5. 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.

  6. Fix the parse 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].

  7. In the Stateflow Editor, select Tools > Parse Diagram to reparse the chart.

    The chart now has no parse errors.

  


Free Stateflow Interactive Kit

Learn how engineers use Stateflow to model state machines in their Simulink models.


Get free kit

Trials Available

Try the latest version of Stateflow.


Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS