Skip to main content



      Home
Home » Modeling » OCL » Parse an OCL String without any Kind Information
Parse an OCL String without any Kind Information [message #527776] Fri, 16 April 2010 08:50 Go to next message
Eclipse UserFriend
Originally posted by: philipp.berger.student.hpi.uni-potsdam.de

Hey guys,
I currently working with ecore.OCL and I want to traverse and use an AST
of an OCLExpression. My problem is, that any helper I found require a
ConstraintKind.
Is there any possibility to convert a given String to an OCLExpression
without any Kind information?
Where can I locate such a parsing method?

Currently I just assume that myExpression is an Invariant (it can be
everything, post/body/init/def)

OCL ocl = org.eclipse.ocl.ecore.OCL.newInstance();
Helper helper = ocl.createOCLHelper();
OCLExpression<EClassifier>
myExpression=helper.createConstraint(ConstraintKind.INVARIAN T,
myExpressionAsString).getSpecification().getBodyExpression() ;

Can I assume that no matter which Kind I give the returned expression
spans the same AST?

Regards,
Phil
Re: Parse an OCL String without any Kind Information [message #527778 is a reply to message #527776] Fri, 16 April 2010 08:56 Go to previous messageGo to next message
Eclipse UserFriend
Hi Philipp

An invariant is supposed to be Boolean valued, so if you do too much
something may complain that your AST is not Boolean.

Is there any reason why you don't just use createQuery(String) ?

Regards

Ed Willink

On 16/04/2010 13:50, Philipp Berger wrote:
> Hey guys,
> I currently working with ecore.OCL and I want to traverse and use an AST
> of an OCLExpression. My problem is, that any helper I found require a
> ConstraintKind.
> Is there any possibility to convert a given String to an OCLExpression
> without any Kind information?
> Where can I locate such a parsing method?
>
> Currently I just assume that myExpression is an Invariant (it can be
> everything, post/body/init/def)
>
> OCL ocl = org.eclipse.ocl.ecore.OCL.newInstance();
> Helper helper = ocl.createOCLHelper();
> OCLExpression<EClassifier>
> myExpression=helper.createConstraint(ConstraintKind.INVARIAN T,
> myExpressionAsString).getSpecification().getBodyExpression() ;
>
> Can I assume that no matter which Kind I give the returned expression
> spans the same AST?
>
> Regards,
> Phil
Re: Parse an OCL String without any Kind Information [message #527792 is a reply to message #527778] Fri, 16 April 2010 09:08 Go to previous message
Eclipse UserFriend
Originally posted by: philipp.berger.student.hpi.uni-potsdam.de

Hey Ed,
actually, there is no reason...
I beg your pardon, but I overlooked this method.

Thanks


Am 16.04.2010 14:56, schrieb Ed Willink:
> Hi Philipp
>
> An invariant is supposed to be Boolean valued, so if you do too much
> something may complain that your AST is not Boolean.
>
> Is there any reason why you don't just use createQuery(String) ?
>
> Regards
>
> Ed Willink
>
> On 16/04/2010 13:50, Philipp Berger wrote:
>> Hey guys,
>> I currently working with ecore.OCL and I want to traverse and use an AST
>> of an OCLExpression. My problem is, that any helper I found require a
>> ConstraintKind.
>> Is there any possibility to convert a given String to an OCLExpression
>> without any Kind information?
>> Where can I locate such a parsing method?
>>
>> Currently I just assume that myExpression is an Invariant (it can be
>> everything, post/body/init/def)
>>
>> OCL ocl = org.eclipse.ocl.ecore.OCL.newInstance();
>> Helper helper = ocl.createOCLHelper();
>> OCLExpression<EClassifier>
>> myExpression=helper.createConstraint(ConstraintKind.INVARIAN T,
>> myExpressionAsString).getSpecification().getBodyExpression() ;
>>
>> Can I assume that no matter which Kind I give the returned expression
>> spans the same AST?
>>
>> Regards,
>> Phil
>
Previous Topic:Ecore data types map to OCL type
Next Topic:Shorten oclAsType and obtain all instances
Goto Forum:
  


Current Time: Wed Jul 23 16:29:25 EDT 2025

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

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

Back to the top