Chapter 8. Model transformation - Compilation

In this next step, we'll discover how to map a logo language to lego Mindstorm environment. Logo language here is like a Platform Independent Model (PIM) and the target program is like a Platform Specific Model (PSM).

Kermeta allow to weave a "compilation" aspect into the logo metamodel.

  1. Copy the folder org.kermeta.kmlogo.logoasm.tutorial/parts/4.compiler/6.NXTCompiler to org.kermeta.kmlogo.logoasm.srcKermeta/kermeta

  2. Open the file 6.NXTCompiler/LogoNXCCompiler.kmt. It adds some operations and properties to the ASMLogo.ecore. In order to provide a compiler to Logo, it weaves "compileToNXC" operations to the ASM metaclasses. The compiled code uses a predefined API specific to the target platform (here a Lego Mindstorm robot).

  3. Find operation "compileToNXC" of class "If" and observe how the code is compiled (remember that you can navigate through the outline view).

  4. Find operation compileToStdOut() of class "NXCCompiler". Normally it should call an operation "getAPI" to define the base API of the target platform but right now it is hard coded until we fix the compiler.

    To launch compiling, refer to the "chapter 10 Using the deployed DSL environment".