20090224 MOFScript Tool

17
MOFScript Ander Zubizarreta 2009-3-18

Transcript of 20090224 MOFScript Tool

Page 1: 20090224 MOFScript Tool

MOFScript

Ander Zubizarreta

2009-3-18

Page 2: 20090224 MOFScript Tool

Big PictureBig Picture

<<conformsTo>>

Code

metamodel

Model

Transformation definition

template

Page 3: 20090224 MOFScript Tool

Big Picture (our example)Big Picture (our example)

C++ Code

Wtsl.ecore

Controllables.wtsl

Transformation definition

Cpp template

<<conformsTo>>

Wtsl.xsd

EMF

Page 4: 20090224 MOFScript Tool

ContentsContents

1. MOFScript Tool

2. MOFScript Language

3. Example

Page 5: 20090224 MOFScript Tool

MOFScript toolMOFScript tool

Eclipse plugin tool for model to text transformation supports generation of implementation code or

documentation from models

MOFScript M2T

<<conformsTo>>Doc

Code

Page 6: 20090224 MOFScript Tool

MOFScript toolMOFScript tool

Rule-based .m2t extension Allows various input models Code completion Transformations can also be represented as

models (XMI)

Page 7: 20090224 MOFScript Tool

MOFScriptMOFScriptCreating transformationCreating transformation

File New Other MOFScript File

1 2

Page 8: 20090224 MOFScript Tool

MOFScriptMOFScriptEditorEditor

Page 9: 20090224 MOFScript Tool

MOFScriptMOFScriptCompilingCompiling

Page 10: 20090224 MOFScript Tool

MOFScriptMOFScriptExecutingExecuting

Select input model

Page 11: 20090224 MOFScript Tool

MOFScriptMOFScriptConsoleConsole

Page 12: 20090224 MOFScript Tool

MOFScript languageMOFScript language

Transformation module– The definition of the transformation– Defined using keyword textmodule or texttransformation

– It defines the input metamodels– The body of the transformation module contains the

rules Transformation Inheritance

– Transformations can be extended using extends keyword

– Rules are inherited and they can be used or overriden in the subtransformation

Page 13: 20090224 MOFScript Tool

MOFScript languageMOFScript language

Imports– A transformation may import other transformations as

libraries

Variables and properties (constants)– Variables and properties can be declared either

globally or locally– They can be of any of the MOFScript types

Page 14: 20090224 MOFScript Tool

MOFScript languageMOFScript language

Rules– Elements of a rule:

• Context type -> metamodel type (optional)• Return type (optional)• Input parameters (optional)• Body -> set of statements

– Types of rules:• Entry point rules

– Defines where the execution starts -> main()– Defines for which metamodel element type it is executed– It is executed as many times as entry point type elements are in the input model

• Entry point rules without context type– It is executed only once

• Abstract rules– Abstract rules can be defined

– Rule Overriding• Rules can be overriden, either from imported transformation or within

the same transformation– Different rule with the same name will be called depending on the context type.

Page 15: 20090224 MOFScript Tool

MOFScript languageMOFScript language

Files– Declaration of an output device for text.– Declared using keyword file.– File name and extension are given as a parameter

If statements, Iterators, While statements, Select expressions, Printing, Logging, Expressions– Similar to other languages

Types– Strings, Integer, Real, Boolean, List, Hashtable, Object, Model

• Many operations available for each type Built-in functions

– Many built-in functions are available in MOFScript: System functions and Output utility functions

Other features:– Reflection support, Java invocation, UML2 integration,

Unprotected Blocks, Aspects, M2M transformation

Page 16: 20090224 MOFScript Tool

MOFScript languageMOFScript language

For more detailed information:– MOFScript Language Reference in Eclipse Help– Mofscript user guide:

http://www.eclipse.org/gmt/mofscript/doc/MOFScript-User-Guide.pdf

Page 17: 20090224 MOFScript Tool

For more information:– http://www.eclipse.org/gmt/mofscript/doc/MOFScript-User-Guide.

pdf–