Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Let expression in OCL without specifying type
Let expression in OCL without specifying type [message #1778201] Mon, 11 December 2017 20:22 Go to next message
Leonid Ripeynih is currently offline Leonid RipeynihFriend
Messages: 150
Registered: February 2012
Senior Member
Hello!

I'm trying to parse following OCL expressions.
This parses with no problems:
let a : Integer = x.y.z in a = 1


This fails to parse
let a = x.y.z in a = 1

with the following exception:
Caused by: org.eclipse.ocl.SyntaxException: 1:22:1:24 "let" unexpected token(s)
	at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:350)
	at org.eclipse.ocl.OCL.parse(OCL.java:317)


From what I read in https://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.ocl.doc%2Fhelp%2FEssentialOCL.html type declaration is optional and type should be derived from initializer expression type.

What am I doing wroing?
I'm using Eclipse Neon.3 as runtime.

Thanks in advance!

[Updated on: Mon, 11 December 2017 20:31]

Report message to a moderator

Re: Let expression in OCL without specifying type [message #1778202 is a reply to message #1778201] Mon, 11 December 2017 20:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The traditional/class Ecore/UML-based OCL complies with the OMG spec. let variiables must be typed.

The new Pivot-based OCL is modelled/extensible has a UI and a CG. It prototypes a next OCL. let variable types can be inferred.

Regards

Ed Willink
Re: Let expression in OCL without specifying type [message #1778230 is a reply to message #1778202] Tue, 12 December 2017 07:36 Go to previous messageGo to next message
Leonid Ripeynih is currently offline Leonid RipeynihFriend
Messages: 150
Registered: February 2012
Senior Member
Hi, Ed.

Thanks for a quick answer.

Thanks for the answer. To clarify - I'm using OCL as an input for a custom Java code generation.
User specify expressions in OCL against their UML model, OCL then parsed to AST, then custom code generator emmits Java (and Typescript) code from it.

I'm not extremely familiar with Pivot OCL - can I use it's parser to build AST Syntax Tree? Will it use classes from org.eclipse.ocl.uml for it's AST representation?

Thanks in advance.
Re: Let expression in OCL without specifying type [message #1778234 is a reply to message #1778230] Tue, 12 December 2017 08:08 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Good luck writing an OCL to Java code generator; it's hard. You would do better to re-use the Eclipse OCL code generator that is integrated with EMF genmodel. In principle you just embed your OCL in UML and the normal UML2ECore2Java genmodeling will give you a Java equivalent.

The Pivot OCL uses NO classes from org.eclipse.ocl.ecotre or org.eclipse.ocl.uml. Instead there is a unified representation that avods template parameterization and supports many new activities and fixes.

I suggest you at least scim the code generation aspects of the OCL tutorials.

The OCL2Java CG is complete but still evolving. It is intended to be extensible to other languages and I'm beginning to think harder about C/C++, but realistically another target will require non-trivial work.

Regards

Ed Willink
Re: Let expression in OCL without specifying type [message #1778239 is a reply to message #1778234] Tue, 12 December 2017 08:55 Go to previous messageGo to next message
Leonid Ripeynih is currently offline Leonid RipeynihFriend
Messages: 150
Registered: February 2012
Senior Member
Hello, Ed.

Thanks again for a quick answer. Indeed, writing CG for OCL is a lot of... fun. But we're working with quite specific requirements. In general we need to support like 20% of OCL, but with Java, Typescript and SQL as target platform.
It can be said that we're actually working with DSL, reusing part of OCL syntax.

As far as I understand to parse let without types we need a major refactoring to the whole 'compiler' as we're using types and visitors from ocl.uml A LOT. Basically switch the underlying OCL model to Pivot implementation.

We will re-evaluate our requirements with this information.

Thanks again for quick answer!
Re: Let expression in OCL without specifying type [message #1778242 is a reply to message #1778239] Tue, 12 December 2017 09:04 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The ocl.pivot model includes 100% of itse classes. The ocl.uml has only the OCL classes, so the ocl.uml visitors only work half the time; you have to use a Switch for UML. The pivot visitors are extensible, work all the time and have some useful default implementations.

Regards

Ed Willink
Previous Topic:maven emf ocl artifacts
Next Topic:Complete OCL for Xtext Validation
Goto Forum:
  


Current Time: Tue Apr 23 07:04:51 GMT 2024

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

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

Back to the top