Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Scoping of path expressions
Scoping of path expressions [message #1019432] Fri, 15 March 2013 17:14 Go to next message
Marco Naddeo is currently offline Marco NaddeoFriend
Messages: 62
Registered: November 2012
Member
Hi all Smile

I'm trying to scope a path expression in my DSL, but to do this I'd need to determine if the reference I'm actually scoping belongs directly to the context object or to the child node of it.

How could I test this?

Thanks in advance,
Marco
Re: Scoping of path expressions [message #1019451 is a reply to message #1019432] Fri, 15 March 2013 18:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13530
Registered: July 2009
Senior Member
HI,

dont get your question. can you post grammar and sample model?


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Scoping of path expressions [message #1020479 is a reply to message #1019451] Mon, 18 March 2013 09:14 Go to previous message
Marco Naddeo is currently offline Marco NaddeoFriend
Messages: 62
Registered: November 2012
Member
Hi

here is a fragment of my grammar:

BaseExpression:
	( this?='this' |
          superExpr=SuperExpression |
          true?='true' |
          false?='false' |
          float=FLOAT_LITERAL |
          integer=INTEGER_LITERAL |
          byte=BYTE_LITERAL |
          string=STRING_LITERAL |
          null?='null' |
          variable=[Variable] |
          '(' expr=Expression ')' |
          newObject=ObjectCreation 
        ) (suffix=BaseExpressionSuffix)?
;

BaseExpressionSuffix:
  {FieldSelectSuffix} '.' mixinName=[MixinDeclaration] '.' fieldName=[FieldDeclaration] (suffix=BaseExpressionSuffix)? |
  {MethodCallSuffix}  '.' mixinName=[MixinDeclaration] '.' methodName=[MethodDeclaration] list=ActualParameters (suffix=BaseExpressionSuffix)?
;


So I have to scope something like this:

msg.HelloWorld.getMessage().String.print();


I try to explain my problem with an example. If I'm writing in the editor the following code:

msg.HelloWorld.getMessage().


then, on dot scoping and in particular my method

IScope scope_BaseExpressionSuffix_mixinName(final EObject context, EReference ref)


is called on context ".HelloWorld.getMessage()" which is a MethodCallSuffix; so in the scoping method I have to filter possible mixins after the dot basing on the return type of the method is called in this MethodCallSuffix.

But when I have finished writing in the editor the complete expression, that is:

msg.HelloWorld.getMessage().String.print();


now scoping for the second MixinDeclaration reference mixinName in this expression is called on context ".String.print()" which is a MethodCallSuffix; so in this case I have to filter possibile mixins for the reference basing on the return type of previous MethodCallSuffix (or, in a similar manner, on the type of the field selected in a previous hypothetical FieldSelectSuffix).

How can I get this? My idea is to test if the reference I'm scoping is in the context element or in its parent, but I don't know if and how I can test this: if I well understood, the ref parameter of type EReference in the scoping method cannot help me, since it coincides with the metadata representing the reference, and not with the actual reference that I'm scoping.
Previous Topic:Parameterised Terminals?
Next Topic:Errors in Domain project from 2.4 latest ?
Goto Forum:
  


Current Time: Sat Aug 15 01:10:50 GMT 2020

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

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

Back to the top