Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » cross-reference ambiguity with grammar rules
cross-reference ambiguity with grammar rules [message #1696024] Thu, 21 May 2015 09:06 Go to next message
Eleanor Richie is currently offline Eleanor RichieFriend
Messages: 125
Registered: August 2014
Senior Member
I currently have cross-reference defined in a place that will solve a lot of issues in the cross referencing but I have to OR with this cross reference another rule that causes ambiguity and adding a syntactic predicate for anyone of them totally disables the other.
Example:

leaf_name returns LeafName:

declarations=[Declarations] | otherName=ID | string=String

;

Declarations cross reference a lot of rules that has something like ('int' name=ID)
All I want from the parser/linker is to link/cross-reference the object IF and ONLY IF it found a declaration with this name otherwise it considers it as a normal ID with no cross-reference.
I tried adding syntactic predicates to anyone of them but It didnt solve my issue.
Any help will be appreciated Smile
Re: cross-reference ambiguity with grammar rules [message #1696027 is a reply to message #1696024] Thu, 21 May 2015 09:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13883
Registered: July 2009
Senior Member
Hi,

since cross references are not a parsing thing but done afterwards, the grammar from a parser point of view looks like

declarations=ID | otherName=ID | string=String

=> on parsing side this cannot be resolved.

of course you could hook into linking and could create a fake Declarations on the fly,
but this is not what you want to do.

if this is not an existing language i strictly recommend you to differentiate both cases syntactically

another possiblility would be not to cross link at all and do the byname lookup in generation, hyperlinking etc manually


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: cross-reference ambiguity with grammar rules [message #1696029 is a reply to message #1696027] Thu, 21 May 2015 09:19 Go to previous messageGo to next message
Eleanor Richie is currently offline Eleanor RichieFriend
Messages: 125
Registered: August 2014
Senior Member
what is the byname lookup? will it do the same job as cross referencing in the grammar? I hope the byname lookup can get me out of grammar cross referencing.
Does hyperlinking help in adding a link between two objects and adding them in the index?
I actually added the cross-reference just for the sake of scoping (and later I found it enabled the go to declaration and quick fixes for free Very Happy ).

[Updated on: Thu, 21 May 2015 09:29]

Report message to a moderator

Re: cross-reference ambiguity with grammar rules [message #1696030 is a reply to message #1696029] Thu, 21 May 2015 09:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13883
Registered: July 2009
Senior Member
No,

then you would not have cross reference and you would have to care yourself.


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: cross-reference ambiguity with grammar rules [message #1696032 is a reply to message #1696030] Thu, 21 May 2015 09:30 Go to previous messageGo to next message
Eleanor Richie is currently offline Eleanor RichieFriend
Messages: 125
Registered: August 2014
Senior Member
how can I start in byname lookup and these stuff?
Re: cross-reference ambiguity with grammar rules [message #1696033 is a reply to message #1696030] Thu, 21 May 2015 09:30 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13883
Registered: July 2009
Senior Member
of course you could try to dive deep into metamodel and linking and

- use a metamodelpostprocesstor to add the cross reference to the model
- make it transient though the transientvalueservice
- adopt linking with your logik.

but it cannot deeply help you with that and dont know if it will finally work out.


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Debugging parser
Next Topic:another code generation question
Goto Forum:
  


Current Time: Fri Apr 16 00:37:02 GMT 2021

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

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

Back to the top