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 "http://www.eclipse.org/emf/2002/Ecore" as ecore
Import "http://www.example.org/uRDF" as uRDF
Import "http://www.xtext.org/example/expressions/ExprDsl" as expr


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

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?

Thanks
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 offline Christian DietrichFriend
Messages: 14665
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' ...


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:FXDiagram does not work with Eclipse Neon?
Next Topic:Adding a genmodl to the workflow
Goto Forum:
  


Current Time: Wed Apr 24 16:06:16 GMT 2024

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

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

Back to the top