112
DSLs: techniques and tools Frédéric Fondement October, 2010 -1- Modeling Wizards - DSLs: techniques and tools

DSLs: techiques and tools - E-Formation

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

DSLs: techniques and tools

Frédéric Fondement

October, 2010

- 1 - Modeling Wizards - DSLs: techniques and tools

Example DSL models

opened

closed

close

unlocked

locked

lock

unlock

open

- 2 - Modeling Wizards - DSLs: techniques and tools

Supporting DSLs

Modeling Wizards - DSLs: techniques and tools

- 3 -

PlanTools around models

Supporting / modeling languages• Abstract syntax• Concrete syntax• Transformation

Language models reuse• Reusing abstract syntax• Reusing tools

Modeling Wizards - DSLs: techniques and tools

- 4 -

Model as a primary artifact

Roughly taken fromIan Sommerville

Repository architectural style

- 5 - Modeling Wizards - DSLs: techniques and tools

MODELREPOSITORY

Supporting models

- 6 - Modeling Wizards - DSLs: techniques and tools

MODELREPOSITORY

Supporting modelsGRAPHICAL EDITOR

SYNCHRONIZATION

TEXTUAL EDITORPARSING / SERIALIZING

- 7 - Modeling Wizards - DSLs: techniques and tools

MODELREPOSITORY

Supporting models

CONSISTENCYCHECKING

- 8 - Modeling Wizards - DSLs: techniques and tools

MODELREPOSITORY

Supporting models

XMI File

SERIALIZER

- 9 - Modeling Wizards - DSLs: techniques and tools

MODELREPOSITORY

Supporting models

CODETRANSLATION

- 10 - Modeling Wizards - DSLs: techniques and tools

MODELREPOSITORY

Supporting models

MODEL INTERPRETOR

CODETRANSLATION

- 11 - Modeling Wizards - DSLs: techniques and tools

MODELREPOSITORY

Supporting models

MODELREPOSITORY

MODEL INTERPRETOR

TRANSLATION

CODETRANSLATION

- 12 - Modeling Wizards - DSLs: techniques and tools

MODELREPOSITORY

Supporting models

MODELREPOSITORY

GRAPHICAL EDITOR

XMI File

SYNCHRONIZATION

SERIALIZER

CONSISTENCYCHECKING

MODEL INTERPRETOR

TRANSLATION

CODETRANSLATION

TEXTUAL EDITORPARSING / SERIALIZING

INTERACTION CONTROLLEDSTORAGE

OPERATIONALIZATION

- 13 - Modeling Wizards - DSLs: techniques and tools

PlanTools around models

Supporting / modeling languages• Abstract syntax• Concrete syntax• Transformation

Language models reuse• Reusing abstract syntax• Reusing tools

Modeling Wizards - DSLs: techniques and tools

- 14 -

Languages…

- 15 - Modeling Wizards - DSLs: techniques and tools

1 language: many sentences

Cos

t

Number of models

- 16 - Modeling Wizards - DSLs: techniques and tools

1 language: many sentences

Price of tool support

Number of models

- 17 - Modeling Wizards - DSLs: techniques and tools

Cos

t

1 language: many sentences

Number of models

- 18 - Modeling Wizards - DSLs: techniques and tools

A modeling languagedeserves to be supported

Cos

t

1 language: many sentences

Number of models

- 19 - Modeling Wizards - DSLs: techniques and tools

A modeling languagedeserves to be supported

Cos

t

(Modeling) language

Concepts

Language

- 20 - Modeling Wizards - DSLs: techniques and tools

(Modeling) language

Concepts

Interface

Language

- 21 - Modeling Wizards - DSLs: techniques and tools

(Modeling) language

Concepts

Interface

Meaning

Language

- 22 - Modeling Wizards - DSLs: techniques and tools

Modeling (modeling) language

Concepts

Interface

Meaning

Language

A model

A model

A model

- 23 - Modeling Wizards - DSLs: techniques and tools

MODELREPOSITORY

Modeling language concepts

MODELREPOSITORY

GRAPHICAL EDITOR

