Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Finding referencing objects
Finding referencing objects [message #946475] Tue, 16 October 2012 08:21 Go to next message
Quentin Boucher is currently offline Quentin BoucherFriend
Messages: 27
Registered: July 2012
Junior Member
Hello,

Here is a simplified version of my grammar:

Model: Feature+;
Feature: 
       {Root_Feature} 'root' name=ID '{' bodyItems+=Feature_Body_Item+ '}'	
     | ref=[Hierarchical_Feature] '{' bodyItems+=Feature_Body_Item+ '}';

Feature_Body_Item:
	| Attribute
	| Feature_Group;

Feature_Group:
	'group' '{' sub_features+=Hierarchical_Feature (',' sub_features+=Hierarchical_Feature)* '}';

Hierarchical_Feature:
	    optional?=('opt')? name=ID ('{' bodyItems+=Feature_Body_Item+'}')?;


The exact grammar of attributes is not important here.
The ref element in "Feature" allows to extend the content of a previously defined Hierarchical_Feature.

For my scope provider, I'd like to find all references to a given Hierarchical_Feature in order to get all attributes declared in that Hierarchical_Feature as well as in its extension points. How can I reach that goal? I read a bit about EcoreUtil.UsageCrossReferencer.find but don't manage to reach my goal.

Thank you for your help!

Quentin
Re: Finding referencing objects [message #946657 is a reply to message #946475] Tue, 16 October 2012 11:27 Go to previous messageGo to next message
Quentin Boucher is currently offline Quentin BoucherFriend
Messages: 27
Registered: July 2012
Junior Member
If I use "EcoreUtil.UsageCrossReferencer.find", I get "An internal error occurred during: "Xtext validation". Cyclic resolution of lazy links"

Thank you for your help!
Re: Finding referencing objects [message #946666 is a reply to message #946657] Tue, 16 October 2012 11:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Do you call this code during scoping?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Finding referencing objects [message #946717 is a reply to message #946666] Tue, 16 October 2012 12:42 Go to previous messageGo to next message
Quentin Boucher is currently offline Quentin BoucherFriend
Messages: 27
Registered: July 2012
Junior Member
I'd like so but I don't know if it possible...
Re: Finding referencing objects [message #946813 is a reply to message #946717] Tue, 16 October 2012 14:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
No it is not possible. You may have to read the node model instead.
Nodemodelutil.findnodesforfeature or something like that

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Finding referencing objects [message #946975 is a reply to message #946813] Tue, 16 October 2012 17:44 Go to previous message
Quentin Boucher is currently offline Quentin BoucherFriend
Messages: 27
Registered: July 2012
Junior Member
Thank you for your answer! I managed to implement it thanks to NodeModelUtils.

I have another question related to operator precedence. I have implemented mine as follow:

Expression12 returns ComplexExpression: 
	Expression11 ({If.left=current} '?' right+=Expression12':' right+=Expression11)*;

Expression11  returns ComplexExpression: 
	Expression10 ({LeftImplication.left=current}'<-' right=Expression10)*;

Expression10  returns ComplexExpression:
	Expression9 ({RightImplication.right=current}'->' left=Expression9)*;

Expression9  returns ComplexExpression:
	Expression8 ({BiImplication.left=current}'<->' right=Expression8)*;

Expression8  returns ComplexExpression:
	Expression7 ({Or.right=current}'||' left=Expression7)*;

Expression7  returns ComplexExpression:
	Expression6 ({And.right=current}'&&' left=Expression6)?;

Expression6  returns ComplexExpression:
	  Expression5 (((({Equality.left=current}'==' | {Inequality.left=current}'!=') right=Expression5) | ({In.left=current}'!=')'in' right=Set_Expression))?;

Expression5  returns ComplexExpression:
	Expression4 =>(({Less.left=current} '<'=>({Lessequal.left=current} '=')?|{Greater.left=current} '>'=>({Greaterequal.left=current} '=')?) right=Expression4)?;

Expression4  returns ComplexExpression:
	Expression3 (({Plus.right=current}'+'| {Minus.right=current}'-') left=Expression3)?;

Expression3  returns ComplexExpression:
	Expression2 (({Multiplication.right=current}'*'| {Division.right=current}'/') left=Expression2)?;

Expression2 returns ComplexExpression:
	Expression (({Excludes.left=current}'excludes' | {Requires.left=current}'requires') right=Expression)?;



Expression:
	  op='!' expression=Expression12
	| op='-' expression=Expression12
	| op='(' expression=Expression12 ')'
	| op='abs' '(' expression=Expression12')'
	| op='sum' '(' (expression_list=Expression_List | child=Children_ID) ')'	
	| op='mul' '(' (expression_list=Expression_List | child=Children_ID) ')'
	| op='min' '(' (expression_list=Expression_List | child=Children_ID) ')'
	| op='max' '(' (expression_list=Expression_List | child=Children_ID) ')'	
	| op='count' '(' (children='children' | children='selectedchildren') ')'	
	| op='avg' '(' (expression_list=Expression_List | child=Children_ID) ')'	
	| op='and' '(' (expression_list=Expression_List | child=Children_ID) ')'	
	| op='or' '(' (expression_list=Expression_List | child=Children_ID) ')'	
	| op='xor' '(' (expression_list=Expression_List | child=Children_ID) ')'
	| value='true'
	| value='false'
	| value=Integer
	| value=Real
	| ref=Long_ID;


However, all my "ComplexExpression" are ambiguous (e.g. Decision can match input such as "'<-'" using multiple alternatives: 1, 2). The same problem applies to the '-' unary operator. Do you have any idea how to solve this? Is enabling backtracking the single solution?

Thank you!
Previous Topic:[xbase] narrow cross references for java based JvmTypes
Next Topic:How do I create Java & Python parsers for the same Xtext DSL
Goto Forum:
  


Current Time: Tue Apr 23 11:04:40 GMT 2024

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

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

Back to the top