Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext cardinality meta model(Looking for model of cardinalities)
Xtext cardinality meta model [message #1803655] Wed, 06 March 2019 09:29 Go to next message
Jakub Vanek is currently offline Jakub VanekFriend
Messages: 1
Registered: March 2019
Junior Member
I am currently working on a project, where I am creating a feature model out of Xtext grammar. My task is to transform grammar syntax into a CSV file importable into eclipse plug-in pure::variants.

Feature model is basicaly tree of features. These features are different types ( mandatory, optional, alternative etc. ).

For constructing the tree, I am using generated ecore meta model of my xtext grammar syntax. This file ( .ecore ) is basically a XML file with objects of the grammar. It is consistent, simple and easy to create tree out of.

My problem is, that I need to assign types ( mandatory, alternative etc. ) to the nodes of my created tree. These types of features correspond to a cardinality operators. These operators are written in xtext grammar like this: ´(no operator)´, ´?´, ´*´ and ´+´ ( this can be seen in xtext user manual section 2.1.3 Problem is, that these cardinalities of xtext grammar don't seem to be anywhere to find. I thought that they would appear in .ecore or .genmodel files, but there are no cardinalities at all.

I imagine that if xtext is able to check and control these cardinalities, it has to have some kind of meta model, where these cardinalities can be seen and are easily gettable ( something like .xml file similiar to .ecore or .genmodel file).

So my question is: Is there some kind of xtext generated file, which contains these cardinalities? If there is not, I would have to somehow get these cardinalities out of grammar itself, but it would be unneccessarily time consuming and complicated, maybe even impossible, because written grammar doesn't fully correspond with ecore metamodel I am getting my feature tree out of and is really complex.

Only generated file I was able to find, which contains something "maybe useful" is generated file ( XXXX stands for name of the grammar ), which is complex generated file, with a lot of library depedencies and I have no idea how to get these cardinalities out of that or if it is even possible. I imagine that there is a possibility, because this file uses a lot of IGrammarAccess methods, such as getRule(), getKeyword() and more, but I am not able to use this file, or print something out of it, because it is a generated file and I am not able to run it on itself.

If there is not some kind of meta model I am looking for, is there any possibility to somehow get these cardinalities different way during generating?

Thank you very much for your answers.
Re: Xtext cardinality meta model [message #1803920 is a reply to message #1803655] Wed, 13 March 2019 16:21 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13612
Registered: July 2009
Senior Member
cross post

Need professional support for Xtext, Xpand, EMF?
Go to:
Twitter : @chrdietrich
Blog :
Previous Topic:Xtext Language Server not working, how to investigate?
Next Topic:DSL with white spaces
Goto Forum:

Current Time: Fri Sep 25 23:48:51 GMT 2020

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

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

Back to the top