XMI File

SYNCHRONIZATION

SERIALIZER

CONSISTENCYCHECKING

MODEL INTERPRETOR

TRANSLATION

CODETRANSLATION

TEXTUAL EDITORPARSING / SERIALIZING

INTERACTION CONTROLLEDSTORAGE

OPERATIONALIZATION

- 24 - Modeling Wizards - DSLs: techniques and tools

MODELREPOSITORY

Modeling language concepts

MODELREPOSITORY

GRAPHICAL EDITOR

XMI File

SYNCHRONIZATION

SERIALIZER

CONSISTENCYCHECKING

MODEL INTERPRETOR

TRANSLATION

CODETRANSLATION

TEXTUAL EDITORPARSING / SERIALIZING

INTERACTION CONTROLLEDSTORAGE

OPERATIONALIZATION

- 25 - Modeling Wizards - DSLs: techniques and tools

MODELREPOSITORY

Modeling language concepts

MODELREPOSITORY

GRAPHICAL EDITOR

XMI File

SYNCHRONIZATION

SERIALIZER

CONSISTENCYCHECKING

MODEL INTERPRETOR

TRANSLATION

CODETRANSLATION

TEXTUAL EDITORPARSING / SERIALIZING

INTERACTION CONTROLLEDSTORAGE

OPERATIONALIZATION

- 26 - Modeling Wizards - DSLs: techniques and tools

Modeling language concepts

Concepts

A model A conceptsmodeling language !

(a.k.a. a metamodelinglanguage)

- 27 - Modeling Wizards - DSLs: techniques and tools

InstancesIn databases

Table "Organismes"Table "Affiliation"Table "Personnes"

4Martin

3Schmitt

2Dupont

1Durand

Code_perNom

33

41

31

12

Code_orgCode_per

IUT4

FST3

FLSH2

ENSISA1

OrganismeCode_org

Inst

ance

Type

- 28 - Modeling Wizards - DSLs: techniques and tools

InstancesIn databases

Table "Organismes"Table "Affiliation"Table "Personnes"

4Martin

3Schmitt

2Dupont

1Durand

Code_perNom

33

41

31

12

Code_orgCode_per

IUT4

FST3

FLSH2

ENSISA1

OrganismeCode_org

Inst

ance

Type

«instanceOf»«instanceOf» «instanceOf»

- 29 - Modeling Wizards - DSLs: techniques and tools

InstancesIn databases

Table "Organismes"Table "Affiliation"Table "Personnes"

4Martin

3Schmitt

2Dupont

1Durand

Code_perNom

33

41

31

12

Code_orgCode_per

IUT4

FST3

FLSH2

ENSISA1

OrganismeCode_org

Inst

ance

Type

«instanceOf» «instanceOf»

- 30 - Modeling Wizards - DSLs: techniques and tools

InstancesIn databases

Table "Organismes"Table "Affiliation"Table "Personnes"

4Martin

3Schmitt

2Dupont

1Durand

Code_perNom

33

41

31

12

Code_orgCode_per

IUT4

FST3

FLSH2

ENSISA1

OrganismeCode_org

«conformsTo»

Inst

ance

Type

- 31 - Modeling Wizards - DSLs: techniques and tools

InstancesIn XML

<?xml version="1.0" encoding="UTF-8"?><personne xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:noNamespaceSchemaLocation="personne.xsd"><nom>de Latour</nom><prenom>Jean</prenom><date_naissance>1967-08-13</date_naissance>

</personne>

<?xml version="1.0" encoding="UTF-8"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="personne"> <xs:complexType> <xs:sequence><xs:element name="nom" type="xs:string"/><xs:element name="prenom" type="xs:string"/><xs:element name="date_naissance" type="xs:date"/>

</xs:sequence> </xs:complexType> </xs:element></xs:schema>

«conformsTo»

Inst

ance

Type

- 32 - Modeling Wizards - DSLs: techniques and tools

InstancesEBNF

