|M2T with Xtext2 and Xtend2 [message #1052814]
||Tue, 30 April 2013 15:16
| Rene Grellert
Registered: April 2013
I'm a bit confused about how Xtext2 and Xtend2 could solve my M2T-problem.
I've worked on a project using Open Architecture Ware ( oAW, or MWE) and the three languages Xpand, Check and Xtend before. My question is, how can the following steps be achived using Xtend2 and Xtext2 like we did with oAW before:
We've written a workflow for parsing a text document and generating code for different platforms. We had an own parser for parsing the textfile and instanciating a respecitve ecore model. Xtend was used then to transform this model into another one and several Chk.-files ensured the validity of the model. Then a Xpand-Template File was triggert with the newly created model generating the text-output.
So, now I have a project where I want to have an equivalent workflow but with Xtend2 and Xtext2 as those seem to be the new state of the art. This is what i've learnt so far:
The Modeling Workflow Engine (MWE) as it was called firstly, is now a part of Xtext2 having the name MWE2. It is a DSL written in Xtext that lets you design workflows pretty easily. Xtext2 is a language for writing own DSLs with full editor-integration. Xtend2 is yet another language based on Xtext2 and tries to fix some of Java's weaknesses by enabling type inference and other features. Its template expressions has the same power of the previous Xpand language.
Ok, now I wonder, if I simply want to transform an (ecore) model into text after performing some parsing and M2M magic, why would I want to write an own DSL inclosing a very complex grammar and stuff. All I need is to create an instance of the let's say "final" model and feed the Xtend2-Generator with it. Is it even sensible to use Xtext2 for this approach? And if not, why is MWE2 a part of Xtext2 and not of Xtend2?
I really hope, I could point out some of my problems here. I guess what makes me confused is that I'm trying to map the previously used approach with MWE on the newly created framework. But I liked it a lot because the way of designing a workflow and performing transformations inside this workflow on manually designed models was a perfect way of ensuring transparency and maintanability.
|Re: M2T with Xtext2 and Xtend2 [message #1053487 is a reply to message #1052814]
||Mon, 06 May 2013 08:54
| Karsten Thoms
Registered: July 2009
Quite a lot of confusion I doubt I can solve it with a few sentences.|
Xtend2 is written with Xtext, but it does not mean that you need to write a DSL with Xtext in order to use Xtend2 to generate code. Xtend2 compiles to Java, so everything is like you would do writing a code generator just with Java, only much easier.
However, when it comes to integrate an Xtend2 based generator into a workflow, there is first-class support only for Xtext based models, since Xtext provides a standard workflow component "GeneratorComponent" that uses the IGenerator implementation as generator root. The infrastructure for code generators becomes less when dealing with non-Xtext models. However, all you need to do is to write a custom worflow component, derived from AbstractWorkflowComponent2, create an instance of your Xtend class and invoke it. I am expecting more support for this in the future, when Xtend's new Active Annotations become mature.
Similar to M2M transformations. They can be written with Xtend2 like before with Xtend1, but invocation requires a custom component.
MWE2 is part of the Xtext project, since it is a language that is is developed with Xtext and to some degree is an example language. It has nothing to do with Xtend2, and actually existed way before Xtend2 was developed. The old-style .mwe/.oaw workflows with XML syntax are still valid, the MWE SDK provides support for that (MWE is part of EMFT).
Validating a model is another thing which has nothing to do with Xtend2. Again, Xtext based models have more support on validating models, since Xtext's MWE Reader component validates models while reading, by using classes with @Check annotations for validation. For non-Xtext models this has to be done otherwise, e.g. by still using the old Check language.
Hope this solves some of the confusion, and not that it just becomes more.
Need professional support for Xtext, Xpand, EMF?
Go to: http://xtext.itemis.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
Powered by FUDForum
. Page generated in 0.02068 seconds