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