program = 'PROGRAM‘ identifier 'BEGIN' (assignment ";")* 'END' ;identifier = alphabetic_character (alphabetic_character | digit)* ;number = ("-")? (digit)+ ;string = '"' ((alphabetic_character | digit | other)* − '"')* '"' ;assignment = identifier , ":=" , ( number | identifier | string ) ;

PROGRAM DEMO1 BEGINA0:=3;B:=45;H:=-100023;D123:=B34A;BABOON:=GIRAFFE;TEXT:="Hello world!";

END

«conformsTo»

Inst

ance

Type

- 33 - Modeling Wizards - DSLs: techniques and tools

Instances

© F.Fondement

MODEL INREPOSITORY

METAMODEL

<<conformsTo>>

With models

- 34 - Modeling Wizards - DSLs: techniques and tools

Metamodeling exampleType Instance

- 35 - Modeling Wizards - DSLs: techniques and tools

«instanceOf»

M1

M2

Metamodeling example

«metaObject»

Metam

odelM

odel

Type Instance

- 36 - Modeling Wizards - DSLs: techniques and tools

«metamodel»DataBaseMM

Table

NamedElement

name : stringname : string

DataBaseA_table_dataBase

table

0..1 *

dataBase Column

isPrimaryKey : boolean

TypedElement

DataType

Element

isPrimaryKey : boolean*

column

A_column_table0..1

table

typedElement

A_type_typedElement

0..1 type

*

Metamodeling example

- 37 - Modeling Wizards - DSLs: techniques and tools

Modeling language concepts

MODEL INREPOSITORY

META-METAMODEL

<<conformsTo>>

METAMODEL INREPOSITORY

<<conformsTo>>

Concepts for the language used to

model a metamodel

- 38 - Modeling Wizards - DSLs: techniques and tools

M2

M1

Metamodeling exampleType Instance

Metam

odelM

odel

- 39 - Modeling Wizards - DSLs: techniques and tools

M3

M2

M1

Instance Of

Metam

odelM

odelM

etametam

odel

Metamodeling exampleType Instance

- 40 - Modeling Wizards - DSLs: techniques and tools

Typical metamodeling constructsClass

Property

Association

Generalization

- 41 - Modeling Wizards - DSLs: techniques and tools

Metamodeling languagesMOF

Ecore (supported by Eclipse EMF)

KM3 (AMMA)

Xcore (XMF)

SMD (Coral)

Alloy

OWL

B

Database schema

Modeling Wizards - DSLs: techniques and tools

- 42 -

Metamodeling language propertyMMM can have MMM as a meta-metamodel

MMM is thus a metamodel

Thus, a metamodeling language can express itself

MMM can have itself as a metamodel

- 43 - Modeling Wizards - DSLs: techniques and tools

Metamodeling language propertyThe following is possible:(though not mandatory)

M0

M1

M2

M3

«conformsTo»

«conformsTo»

«conformsTo»

«conformsTo»

- 44 - Modeling Wizards - DSLs: techniques and tools

Example: EBNF

Modeling Wizards - DSLs: techniques and tools

- 45 -

rules = (rule)* ';' ;rule = identifier '=' ruleBody ;ruleBody = choice | sequence | atom | '(' ruleBody ')' (('?'|'*'|'+'))?;choice = ruleBody ('|' ruleBody)* ;sequence = ruleBody (ruleBody)*;atom = identifier | '"' (character | digit | other)* '"' ;identifier = character (character | digit)* ;

«conformsTo»

Example: XSD

Modeling Wizards - DSLs: techniques and tools

- 46 -

«conformsTo»

XSD.XSD

An XML Schema schema document for XML Schema schema documents :

http://www.w3.org/2001/XMLSchema.xsd© W3C

Nobody’s perfect……even metamodeling languages !

Metamodel:• Structure that makes possible to construct models…

• …still, some of those possible models can be invalid(i.e. out of the desired language)!

Person*

0,2parents

children

Bob Alice

Philip

- 47 - Modeling Wizards - DSLs: techniques and tools

ConstraintsMetamodel:

• Structure that makes possible to construct models

Static semanticsa.k.a. Well formedness rules

