Skip to content

Model Transformations in NTL

Georg Hinkel edited this page Sep 29, 2017 · 1 revision

To support model transformation, NMF contains the NMF Transformations Language (NTL), an internal model transformation language integrated in C#, reusing the tool support for C#. This transformation language allows to specify extensible rule-based model transformations with explicit dependencies between the transformation rules. The underlying transformation engine is not restricted to NMeta models as input or output models such that also arbitrary CLR objects can be transformed where the CLR denotes the .NET virtual machine, similar to the JVM in Java.

Model transformations in NTL are essentially classes whose transformation rules are inferred by the public nested classes. These are encoded also as separate classes that inherit from a set of generic base classes and the generic type parameters specify the source and target model elements. These transformation rule classes may override a method to define their dependencies. Inside this method, transformation rules may define dependencies to other transformation rules, their instantiation or patterns that declaratively specify when the transformation rule should be called. Other than that, the transformation rules may override a method that is called to initialize the transformation rule result. Similar to ATL, NTL also allows transformations to be based on other transformation rules overriding some of their transformation rules. This technique is called superimposition in ATL, in NTL it is called transformation rule inheritance as it is realized in inheriting the transformation rule classes.

The fact that NTL allows to target models not formally described by an NMeta metamodel yields the potential to reuse existing code and especially analyses. As an example transformation, the NMF code generator, probably the largest model transformation ever written in NTL, transforms NMeta metamodels into code models of the .NET framework System.CodeDOM object model. From this object model, code can be generated in a multitude of languages so that our code generator does not only support to generate C# model representation code but also code for other languages like VB.NET, C++ and F#. Here, the .NET framework code to generate code based on a System.CodeDOM model can be reused to generate the model representation code. This not only has the advantage that we do not have to write code generators for each of the supported languages separately, but also means that we can inherit support for more exotic .NET languages such as Boo, as soon as they support a System.CodeDOM code generator.

This code generator is also a showcase for the extensibility of NTL as it is a refinement of a more general code generator component that resolves multiple inheritance into interfaces and implementation classes, replicating the code if necessary, also part of the NMF framework. This code generator can be reused if model representation code should be generated from other models than NMeta metamodels.