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](http://www.eclipse.org/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: * **Executable metamodeling**: Using K3, one can insert new methods in existing Ecore meta-classes, with their implementation. These methods define the execution semantics of the corresponding metamodel in the form of an interpreter; * **Metamodel extension**: The very same mechanism can be used to extend existing Ecore metamodels and insert new features (eg. attributes) in a non-intrusive way; * **Full Java compatibility**: K3 files are plain Xtend files. As such, K3 files are ultimately compiled as plain Java code. This means that Java code and API can be used in K3 files and *vice versa*. # 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: * weaving operational semantics in metamodel definition, * defining model checkers, * defining *model-to-model transformations*, or * defining *model-to-text transformations*. ## 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: ```xtend 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: ```xtend 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](http://melange-lang.org).
Follow me on Twitter:
@DiverSE_inria