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

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

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

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

	"Bye!" name=ID 

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

	'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: 13761
Registered: July 2009
Senior Member

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.


Need professional support for Xtext, Xpand, EMF?
Go to:
Twitter : @chrdietrich
Blog :
Previous Topic:a type serializer for JvmType
Next Topic:warning: "using multiple alternatives: 1, 2 ..." in syntax for constant values
Goto Forum:

Current Time: Tue Mar 02 21:21:12 GMT 2021

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

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

Back to the top