Rhapsody roundtrip reports parsing error if terminator is missing in macro statement inside of preserve code block
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".
Example preserve block:
You will see the following dialog displayed when parser encounters an unexpected error:
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:
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.
- 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.
More support for:
Software version: 7.6, 18.104.22.168, 7.6.1, 22.214.171.124, 126.96.36.199, 188.8.131.52, 8.0, 8.0.1, 8.0.2
Operating system(s): Linux, Windows
Reference #: 1640085
Modified date: 20 June 2013