Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Inherit properties of supertype
Inherit properties of supertype [message #1403693] Fri, 25 July 2014 11:41 Go to next message
Stephan S. is currently offline Stephan S.Friend
Messages: 2
Registered: July 2014
Junior Member
Hi there,

I work on a grammar for parsing an existing language, which can not be changed. I want to process the generated EMF model instance later. Parsing works fine, but I want to tweak the resulting model a bit in order to make it easier to handle.

At the moment I try to create a supertype with some properties. The relevant part of my grammer looks like this:

ClassifierWithModifier:
	modifiers+=Modifier* classifier=Classifier;

Classifier:
	ClassDeclaration | InterfaceDeclaration;


What I would like to have is a supertype classifier, which contains the modifier property. The class and interface declaration shall be subtypes of classifier. Its quite similar to the example given in [1], but I have to parse the property before the classifier.

Is this even possible?

Thanks in advance
Stephan

[1] http://www.eclipse.org/forums/index.php/t/214166/
Re: Inherit properties of supertype [message #1403729 is a reply to message #1403693] Fri, 25 July 2014 16:08 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13280
Registered: July 2009
Senior Member
hi,

first you can always switch to a manually maintained metamodel.

the xtext metamodel inferrer should pull up the common features anyway

Classifier:
ClassDeclaration | InterfaceDeclaration;

enum Modifier: public | private;

ClassDeclaration: modifiers+=Modifier* "class" name=ID;

InterfaceDeclaration: modifiers+=Modifier* "interface" name=ID;


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Inherit properties of supertype [message #1403836 is a reply to message #1403729] Mon, 28 July 2014 08:23 Go to previous message
Stephan S. is currently offline Stephan S.Friend
Messages: 2
Registered: July 2014
Junior Member
Hi,

thanks for your reply. I noticed this feature, but it seems to be not as reliable as expected. For the simple case given in your example this works well. Are there any known limitations in complex situations?

At the moment I'm struggeling to find a short self contained example where the problem occurs. For the example below the property extraction does not work for my grammer. If I remove some features (not listed here) it works.

ClassDeclaration:
	NormalClassDeclaration | EnumDeclaration;

NormalClassDeclaration:
	'class' identifier=ID typeparameters=TypeParameters?
	('extends' superType=Type)?
	('implements' implementedTypes=TypeList)?
	classbody=ClassBody;

EnumDeclaration:
	'Enum' identifier=ID ('implements' implementedTypes=TypeList)? enumbody=EnumBody;


I will try to come up with a short example in the next days.

Best regards
Stephan
Previous Topic:Xbase: proposals of non-final variables in lambdas
Next Topic:Embeddededitor - Keybinding conflicts occur
Goto Forum:
  


Current Time: Mon Dec 16 10:19:13 GMT 2019

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

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

Back to the top