Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Cross reference customisation
Cross reference customisation [message #907151] Mon, 03 September 2012 12:00 Go to next message
asma geg is currently offline asma gegFriend
Messages: 5
Registered: April 2012
Junior Member
I am writing a grammar and I have two problems that I couldn't resolve.
This is the grammar :
Fonction :
	'$FCT_'name=ID '.' field=ID ';' ;
Loop :
	'For' name=ID 'in' Table=ID ';'
	contents+=(Variable |Loop |Fonction)+

Variable :
	'$' name=[Loop] '.' field=ID ';';

1_ My first problem is related to the customisation of the cross reference that links variable to loop. In fact, without any customisation , it is possible to write :
For i in table1;
For j in table2;
$j.attribute;   // We are not in the j-loop

because the cross reference refers to all the loops of the model.
However, I want the variable to refer only to the loops that contain it. I guess that this is possible by implementing a method in the scopeProvider file, but I don't know how! Any idea?

2_ The second problem is due to a conflict between the fonction and the variable. In fact, if I write
For F in table;

xtext returns an error because it expects to have $FCT and didn't understand that in this context, the content is a variable. What do you suggest?
Re: Cross reference customisation [message #1006114 is a reply to message #907151] Wed, 30 January 2013 00:26 Go to previous message
Ian McDevitt is currently offline Ian McDevittFriend
Messages: 70
Registered: December 2012
Location: Belfast
For the second problem try splitting the '$' away from the 'FCT'. Then the tokenizer will not be able to go down the wrong path when it sees $F.
Fonction :
	'$' 'FCT_' name=ID '.' field=ID ';' ;

I haven't tried this but I'm guessing it will consume the '$' and then try the next token which is 'F' and which can only be Loop reference.
Previous Topic:About cross references & scoping
Next Topic:JvmModelInferrer refer to a java class not in the model
Goto Forum:

Current Time: Sat May 30 22:57:56 GMT 2020

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

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

Back to the top