Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [XText] newbie question: Can XText generate code.
[XText] newbie question: Can XText generate code. [message #45850] Thu, 28 May 2009 13:55 Go to next message
Mikai Yang is currently offline Mikai YangFriend
Messages: 149
Registered: July 2009
Senior Member
Hi,
I am a newbie of XText. So far, I have known that XText can be used to generate parsers and language editors. However I am wondering whether XText can be used to
generate code, and how. In fact, I did not find any Java class is intended for generating code in a built-in example XText project. Hints are welcome.
Thanks.
Regards
Michael
Re: [XText] newbie question: Can XText generate code. [message #45998 is a reply to message #45850] Fri, 29 May 2009 05:42 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Michael,

Xtext is a framework that helps you to create textual domain specific
languages and appropriate tooling for them. Keeping that in mind, I
won't say Xtext is a classic code generator. But you may use it to store
a semantic model in a concrete textual syntax (generate something). With
the help of the generated parser, these text files can be loaded back
into memory. During the loading process Xtext will recreate your
semantic model.

That said, you can do some kind of roundtrip engineering with Xtext:

Text -[parsing/loading]->
Model -[in memory modification aka transformation, refactoring ..]->
Model -[serialization]->
Text ...

Doesn't look like the classic code generator usecase, does it?

Please describe in a few words what you are trying to achieve.

Regards,
Sebastian


Am 28.05.2009 15:55 Uhr, schrieb Michael:
> Hi,
> I am a newbie of XText. So far, I have known that XText can be used to
> generate parsers and language editors. However I am wondering whether
> XText can be used to
> generate code, and how. In fact, I did not find any Java class is
> intended for generating code in a built-in example XText project. Hints
> are welcome.
> Thanks.
> Regards
> Michael
Re: [XText] newbie question: Can XText generate code. [message #46057 is a reply to message #45850] Fri, 29 May 2009 06:57 Go to previous messageGo to next message
Steffen Stundzig is currently offline Steffen StundzigFriend
Messages: 23
Registered: July 2009
Junior Member
Hi Michael,

if you use the "New Project/Xtext Project"-Wizard, you got a generator
project in your workspace. In this generator project you could find a
sample model and sample templates (xpand) to generate some sample code
with the modeling workflow engine (openArchitectureWare).

Xtext is the tool to build editors, mwe(oaw) is the tool to generate code
from models created with your own Xtext editor.

hth.

regards


Michael wrote:

> Hi,
> I am a newbie of XText. So far, I have known that XText can be used to
generate parsers and language editors. However I am wondering whether XText
can be used to
> generate code, and how. In fact, I did not find any Java class is intended
for generating code in a built-in example XText project. Hints are welcome.
> Thanks.
> Regards
> Michael
Re: [XText] newbie question: Can XText generate code. [message #46086 is a reply to message #46057] Fri, 29 May 2009 07:27 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Steffen Stundzig schrieb:
> Hi Michael,
>
> if you use the "New Project/Xtext Project"-Wizard, you got a generator
> project in your workspace. In this generator project you could find a
> sample model and sample templates (xpand) to generate some sample code
> with the modeling workflow engine (openArchitectureWare).
>
> Xtext is the tool to build editors, mwe(oaw) is the tool to generate
> code from models created with your own Xtext editor.
> hth.
>

The code generation technology is called Xpand (M2T Xpand).
MWE is just a tool to orchestrate and configure things like code
generators, model parsers and model transformations.

Sven
Re: [XText] newbie question: Can XText generate code. [message #47038 is a reply to message #46086] Tue, 02 June 2009 08:52 Go to previous messageGo to next message
Steffen Stundzig is currently offline Steffen StundzigFriend
Messages: 23
Registered: July 2009
Junior Member
Sven Efftinge wrote:

> The code generation technology is called Xpand (M2T Xpand).
> MWE is just a tool to orchestrate and configure things like code
> generators, model parsers and model transformations.

thx for the clarification again. In my simple _obsolete_ world, there
exists only the two components xtext and oaw in mind. ;)

regards
Steffen...
Re: [XText] newbie question: Can XText generate code. [message #47068 is a reply to message #47038] Tue, 02 June 2009 13:15 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Hi Steffen,

sure, I just wanted to clarify in order to avoid confusing other people,
who don't have the oAW background but are looking at the stuff from the
Eclipse-point of view, where the components live in different projects.

Cheers,
Sven

Steffen Stundzig schrieb:
> Sven Efftinge wrote:
>
>> The code generation technology is called Xpand (M2T Xpand).
>> MWE is just a tool to orchestrate and configure things like code
>> generators, model parsers and model transformations.
>
> thx for the clarification again. In my simple _obsolete_ world, there
> exists only the two components xtext and oaw in mind. ;)
>
> regards
> Steffen...
>
Re: [XText] newbie question: Can XText generate code. [message #47213 is a reply to message #47068] Tue, 02 June 2009 14:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sderrienREMOVE.irisa.fr

Hi,

Just a very naive question : how difficult would it be to automatically
generate a xpand template that would map a model onto a textual
representation generated according to the xtext grammar (a kind of
source to source workflow)?

Steven

Sven Efftinge a écrit :
> Hi Steffen,
>
> sure, I just wanted to clarify in order to avoid confusing other people,
> who don't have the oAW background but are looking at the stuff from the
> Eclipse-point of view, where the components live in different projects.
>
> Cheers,
> Sven
>
> Steffen Stundzig schrieb:
>> Sven Efftinge wrote:
>>
>>> The code generation technology is called Xpand (M2T Xpand).
>>> MWE is just a tool to orchestrate and configure things like code
>>> generators, model parsers and model transformations.
>>
>> thx for the clarification again. In my simple _obsolete_ world, there
>> exists only the two components xtext and oaw in mind. ;)
>>
>> regards
>> Steffen...
>>
Re: [XText] newbie question: Can XText generate code. [message #47289 is a reply to message #47213] Tue, 02 June 2009 18:25 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Hi Steven,

I'm not sure what you mean but if you're talking of serializing a parsed
model back to its textual representation, I can say that it's hard
generate such a serializer from a grammar.
I know this because we've had (actually Moritz Eysholdt had) hard time
to solve this. But it is solved and with TMF Xtext you get this
serialization mechanism generated for your grammar. :-)

But I bet you knew that already and I completely missed the point...

Cheers,
Sven

Steven Derrien schrieb:
> Hi,
>
> Just a very naive question : how difficult would it be to automatically
> generate a xpand template that would map a model onto a textual
> representation generated according to the xtext grammar (a kind of
> source to source workflow)?
>
> Steven
>
> Sven Efftinge a écrit :
>> Hi Steffen,
>>
>> sure, I just wanted to clarify in order to avoid confusing other
>> people, who don't have the oAW background but are looking at the stuff
>> from the Eclipse-point of view, where the components live in different
>> projects.
>>
>> Cheers,
>> Sven
>>
>> Steffen Stundzig schrieb:
>>> Sven Efftinge wrote:
>>>
>>>> The code generation technology is called Xpand (M2T Xpand).
>>>> MWE is just a tool to orchestrate and configure things like code
>>>> generators, model parsers and model transformations.
>>>
>>> thx for the clarification again. In my simple _obsolete_ world, there
>>> exists only the two components xtext and oaw in mind. ;)
>>>
>>> regards
>>> Steffen...
>>>
Re: [XText] newbie question: Can XText generate code. [message #47363 is a reply to message #47289] Tue, 02 June 2009 21:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: sderrienREMOVE.irisa.fr

Hi,

Sven Efftinge a écrit :
>
> Hi Steven,
>
> I'm not sure what you mean but if you're talking of serializing a parsed
> model back to its textual representation, I can say that it's hard
> generate such a serializer from a grammar.
> I know this because we've had (actually Moritz Eysholdt had) hard time
> to solve this. But it is solved and with TMF Xtext you get this
> serialization mechanism generated for your grammar. :-)
>
> But I bet you knew that already and I completely missed the point...

No you did not, I didn't know that this feature was available in xtext.

Is it documented somewhre, are there some examples ?

It seems that it's me who completely missed the point ...

Steven
>
> Cheers,
> Sven
>
> Steven Derrien schrieb:
>> Hi,
>>
>> Just a very naive question : how difficult would it be to
>> automatically generate a xpand template that would map a model onto a
>> textual representation generated according to the xtext grammar (a
>> kind of source to source workflow)?
>>
>> Steven
>>
>> Sven Efftinge a écrit :
>>> Hi Steffen,
>>>
>>> sure, I just wanted to clarify in order to avoid confusing other
>>> people, who don't have the oAW background but are looking at the
>>> stuff from the Eclipse-point of view, where the components live in
>>> different projects.
>>>
>>> Cheers,
>>> Sven
>>>
>>> Steffen Stundzig schrieb:
>>>> Sven Efftinge wrote:
>>>>
>>>>> The code generation technology is called Xpand (M2T Xpand).
>>>>> MWE is just a tool to orchestrate and configure things like code
>>>>> generators, model parsers and model transformations.
>>>>
>>>> thx for the clarification again. In my simple _obsolete_ world,
>>>> there exists only the two components xtext and oaw in mind. ;)
>>>>
>>>> regards
>>>> Steffen...
>>>>
Re: [XText] newbie question: Can XText generate code. [message #47453 is a reply to message #47363] Wed, 03 June 2009 09:46 Go to previous message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
Steven Derrien schrieb:
>
> Is it documented somewhre, are there some examples ?

The serialization and pretty printing is not yet documented.
But we'll add it to the documentation within the next weeks (i.e. will
be documented in the Galileo release which is due June 24th).

Cheers,
Sven
Previous Topic:[Announce] TMF XTEXT 0.7.0RC3 is available
Next Topic:[Xtext] Using Eclipse Modeling tools download for Galileo RC2
Goto Forum:
  


Current Time: Wed Jan 15 11:55:40 GMT 2025

Powered by FUDForum. Page generated in 0.03801 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top