Book a Demo

Author Topic: Code generation: custom languages  (Read 2932 times)

Erkki

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Code generation: custom languages
« on: January 27, 2005, 01:17:26 pm »
Is it possible at the moment to generate code in any language? Specifically, I want to generate (and preferably even roundtrip) UnrealScript, which is similar to Java, but has many differences. How would I do that if it's possible right now?
I heard better support for custom languages is coming in a future version?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code generation: custom languages
« Reply #1 on: January 27, 2005, 01:54:08 pm »
Yes, it is possible.  The first step is to set up the datatypes for the language.  This is done using the Programming Languages Datatypes dialog.  (Configuration | Language Datatypes)  You need to add at least one datatype for your language before EA will know about that language.

The second (and much more involved) step is writing the templates using the Code Template Editor.  (Configuration | Code Generation Templates)  The documentation for this dialog and for writing templates can be found in the EA help files under "Code Engineering" | "Code Template Framework".  It's very comprehensive and I still refer to parts of it on a regular basis.

As a starting point I recommend looking at the default templates for the supported languages.  These use most of what is available to use in the templates and show the general form that you should expect things to look like.  Often you will want to copy and paste elements out of them into your new templates.

You may also find the people on this forum a great help.  I know that a few have written templates for new languages, others have extensively modified the existing templates.

You won't be able to round trip with just templates.  Reverse engineering support with grammars is on the way, but it's not here yet.  That may be the better support that you heard of.

Simon

Erkki

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Code generation: custom languages
« Reply #2 on: January 27, 2005, 02:17:12 pm »
Thanx for the quick reply! I think that's enough information to get me started.

Erkki

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Code generation: custom languages
« Reply #3 on: January 27, 2005, 03:26:53 pm »
Hmm... I almost managed to generate an empty class now, but the parent class is not included.

I copied the File, Class, ClassDeclaration, ClassInherits templates from Java (with minimal changes like removing the scope info), but the 'extends ClassX' is left out.
I'm using a generalisation association between two classes, and if I made it generate Java instead, it worked fine.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code generation: custom languages
« Reply #4 on: January 27, 2005, 08:14:50 pm »
Look at the following templates.

  • Class Inherits
  • Class Base
  • Class Interface
  • Linked Class Base
  • Linked Class Interface


Most of those are "advanced" templates.  Just ignore that though and check the Advanced checkbox.

Simon