• Expressions restricting the number of possible models

MODELREPOSITORY

CONSISTENCYCHECKING

Consistencymodel

Metamodel

- 48 - Modeling Wizards - DSLs: techniques and tools

Consistency ModelObject Constraint Language

A model query language

Can be adapted to other class languages than UML

Can be used to• Additional operations / derived attributes• Constraints (!)• Transformation languages• Code generation rules• …

Other languages (e.g. Check), same principles

Modeling Wizards - DSLs: techniques and tools

- 49 -

Modeling (modeling) language

Concepts

Interface

Language

A model

A model

- 50 - Modeling Wizards - DSLs: techniques and tools

MODELREPOSITORY

Supporting models

MODELREPOSITORY

GRAPHICAL EDITOR

XMI File

SYNCHRONIZATION

SERIALIZER

CONSISTENCYCHECKING

MODEL INTERPRETOR

TRANSLATION

CODETRANSLATION

TEXTUAL EDITORPARSING / SERIALIZING

CONTROLLEDSTORAGE

OPERATIONALIZATION

- 51 - Modeling Wizards - DSLs: techniques and tools

INTERACTION

Language description

+ layout constraints

sm ::= "Statemachine" IDENT compositeState

state ::= normalState | pseudostate

normalState ::= "initial"? (simpleState | compositeState)

simpleState ::= "State" IDENT

compositeState ::= "CompositeState IDENT? LCURLYBRACKET(state | transition)* RCURLYBRACKET

transition ::= "Transition" IDENT? "from" IDENT "to" IDENT ("on" IDENT)?

pseudoState ::= "FinalState" IDENT | "Choice" IDENT

- or -

- 52 - Modeling Wizards - DSLs: techniques and tools

Textual concrete syntax

Possible language gap…

AbstractSyntax

(Metamodel)

Model

«conformsTo»

Code Generator

Templates

Code

Compilercompiler

Grammar

Semanticanalysis

Intermediatetree

«conformsTo»

«conformsTo»

M2: whiteM1: grey

- 53 - Modeling Wizards - DSLs: techniques and tools

Textual concrete syntaxAbstractSyntax

(Metamodel)

Model

«conformsTo»

Code Generator

Templates

Code

Compilercompiler

Grammar

Semanticanalysis

Intermediatetree

«conformsTo»

«conformsTo»

M2: whiteM1: grey

Textualconcretesyntaxmodels

- 54 - Modeling Wizards - DSLs: techniques and tools

Textual concrete syntaxAbstractSyntax

(Metamodel)

Model

«conformsTo»

Code Generator

Templates

Text

Grammar

ModelParser

«conformsTo»

«conformsTo»

M2: whiteM1: grey

Textualconcretesyntaxmodels

- 55 - Modeling Wizards - DSLs: techniques and tools

Textual concrete syntaxAbstractSyntax

(Metamodel)

Model

«conformsTo»

Text

Grammar

«conformsTo»

ReversibleText Processor

SINTAKS

M2: whiteM1: grey

Textualconcretesyntaxmodel

- 56 - Modeling Wizards - DSLs: techniques and tools

Textual concrete syntax patternsA ::= (pub?=‘public’)? ‘AnA’ name=ID

A ::= B | C | D

A ::= (bs+=B)+

Modeling Wizards - DSLs: techniques and tools

- 57 -

A

B C D

A Bbs

1..*

A

pub : Booleanname : String

AbstractSyntax

(Metamodel)

Model

«conformsTo»

Text

Grammar

«conformsTo»

ReversibleText Processor

Textual concrete syntax M2: whiteM1: grey

AbstractAND

Textualconcretesyntaxmodel

- 58 - Modeling Wizards - DSLs: techniques and tools

AbstractSyntax

(Metamodel)

Model

«conformsTo»

Text

Grammar

«conformsTo»

Text Processor

Textual concrete syntax M2: whiteM1: grey

- 59 - Modeling Wizards - DSLs: techniques and tools

AbstractSyntax

(Metamodel)

Model

«conformsTo»

Text

Grammar

«conformsTo»

