Book a Demo

Author Topic: reverse engineering for self-defined language  (Read 3009 times)

Jsc

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
reverse engineering for self-defined language
« on: January 23, 2020, 06:58:56 pm »
Hi Everyone,

I have written a new code generation template to generate PLC code, which is a self-defined language. Now i would like to try the reverse engineering for these codes.
From this link: https://www.sparxsystems.com/enterprise_architect_user_guide/15.0/model_domains/grammar_editor_for_imported_co.html

I have known that, i should write my own grammer to realize the reverse engineering. I have tried the example from EA: test.ssl and SSL.nbnf from:
https://www.sparxsystems.com/enterprise_architect_user_guide/15.0/model_domains/example_grammars.html

But the problem is, after the parsing i can only get the abstract syntax tree. How can i eventuelle get the uml model from the code.

thanks

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: reverse engineering for self-defined language
« Reply #1 on: January 23, 2020, 07:35:11 pm »
If you wrote the compiler yourself, you're best of to dump the syntax tree as sort of XMI you can read with a script to create a class structure. Or you modify your compiler and create a 2nd version to cross-compile to EA (creating the class structure inside EA).

Creating XMI directly for EA-import would likely be a PITA.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: reverse engineering for self-defined language
« Reply #2 on: January 24, 2020, 09:11:26 am »
If you've got an abstract syntax tree that matches the items EA will look for as described at https://www.sparxsystems.com/enterprise_architect_user_guide/15.0/model_domains/context_labels.html.

Add the grammar into an MDG technology and EA will provide the import functions.

https://www.sparxsystems.com/enterprise_architect_user_guide/15.0/modeling/addingcodemodulesinmdgtec.html