Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Import Ecore model mapping
Import Ecore model mapping [message #1866144] Wed, 22 May 2024 05:12 Go to next message
Eclipse UserFriend
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 06:12 Go to previous messageGo to next message
Eclipse UserFriend
Am not sure if I understand anything

You can have a import and a generate

On rules you can say

Myrule returns importedmetamodel::Type

[Updated on: Wed, 22 May 2024 06:16] by Moderator

Re: Import Ecore model mapping [message #1866846 is a reply to message #1866159] Sun, 09 June 2024 03:29 Go to previous message
Eclipse UserFriend
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: Tue Jul 15 16:08:00 EDT 2025

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

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

Back to the top