Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Reference does not work
Reference does not work [message #1386469] Tue, 17 June 2014 18:03 Go to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEMFriend
Messages: 96
Registered: April 2013
Member
Hi,

I have a parseRule named ElementSyntax which can provide this form of element : {e1}, {e2,e12,e9}.

What I want is to get the reference of ElementSyntax. Below, you will see how I wrote my grammar but it's not working.

ElementSyntax :
	'{'	elt=ElementID (',' eltIDs+=ElementID)* '}' ;

ElementID:
	name=ID ;

ExcludeDecision:
	'and' 'exclude' rule=[Rule] 'for' elementID=[ElementSyntax] ;


Any help is greatly appreciated.
Best Regards,
Felix
Re: Reference does not work [message #1386470 is a reply to message #1386469] Tue, 17 June 2014 18:05 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

if you dont have an attribute named 'name' you have to adapt IQualifiedNameProvider(subclassing DefaultDeclarativeQualifiedNameProvider)

what shall be the ElementSyntax name? it has multiple ElementIDs in your case.

can you share a complete reproducable example?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Tue, 17 June 2014 18:07]

Report message to a moderator

Re: Reference does not work [message #1386476 is a reply to message #1386470] Tue, 17 June 2014 18:26 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEMFriend
Messages: 96
Registered: April 2013
Member
Hi,

Here is the complete reproducable example:
http://tinypic.com/view.php?pic=2hhf9md&s=8#.U6CIFPl_tyU

The complete grammar
Quote:

/********************** Alternative *************************/
Alternative:
'Alternative' id=INT ':'
for='for' name=ElementSyntax select='select' ':'
rule=Rule (params+=RuleList)* ';' ;

RuleList:
'or' rule=Rule ;
/********************** End Alternative **********************/



/********************** Decision *************************/
Decision:
'Decision' id=Entier ':' select=Select ';'
'consequences' ':' consequenceDecl=ConsequencesDeclaration ;

ConsequencesDeclaration:
NoneDecision | (subDecisions+=SubDecision)+ | SelectDecision
;

NoneDecision:
name='none' ';' ;

SubDecision:
'decision' i=[Entier]'.'j=Entier ':' select=Select (excludes+=ExcludeDecision)+ ';' ;

SelectDecision:
select=Select (excludes+=ExcludeDecision)+ ';' ;

ExcludeDecision:
'and' 'exclude' rule=[Rule] 'for' elementID=ElementSyntax ; //[ElementSyntax]

Select:
'select' rule=[Rule] 'for' elementID=ElementSyntax ; //[ElementSyntax]

Entier :
id=INT ;
/********************** End Decision **********************/

ElementSyntax :
'{' elt=ElementID (',' eltIDs+=ElementID)* '}' ;
Re: Reference does not work [message #1386477 is a reply to message #1386476] Tue, 17 June 2014 18:28 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEMFriend
Messages: 96
Registered: April 2013
Member
Hi,

Here is the complete example:
http://i57.tinypic.com/2hhf9md.jpg
Re: Reference does not work [message #1386478 is a reply to message #1386477] Tue, 17 June 2014 18:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Still the question,
what is the semantic meaning of

ElementSyntax :
'{'	elt=ElementID (',' eltIDs+=ElementID)* '}' ;


and that is the name of an ElementSyntax

the grammar says:

a ElementSyntax has a elt of type ElementID and a list of ElementID named eltIDs

so why not

ElementSyntax :
'{'	name=ID (',' eltIDs+=ElementID)* '}' ;


or as i said adapt IQualifiedNameProvider


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference does not work [message #1386480 is a reply to message #1386478] Tue, 17 June 2014 18:43 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
http://christiandietrich.wordpress.com/2011/07/16/iqualifiednameproviders-in-xtext-2-0/

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference does not work [message #1386492 is a reply to message #1386480] Tue, 17 June 2014 20:28 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEMFriend
Messages: 96
Registered: April 2013
Member
Hi Christian,
I did what you said but from
ElementSyntax :
'{'	elt=ElementID (',' eltIDs+=ElementID)* '}' ;

I can retreive elt and not all ElementSyntax (elt + eltIDs + identifier).
I am saying that because as you can see in the snapshot, {E1,E2, E112} isn't {E1,E2,E3} so I should have get an error.

http://i59.tinypic.com/drxo2.jpg

How to make a reference to the exact object ElementSyntax ({E1} or {E1,E2,E3} in my example).

Thank,
Felix
Re: Reference does not work [message #1386493 is a reply to message #1386492] Tue, 17 June 2014 20:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

i still do no get your semantics. to you say the ElementSyntax
has the the names E1 E2 and E3????

if so you have to adapt the IDefaultResourceDescriptionStrategy or rethink your grammar to

ElementSyntaxContainer :
'{'	syntaxes+=ElementSyntax* (',' syntaxes+=ElementSyntax)* '}' ;

ElementSyntax: name=ID;

... 'for' elementID=ElementSyntaxContainer ; /


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference does not work [message #1386495 is a reply to message #1386493] Tue, 17 June 2014 20:46 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
and you may have to adapt scoping as well,
but i still do not understand your semantics so it is hard to tell


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference does not work [message #1386498 is a reply to message #1386495] Tue, 17 June 2014 20:59 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
P.S: which Element Syntaxes shall be visible in a Select?
only the ones from the rule? if you you definitively have to adapt scoping

Select:
'select' rule=[Rule] 'for' elementID=[ElementSyntax]  ; //

@Inject IQualifiedNameProvider nameProvider
IScope scope_Select_elementID(Select ctx, EReference r) {
ruleElements = ctx.getRule().getAllElements() //your logic, with partial grammar not to tell.
Scopes.scopeFor(ruleElments,nameProvider,IScope.NULLSCOPE)
}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference does not work [message #1386591 is a reply to message #1386493] Wed, 18 June 2014 13:35 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEMFriend
Messages: 96
Registered: April 2013
Member
Hi,

What I am calling the ElementSyntax is what you actually called ElementSyntaxContainer.
I do not want a reference to a an ID but to an object who will have this form {ID, ID2, ..., IDn}.

Root:
    root+=RootElement+;

RootElement:
    ElementIwantAReference | GetReference;

GetReference:
    retreiveReference = [ElementIwantAReference];

ElementIwantAReference:
    '{' elt=Element (elts+=Element)* '}';

Element: name=ID;
Re: Reference does not work [message #1386592 is a reply to message #1386591] Wed, 18 June 2014 13:41 Go to previous messageGo to next message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEMFriend
Messages: 96
Registered: April 2013
Member
ElementSyntax is for an and element (parseRule) like STRING.
In Select Rule and ElementSystax shoul be both visible.
Re: Reference does not work [message #1386597 is a reply to message #1386592] Wed, 18 June 2014 14:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

you what you actually want to have is:

the name of an ElementSyntax is the whole thing???? {E1,E2,E3}

ElementSyntax:
	name=ElementSyntaxName
;

ElementSyntaxName: '{' ID (',' ID)* '}';

.... 'for' element=[ElementSyntax|ElementSyntaxName];



[ElementSyntax|ElementSyntaxName] means ElementSyntax by ElementSyntaxName


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Reference does not work [message #1386603 is a reply to message #1386597] Wed, 18 June 2014 14:52 Go to previous message
Félix SILINOU KAMDEM is currently offline Félix SILINOU KAMDEMFriend
Messages: 96
Registered: April 2013
Member
Yes it works,

thank you Christian.
Previous Topic:Integrate and validate OCL grammer in XText
Next Topic:Adding function calls to DSL syntax
Goto Forum:
  


Current Time: Thu Mar 28 20:39:18 GMT 2024

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

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

Back to the top