Book a Demo

Author Topic: Error parsing Delphi .pas files  (Read 7786 times)

mdo

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Error parsing Delphi .pas files
« on: January 12, 2016, 02:35:57 am »
Hi,

i am trying to generate class diagrams by sourcecode. Unfortunately the sourcecode parser gives an error when parsing generic types.

TTest = class
  private
    Flist: TList<integer>;
end;

will give an error "unexpected symbol <".

What can i do?  :-\

Regards

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Error parsing Delphi .pas files
« Reply #1 on: January 12, 2016, 07:41:34 am »
If you are using the latest version (currently 12.1.1225) then Report a Bug to Sparx

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Error parsing Delphi .pas files
« Reply #2 on: January 12, 2016, 09:05:28 am »
Delphi parsing hasn't been updated to support generics.

Support does have an MDG technology that allows some handling of generics. It's only based on a handful of examples though.

mdo

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Error parsing Delphi .pas files
« Reply #3 on: January 12, 2016, 11:03:53 pm »
Hello and thank you for your replies!

Hmm - actually to me this looks more like a "bug". Those type definitions have been available in delphi for many years now, meaning if the software states to be delphi compatible that should be supported i guess. Otherwise that feature is not usable at all, which would unfortunately question the use of EA itself in our case.

Or is this supported in EA 12 ?

I filed a bug report,

hopefully my request will be heared  ;D!

Thanks a lot for your help!

Regards

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Error parsing Delphi .pas files
« Reply #4 on: January 13, 2016, 08:38:45 am »
When Delphi generics were introduced we were unable to find a specification or sufficient examples to update EA to support them with any confidence.

In your words, for "many years" we have effectively had an undocumented maximum version of Delphi supported and had few requests to add the latest. I'm not sure what has changed recently but there has been an influx of support requests for Delphi generics. Thanks to the examples sent in, we have produced an MDG technology that allows parsing generics. There's still far too few examples to add to Enterprise Architect and claim that it will work though.

cesarliws

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Error parsing Delphi .pas files
« Reply #5 on: April 15, 2016, 12:34:42 am »
When Delphi generics were introduced we were unable to find a specification or sufficient examples to update EA to support them with any confidence.

In your words, for "many years" we have effectively had an undocumented maximum version of Delphi supported and had few requests to add the latest. I'm not sure what has changed recently but there has been an influx of support requests for Delphi generics. Thanks to the examples sent in, we have produced an MDG technology that allows parsing generics. There's still far too few examples to add to Enterprise Architect and claim that it will work though.

Hi Simon,

Thank you for your reply in this thread! I have interest in this topic, and  I would be happy to help you on the matter.

The current Delphi language support is mostly at the same level as C# or Java, what do you need to update the support Delphi new features?
I can provide you source code with all features you want to support, please let me know how.

So far, I cannot use EA for any serious work related to Delphi source code engineering.
- My first test the parser stops in nested compiler directives
- For DTO/Entities objects, it stops in generics properties/fields declaration

So far, I can not get to the point to test any other new feature, since the parse stops in the beggining of the unit Interface, but I suspect we will have problems with anonymous methods either, among other new features.

There is a project "Delphi AST"  https://github.com/RomanYankovsky/DelphiAST, it parses Delphi source code and creates  an abstract syntax tree.

Delphi AST is a opensource project actively updated, I have been using it, and I know for fact that several opensources projects is using it too, maybe you can use it to import Delphi source code.

PS: A plus would be suport for Model Transformation (MDA) for Delphi.

Regards,


Cesar Romero


Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Error parsing Delphi .pas files
« Reply #6 on: April 15, 2016, 09:03:45 am »
If you want to send in some samples that fail to parse we will do what we can in order to get you going.

cesarliws

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Error parsing Delphi .pas files
« Reply #7 on: April 16, 2016, 01:46:16 am »
If you want to send in some samples that fail to parse we will do what we can in order to get you going.

A project that is reference for new Delphi features is Spring4D branch release/1.2, this project supports features for Delphi 2010 >.
If we can parse the Spring4D source code, then almost all my needs will be covered.

The following source code will cover almost all the new features, to name some of then:

- Attributes (annotation)
- Anonimous Methods
- Virtual Method Interception
- Generics


https://bitbucket.org/sglienke/spring4d/src/9afccb1066533c891c914ba514e86d3dbb28523d/Marshmallow/Test/TestEntities.pas?at=release%2F1.2&fileviewer=file-view-default

- Collections
https://bitbucket.org/sglienke/spring4d/src/9afccb1066533c891c914ba514e86d3dbb28523d/Source/Base/Collections/?at=release/1.2

- ORM
https://bitbucket.org/sglienke/spring4d/src/9afccb1066533c891c914ba514e86d3dbb28523d/Source/Persistence/?at=release/1.2


- Mocking
https://bitbucket.org/sglienke/spring4d/src/9afccb1066533c891c914ba514e86d3dbb28523d/Source/Core/Mocking/?at=release/1.2

- Logging
https://bitbucket.org/sglienke/spring4d/src/9afccb1066533c891c914ba514e86d3dbb28523d/Source/Core/Logging?at=release%2F1.2
https://bitbucket.org/sglienke/spring4d/src/9afccb1066533c891c914ba514e86d3dbb28523d/Source/Base/Logging/?at=release/1.2


Regards,


Cesar Romero