Author Topic: Adding support for new language (Kotlin) round trip engineering  (Read 8925 times)

SannyManx

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Adding support for new language (Kotlin) round trip engineering
« on: January 31, 2018, 01:27:18 am »
I'm attempting to add code generation support for Kotlin but the docs are absolutely mind-boggling. I've successfully added Kotlin as a language with basic types and code generation template but can't find how to change things like the default file extension, which according to the docs can be defined in an XML file and then imported ... how? Where???

Very frustrated.

Is there a tutorial available for the entire process of adding a new language?

The docs are very confusing and miss important steps or cross-reference a ton of other docs but there's nothing that takes you through the whole process step by step.

Please help!!!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 7983
  • Karma: +114/-20
    • View Profile
Re: Adding support for new language (Kotlin) round trip engineering
« Reply #1 on: January 31, 2018, 08:34:49 am »
This is how you define the import.
http://www.sparxsystems.com/enterprise_architect_user_guide/13.5/model_domains/grammar_editor_for_imported_co.html

The Learn more link at the bottom tells you how you can combine it into an MDG Technology file.

SannyManx

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Adding support for new language (Kotlin) round trip engineering
« Reply #2 on: January 31, 2018, 07:48:59 pm »
So do I need to define a new MDG technology?
I was confused because the in built languages aren't listed in the MDG tech list. So are you saying that I need to create an MDG tech for Kotlin?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 7983
  • Karma: +114/-20
    • View Profile
Re: Adding support for new language (Kotlin) round trip engineering
« Reply #3 on: February 01, 2018, 08:19:16 am »
Yes, you need to create a technology.

SannyManx

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Adding support for new language (Kotlin) round trip engineering
« Reply #4 on: February 02, 2018, 09:48:54 pm »
Thanks.

I would like to take the Java templates and Grammar NBNF files and tweak them for Kotlin but I can't find the Java grammar files in EA. Are they accessible somewhere or built more deeply into EA in a different way?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 7983
  • Karma: +114/-20
    • View Profile
Re: Adding support for new language (Kotlin) round trip engineering
« Reply #5 on: February 05, 2018, 08:50:44 am »
Grammars for built-in languages are not available.

qwerty

  • EA Guru
  • *****
  • Posts: 13495
  • Karma: +392/-299
  • I'm no guru at all
    • View Profile
Re: Adding support for new language (Kotlin) round trip engineering
« Reply #6 on: February 05, 2018, 10:28:36 am »
It would probably be a good idea to offer one of them (Cxx or Java for example) as a downloadable sample where people can start from.

q.

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Adding support for new language (Kotlin) round trip engineering
« Reply #7 on: February 05, 2018, 08:34:55 pm »
It would probably be a good idea to offer one of them (Cxx or Java for example) as a downloadable sample where people can start from.
I don't know about "good" -- those are pretty big languages. The small samples that come with the EA installation are better I think, since they're easier to wrap your head around.

/U
My theories are always correct, just apply them to the right reality.

SannyManx

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Adding support for new language (Kotlin) round trip engineering
« Reply #8 on: February 06, 2018, 12:57:49 am »
For my particular needs, it would have been great to have the Java grammar files because I could have tweaked them easily for Kotlin. I guess they're not available because the in build languages were created using a different process.

I have to say that the documentation provided from Sparx on this is very, very poor.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 7983
  • Karma: +114/-20
    • View Profile
Re: Adding support for new language (Kotlin) round trip engineering
« Reply #9 on: February 06, 2018, 08:40:07 am »
Start with the "Simple Sample Language" grammar in the Code Samples directory in your install.

qwerty

  • EA Guru
  • *****
  • Posts: 13495
  • Karma: +392/-299
  • I'm no guru at all
    • View Profile
Re: Adding support for new language (Kotlin) round trip engineering
« Reply #10 on: February 06, 2018, 08:58:05 am »
those are pretty big languages
Not really. They are all LR(k) grammars and differ only slightly. Setting up  grammar from scratch is just stupid work and BNFs from such grammars are (more or less) freely available. Just that (most likely) EA wants the grammar itself to be of a certain flavor (BNF or EBNF, I don't know). But these are the tedious things users want to be saved from. So instead of hiding them (it's no rocket science you need to protect) it could as well be placed on github.

q.

SannyManx

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Adding support for new language (Kotlin) round trip engineering
« Reply #11 on: February 07, 2018, 04:37:18 am »
Well said Querty.

Perhaps they can't provide the files because the inbuilt languages were implemented in a different way. The nbnf approach may have been added to support customisation.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 7983
  • Karma: +114/-20
    • View Profile
Re: Adding support for new language (Kotlin) round trip engineering
« Reply #12 on: February 07, 2018, 08:21:28 am »
Not really. They are all LR(k) grammars and differ only slightly.
That's hilarious. Is an apple only slightly different from an orange?

Starting off from a Java or C++ grammar would be harder and more work than starting from our "Simple Sample Language" grammar, which has as much in common as any C-like language.

Setting up  grammar from scratch is just stupid work ... EA wants the grammar itself to be of a certain flavor (BNF or EBNF, I don't know). But these are the tedious things users want to be saved from.
Which is why the  sample provided demonstrates the EA specific syntax without complicating it with all the complexities from parsing multiple versions and variants of a production language.

So instead of hiding them (it's no rocket science you need to protect) it could as well be placed on github.
Until I'm told otherwise, I consider them part of EA's source code.

ea0223

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Adding support for new language (Kotlin) round trip engineering
« Reply #13 on: February 02, 2024, 08:10:09 pm »
This topic is still hot! I am trying to do the same now.
Reg. the grammar files there are now actually one for Java (and several other languages) in the installation folder
under C:\Program Files\Sparx Systems\EA\Code Samples\Grammar_Samples

My goal is to make it possible to import Kotlin code into EA. Any who has achieved this yet?

br.
Allan