Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Grammar mixin
Grammar mixin [message #1765596] Mon, 12 June 2017 16:33 Go to next message
Carsten Wrobel is currently offline Carsten WrobelFriend
Messages: 9
Registered: May 2017
Junior Member
Is it possible to combine 2 different meta models - defined in 2 different ecore files and mix them together in a common grammar?

Example grammar:

Grammar org.xtext.urdf.Dsl with org.eclipse.xtext.common.Terminals

Import "" as ecore
Import "" as uRDF
Import "" as expr

Robot returns uRDF :: Robot:
'Robot' name = ID
(Link + = link | joint + = joint) *

The type Robot relates to the uRDF model and Addition relates to the expression model. Since Addition is not included as a feature in Robot, the reference fails.

The expression model is independent of uRDF, but not vice versa. In order to get the references in place, the expression model can be built into uRDF, but we would like to keep the models separate for clarity. Therefore, the question of it is possible to connect the types from different ecore files in a grammar.

It seems like multiple inheritance (eg.-> grammar urdf with super, expr, sub1, sub2) maybe could solve this, and from earlier posts I saw that xtext didn't support that. Any update to that?

Re: Grammar mixin [message #1765597 is a reply to message #1765596] Mon, 12 June 2017 16:36 Go to previous message
Christian Dietrich is currently online Christian DietrichFriend
Messages: 14286
Registered: July 2009
Senior Member
You could infer a third model and introduce a subclass of robot that has that feature

(Generate statement in grammar)

MyRobot returns udrf::Robot:
{MyRobot} 'Robot' ...

Need professional support for Xtext, Xpand, EMF?
Go to:
Twitter : @chrdietrich
Blog :
Previous Topic:FXDiagram does not work with Eclipse Neon?
Next Topic:Adding a genmodl to the workflow
Goto Forum:

Current Time: Sat Jul 02 18:37:38 GMT 2022

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

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

Back to the top