ReversibleText Processor

XMI

Textual concrete syntax M2: whiteM1: grey

- 60 - Modeling Wizards - DSLs: techniques and tools

XMI example

Modeling Wizards - DSLs: techniques and tools

- 61 -

<?xml version="1.0" encoding="UTF-8"?><sc:StateMachine xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sc="http://dummy/sc" name="<states xsi:type="sc:InitialState" outgoing="//@transitions.0"/><states xsi:type="sc:SimpleState" name="Opened" incoming="//@transitions.0 //@transitions.2

outgoing="//@transitions.1"/><states xsi:type="sc:CompositeState" name="Closed" incoming="//@transitions.1"><states xsi:type="sc:SimpleState" name="Unlocked" incoming="//@states.2/@transitions.1 //@

outgoing="//@states.2/@transitions.0"/><states xsi:type="sc:InitialState" outgoing="//@states.2/@transitions.2"/><states xsi:type="sc:SimpleState" name="Locked" incoming="//@states.2/@transitions.0"

outgoing="//@states.2/@transitions.1 //@transitions.2"/><transitions event="lock" from="//@states.2/@states.0" to="//@states.2/@states.2"/><transitions event="unlock" from="//@states.2/@states.2" to="//@states.2/@states.0"/><transitions from="//@states.2/@states.1" to="//@states.2/@states.0"/>

</states><transitions from="//@states.0" to="//@states.1"/>

<transitions event="close" from="//@states.1" to="//@states.2"/><transitions event="open" from="//@states.2/@states.2" to="//@states.1"/>

</sc:StateMachine>

Language description

+ layout constraints

sm ::= "Statemachine" IDENT compositeState

state ::= normalState | pseudostate

normalState ::= "initial"? (simpleState | compositeState)

simpleState ::= "State" IDENT

compositeState ::= "CompositeState IDENT? LCURLYBRACKET(state | transition)* RCURLYBRACKET

transition ::= "Transition" IDENT? "from" IDENT "to" IDENT ("on" IDENT)?

pseudoState ::= "FinalState" IDENT | "Choice" IDENT

- or -

- 62 - Modeling Wizards - DSLs: techniques and tools

Graphical concrete syntax

Modeling Wizards - DSLs: techniques and tools

- 63 -

AbstractSyntax

(Metamodel)

Model

RepresentationData

Mapping

RepresentationLanguage

Interaction«conformsTo»

GraphicalModel Representer

Diagram

«conformsTo»

DiagramDiagram

Graphical concrete syntax

Modeling Wizards - DSLs: techniques and tools

- 64 -

AbstractSyntax

(Metamodel)

Model

RepresentationData

Mapping

RepresentationLanguage

Interaction«conformsTo»

GraphicalModel Representer

Diagram

«conformsTo»

DiagramDiagram

Graphicalconcretesyntaxmodels

In practice, more or less

mixed

hidden

Graphical concrete syntax

Modeling Wizards - DSLs: techniques and tools

- 65 -

AbstractSyntax

(Metamodel)

Model

RepresentationData

Mapping

RepresentationLanguage

Interaction«conformsTo»

GraphicalModel Representer

Diagram

«conformsTo»

DiagramDiagram

Notions for

Shape• Rectangle• Polyline• …

Connector• Connector end• …

AbstractSyntax

(Metamodel)

Model

RepresentationData

Mapping

RepresentationLanguage

Interaction«conformsTo»

GraphicalModel Representer

Diagram

«conformsTo»

DiagramDiagram

Graphical concrete syntax

Modeling Wizards - DSLs: techniques and tools

- 66 -

Possible graphical interactions

• Move• Resize• …

Layout constraints

Layout constraints ?

Modeling Wizards - DSLs: techniques and tools

- 67 -

opened

closedclose

unlocked

locked

lock unlockopen

Layout constraints ?

Modeling Wizards - DSLs: techniques and tools

- 68 -

Graphical concrete syntax

Modeling Wizards - DSLs: techniques and tools

- 69 -

AbstractSyntax

(Metamodel)

Model

RepresentationData

