Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Import Ecore model mapping
Import Ecore model mapping [message #1866144] Wed, 22 May 2024 09:12 Go to next message
Klarise Hund is currently offline Klarise HundFriend
Messages: 25
Registered: October 2022
Junior Member
Hi,

When defining an Xtext grammar for an already existing Ecore model (hence importing the Ecore model) , can you add concepts to the grammar which are not in the Ecore model?

More specifically, should the grammar and imported Ecore model (consider it is just one Ecore model being imported):

1- have a one to one match (I believe it is possible that the textual grammar can cover also just part of the Ecore model),

2- or it could be also that you can add concepts in the grammar not present in the Ecore model, or for instance if there is a concept A in the Ecore model, this concept A in the Ecore model to be matches partly with concept B and partly with concept C in the grammar (e.g., State in the Ecore model be mapped to either Initialstate or State in the grammar).

To the best of my knowledge, it is the first case, but maybe I am missing something. Any input on this is appreciated.

Thank you!

Re: Import Ecore model mapping [message #1866159 is a reply to message #1866144] Wed, 22 May 2024 10:12 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14698
Registered: July 2009
Senior Member
Am not sure if I understand anything

You can have a import and a generate

On rules you can say

Myrule returns importedmetamodel::Type


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Wed, 22 May 2024 10:16]

Report message to a moderator

Re: Import Ecore model mapping [message #1866846 is a reply to message #1866159] Sun, 09 June 2024 07:29 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7665
Registered: July 2009
Senior Member
All options are possible.

Much the easiest is to have a 1:1 match so that the autogenerated functionality just works.

Minor mismatches can be accommodated with a little bit of custom code/ingenuity.

Significant mismatches require rather more care. Xcore may be a good example here; the Ecore model was frozen long before an Xtext grammar was considered.

Really significant mismatches may merit an intermediate model so that you have a relatively 1:1 from grammar to Concrete Syntax model and then a non-trivial M2M from Concrete Syntax model to Abstract Syntax model. OCL may be a 'good' example here; both Abstract Syntax and Grammar were 'frozen' and Concrete Syntax suggested long before Xtext was considered. I'm not at all sure that it wouldn't have been better to unfreeze something to make tooling less painful.
Previous Topic:Embedding Comments in Custom DSL Files
Next Topic:Embedding Comments in Custom DSL Files
Goto Forum:
  


Current Time: Sat Jul 20 01:55:55 GMT 2024

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

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

Back to the top