Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Context based expressions
Context based expressions [message #883271] Fri, 08 June 2012 07:21 Go to next message
P.-C. Bue is currently offline P.-C. BueFriend
Messages: 11
Registered: November 2011
Junior Member
Hi all,

I have a question on context based expression resolution.

For example, consider an example based on OCL. In OCL, i can write this kind of constraint :

x->select(x | predicate on x)->select(x | predicate on x)

In this predicate, there is 3 different "x" references. The first x refers to, for example, a class, but the two others can refer to attribute of the class.

How can i use XText to provide such context sensitive recognition ? Such as :
1 - external based context, how to add context to xtext editor ?
2 - inner based context, how to make the difference between the two "x" in select operations, i.e. how does xtext knows that the first x only applied to the first select ??

I already tooked a look at the following resources:
- blogs.itemis.de/stundzig/archives/773,
- XText "big pdf file" documentation ,
- OCLEssential plugin sources

I don't know if the solution of my problem holds on scoping, naming, validation, or other functionality ... For example, the OCLInEcore editor support context completion (in the operation Book.isAvailable, the member loans of Book is proposed as a possible valid completion, but i can't find in the sources where and understand why XText proposed it.
Re: Context based expressions [message #883278 is a reply to message #883271] Fri, 08 June 2012 07:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

this is done by scoping. you make only variables visible that make sense at a certain place.
and outer variables are hidden/covered by inner ones.
and since then you know which variable is meant you can calculate its type
and thereby know which operations are in scope.

if you have a simplyfied example of your problem feel free to share

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Fri, 08 June 2012 07:40]

Report message to a moderator

Re: Context based expressions [message #883288 is a reply to message #883278] Fri, 08 June 2012 08:07 Go to previous messageGo to next message
P.-C. Bue is currently offline P.-C. BueFriend
Messages: 11
Registered: November 2011
Junior Member
Thanks for your quick reply.

My example is the following. It is a simplified version of OCL. I have linked my xtext grammar, i have not modified any particular other files. This grammar recognize the example i give in the first post. It aim to recognize simplified pre/post constraints in operations of UML class.

Can you point me to the file(s) responsible for scoping resolution in OCLInEcore ?

[Updated on: Fri, 08 June 2012 08:10]

Report message to a moderator

Re: Context based expressions [message #883320 is a reply to message #883288] Fri, 08 June 2012 09:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hmmm,

maybe you should frist do some scoping stuff on a bit simpler grammar

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Context based expressions [message #883340 is a reply to message #883320] Fri, 08 June 2012 10:18 Go to previous messageGo to next message
P.-C. Bue is currently offline P.-C. BueFriend
Messages: 11
Registered: November 2011
Junior Member
Ok, i will try to get a simpler grammar to start the scoping functionnality ...
Is there somewhere a concrete scoping example ?
Re: Context based expressions [message #892600 is a reply to message #883340] Thu, 28 June 2012 17:02 Go to previous message
Marcus Mathioudakis is currently offline Marcus MathioudakisFriend
Messages: 18
Registered: June 2012
Junior Member
No Message Body
Previous Topic:Eclipse Marketplace contains old version
Next Topic:generating classes for evaluating Xbase expressions in Xtext?
Goto Forum:
  


Current Time: Fri Apr 19 19:43:02 GMT 2024

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

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

Back to the top