OCL (Object Constraint Language) expression evaluator built on the EMFTs framework.
Implements the evaluation semantics of the OMG Object Constraint Language specification (v2.4, formal/2014-02-03) — standard library, three-valued logic and iterator operations — over the @emfts/ocl.model metamodel.
- Evaluation of OCL expressions against EObject models
- Constraint validation with diagnostic reporting
- Full OCL standard library (collection operations, type operations, etc.)
- Switch-based AST visitor pattern (via
@emfts/ocl.model)
npm install @emfts/ocl.engineimport { OclEngine } from '@emfts/ocl.engine'
const engine = new OclEngine()
// Evaluate an OCL expression against a context object
const result = engine.evaluate(expression, { self: myEObject })
// Validate a single constraint (e.g. produced by @eclipse-fennec/ocl.langium)
const { valid, diagnostics } = engine.evaluateConstraint(constraint, { self: myEObject })
// Validate many constraints against one object (optionally with a model extent)
const results = engine.validateAll(constraints, myEObject, extent)The Constraint / OclExpression inputs are instances of the @emfts/ocl.model
metamodel. Parsing OCL source text into that metamodel is the job of
@eclipse-fennec/ocl.langium
(via its OclAstConverter); this package only evaluates the resulting AST.
- Node.js 20 or 22
- npm
npm install
npm run buildsrc/
OclEngine.ts # Main engine facade
OclEvaluator.ts # AST visitor / expression evaluator
OclEvalEnvironment.ts # Variable scoping environment
OclStdlib.ts # OCL standard library operations
OclInvalid.ts # OclInvalid sentinel value
index.ts # Public API exports
| Registry | npmjs.com |
| Package | @emfts/ocl.engine (public) |
| Build output | dist/ (ESM, tsc) — only dist is published (see files in package.json) |
| Source | https://github.com/eclipse-fennec/ocl.engine (default branch main) |
| Project | Eclipse Fennec |
Releases are published to the npm registry under the @emfts scope.