Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Scoping of references in my DSL
Scoping of references in my DSL [message #1016492] Wed, 06 March 2013 16:43 Go to next message
Marco Naddeo is currently offline Marco NaddeoFriend
Messages: 62
Registered: November 2012
Hi all Smile

My DSL grammar defines a base expression in this way:

  ( t='this' |
    res+=SuperExpression |
    t='true' |
    t='false' |
    t='null' |
    ref=[Variable] |
    '(' res+=Expression ')' |
  ) ( res+=MethodCallSuffix | res+=FieldSelectSuffix )*

  '.' methodMixin=[MixinDeclaration] '.' methodName=[MethodDeclaration|FQN] list=ActualParameters

  '.' mixinName=[MixinDeclaration] '.' fieldName=[FieldDeclaration|FQN]

I'd like to scope the MixinDeclaration references in last two rules to limit the referenceable mixins.

To do that, I'm trying to define two methods in my DSLScopeProvider:

IScope scope_MethodCallSuffix_methodMixin(BaseExpression expr, EReference mixin) {
IScope scope_FieldSelectSuffix_mixinName(BaseExpression expr, EReference mixin) {

The referenceable mixins depends on what precedes the '.', but I don't understand how I can obtain this previous element. For example, if before I have a MethodCallSuffix, then I have to consider the return type of the previous called method; if I have a variable or object creation, the type of this object; and so on.

Could you please help me? Is there somewhere an example of a similar scoping?

Thanks in advance,
Re: Scoping of references in my DSL [message #1016500 is a reply to message #1016492] Wed, 06 March 2013 17:01 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 9846
Registered: July 2009
Senior Member

you might get some ideas from here:

Alerternatively consider to use Xbase/JvmModelinferrer to get most of it 4 free.
Previous Topic:Xtext editor with pages
Next Topic:Strange behavior of INT
Goto Forum:

Current Time: Wed Oct 26 19:32:18 GMT 2016

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

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