Skip to main content



      Home
Home » Modeling » TMF (Xtext) » adding default members
adding default members [message #1475478] Sun, 16 November 2014 03:57 Go to next message
Eclipse UserFriend
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 04:05] by Moderator

Re: adding default members [message #1475483 is a reply to message #1475478] Sun, 16 November 2014 04:01 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

have a look at http://xtextcasts.org/episodes/18-model-optimization
Re: adding default members [message #1475488 is a reply to message #1475483] Sun, 16 November 2014 04:06 Go to previous messageGo to next message
Eclipse UserFriend
Thanks
Re: adding default members [message #1475513 is a reply to message #1475488] Sun, 16 November 2014 04:35 Go to previous message
Eclipse UserFriend
p.s.: for the expression part: simply adapt scoping.

pps: maybe not reinventing the wheel and using xbase is even better
Previous Topic:Problem with xtend
Next Topic:XML based DSL using xTEXT
Goto Forum:
  


Current Time: Fri Sep 26 03:28:07 EDT 2025

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

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

Back to the top