Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Scoping for names with Integer type
Scoping for names with Integer type [message #819760] Tue, 13 March 2012 09:47 Go to next message
Steffen Schuette is currently offline Steffen SchuetteFriend
Messages: 26
Registered: August 2010
Junior Member
Hi,

I have a scoping problem. In one file the user shall define items that have an id of type INT and a description of type STRING. The id shall be unique. I've aded a validation check for this.

However, in another file, the user shall be able to reference these items. This workes fine if the id field is called 'name' and the type is STRING or ID. But I want to have INT there.

So how do I do the scoping in such a case?

Here is my grammar:

Model:
	(Items|References);
	
Items:
	'Items'
	items+=Item*;
	
Item:
	name=STRING description=STRING;
	//should be name=INT description=STRING;
	
References:
	'References'
	ref+=[Item|QualifiedName];
	
QualifiedName:
  ID ('.' ID)*;




Thx again,

Steffen
Re: Scoping for names with Integer type [message #819987 is a reply to message #819760] Tue, 13 March 2012 15:33 Go to previous message
Steffen Schuette is currently offline Steffen SchuetteFriend
Messages: 26
Registered: August 2010
Junior Member
Hi,

found the solution in forum post 298572.

The approach is to wrap an INT terminal in a data type rule and the use this as type in the reference:

Model:
	(Items|References);
	

Items:
	'Items'
	items+=Item*;

INT_ID: 
	INT;
	
Qualified_INT_ID:
  INT_ID ('.' INT_ID)*;
	
Item:
	name=INT_ID description=STRING;
	
References:
	'References'
	ref+=[Item|Qualified_INT_ID];
Previous Topic:Helping Xtext to resolve cross references across several files
Next Topic:Xtext/Xtend export issues.
Goto Forum:
  


Current Time: Tue Apr 07 08:08:48 GMT 2020

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

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

Back to the top