Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to imply a value for a field via the grammar
How to imply a value for a field via the grammar [message #1033457] Thu, 04 April 2013 08:42 Go to next message
Chris Ainsley is currently offline Chris AinsleyFriend
Messages: 78
Registered: March 2010
Location: UK
Member
Hello,

I have designed a DOM-like DSL, and created a basic XText definition.

Node:
	 (type=ID  name=STRING  )
	 '{'
	 (items+=ModelItem*) '}'
;

NodeWithoutId returns Node:
	 ( (type=ID ))
	 '{'
	 (items+=ModelItem*) '}'
;



The 'type' field represents the type of a node, and the 'name' field represents the identifier of a field.

I have two types of node. One with an id and one without an ID, and I'm auto-generating the model from the .xtext file.

My question is, for NodeWithoutId, how do I set the name and the type field to the value of what is currently just the type field? That is, for Node, the name and type should be independent, but for the NodeWithoutId grammar, the name and the type should be one word in the grammar but the same value should be stored in both the name and the type fields.

Thanks.
Re: How to imply a value for a field via the grammar [message #1034618 is a reply to message #1033457] Fri, 05 April 2013 17:13 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
Hi,

are you talking about cross refs (in this case a iqualifiednameprovider customization would do the trick)
if you want a eoperation or a derived eattribute in the metamodel then have a look at
IXtext2EcorePostProcessor

see http://christiandietrich.wordpress.com/2011/07/22/customizing-xtext-metamodel-inference-using-xtend2/
for an example


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Indentation around formatting
Next Topic:Context sensitive references?
Goto Forum:
  


Current Time: Fri Apr 26 19:51:39 GMT 2024

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

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

Back to the top