I am writing a grammar and I have two problems that I couldn't resolve.
This is the grammar :
'$FCT_'name=ID '.' field=ID ';' ;
'For' name=ID 'in' Table=ID ';'
contents+=(Variable |Loop |Fonction)+
'$' 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?