Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Generating default XText from XCore/Genmodel
Generating default XText from XCore/Genmodel [message #1081074] Tue, 06 August 2013 19:22 Go to next message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Hi all,

Is there a simpler way to generate a new xtext grammar instance from a subsequently modified xcore (through genmodel) file?

If not, this would be a really helpful feature for prototyping. Even though you end up wanting to cusotmize things in the end, it isrealyy rare that you wouldn't make some change to the xcore before committing to a language design. The current workflow of having to drive the xtext project creation with default values is tedious to put it mildly. Wink

cheers,

Miles
Re: Generating default XText from XCore/Genmodel [message #1081594 is a reply to message #1081074] Wed, 07 August 2013 12:32 Go to previous messageGo to next message
Hugo A. Garcia is currently offline Hugo A. GarciaFriend
Messages: 258
Registered: July 2009
Senior Member
On 2013-08-06 21:22, Miles Parker wrote:
> Hi all,
>
> Is there a simpler way to generate a new xtext grammar instance from a
> subsequently modified xcore (through genmodel) file?
>
> If not, this would be a really helpful feature for prototyping. Even
> though you end up wanting to cusotmize things in the end, it isrealyy
> rare that you wouldn't make some change to the xcore before committing
> to a language design. The current workflow of having to drive the xtext
> project creation with default values is tedious to put it mildly. ;)
>
> cheers,
>
> Miles

I agree. It would be nice if the Xtext could depend and synchroize with
the embedded Xcore genmodel than having to generate a separate genmodel
+ ecore instance every time one changes the Xcore model.

-H
Re: Generating default XText from XCore/Genmodel [message #1081766 is a reply to message #1081594] Wed, 07 August 2013 17:07 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
I am not sure what you mean.
Are you referring to
http://koehnlein.blogspot.de/2013/06/using-xcore-in-xtext.html ?

Am 07.08.13 14:32, schrieb Hugo A. Garcia:
> On 2013-08-06 21:22, Miles Parker wrote:
>> Hi all,
>>
>> Is there a simpler way to generate a new xtext grammar instance from a
>> subsequently modified xcore (through genmodel) file?
>>
>> If not, this would be a really helpful feature for prototyping. Even
>> though you end up wanting to cusotmize things in the end, it isrealyy
>> rare that you wouldn't make some change to the xcore before committing
>> to a language design. The current workflow of having to drive the xtext
>> project creation with default values is tedious to put it mildly. ;)
>>
>> cheers,
>>
>> Miles
>
> I agree. It would be nice if the Xtext could depend and synchroize with
> the embedded Xcore genmodel than having to generate a separate genmodel
> + ecore instance every time one changes the Xcore model.
>
> -H


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: Generating default XText from XCore/Genmodel [message #1081787 is a reply to message #1081766] Wed, 07 August 2013 17:47 Go to previous messageGo to next message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Hi Jan,

That looks really cool. I'm not sure if it addresses what I'm getting at or not, honestly. Currently, you can take an xcore model A.xcore you're working with, export a genmodel A.genmodel, and then generate a set of xtext projects based on the (implicit) DSL defined A. This infers a new "B.xtext" grammer that provides a skeleton that wraps a DSL around your ecore / xcore model. But, if you make any changes to A, you have to go through the whole process again in order to get a new B. And that actually requires starting over with the XText projects. (Or of course you could try to maintain the changes by hand but that quickly becomes a pain.)

Are you saying that this is a way to provide a more direct workflow for specifying a (customizable) grammer for a generic (e.g. not designed as a DSL per se) xcore/ecore model that tracks changes in that model?

thanks,

Miles
Re: Generating default XText from XCore/Genmodel [message #1081802 is a reply to message #1081787] Wed, 07 August 2013 18:07 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
so you want to use the "New Xtext Project from Existing Ecore Model" dialog with an .xcore file

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Generating default XText from XCore/Genmodel [message #1081810 is a reply to message #1081802] Wed, 07 August 2013 18:24 Go to previous messageGo to next message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Christian Dietrich wrote on Wed, 07 August 2013 14:07
so you want to use the "New Xtext Project from Existing Ecore Model" dialog with an .xcore file


It would be the ideal to go directly from the xcore file, but the important part is just to be able to infer a new .xtext file from a given .genmodel/.ecore as well. Like "Export.." -> XText Grammer. Obviously the new XText project from Ecore model wizard already does that, so this would just be breaking that little bit of functionality out.

I thought that this is probably done internally w/ a workflow so perhaps there would be a way to invoke that myself...
Re: Generating default XText from XCore/Genmodel [message #1081827 is a reply to message #1081810] Wed, 07 August 2013 18:48 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
I am getting more and more confused :-(

The "New Xtext project from Ecore model" is a very poor way to create an
Xtext language for a given Ecore model as it creates a very generic
syntax that is really just slightly better than XML. I cannot believe it
is useful for any other purpose than to initially scaffold a grammar
from a big Ecore model and refactor that afterwards.

The proposed Xtext way is to start your language from a grammar with an
inferred Ecore model and switch to an imported - a such manually
maintained - model when the language starts to converge. Up to that
point you didn't care what syntax your Ecore model had been defined in.
But this seems to be a good moment to think about switching to Xcore, as
you will have to change the workflow anyway and because Xcore is likely
easier to maintain.

When you're using a (manually maintained) Xcore model as imported model
in Xtext as in the blog post, you don't have to care about genmodels
anyway: Xtext is not in charge of generating the EMF stuff (the Xcore
builder does) and the genmodel is automtically inferred within the Xcore
resource (also by Xcore itself) and from there picked up by Xtext.

So what is the usage scenario you want to be better supported?

Am 07.08.13 20:24, schrieb Miles Parker:
> Christian Dietrich wrote on Wed, 07 August 2013 14:07
>> so you want to use the "New Xtext Project from Existing Ecore Model"
>> dialog with an .xcore file
>
>
> It would be the ideal to go directly from the xcore file, but the
> important part is just to be able to infer a new .xtext file from a
> given .genmodel/.ecore as well. Like "Export.." -> XText Grammer.
> Obviously the new XText project from Ecore model wizard already does
> that, so this would just be breaking that little bit of functionality out.
>
> I thought that this is probably done internally w/ a workflow so perhaps
> there would be a way to invoke that myself...


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: Generating default XText from XCore/Genmodel [message #1081838 is a reply to message #1081810] Wed, 07 August 2013 19:09 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
You might want to have a look at
org.eclipse.xtext.xtext.ui.ecore2xtext.Ecore2XtextGenerator
from our test plug-in
org.eclipse.xtext.xtext.ui.tests.
This is an MWE2 component that generates an Xtext grammar from an Ecore
file. You could use this (maybe slightly adapted) in your MWE2 workflow.


Am 07.08.13 20:24, schrieb Miles Parker:
> Christian Dietrich wrote on Wed, 07 August 2013 14:07
>> so you want to use the "New Xtext Project from Existing Ecore Model"
>> dialog with an .xcore file
>
>
> It would be the ideal to go directly from the xcore file, but the
> important part is just to be able to infer a new .xtext file from a
> given .genmodel/.ecore as well. Like "Export.." -> XText Grammer.
> Obviously the new XText project from Ecore model wizard already does
> that, so this would just be breaking that little bit of functionality out.
>
> I thought that this is probably done internally w/ a workflow so perhaps
> there would be a way to invoke that myself...


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: Generating default XText from XCore/Genmodel [message #1081844 is a reply to message #1081827] Wed, 07 August 2013 19:19 Go to previous messageGo to next message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Jan Kohnlein wrote on Wed, 07 August 2013 14:48
I am getting more and more confused Sad

The "New Xtext project from Ecore model" is a very poor way to create an
Xtext language for a given Ecore model as it creates a very generic
syntax that is really just slightly better than XML. I cannot believe it
is useful for any other purpose than to initially scaffold a grammar
from a big Ecore model and refactor that afterwards.


Agreed, I'd hope never to expose my users to that. Though it is (more than slightly) better than XML, which is already an improvement over what everyone else does!

But there is one other case... As I'm exploring the creation of a new domain model, I also need to be able to maintain instances of it. And often you don't know how well something is going to work until you play around w/ instantiations of it.

So what I'd like is a way to make that process of evolution as seamless as possible.

Quote:
The proposed Xtext way is to start your language from a grammar with an
inferred Ecore model and switch to an imported - a such manually
maintained - model when the language starts to converge. Up to that
point you didn't care what syntax your Ecore model had been defined in.
But this seems to be a good moment to think about switching to Xcore, as
you will have to change the workflow anyway and because Xcore is likely
easier to maintain.


I'm already committed to using Xcore. And I'm starting w/ a totally fresh model so I don't even have to worry about starting from an inferred Ecore model per se. I could just as easily have defined a grammar in Xtext and ended up w/ one reference model, right?

But here's the problem with that. In my experience, Domain models do not actually make good DSL's and DSL's can make lousy domain models. I think one of the biggest failures of XML (beyond the gruesome syntax) is that it mixes the two. Also of course, there are many things you can specify in xcore that they're aren't semantics for in .xtext. OTOH, what I don't want to do is spend all of my time maintaining two different models. (Added a field to my xcore model, better remember to change that in the grammar too...)

Ideally, you'd be able to simply reuse an Xcore model directly, with some kind of basic assumptions about instantiation grammar, and then have the ability to override those definitions. But that sounds like another CS project.. Wink -- I'd settle for just being able to quickly emit a bare-bones .xtext grammar for an arbitrary xcore file.

Does that make more (or less) sense?

Re: Generating default XText from XCore/Genmodel [message #1081847 is a reply to message #1081838] Wed, 07 August 2013 19:22 Go to previous messageGo to next message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Jan Kohnlein wrote on Wed, 07 August 2013 15:09
You might want to have a look at
org.eclipse.xtext.xtext.ui.ecore2xtext.Ecore2XtextGenerator
from our test plug-in
org.eclipse.xtext.xtext.ui.tests.
This is an MWE2 component that generates an Xtext grammar from an Ecore
file. You could use this (maybe slightly adapted) in your MWE2 workflow.


Cool. I'll take a look at that. But now I'm more intrigued by the idea of figuring out how to make Xcore and Xtext work together more intimately...
Re: Generating default XText from XCore/Genmodel [message #1081857 is a reply to message #1081847] Wed, 07 August 2013 19:42 Go to previous message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Actually, as I play with this more, I'm wondering if what I really want to do is experiment with the xtext model, and then as the model becomes more and more refined, emit an xcore version of it for reification! But in that case, I'd still have the problem of then recovering a new version of the same xtext grammar that matched the reified xcore model.
Previous Topic:Built in types for non Xbase based language
Next Topic:no java class from extend class
Goto Forum:
  


Current Time: Sat Apr 27 00:16:34 GMT 2024

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

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

Back to the top