Mapping

RepresentationLanguage

Interaction«conformsTo»

GraphicalModel Representer

Diagram

«conformsTo»

DiagramDiagram

Mapping icons with model elements

• Synchronization between diagram and model

Graphical concrete syntax

Modeling Wizards - DSLs: techniques and tools

- 70 -

AbstractSyntax

(Metamodel)

Model

RepresentationData

Mapping

RepresentationLanguage

Interaction«conformsTo»

GraphicalModel Representer

Diagram

«conformsTo»

DiagramDiagram

“There is an icon III of shape XXXlocated on diagram DDD at position X,Xsized W,H that represents element YYY in the model”

Graphical concrete syntax

Modeling Wizards - DSLs: techniques and tools

- 71 -

AbstractSyntax

(Metamodel)

Model

RepresentationData

Mapping

RepresentationLanguage

Interaction«conformsTo»

GraphicalModel Representer

Diagram

«conformsTo»

Diagram InterchangeDiagramDiagram

Modeling (modeling) language

Concepts

Interface

Meaning

Language

A model

A model

A model

- 72 - Modeling Wizards - DSLs: techniques and tools

MODELREPOSITORY

Modeling language concepts

MODELREPOSITORY

GRAPHICAL EDITOR

XMI File

SYNCHRONIZATION

SERIALIZER

CONSISTENCYCHECKING

MODEL INTERPRETOR

TRANSLATION

CODETRANSLATION

TEXTUAL EDITORPARSING / SERIALIZING

INTERACTION CONTROLLEDSTORAGE

OPERATIONALIZATION

- 73 - Modeling Wizards - DSLs: techniques and tools

Model operationalizationTransformation problem

Model to model transformation (M2M)

Model to text transformation (M2T)

Model interpretation• Only for computer-executable

languages !

Modeling Wizards - DSLs: techniques and tools

- 74 -

M2M Transformation model

Modeling Wizards - DSLs: techniques and tools

- 75 -

Set up @4537HMov ah, upInt 4CH

App

licat

ion

Leve

l(p

roje

ct)

M1 :T

Transformation model

Modeling Wizards - DSLs: techniques and tools

- 76 -

Set up @4537HMov ah, upInt 4CH

:T

App

licat

ion

Leve

l(p

roje

ct)

M1

TargetLanguage(s)

(Metamodel(s))<<conformsTo>><<conformsTo>>

Def

initi

onLe

vel

(met

hod) Source

Language(s)(Metamodel(s))

M2

Transformation model

Modeling Wizards - DSLs: techniques and tools

- 77 -

Set up @4537HMov ah, upInt 4CH

:T

App

licat

ion

Leve

l(p

roje

ct)

M1

TargetLanguage(s)

(Metamodel(s))<<conformsTo>><<conformsTo>>

Def

initi

onLe

vel

(met

hod) Source

Language(s)(Metamodel(s))

M2 T

<<conformsTo>>

Transformation model

Modeling Wizards - DSLs: techniques and tools

- 78 -

Set up @4537HMov ah, upInt 4CH

:T

App

licat

ion

Leve

l(p

roje

ct)

M1

TargetLanguage(s)

(Metamodel(s))<<conformsTo>><<conformsTo>>

Def

initi

onLe

vel

(met

hod) Source

Language(s)(Metamodel(s))

M2 T

<<conformsTo>>

ModelTransformation

Language

<<conformsTo>>

M3

Information / intention origins

Modeling Wizards - DSLs: techniques and tools

- 79 -

Information / intention origins

Modeling Wizards - DSLs: techniques and tools

- 80 -

Reversibility

Modeling Wizards - DSLs: techniques and tools

- 81 -

MISSING

Reversibility

Modeling Wizards - DSLs: techniques and tools

- 82 -

MISSINGTrace model:

to recover removed information

to retrieve information source

Transformation hintsLook for input model elements

• According to properties • Metaclass• OCL can help

• Create output model elements• Information trasmission

2 ways• Imperative

• Clear steps• Declarative

• Declare only transformation information

Modeling Wizards - DSLs: techniques and tools

