Troubleshooting
Problem
Attempts to round-trip a preserve block added to the code generated by IBM Rational Rhapsody result into a parsing error "Rhapsody has found parsing errors as a result of your changes".
Symptom
Example preserve block:
//#[ preserve
MACRO_WITH_TERMINATOR_A;
MACRO_WITH_NO_TERMINATOR_B
//#] preserve
You will see the following dialog displayed when parser encounters an unexpected error:
Cause
Rhapsody provides a code exclusion feature by allowing you enclose the section you want to exclude from round-tripping with using preserve annotation, but there is a certain rule applied for the code you can enter in the preserve block since parser analyzes the block and produce an error if it encounters an unexpected statement such as a macro statement which does not have a line terminator ( ; ) at the end.
Resolving The Problem
Parser is invoked during RoundTrip process to ensure that statements within preserve block is compilable. Although it is compilable and correct in a C++ sense, macro statement without a terminator ( ; ) is considered "incorrect" by Rhapsody's parser and thus an error is generated. So if parser fails continuing due to the missing terminator within preserve blocks, you can use the following format instead:
//#[ preserve
MACRO_WITH_TERMINATOR_A;
MACRO_WITH_NO_TERMINATOR_B
;
//#] preserve
Alternatively, you can simply put MACRO_WITH_NO_TERMINATOR_B (without a value assigned) to CPP_Roundtrip::General::PredefineMacros or CPP_ReverseEngineering::Parser::Defined property. The difference is explained later (*1) but the two properties can be used in the same way, telling parser about macros values and ensuring the line containing the specific macro is compilable after the macro being expanded. In this given scenario, MACRO_WITH_NO_TERMINATOR_B will be translated as a blank line, thus parser will simply ignore the line and move on to the next line to process.
(*1)
- CPP_ReverseEngineering::Parser::Defined is used both in Reverse engineering and RoundTrip. It is primarily provided to store user-defined macros, and should be used for any user-defined macro that is not defined anywhere in the generated code but defined in external code or in make file.
- CPP_Roundtrip::General::PredefineMacros is used only in RoundTrip and contains the macros that Rhapsody adds to its generated code for complex elements - as a best practice, it is recommended not to mix up this property values with user-defined macros.
Related Information
Product Synonym
Rational Rhapsody
Was this topic helpful?
Document Information
Modified date:
27 May 2022
UID
swg21640085