Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » adding default members
adding default members [message #1475478] Sun, 16 November 2014 08:57 Go to next message
Yoel Pinhas is currently offline Yoel PinhasFriend
Messages: 17
Registered: October 2013
Junior Member
Hi All,

Lets say I have the following grammar:
Entity: 'entity' name=ID '{' members+=Member* '}';

Member: Field | Method;

Field: 'val' type=[Entity] name=ID
Method: 'def' type=[Entity] name=ID '{' expressions+=Expression* '}'


I would like to have a field member for each entity named 'this' the type of the entity itself, and, a method named 'this' with the same type as well.

the poor-man solution i currently use is to validate that are indeed such members (with the correct type and name)
but this is boilerplate code that i would like to avoid since it repeats itself.

I've tried to create a new Field using emf factory create methods and add it to the entity instance but i got a 'dangling reference' error message

What is a proper way of doing this?
Thank you in advance Smile

[Updated on: Sun, 16 November 2014 09:05]

Report message to a moderator

Re: adding default members [message #1475483 is a reply to message #1475478] Sun, 16 November 2014 09:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

have a look at http://xtextcasts.org/episodes/18-model-optimization


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: adding default members [message #1475488 is a reply to message #1475483] Sun, 16 November 2014 09:06 Go to previous messageGo to next message
Yoel Pinhas is currently offline Yoel PinhasFriend
Messages: 17
Registered: October 2013
Junior Member
Thanks
Re: adding default members [message #1475513 is a reply to message #1475488] Sun, 16 November 2014 09:35 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
p.s.: for the expression part: simply adapt scoping.

pps: maybe not reinventing the wheel and using xbase is even better


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Problem with xtend
Next Topic:XML based DSL using xTEXT
Goto Forum:
  


Current Time: Tue Apr 23 06:57:12 GMT 2024

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

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

Back to the top