- 83 -

Imperative example : Kermeta

Modeling Wizards - DSLs: techniques and tools

- 84 -

operation transform(inputModel : Package) : RDBMSModel is do…

// Create tablesinputModel.classes.select{ c | c.is_persistent }.each{ c |

var table : Table init Table.newtable.name := c.nameclass2table.storeTrace(c, table)result.table.add(table)}

// Create columnsinputModel.classes.select{ c | c.is_persistent }.each{ c |

createColumns(class2table.getTargetElem(c), c)}

end

operation createColumns (t: Table, c : Class) is do …

Declarative example :

Modeling Wizards - DSLs: techniques and tools

- 85 -

rule PersistentClass2Table {

from c : SimpleUML!Class (c.isPersistent

)

to t : RDBMS!Table (name <- c.name,…

)

}

rule ClassicAttribute2Column{from a : SimpleUML!Attribute(

a.container.isPersistent)

to c : RDBMS!Column(name <- a.name,type <- a.type.kindAsString

)}

Transformation languagesDeclarative

• QVT relational• Triple graph grammars (MOFLON-TGG)

• What to seek• What to produce• What to trace

Imperative• QVT operational• Any programming language (Java, Python, …)

• API offered by model repositories (JMI)

Incremental / Bidirectional

Possible number of in/out/inout models/metamodels• E.g. refactorings

Modeling Wizards - DSLs: techniques and tools

- 86 -

MODELREPOSITORY

M2T: code generatorsSerialization methods

• Added to metaclasses

Based on templates

Xpand example:

Modeling Wizards - DSLs: techniques and tools

- 87 -

«DEFINE run FOR StateMachine»«EXPAND run_sign FOR this» {//State Machine «this.name»«EXPAND run_output

FOREACH this.states.select(e|!e.outgoing.isEmpty)SEPARATOR "\n"»

«EXPAND run FOREACH this.states»}

«ENDDEFINE»

Interpreting modelsMost of the time ad-hoc visitors

“exec” function injections• Kermeta

Modeling Wizards - DSLs: techniques and tools

- 88 -

Interpreting modelsMost of the time ad-hoc visitors

“exec” function injections

Model with Ecore:

Modeling Wizards - DSLs: techniques and tools

- 89 -

Interpreting modelsMost of the time ad-hoc visitors

“exec” function injections

Model with Kermeta:

Modeling Wizards - DSLs: techniques and tools

- 90 -

All-in-one toolsMetamodeling language

Concrete syntax definition language• Usually graphical editor for graphical concrete syntax definition

Transformation language• … and / or code generator

Modeling Wizards - DSLs: techniques and tools

- 91 -

All-in-one toolsMetamodeling language

Concrete syntax definition language• Usually graphical editor for graphical concrete syntax definition

Transformation language• … and / or code generator

Modeling Wizards - DSLs: techniques and tools

- 92 -

Co-evolution

Modeling Wizards - DSLs: techniques and tools

- 93 -

MODELREPOSITORY

MODELREPOSITORY

GRAPHICAL EDITOR

XMI File

SYNCHRONIZATION

SERIALIZER

CONSISTENCYCHECKING

MODEL INTERPRETOR

TRANSLATION

CODETRANSLATION

TEXTUAL EDITORPARSING / SERIALIZING

METAMODEL

<<conformsTo>>

Reuse

Modeling Wizards - DSLs: techniques and tools

- 94 -

PlanTools around models

Supporting / modeling languages• Abstract syntax• Concrete syntax• Transformation

Language models reuse• Reusing abstract syntax• Reusing tools

Modeling Wizards - DSLs: techniques and tools

- 95 -

- 96 - Modeling Wizards - DSLs: techniques and tools

Tuning languagesUse decorations

• UML Profiles

Higher-order hierarchies• Package merge

Tool support• Dedicated tools• Existing tools improved

(e.g. with AOP)• “Folding” extensions to the

original language

DecoratedMetamodel Metamodel

«model transformation»Decoration Folding

«merge»

ProfilesSébastien will introduce that !

