Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Use external Metamodel as library
Use external Metamodel as library [message #1854090] Mon, 01 August 2022 04:52 Go to next message
Eclipse UserFriend
We're currently defining the grammar for a DSL which uses datatypes. However the DSL language must not be used for defining those datatypes. The set of datatypes is initially fixed (e.g. to Boolean and Integer), however this can be extended in the future (e.g. to add Double, String, etc.).

Our approach to solve this, is to have a metamodel for our datatypes (just an Ecore without Xtext grammar associated) and make our Xtext grammar import it. This so far is fine, our Xtext grammar recognizes the imports and I'm able to define rules with cross-references to EClasses of the datatype metamodel.

Our concerns are more during runtime, as far as we know, the cross reference will accept EObjects already existing. To do so, we've instantiated a datatype model in an XMI file with just 2 datatypes (EObjects called Boolean and Integer). Our idea is to use the "Library" approach to make these 2 datatypes EObjects visible and usable on our textual representation. However, we're a bit lost on whether this is a "valid" approach and in positive case, which are the steps to accomplish this.

So far we've seen how the library approach works in the book "Implementing Domain Specific Languages with Xtext and Xtend" but the SmallJava language just uses one metamodel and does not fit 100% on what we're trying to achieve.

Any suggestions would be really appreciated.
Re: Use external Metamodel as library [message #1854368 is a reply to message #1854090] Tue, 16 August 2022 07:44 Go to previous message
Eclipse UserFriend
Hi Alejandro,

we use the approach you describe and it works nicely. See https://github.dev/dsldevkit/dsl-devkit/blob/316d34fb729a82717e8fb38da8001d5010ebbd42/com.avaloq.tools.ddk.typesystem/model-instance/BuiltInTypeModel.xmi#L4 for an example of an XMI file which is used in production. We have other XMI's, and it works fine, but I cannot point you to examples, since that part is not open source.

You will also find in the same plugin utilities to read the xmi file.

Regards
Previous Topic:Replacement for Xtend code generation
Next Topic:Standalone application load cross reference
Goto Forum:
  


Current Time: Fri May 16 05:51:42 EDT 2025

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

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

Back to the top