Skip to content

eclipse-fennec/ocl.langium

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@emfts/ocl.langium

Langium-based OCL (Object Constraint Language) parser with LSP support for EMFTS.

Implements the OMG Object Constraint Language specification (v2.4, formal/2014-02-03). Parsed expressions are evaluated by @emfts/ocl.engine over the @emfts/ocl.model metamodel.

Features

  • Full OCL grammar implementation using Langium
  • Language Server Protocol (LSP) support
    • Code completion
    • Hover information
    • Validation
    • Scoping
  • OCL expression evaluator (backed by @emfts/ocl.engine)
  • EMF bridge for model integration via @emfts/core and @emfts/ocl.model
  • Generated AST types and type guards

Installation

npm install @emfts/ocl.langium

Usage

import { createOclServices, parseOcl, OclEvaluator } from '@emfts/ocl.langium';

// Create parser services
const services = createOclServices();

// Parse an OCL document
const result = await parseOcl('context Person inv: self.age >= 0');

// Evaluate against a context object
const evaluator = new OclEvaluator();
const evalResult = evaluator.evaluate(result.document, personObject);
console.log(evalResult.valid); // true or false

LSP Integration

import { createOclLspServices } from '@emfts/ocl.langium';

const lspServices = createOclLspServices();

Development

Prerequisites

  • Node.js 20 or 22
  • npm

Build

npm install
npm run build

Watch Mode

npm run watch

Generate Grammar

npm run langium:generate

Test

npm run test

Project Structure

src/
  grammar/          # OCL grammar definition (.langium)
  generated/        # Generated AST, grammar, and module
  language/         # LSP services (completion, hover, validation, scoping)
  evaluator/        # OCL expression evaluator
  bridge/           # EMF bridge (AST converter)
  index.ts          # Public API exports

Deployment & Artifacts

Registry npmjs.com
Package @emfts/ocl.langium (public)
Build output dist/ (ESM, tsc) — only dist is published (see files in package.json)
Source https://github.com/eclipse-fennec/ocl.langium (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 langium grammar

Resources

License

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors