Main Content

parse

Class: Simulink.CodeImporter
Namespace: Simulink

Analyze custom code for functions, types, global variables, and their dependencies

Since R2021a

Description

success = parse(obj), where obj is an object of Simulink.CodeImporter or sltest.CodeImporter class, parses the custom code, but does not re-parse the custom code if the custom code has been parsed previously and neither the custom code nor the settings of obj.CustomCode have changed since the previous parse. Results of a successful parse or error information from an unsuccessful parse are stored in the ParseInfo property of obj.

example

success = parse(obj, 'Force','On') parses the custom code irrespective of whether any changes have been made since a previous parse.

success = parse(obj, 'Force','Off') has the same effect as success = parse(obj).

Output Arguments

expand all

Indicator of whether parsing is successful, returned as a logical scalar. Simulink® throws an exception if parsing is unsuccessful.

Examples

expand all

%% Create code importer object
obj = Simulink.CodeImporter;

%% Set the custom code to import
obj.CustomCode.InterfaceHeaders = ["pumpController.h"];
obj.CustomCode.IncludePaths = ["./include"];
obj.CustomCode.SourceFiles = ["src/pumpController.c" "src/utils.c"];

%% Parse custom code
s = parse(obj);
obj.ParseInfo
ans = 

  ParseInfo with properties:

               Success: 1
    AvailableFunctions: ["Controller"    "setFanTempThreshold"    "setPumpTempThreshold"]
        EntryFunctions: ["Controller"    "setFanTempThreshold"    "setPumpTempThreshold"]
        AvailableTypes: "pump_control_bus"
                Errors: []

Version History

Introduced in R2021a