Context based expressions [message #883271] |
Fri, 08 June 2012 07:21 |
P.-C. Bue 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 |
|
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 |
P.-C. Bue 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
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04046 seconds