Implementing Language Extensions with Model Transformations Ivan Kurtev Software Engineering Group University of Twente the Netherlands
Outline The Role of Languages in MDE; Language Elements; Language Extensions; Examples: Language composition; Abstract syntax extension; Conclusions;
Use of Languages in MDE Languages for expressing models: Meta-modeling: modeling of languages; Transformation languages: Can we use MDE techniques to solve language design problems?
Language Elements Concrete Syntax Abstract Syntax (L) Semantics: 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
Language Extensions Syntax Extensions: Semantic Extensions: Extensible grammars; Extensible parsers; Macro definitions; Semantic Extensions: Modular attribute grammars; Monads; Action semantics; Language Composition: Involves syntax and semantic extensions;
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
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;
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;
Transformation Pattern for XML Processing Schema-less processing: based on DOM; Schema-based processing: an XML schema and DOM are available;
Structure of XML Applications Separation of concerns: Syntax (schema); Processing logic (transformation specification); Application classes (semantic domain);
Example (1) Processing of a subset of SMIL timing module; Source schema: <attribute name=’begin’ type=’string’/> <attribute name=’end’ type=’string’/> <attribute name=’dur’ type=’string’/> <attribute 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
Example (2) Target Application Classes:
Composition of XML Languages A new language may be composed with the timing module: New processor is obtained via: Composing target application classes (software composition); Composing transformation definitions (based on the transformation language constructs);
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;
Example 2: Implementation Extended syntax is transformed to the initial syntax:
Sequential Composition of Extensions
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,…)