1

I know the following:

  • OCL is a constraint language that to specify constraints on my class diagram models
  • I know, that in the OMG world for class diagrams there are 3 levels of models: M1 (model), M2 (meta-mode), M3 (meta-meta model)
  • M3: defines what a class diagram is and what it consists of
  • M2: Is the meta-model of my problem/domain (e.g.: meta-model of a shelf that contains books)
  • M3: is the model instance (e.g: a Shelf that contains two specific books)

What i would like to know:

  • Is there a a common meta-model for class diagrams and OCL; basically something that defines the relationship between model elements and constraints
  • I suppose it should somehow be defined at M1 level

I am asking because:

  • I would like to define a meta-model for a constraint language (lightweight OCL) that would allow for me to reason about my model elements (books on the shelf).
  • How would i connect the meta-models of my domain and of my constraint language?
JennyDong
  • 9
  • 3

1 Answers1

0

The OCL specification [1] defines a metamodel for OCL, however there are a variety of problems that mean that practical tools have to 'improve' upon it in proprietary ways. The new Pivot variant of Eclipse OCL prototypes solutions to OMG specification problems and produces an XMI serialization that is credible. It uses an Xtext grammar [2] that you might use as a starting point. This will reveal how much semantic resolution is necessary to resolve the parts of "a.b.c.d". Not easy.

The common metamodel [3] for Pivot OCL is autogenerated by a merge of UML and OCL contributions.

Since OCL may be used to constrain stereotypes or metamodels or even run-time, OCL can be between and pair of Mn/Mn+1 levels.

If you succeed in coming up with an accurate complete lightweight parser, please share.

[1] https://www.omg.org/spec/OCL/2.4

[2] https://git.eclipse.org/c/ocl/org.eclipse.ocl.git/tree/plugins/org.eclipse.ocl.xtext.essentialocl/src/org/eclipse/ocl/xtext/essentialocl/EssentialOCL.xtext

[3] https://git.eclipse.org/c/ocl/org.eclipse.ocl.git/tree/plugins/org.eclipse.ocl.pivot/model/Pivot.ecore

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ed Willink
  • 1,205
  • 7
  • 8
  • There is a yaccable grammar for OCL in the Issue 10439 response at: http://www.omg.org/cgi-bin/doc?ptc/10-12-01.pdf (the resolution did not proceed since it imposed LALR tooling when LL was becoming more popular.) – Ed Willink Aug 03 '22 at 10:21