A language can become extensible by introducing the profile notion in its metamodel.

• So do UML and MOF…

Modeling Wizards - DSLs: techniques and tools

- 97 -

«metaclass»InstanceSpecification

1..*

distributed 0..*

servants

«stereotype»Distributed

«stereotype»Servant

«profile»DistributionProfile

«metaclass»Interface

{inv: self.classifier->forAll(c | c.conformsTo(self.distributed))}

Package mergeSome kind of inheritance between packages

• Mutiple «merge» possible • Matching elements found

by name•Ext::Element implicitly

exists

Modeling Wizards - DSLs: techniques and tools

- 98 -

Infra

Ext

«merge»

Element

Named

Package mergeSome kind of inheritance between packages•Ext::Element has a name attribute and is owned by an Ext::Package

Modeling Wizards - DSLs: techniques and tools

- 99 -

Infra

Ext

«merge»

Element

Element

name : String

Package

Modeling Wizards - DSLs: techniques and tools

- 100 -

Package mergeMOF meta-metamodel designed for reuse

Essential MOF Complete MOF

«merge»

«merge»

UML Infrastructure

UML Superstructure

«merge»

«conformsTo»«conformsTo»«conformsTo»

«conformsTo»

Profiles

Improving package mergeName matching a bit naïve…

Model composition:Complex composition directives

• Kompose

Model comparison / matching:Comparing independent metamodels

• Versions of the same metamodel• Expected vs. obtained metamodel• Identification of “matcheable” elements• Federated models• EMF Compare

Modeling Wizards - DSLs: techniques and tools

- 101 -

PlanTools around models

Supporting / modeling languages• Abstract syntax• Concrete syntax• Transformation

Language models reuse• Reusing abstract syntax• Reusing tools

Modeling Wizards - DSLs: techniques and tools

- 102 -

Tuning transformations

Modeling Wizards - DSLs: techniques and tools

- 103 -

Metamodel A Metamodel BTransformation

TunedMetamodel A

«model transformation aspect»Tuned Transformation

«Weaves In»

Tuning transformationsHigher-order transformations:Transformations that transforms transformations !

Modeling Wizards - DSLs: techniques and tools

- 104 -

ModelTransformation

Language

Transformation

«conformsTo»

Tuning transformationsAn aspect language for transformationAspect ?

Extension of a source language• E.g.: AspectJ is an extension of Java

Directives to change the extended language• E.g.: At these places, that must be inserted.

Modeling Wizards - DSLs: techniques and tools

- 105 -

Tuning transformationsAn aspect language for transformation

Modeling Wizards - DSLs: techniques and tools

- 106 -

ModelTransformation

Language

Transformation

«conformsTo»

Aspect ModelTransformation

Language

Aspect Weaver

«conformsTo»

Tuning transformationsAn aspect language for transformation

Modeling Wizards - DSLs: techniques and tools

- 107 -

ModelTransformation

Language

Transformation

«conformsTo»

Aspect ModelTransformation

Language

Aspect Weaver

«conformsTo»

«extends»

ConclusionDSLs

• Few concepts• Limited set of users• Tool support is a key factor• Few resources

Languages• Abstract syntax, concrete syntax, translation• Reuse

DSLs for DSLs• Languages to express languages

• Various approaches• Tool support by generation or interpretation

Modeling Wizards - DSLs: techniques and tools

- 108 -

ConclusionProblems

• Abstractions for languages• Syntax, semantics, reuse…

• Quality• Maintainability• Scaling• Optimization• …• Many introduced in here in Oslo

Modeling Wizards - DSLs: techniques and tools

- 109 -

Conclusion

Modeling Wizards - DSLs: techniques and tools

- 110 -

Pric

e pe

r mod

el re

aliz

ed

Number of models

A modeling languagedeserves to be supported

Conclusion

Modeling Wizards - DSLs: techniques and tools

- 111 -

Pric

e pe

r mod

el re

aliz

ed

Number of models

Thank you !More or less questions than before lunch ?

Modeling Wizards - DSLs: techniques and tools

- 112 -