0

I am trying to find a parser for OCL that can generate an Ecore model File so that I can use model to model methods in order to transform the OCL statements into other language models, e.g OCL to SQL (but not only to SQL).

Does anyone know how to OCL to Ecore converter?

Lii
  • 11,553
  • 8
  • 64
  • 88
Clint
  • 1

3 Answers3

0

You need to override ToStringVisitor Class in eclipseOCL.

Hammad
  • 101
  • 1
  • 10
  • Once you have an OCL parser, you could override ToStringVisitor to implement OCL2Ecore as a custom M2T, but since Ecore is modelled, creating Ecore textually is a rather roundabout solution. You could use the Visitor framework for a custom M2M, but better to use the already available M2M. – Ed Willink Aug 18 '18 at 10:56
0

There is no implementable standard model representation for OCL, but Eclipse OCL prototypes a solution to the many problems with the OMG OCL specification.

Using Eclipse OCL you can use OCL->Save Abstract Syntax within OCLinEcore or Complete OCL editors to create a model that conforms to Pivot.ecore.

See http://git.eclipse.org/c/ocl/org.eclipse.ocl.git/tree/plugins/org.eclipse.ocl.pivot/model-gen/OCL-2.5.oclas for a model of the OCL standad library.

Ed Willink
  • 1,205
  • 7
  • 8
0

The MDT project supports OCL: http://www.eclipse.org/modeling/mdt/?project=ocl There is an EMF metamodel of the OCL language so you can use it for your transformation.

Laurent Legrand
  • 1,104
  • 6
  • 6
  • Thanks for the answer, from your experience(or maybe others experience), does this project know how to parse the ocl code and convert it into a model ? – Clint Sep 12 '11 at 12:30
  • I've never used that API but there is a Developer's Guide in the Eclipse Help with code snippet: http://help.eclipse.org/helios/index.jsp?nav=/40_0 – Laurent Legrand Sep 12 '11 at 12:37
  • That link is wrong. Perhaps you meant http://help.eclipse.org/photon/topic/org.eclipse.ocl.doc/help/PivotParsingDocuments.html (It is hard to copy links correctly fro the Eclipse help hierarchy.) – Ed Willink Aug 18 '18 at 11:02