Include/Import other models in an Xtext DSL for an existing ecore model [message #696111] |
Wed, 13 July 2011 09:43 |
Jeppe Cramon Messages: 37 Registered: July 2009 |
Member |
|
|
Hi
I'm unsure how to define references to other definitions in my ecore metamodel.
I currently have an ecore metamodel called Structure which can contain Attributes. An attribute can have a type which references an IntrinsicType instance. IntrinsicType is defined in the ecore metamodel Types (Defined as children of a top level TypeContainer). Also an Attribute can point to a different Structure.
I've created an Xtext DSL for the Types ecore meta model and one for the Structure meta model.
When it comes to creating instances using these DSL's I would like to be able to reference Types, defined in an instance of the Types DSL, and be able to reference Structures defined in other instances of the Structure DSL from with in a given Structure DSL instance (in general there will be one Types DSL instance and a Structure DSL instance for every structure in the system).
The Structure DSL that works with Attributes looks like the following:
grammar dk.example.structure.dsl.StructureDsl with org.eclipse.xtext.common.Terminals
import "platform:/resource/dk.example.metamodels/model/Structure.ecore"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
import "platform:/resource/dk.example.metamodels/model/Types.ecore" as types
Attribute returns Attribute:
{Attribute}
'Attribute'
name=EString
'{'
('foreignKeyReference' foreignKeyReference=[Structure])?
('type' type=[types::IntrinsicType])?
'}';
For DSLs that generate their own meta model I've seen examples of using import using QualifiedName and Include using URI, but I have no idea on how to model this into my Structure metamodel and connect this properly in the xtext DSL defined above...
Any tips?
/Jeppe
[Updated on: Wed, 13 July 2011 09:46] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04125 seconds