Skip to content

eclipse-fennec/ocl.engine

Repository files navigation

@emfts/ocl.engine

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.

Features

  • 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)

Installation

npm install @emfts/ocl.engine

Usage

import { 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.

Development

Prerequisites

  • Node.js 20 or 22
  • npm

Build

npm install
npm run build

Project Structure

src/
  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

Deployment & Artifacts

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.

License

EPL-2.0 — see LICENSE.

About

OCL Engine

Resources

License

Security policy

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors