Import Ecore model mapping [message #1866144] |
Wed, 22 May 2024 05:12  |
Eclipse User |
|
|
|
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 #1866846 is a reply to message #1866159] |
Sun, 09 June 2024 03:29  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.28541 seconds