Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Understanding cross reference
Understanding cross reference [message #757634] Sun, 20 November 2011 19:44 Go to next message
Fon Vitale is currently offline Fon VitaleFriend
Messages: 14
Registered: November 2011
Junior Member
Hi!

I have found a situation about cross reference which I don't understand. Supose our grammar is:

Model:
	( greetings+=Greeting |
	conversations+=Conversation )*
;
	
Greeting:
	'Greeting' name=ID '{' (beginings+=Hellos | endings+=Byes)* '}'
;

Hellos:
	"Hi!" name=ID (persons+=Person*)?
;

Byes:
	"Bye!" name=ID 
;

Conversation:
	'Conversation' name=ID '{' firts=[Hellos] last=[Byes] '}'
;

Person:
	'Person' name=ID
;


If we try the editor and write something like:

Greeting greet1
{
	Hi! hi1 Person luis
	Bye! bye1
}

Conversation hi1


We get:

Couldn't resolve reference to Hellos 'hi1'.	p.mydsl	/Sample/src	line: 7 /Sample/src/p.mydsl	Xtext Check (fast)


Can anybody explain me this behavour? How can I reference to Hellos and Byes object from Conversation?

Thank you!
Re: Understanding cross reference [message #757636 is a reply to message #757634] Sun, 20 November 2011 20:59 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13416
Registered: July 2009
Senior Member
Hi,

Xtext has a certain pattern how the (qualified) names are built that are use for (index based) scoping.
by default this is <parents qualifiedname>.<name> so in your case the Hellos have actually the names
greet1.hi1, since you have in your grammar a firts=[Hellos] which is short for firts=[Hellos|ID]
and means parse an ID and ref to a Hellos. the . is not allowed in ID

you have basically 2 options

(1) change the grammar to use this firts=[Hellos|FQN] ...;
FQN: ID ("." ID)*;
(2) change your iqualifiednameprovider to give the Hellos their (simple) name as qualified name.

~Christian



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:a type serializer for JvmType
Next Topic:warning: "using multiple alternatives: 1, 2 ..." in syntax for constant values
Goto Forum:
  


Current Time: Thu Apr 02 07:12:44 GMT 2020

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

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

Back to the top