Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Grammar mixin
Grammar mixin [message #1765596] Mon, 12 June 2017 12:33 Go to next message
Eclipse UserFriend
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 12:36 Go to previous message
Eclipse UserFriend
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' ...
Previous Topic:FXDiagram does not work with Eclipse Neon?
Next Topic:Adding a genmodl to the workflow
Goto Forum:
  


Current Time: Tue Jul 08 14:15:58 EDT 2025

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

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

Back to the top