Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Re: OCL and Xtext combination
Re: OCL and Xtext combination [message #660971] Tue, 22 March 2011 14:13 Go to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Hi Ed,

inline....

On 23-02-11 19:56, Ed Willink wrote:
> Hi Christophe
>
> Sorry for the delayed reply. The TMF newsgroup is so busy that I don't
> look at it much now.
>
yeah..my bad. I should have cc. the OCL newsgroup, which I am doing now.

> OCL is a complex language and so it is unhelpful to refer to 'the' AST
> as you can do for a simple calculator language.
>
> OCL requires a two level approach a Concrete Syntax Tree analoguous to
> the AST you refer tpo and which Xtext produces, and an Abstract Syntax
> Tree (actually a graph) that complies with the OMG-specified meta-model
> and generally provides a more sensible model of the information.
>
> Eclipse OCL provides three extended Essential OCL languages, which share
> much of the CST to AST conversion infrastructure. However that code is
> currently manually written and klunky.
>
> The CST to AST mapping is defined using OCL in the OCL specification, so
> it is my intention to autogenerate this mapping. This would be much more
> compact and reliable and extensible. Doesn't help you today.
>
> Currently the extended languages extend grammars and meta-models and use
> a fair amount of auto-generation of visitor frameworks.
>
> An easier approach could be to emulate the OCLinEcore editor where the
> OCL can be just a string within and embedded meta-model. I found the
> following trick very useful:
>
>
> terminal UNQUOTED_STRING: // Never forward parsed;
> '£$%^£$%^'
> ;
>
> InvariantConstraintCS returns OCLinEcoreConstraintCS:
> stereotype='invariant' (name=UnrestrictedName ('('
> (ownedMessage=ExpCS|messageString=UNQUOTED_STRING) ')')?)?
> ':' (ownedExpression=ExpCS|exprString=UNQUOTED_STRING)? ';'
> ;
>
> in which persisted OCL as a string is model-to-text serialized via the
> UNQUOTED_STRING terminal yet text-to-model validated by the ExpCS
> embedding of e.g.
>
> invariant Something(OCLmessageExpression) : OCLcheckingExpression ;
>
OK, so I would have to live with some "escape to OCL" with brackets to
serialize into the engine.. I still wonder how it was done with QVTO.
But perhaps the QVTO grammar is not xtext based?, is that the difference?.



> Regards
>
> Ed Willink
>
> On 08/02/2011 10:41, Christophe Bouhier wrote:
>> @ Ed Willink,
>>
>> Below, a somewhat older post, which I would like to refer to, as a
>> starting point from what I would like to do.
>>
>> > If your grammar is for a language that extends OCL, then your comments
>> > begin to make sense, although most languages extend EssentialOCL rather
>> > than CompleteOCL. You may use the CompleteOCL grammar as an example of
>> > how the EssentialOCL grammar is extensible.
>>
>>
>> So, I would like to mix the essentialOCL grammar with a custom grammar,
>> ( and OCL intepreter ). I need a hint on how the AST would be consumed.
>>
>> Will an instance of this combined grammar, be a combination/mixin of
>> both ecore models? (My generated xtext ecore, and essentialOCL ecore).
>>
>> Would I need therefor my AST visitor, to act on the EObjects
>> accordingly? And if I run into a type from essentialOCL, which OCL
>> library would I need to embed to interpret the OCL? Where in the
>> examples do I need to look for the OCL AST visitor code?
>>
>>
>> Extending on the xtext Calculator example, I would have a dispatcher
>> either interpreting my grammar nodes, or OCL nodes.
>>
>>
>> Thank You,
>> Christophe Bouhier
>>
>>
>>
>>
>>
>>
>> On 21-08-10 20:24, Ed Willink wrote:
>>> Hi Joern
>>>
>>> Your comments leave me a little confused, since there is no obvious need
>>> for Xtext and OCL integration.
>>>
>>> Xtext provides tooling that enables the CompleteOCL editor to be
>>> developed. Similarly Javac provides tooling that enables the CompleteOCL
>>> editor to be compiled. In neither case is there any integration, just
>>> usage.
>>>
>>> If you are developing your own grammar then you use Xtext and have no
>>> need for OCL. Perhaps a future release of Xtext might support some form
>>> of constraints, but there is certainly no need for Xtext to use OCL at
>>> present.
>>>
>>
>>
>>> If your grammar is for a language that extends OCL, then your comments
>>> begin to make sense, although most languages extend EssentialOCL rather
>>> than CompleteOCL. You may use the CompleteOCL grammar as an example of
>>> how the EssentialOCL grammar is extensible.
>>>
>>> Perhaps you are refering to validation (which is missing from the Helios
>>> release of the MDT/OCL editors). Xtext supports the use of custom Java
>>> or its Check language. The ability to embed OCL in Ecore,
>>> possibly supported by the OCLinEcore editor allows OCL to be used for
>>> validation, without Xtext being aware that anything other than normal
>>> Ecore is being used; provided you ensure that you have an OCL Ecore
>>> plugin dependency. (For standalone you have to work harder, see the OCL
>>> FAQ.)
>>>
>>> OCL validation does not support customisable error messages; an OCL
>>> issue has been raised to resolve this and MDT/OCL will probably have a
>>> solution for Indigo.
>>>
>>> Regards
>>>
>>> Ed Willink
>>>
>>>
>>>
>>> On 21/08/2010 18:41, Joern wrote:
>>>> Reading through the entries of this forum I did not get a clear picture
>>>> considering OCL and Xtext integration by now. Is there a best practice
>>>> documented somewhere?
>>>>
>>>> My basic idea has been to start with a Xtext grammar, adding somewhere
>>>> my .ocl file created with the CompleteOCL editor referencing the
>>>> generated Ecore model and containing the additional invariants and
>>>> operations but leaving the Xtext lifecycle intact (i.e. editing the
>>>> grammar and generating the Ecore model and editor).
>>>>
>>>> Or are other solutions more feasible?
>>>>
>>>> Thank you in advance
>>>>
>>>> Joern
>>>
>>
>
Re: OCL and Xtext combination [message #660972 is a reply to message #660971] Tue, 22 March 2011 14:22 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4188
Registered: July 2009
Senior Member
Hi Christophe

> OK, so I would have to live with some "escape to OCL" with brackets to
> serialize into the engine.. I still wonder how it was done with QVTO.
> But perhaps the QVTO grammar is not xtext based?, is that the
> difference?.
>
M2M/QVTo was developed long before Xtext was available.

The M2M/QVTd grammars extend the MDT/OCL LPG grammars.

The OMG exposition of the QVTo grammar is not clearly correlated with
the OCL grammar that it extends, since there are significant additions
of Imperative syntaxes.

I haven't studied the code, but I have noticed that M2M/QVTo has a
safety copy of the MDT/OCL LPG EssentialOCL.g grammar, so it probably
extends it.

Regards

Ed Willink
Previous Topic:[OCLInEcore] Defining Helper Operations in Java
Next Topic:help with tools to use OCL from the beginning
Goto Forum:
  


Current Time: Sun Dec 21 21:36:25 GMT 2014

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

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