20090224 MOFScript Tool
-
Upload
ander-zubizarreta -
Category
Documents
-
view
95 -
download
0
Transcript of 20090224 MOFScript Tool
MOFScript
Ander Zubizarreta
2009-3-18
Big PictureBig Picture
<<conformsTo>>
Code
metamodel
Model
Transformation definition
template
Big Picture (our example)Big Picture (our example)
C++ Code
Wtsl.ecore
Controllables.wtsl
Transformation definition
Cpp template
<<conformsTo>>
Wtsl.xsd
EMF
ContentsContents
1. MOFScript Tool
2. MOFScript Language
3. Example
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
MOFScript toolMOFScript tool
Rule-based .m2t extension Allows various input models Code completion Transformations can also be represented as
models (XMI)
MOFScriptMOFScriptCreating transformationCreating transformation
File New Other MOFScript File
1 2
MOFScriptMOFScriptEditorEditor
MOFScriptMOFScriptCompilingCompiling
MOFScriptMOFScriptExecutingExecuting
Select input model
MOFScriptMOFScriptConsoleConsole
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
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
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.
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
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
For more information:– http://www.eclipse.org/gmt/mofscript/doc/MOFScript-User-Guide.
pdf–