Implementing Language
Extensions with Model
Transformations
Ivan Kurtev
Software Engineering Group
University of Twente
the Netherlands
Symposium How Adaptable is MDA
May 20, 2005
Enschede
Sheet 1
Outline




The Role of Languages in MDE;
Language Elements;
Language Extensions;
Examples:
 Language composition;
 Abstract syntax extension;
 Conclusions;
Symposium How Adaptable is MDA
May 20, 2005
Enschede
Sheet 2
Use of Languages in MDE
 Languages for expressing models:
Computation
Independent
Model (CIM)
Platform
Independent
Model (PIM)
Platform
Specific
Model (PSM)
 Meta-modeling: modeling of languages;
 Transformation languages:
Transformation
Specification
Source Model
Transformer
Target Model
Can we use MDE techniques to solve language design problems?
Symposium How Adaptable is MDA
May 20, 2005
Enschede
Sheet 3
Language Elements
 Concrete Syntax
 Related to parsing;
 Textual, visual;
 Abstract Syntax (L)
 Defines the structures represented by the concrete syntax;
 Semantics:
 Semantic Domain (D);
 Semantic Mapping (M)
M: L -> D
Symposium How Adaptable is MDA
May 20, 2005
Enschede
Sheet 4
Language Extensions
 Syntax Extensions:
 Extensible grammars;
 Extensible parsers;
 Macro definitions;
 Semantic Extensions:
 Modular attribute grammars;
 Monads;
 Action semantics;
 Language Composition:
 Involves syntax and semantic extensions;
Symposium How Adaptable is MDA
May 20, 2005
Enschede
Sheet 5
Language Elements in MDA Terms (1)
 Concrete Syntax: ?
 Abstract Syntax (L)
 Defined as a meta-model;
 Semantics:
 Semantic Domain (D): a model
 Semantic Mapping (M): a model transformation;
M: L -> D
Symposium How Adaptable is MDA
May 20, 2005
Enschede
Sheet 6
Language Elements in MDA Terms (2)
How can MDA techniques be used for language design
tasks?
 What do we gain (do we do better than the current
techniques) ?
 How are traditional problems solved in MDA?
 Language reuse;
 Language composition;
 Language extension;
Symposium How Adaptable is MDA
May 20, 2005
Enschede
Sheet 7
Example 1: Composing XML Languages
 Application-specific XML processing:
XML
Document
DOM
Parser
Processing
Code
DOM Tree
Application Objects
Transformation
 Transformation from XML document to application objects;
 XML Language Composition:
 Concrete syntax composition is solved;
 Semantic mapping: composition of transformations;
 Semantic domain: software composition;
 Application: hybrid XML languages and compound
documents;
Symposium How Adaptable is MDA
May 20, 2005
Enschede
Sheet 8
Transformation Pattern for XML Processing


Schema-less processing: based on DOM;
Schema-based processing: an XML schema and DOM are available;
Transformation
Language
written in
SchemaInstOfDef
XML Schema
Model
XML Document
Model
instanceOf
uses
Transformation
Specification
uses
instanceOf
Application
Classes
instanceOf
executed by
SchemaInstOf
an XML schema
XML Document
input
Symposium How Adaptable is MDA
May 20, 2005
Transformation
Engine
Enschede
Objects
output
Sheet 9
Structure of XML Applications
Transformation
Language
written in
Static part of an XML application
XML Schema
Model
instanceOf
an XML schema
uses
XML Document
Model
uses
Transformation
Specification
instanceOf
executed by
XML Document
input
Transformation
Engine
Application
Classes
instanceOf
Objects
output
Dynamic part of an XML application
Separation of concerns:
 Syntax (schema);
 Processing logic (transformation specification);
 Application classes (semantic domain);
Symposium How Adaptable is MDA
May 20, 2005
Enschede
Sheet 10
Example (1)
 Processing of a subset of SMIL timing module;
 Source schema:
<attribute
<attribute
<attribute
<attribute
name=’begin’ type=’string’/>
name=’end’ type=’string’/>
name=’dur’ type=’string’/>
name=’timeContainer’ type=’string’/>
 Example of a timed document:
<a timeContainer=’seq’ begin=’1’ dur=’20’>
<b timeContainer=’par’ dur=’10’>
<c timeContainer=’none’ dur=’10’/>
<d timeContainer=’none’ dur=’10’/>
</b>
<e timeContainer=’none’ dur=’10’/>
</a>
SMIL – Synchronized Multimedia Integration Language
Symposium How Adaptable is MDA
May 20, 2005
Enschede
Sheet 11
Example (2)
 Target Application Classes:
«interface»
ControlledObject
+activate()
+deactivate()
«JavaClass»
TimedElement
begin
end
dur
ctrlObject : ControlledObject
start()
stop()
«JavaClass»
Interval
*
+components
«JavaClass»
TimeContainer
1
«JavaClass»
Parallel
Symposium How Adaptable is MDA
May 20, 2005
Enschede
«JavaClass»
Sequence
Sheet 12
Composition of XML Languages
 A new language may be composed with the timing module:
instanceOf
Widget Transformation
XML Document
Model
XML Schema
Model
Timing Transformation
instanceOf
Widget Classes
Time Graph
Classes
instanceOf
executed by
Widget language
Timing Module
XML Document
(time constrained
widgets)
Transformation
Engine
Time graph and
widget objects
 New processor is obtained via:
 Composing target application classes (software composition);
 Composing transformation definitions (based on the
transformation language constructs);
Symposium How Adaptable is MDA
May 20, 2005
Enschede
Sheet 13
Example 2: Abstract Syntax Extensions
 Problem:
 what if a transformation language does not support required
compositional operators?
 Possible Solutions:
 Compose transformation definitions by applying a transformation;
 Extend the transformation language with new constructs;
 Example:
 Extending the abstract syntax of a language;
Symposium How Adaptable is MDA
May 20, 2005
Enschede
Sheet 14
Example 2: Implementation
 Extended syntax is transformed to the initial syntax:
Extends
TLMeta-ModelExt
TLMeta-Model
InstanceOf
Source
Target
InstanceOf
InstanceOf
ExtensionImpl
Executed by
Input
TExt
Symposium How Adaptable is MDA
Output
TLTranslation
May 20, 2005
Enschede
T
Sheet 15
Sequential Composition of Extensions
Extends
TLMeta-Model’Ext
Extends
TLMeta-ModelExt
TLMeta-Model
InstanceOf
InstanceOf
Source
Target
Source
Extension’Impl
ExtensionImpl
InstanceOf
InstanceOf
Executed by
T‘Ext
Target
Executed by
TLTranslation
Symposium How Adaptable is MDA
InstanceOf
May 20, 2005
TExt
Enschede
TLTranslation
T
Sheet 16
Conclusions
 Examples of applicability of MDA techniques:
 Composition of XML languages;
 Abstract syntax extension;
 Open Questions:
 Are model transformations suitable for defining semantic
mappings?
 For which type of languages?
 Scalability in case of language composition?
 Comparison to other techniques (attribute grammars, action
semantics,…)
Symposium How Adaptable is MDA
May 20, 2005
Enschede
Sheet 17
Descargar

Document