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 04:42 Go to next message
Chris Ainsley is currently offline Chris Ainsley
Messages: 74
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 13:13 Go to previous message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6228
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
Previous Topic:Indentation around formatting
Next Topic:Context sensitive references?
Goto Forum:
  


Current Time: Thu Aug 28 05:23:11 EDT 2014

Powered by FUDForum. Page generated in 0.01517 seconds