Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Qualified Name to a custom scope(attr.attr.attr)
Qualified Name to a custom scope [message #764108] Sun, 11 December 2011 11:24 Go to next message
Moritz   is currently offline Moritz Friend
Messages: 22
Registered: July 2011
Junior Member
Hi,

I am stuck with the qualified name provider. Can someone help me with the right approach for the following?

I try to address an attribute with a path notation as shown in the following example. When using the default behaviour, the FQN only allows me to reference the attributes statical like A.a or B.r; but what I want is to use the scope of the attribute path.

entity A {
	attr a
}

entity B {
	attr a
	attr r : A
}

entity C {
	attr r : B
	
	set r = 3	// works
	set r.a = 4	// ?
	set r.r.a = 5	// ?
}


Here is the grammar for this example.

Model:
	(entities += Entity)*;
	
Entity:
	'entity' name = ID '{'
		(attributes += Attribute)*
		(settings += Setting)*
	'}';

Attribute:
	'attr' name = ID (':' type = [Entity])?;

Setting:
	'set' attributePath = [Attribute|FQN] '=' value = INT;
//	'set' path += [Attribute] ('.' path += [Attribute])* '=' value = INT; // Alternative approach

FQN:
	ID ('.' ID)*;



When the attribute path has a fixed length, the path-sensitive scoping works great with a custom scope provider.
To allow a path of arbitrary length, I also tried to use attributePath+=[Attribute]*, but when the ScopeProvider is asked for the next scope, I don't know which path element is currently visited. The FQN approach only lets me choose the static qualified names...

Can someone help me here, please?

Best Regards,
Moritz
Re: Qualified Name to a custom scope [message #764124 is a reply to message #764108] Sun, 11 December 2011 12:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

one basic idea to solv such a problem is described here http://dslmeinte.wordpress.com/2010/08/16/path-expressions-in-entity-models/

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Qualified Name to a custom scope [message #764194 is a reply to message #764124] Sun, 11 December 2011 16:24 Go to previous messageGo to next message
Moritz   is currently offline Moritz Friend
Messages: 22
Registered: July 2011
Junior Member
Hi,

ok, this looks like Meinte wrote this article just to anticipate an explanation for what seems to be exactly my question + sample. Somehow it didn't came to my mind that "xtext path expression" are already the correct search terms. @Meinte, I googled for "xtext qualified name scope" instead.

Thank you very much, Christian

Best regards
Moritz


P.S. For future readers: There is a link to an updated Post at the end of the article

[Updated on: Sun, 11 December 2011 16:25]

Report message to a moderator

Re: Qualified Name to a custom scope [message #764512 is a reply to message #764194] Mon, 12 December 2011 10:33 Go to previous message
Meinte Boersma is currently offline Meinte BoersmaFriend
Messages: 434
Registered: July 2009
Location: Leiden, Netherlands
Senior Member
@Christian: thanks for plugging my posts! Smile (Saves me from shamelessly having to do so Wink)

Previous Topic:Strange errors when using several model files
Next Topic:Trouble with semantic highlighting
Goto Forum:
  


Current Time: Fri Apr 19 06:09:15 GMT 2024

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

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

Back to the top