Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Porting Xpand to Xtend2(How to port Xpand templates to Xtend2)
Porting Xpand to Xtend2 [message #878948] Wed, 30 May 2012 04:55 Go to next message
Andy Gotz is currently offline Andy Gotz
Messages: 32
Registered: July 2010
Member
Hi,

I am an absolute newbie porting a DSL code generator project from Xpand to Xtend2. I have downloaded the Xtext distribution from itemis based on Eclipse 3.7.1. I see that the Xpand templates having an .xpt extension are not recognised by Xtext. How should I best go about porting these templates to Xtend2? Should I just rename them .xtend and then fix the errors eventually using the Xtend language features instead of the Xpand ones? Is there a porting guide I could read?

Thanks for any help you can give an absolute newbie ...

Andy
Re: Porting Xpand to Xtend2 [message #878968 is a reply to message #878948] Wed, 30 May 2012 05:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6142
Registered: July 2009
Senior Member
Hi,

there is no porting guide. from personal porting experience i can say:
- start with a new file foreach xpand file
- create a dispatch method for every define statements.
<<DEFINE xxx FOR YYY>>
...
<<ENDDEFINE>>


def dispatch xxx(YYY yyy) '''
...
'''

- migration might be tricky at some points but mostly it should be straigt forward
(depending on the metamodelcontributor you use)

Feels free to ask any questions.

~Christian
Re: Porting Xpand to Xtend2 [message #879707 is a reply to message #878948] Thu, 31 May 2012 13:20 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten Thoms
Messages: 353
Registered: July 2009
Location: Dortmund
Senior Member

Hi Andy,

although Xpand and Xtend2 are rather close related, porting is a manual task. Attached PERL script does some of those conversions that can be decided half-automatically. However, the resulting file won't be fully compilable. The script is just meant to "preprocess" Xpand templates and convert them to something more closely to Xtend2, like converting DEFINE to def functions, removing "-" signs, converting FOR loops. It is required to know Xtend to fix the remaining.

Porting templates is just one side, you'll need also an according workflow. If using Xtext as models, the infrastructure is already there and a skeleton of a generator workflow is available. If using non-Xtext models, you can either code a workflow component yourself and file access, or reuse Xtext's infrastructure. I tend to use the latter, but it requires some setup of Guice.

Best wishes,
~Karsten

  • Attachment: xpt2xtend.txt
    (Size: 14.16KB, Downloaded 124 times)


Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: Porting Xpand to Xtend2 [message #880534 is a reply to message #878968] Sat, 02 June 2012 04:05 Go to previous messageGo to next message
Andy Gotz is currently offline Andy Gotz
Messages: 32
Registered: July 2010
Member
Hi Christian,

thank you for your quick answer. This sounds relatively straightforward but I am stuck on the first line already:

«IMPORT pogoDsl»
«EXTENSION fr::esrf::tango::pogo::cpp::_CppConstants»
«EXTENSION fr::esrf::tango::pogo::cpp::_CppUtil»


How would I port this to Xtend? I have not understood how Xpand IMPORT relate to Xtend2 ...

Thanks

Andy
Re: Porting Xpand to Xtend2 [message #880540 is a reply to message #880534] Sat, 02 June 2012 04:23 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6142
Registered: July 2009
Senior Member
Hi,

i guess you should do some Xtend tutorial first.
this would tell you that Xtend in something like a better java

=> you create classes.
=> you import the FQN names of you Java!!!!! Metaclasses.
=> you use @Inject extension ExtensionClassName for extensions.

btw i think top down porting is a bad idea.

~Christian

[Updated on: Sat, 02 June 2012 04:25]

Report message to a moderator

Re: Porting Xpand to Xtend2 [message #880552 is a reply to message #879707] Sat, 02 June 2012 05:05 Go to previous messageGo to next message
Andy Gotz is currently offline Andy Gotz
Messages: 32
Registered: July 2010
Member
Hi Karsten,

I just saw your message. Thanks for the perl script. It worked like a charm. Now we have some idea where to start the porting.

Where to find the com.atoss.ses.amf.oaw package? Do we need it? What does it provide?

We are using the manual workflow you helped us setup.

Thanks again

Andy
Re: Porting Xpand to Xtend2 [message #880553 is a reply to message #880540] Sat, 02 June 2012 05:08 Go to previous messageGo to next message
Andy Gotz is currently offline Andy Gotz
Messages: 32
Registered: July 2010
Member
Hi Christian,

I agree with your comments i.e. we should do the Xtend tutorial and not do topdown porting. We have a medium sized project based on Xpand which we are trying to modernise with Xtend2. We are trying to understand how by attacking it from all sides. The top down porting is part of this to find out what are the changes. But eventually we will need to do properly.

Thanks again for your help

Andy
Re: Porting Xpand to Xtend2 [message #880563 is a reply to message #880552] Sat, 02 June 2012 05:39 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten Thoms
Messages: 353
Registered: July 2009
Location: Dortmund
Senior Member

The package is not interesting for you. It is from a customer project, where this script was initiated.

Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Re: Porting Xpand to Xtend2 [message #881085 is a reply to message #880563] Sun, 03 June 2012 17:36 Go to previous messageGo to next message
Andy Gotz is currently offline Andy Gotz
Messages: 32
Registered: July 2010
Member
Hi,

I have followed the tutorials and read the Xtext and Xtend documentation but to no avail. I still do not know how to port my project from Xpand to Xtext2. I have attached an example Xpand file. We have tens of these. I must be quite stupid or the documentation is not destined for beginners. It is very frustrating. I hope someone will write a good book on using this technology soon ...

Thanks anyway

Andy
Re: Porting Xpand to Xtend2 [message #881205 is a reply to message #881085] Mon, 04 June 2012 02:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6142
Registered: July 2009
Senior Member
Hmm

without telling anything what your actual problem is i can only guess.
so what is your problem?

~Christian
Re: Porting Xpand to Xtend2 [message #881571 is a reply to message #881205] Mon, 04 June 2012 17:17 Go to previous messageGo to next message
Andy Gotz is currently offline Andy Gotz
Messages: 32
Registered: July 2010
Member
Hi,

we have got over some of our problems and we have the beginning of a code generator.

Now I have a more precise question. In our grammar we have this field:

filestogenerate= STRING // File(s) to generate (code, makefile,....)

We are running the code generator with an mwe2 workflow.

My question: can I set this field in the model via the arguments of the workflow launch configuration - how?

Thanks

Andy

Re: Porting Xpand to Xtend2 [message #881584 is a reply to message #881571] Mon, 04 June 2012 17:49 Go to previous message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6142
Registered: July 2009
Senior Member
Hi,

i am not quite sure what this question is targeting:
you want to maniplulate the model/do a m2m?
what about writing a custom workflow component for that.

~Christian
Previous Topic:[xPand] Access OCL derivation during generation
Next Topic:[Acceleo] Performance Profiling
Goto Forum:
  


Current Time: Wed Jul 30 05:25:17 EDT 2014

Powered by FUDForum. Page generated in 0.10412 seconds