Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Context based expressions
Context based expressions [message #883271] Fri, 08 June 2012 03:21 Go to next message
Eclipse UserFriend
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 03:40 Go to previous messageGo to next message
Eclipse UserFriend
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

[Updated on: Fri, 08 June 2012 03:40] by Moderator

Re: Context based expressions [message #883288 is a reply to message #883278] Fri, 08 June 2012 04:07 Go to previous messageGo to next message
Eclipse UserFriend
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 04:10] by Moderator

Re: Context based expressions [message #883320 is a reply to message #883288] Fri, 08 June 2012 05:35 Go to previous messageGo to next message
Eclipse UserFriend
Hmmm,

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

~Christian
Re: Context based expressions [message #883340 is a reply to message #883320] Fri, 08 June 2012 06:18 Go to previous messageGo to next message
Eclipse UserFriend
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 13:02 Go to previous message
Eclipse UserFriend
No Message Body
Previous Topic:Eclipse Marketplace contains old version
Next Topic:generating classes for evaluating Xbase expressions in Xtext?
Goto Forum:
  


Current Time: Wed Jul 23 13:37:14 EDT 2025

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

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

Back to the top