Home Documentation Presentation Language Memento Language Reference UI user guide Implementation details Download Fork on Github Kermeta 1 & 2 - Web site Kermeta 1 & 2 - Documentation Kermeta 1 & 2 - Model Development Kit Kermeta 1 & 2 - Download

K3

Kermeta 3 (K3) is an action language built on top of the Xtend programming language and mainly used to implement the execution semantics of Ecore metamodels. Concretely, K3 allows to "re-open" the classes generated from an Ecore metamodel using simple annotations in order to weave new features and operations.

Main features of K3 include:

Breathe life into you metamodel

Kermeta make it easy to address a wide range of activities related to model element manipulation. This includes activites such as:

Open-class mechanism

In a nutshell, the open-class mechanism of K3 allows to "re-open" existing meta-classes of an Ecore metamodel to insert new features such as attributes, references, or operations. The following listings illustrate a typical use of this mechanism. The @Aspect annotation takes as argument the meta-class to re-open, and inserts new features into it. In this case, a new attribute 'counter' and a method 'increment' are inserted:

package mypackage

import fr.inria.diverse.k3.al.annotationprocessor.Aspect

import mymetamodel.MyClass

@Aspect(className = MyClass)
class MyClassAspect {
    int counter = 0

    def void increment() {
        println("Invoking MyClassAspect::increment()")
         _self.counter = _self.counter + 1
    }
}

New features inserted by the aspect can then be transparently accessed from anywhere else, as if they were actual members of the class:

import mymetamodel.MyClass

import static extension mypackage.MyClassAspect.*

class Main {
    def static void main(String[] args) {
        val MyClass testCls = new MyClass()
        testCls.increment() // Prints message and increments the internal counter
    }
}

Compatibilty with Melange

Melange is a language workbench that supports language extension, composition, and interoperability. In Melange, language designers can define the syntax and semantics of their DSLs and use high-level operators to extend and compose DSLs together. Melange relies on Ecore for the definition of the abstract syntax of a DSL and on K3 for the definition of its operational semantics. More information on Melange can be found on the official website.


Follow me on Twitter: @DiverSE_inria