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
Member
Hi all Smile

My DSL grammar defines a base expression in this way:

BaseExpression:
  ( t='this' |
    res+=SuperExpression |
    t='true' |
    t='false' |
    t=FLOAT_LITERAL |
    t=INTEGER_LITERAL |
    t=BYTE_LITERAL |
    t=STRING_LITERAL |
    t='null' |
    ref=[Variable] |
    '(' res+=Expression ')' |
    res+=ObjectCreation 
  ) ( res+=MethodCallSuffix | res+=FieldSelectSuffix )*
;

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

FieldSelectSuffix:
  '.' 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,
Marco
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: 6494
Registered: July 2009
Senior Member
Hi,

you might get some ideas from here:
http://dslmeinte.wordpress.com/2011/11/23/path-expressions-in-entity-models-revisited/
http://dslmeinte.wordpress.com/2010/08/16/path-expressions-in-entity-models/

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 Nov 26 06:00:01 GMT 2014

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

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