Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Scoping Question (Beginner)
Scoping Question (Beginner) [message #932066] Wed, 03 October 2012 20:06 Go to next message
Andreas Studer is currently offline Andreas Studer
Messages: 2
Registered: July 2009
Junior Member
Hello all

Given the following language definition (simplified to cover the problem ;-):
Model:
	mainclasses+=MainClazz*
	takes+=Take*
;
	
Clazz:
	MainClazz|SubClazz;

MainClazz:
	'main' name=ID
	'subclasses' subclazz+=SubClazz* '.'
;

SubClazz:
	name=ID
;

Take:
	'take' name=ID
	'Class' clazz=[Clazz]
;

So in this constellation, I only have access with the generated DSL to the instances of "MainClazz" in Take.clazz. However, if I have a look at the generated ecore model, it seems to me as I would have the possibility of referencing all instances of SubClazz and MainClazz with the superclass Clazz in the attribute Take.clazz (as I would expect).

index.php/fa/11712/0/

Is there a way to get all instances of Clazz availabe for Take.clazz? Is this in context with the scoping feature of xtext? Or should I do it completely different?

Thanks for any help or clarification.

Andreas
  • Attachment: Clazzes.jpg
    (Size: 16.11KB, Downloaded 126 times)
Re: Scoping Question (Beginner) [message #932075 is a reply to message #932066] Wed, 03 October 2012 20:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6388
Registered: July 2009
Senior Member
Hi,

clazz=[Clazz|FQN]

FQN: ID ("." ID)*;

should do the trick
Re: Scoping Question (Beginner) [message #934232 is a reply to message #932075] Fri, 05 October 2012 19:33 Go to previous messageGo to next message
Andreas Studer is currently offline Andreas Studer
Messages: 2
Registered: July 2009
Junior Member
Hello Christian

Thanks. That was really the trick.

However, I don't understand exactly why this works, but it does...
(it seems to me like a "...and here some magic happens" solution Wink )

Andreas
Re: Scoping Question (Beginner) [message #934236 is a reply to message #934232] Fri, 05 October 2012 19:36 Go to previous message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6388
Registered: July 2009
Senior Member
clazz=[Clazz] us short for clazz=[Clazz|ID]
which means "ref to a Clazz and therefore parse an ID"

Names a by default built hierachically
=> parentname.childname

an id does not allow a dot
=> you get only clazzes with a name without dot => parents
Previous Topic:Suggest feature only if another feature exists
Next Topic:Compilation test for multiple sources
Goto Forum:
  


Current Time: Sun Oct 26 04:42:38 GMT 2014

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

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