Products & Services Solutions Academia Support User Community Company

Learn more about Stateflow   

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

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.

    This action selects State A in the upper left corner, and this message appears in the Parser window and the MATLAB Command Window.

  2. Fix the parse error.

    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.

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

    This message appears in the Parser window and the MATLAB Command Window.

  4. Fix the parse error.

    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.

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

    This message appears in the Parser window and the MATLAB Command Window.

  6. Fix the parse error.

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

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

  


Related Products & Applications

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