Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Disambiguate between reference and ValidID
Disambiguate between reference and ValidID [message #1731570] Fri, 06 May 2016 22:05 Go to next message
Larry LeBron is currently offline Larry LeBronFriend
Messages: 124
Registered: October 2015
Senior Member
I have a point in my grammar where I would like to handle either a ValidID or a cross-reference.

However, this creates an ambiguity, as the cross-reference also relies on the RULE_ID.

Is there a good solution to this, other than inserting some kind of special token?

Here's a simple example grammar to illustrate:

Declaration:
   name=ID
;

Reference:
   IDReference | DeclarationReference
;

IDReference:
   idRef = ValidID ';'
;

DeclarationReference:
   declRef = [Declaration] ';'
;


I could just use the ValidID rule, and then internally check if such an ID matches a known declaration. If that's the best option, can do, though it'll mean losing the inherent benefits of the cross-reference system.
Re: Disambiguate between reference and ValidID [message #1731577 is a reply to message #1731570] Sat, 07 May 2016 05:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13193
Registered: July 2009
Senior Member
In case you dont know it. [Type] is Short for [Type|ID] so an ID will be used. Of Course you can change this to whatever you like e.g [Type|YourID] with YourID being a Terminal Or a datatype rule

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Disambiguate between reference and ValidID [message #1731578 is a reply to message #1731577] Sat, 07 May 2016 05:05 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13193
Registered: July 2009
Senior Member
Of you Reality dont Want to Cross ref you have do adapt linking.

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Check if EObject is fully parsed
Next Topic:Type for variable
Goto Forum:
  


Current Time: Sat Nov 16 01:32:04 GMT 2019

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

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

Back to the top