Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Disambiguate between reference and ValidID
Disambiguate between reference and ValidID [message #1731570] Fri, 06 May 2016 18:05 Go to next message
Eclipse UserFriend
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 01:03 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Disambiguate between reference and ValidID [message #1731578 is a reply to message #1731577] Sat, 07 May 2016 01:05 Go to previous message
Eclipse UserFriend
Of you Reality dont Want to Cross ref you have do adapt linking.
Previous Topic:Check if EObject is fully parsed
Next Topic:Type for variable
Goto Forum:
  


Current Time: Sun Jul 13 07:08:04 EDT 2025

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

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

Back to the top