Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: RIL on February 20, 2024, 09:05:38 am
-
Trying to import some legacy Delphi code the code importer failed the import with with unrecognized keywords "set of" and "of".
Example of code that fails to import:
TSmallEventSet = set of TSmallEvent;
TExtendedEventHandler = procedure (
Originator: TObject; OriginalEvent: TEvent;
RequestedEvent: TRequestedEvent; const Args: array of const) of object;
These keywords are from around 2000 (Delphi 6 or 7) but seems to still be valid syntax as of at least Delphi 10.4.
https://docwiki.embarcadero.com/RADStudio/Sydney/en/Structured_Types_(Delphi)
Perhaps there's an alternate syntax I could transform into before importing?
//Rolf
These
-
Interestingly enough, EA doesn't even skip commented lines, it still complains about an "of" on line 152 even if it's been commented out and the former row isn't even on the same line anymore.
148 // RIL Disabled:
149 // TEventHandler = procedure (
150 // Originator: TObject; OriginalEvent: TEvent;
151 // RequestedEvent: TRequestedEvent) of object;
152 TEventHandler = T_procedure_RILFakeEvent; // Gotta let EA create something...
I realize that Delphi code isn't really supported by EA.
//Rolf
-
Interestingly enough, EA doesn't even skip commented lines, it still complains about an "of" on line 152 even if it's been commented out and the former row isn't even on the same line anymore.
148 // RIL Disabled:
149 // TEventHandler = procedure (
150 // Originator: TObject; OriginalEvent: TEvent;
151 // RequestedEvent: TRequestedEvent) of object;
152 TEventHandler = T_procedure_RILFakeEvent; // Gotta let EA create something...
Just a guess (not done Delphi for a long time) - is that because you have a semicolon between your definitions of Originator and OriginalEvent on Line 150, so EA treats that as a newline (hence the 'of' which you have on numerical Line 151 could 'technically' be treated by EA as Line 152 by EA)?
Doesn't help you at all, I'm just interested! :)
I realize that Delphi code isn't really supported by EA.
Ultimately I think this is your answer.
-
Just a guess (not done Delphi for a long time) - is that because you have a semicolon between your definitions of Originator and OriginalEvent on Line 150, so EA treats that as a newline (hence the 'of' which you have on numerical Line 151 could 'technically' be treated by EA as Line 152 by EA)?
In this particular case I have in an earlier step tried to comment away the failing code altogether (see the "//" in the left margin). But that only proved to me that EA doesn't even respect the comment symbols, it still tries to parse the commented code as some code it needs to pick up...
That's when I really started doubting that Delphi code language has been supported for a long long time... :-(
Now, at this time I don't really need Delphi code that compiles, I just need to import a bunch of classes to study the structure. There are more than 16.000 files in the project (yes sixteen thousand+), which is the reason I want to examine the code also with the help of UML. But when it became obvious that EA doesn't even respect (or skip parsing) the commented code, it felt rather cheap. I had to use regex to pick up the "of" keywords and split it into "o/f" so EA wouldn't nose-dive into it.
The Delphi language in EA hasn't received much love in recent decades, I can tell. :)
Although I program mostly in C# these days, the listed support for the Delphi language was one of the reasons I bought EA, because I have plenty of legacy Delphi code I could make use of if having the right tools for it.
//Rolf
-
If you are fiddling with regex to change the code, it may be an option to check whether EA can use another character combination to recognise a commented line.
I.e. the '#' character is often used to comment out lines of code...