sle meets mde and compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/guy.pdf · syntax,...
TRANSCRIPT
![Page 1: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/1.jpg)
SLE meets MDE and CompilationClément Guy, Steven Derrien, Benoît Combemale, Jean-Marc Jézéquel
Triskell & Cairn teams
IRISA-INRIA
![Page 2: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/2.jpg)
2
General-purpose
Language
<<represents>>
<<conformsTo>>
Complex software systems (including
compilers)
![Page 3: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/3.jpg)
3
<<represents>>
DSL1
DSL2 DSL3
DSL4
<<conformsTo>>
<<conformsTo>><<conformsTo>>
<<conformsTo>>
![Page 4: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/4.jpg)
DSL1
DSL2 DSL3
DSL4
<<represents>>
<<conformsTo>>
<<conformsTo>><<conformsTo>>
<<conformsTo>>
DSL1
DSL2 DSL3
DSL4
<<represents>>
<<conformsTo>>
<<conformsTo>><<conformsTo>>
<<conformsTo>>
4
<<represents>>
<<conformsTo>>
DSL1
DSL2 DSL3
DSL4
<<represents>>
<<conformsTo>>
<<conformsTo>><<conformsTo>>
<<conformsTo>>
![Page 5: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/5.jpg)
Our Motivations and Challenges
• Language multiplication
▫ Need for operations capitalization
▫ Need for inter-languages mappings
• Language operations multiplication
▫ Need for ways to ensure a sound combination of these operations
• Need for “best practices” for language definition
5
![Page 6: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/6.jpg)
Capitalization Example:
Dead Code Elimination/Trimming
6
if (true) {
…
![Page 7: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/7.jpg)
• Introduction: From Software Language “Craft” to Software Language Engineering
• Compilation, MDE and Programming Languages
• Typing in MDE
7
![Page 8: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/8.jpg)
Motivations of SLE[Dagstuhl Seminar Proceedings: Language Engineering for Model-Driven Software
Development, 2004]
• Need for systematic approach of languages definition and tooling
• Go from “Software Language Craft” to Software Language Engineering
• Goals:
▫ Capture expert domains (DSLs)
▫ Process expert domains (analyses + transf.)
▫ Automate the path from expert domain to executable languages (compiler generation)
8
![Page 9: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/9.jpg)
Challenges
• Facilities for the definition of languages (abstract syntax, concrete syntax, semantic domain, semantic mapping)
• Suitable user interfaces
• Automate process whenever possible
• Coping with many languages
9
![Page 10: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/10.jpg)
• Introduction: From Software Language “Craft” to Software Language Engineering
• Compilation, MDE and Programming Languages
• Typing in MDE
10
![Page 11: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/11.jpg)
Cross-Fertilization of MDE and
Compilers Research Communities
11
MDE
CompilationProgramming
Languages
![Page 12: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/12.jpg)
Compilers Research
• Pros:
▫ Introduction of formal methods in languages
▫ Experience in program refactoring (e.g., tree rewritings)
▫ Experience in complex optimization problems (e.g., registers allocation, instructions selection, etc.)
• Cons:
▫ The number of transformations and their complexity increase:
Need for reuse and consistency
12
![Page 13: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/13.jpg)
General-Purpose Programming
Languages• Pros:
▫ Software languages formalization
Abstract syntax, concrete syntax, semantic domain, semantic mapping
▫ Type systems
• Cons:
▫ Difficult to use for a non-expert
13
![Page 14: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/14.jpg)
MDE
• System abstraction using domain specific models
• A model:
▫ Address one particular concern (security, business, UI…)
▫ Conforms to a metamodel
• A metamodel:
▫ Defines the concepts used in models (abstract syntax of a Domain Specific Modeling Language)
▫ Conforms to a metalanguage
14
![Page 15: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/15.jpg)
MDE
15
The BPO has 154 agencies in 7 departments, employing 1470 persons. It has 341000 clients.…
Real world
Model BPO: Bank
RennesCentre:
Agency
RennesGare:
Agency
ClémentGuy:
Client: Account
: Account…
Metalanguage Class Reference
DSML
Bank: Class
Agency: Class Client: Class
Account: Classcontext Bank inv:
agencies.forall{ag|
accounts.forall{ac|
ac.owner.agency = ag
}
}
![Page 16: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/16.jpg)
MDE
• Pros:
▫ Expertise on DSMLs definition and tooling:
Design by contract, generative approaches, metatools
• Cons:
▫ Lack of reuse
→Reuse of model operations through genericity
16
![Page 17: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/17.jpg)
17
MDE
CompilationProgramming
Languages
Compilers
generators
Genericity
in MDE
Automatic
parallelization
Genericity
Inheritance &
Polymorphism
Function
typing &
Higher order
V & V
Tree
rewriting
[CLU: reference manual, Liskov et al., 1981]
[Genericity in Java with virtual types, Thorup, 1997]
[The essence of functional programming, Wadler, 1992]
[Simula, an Algol-based simulation language, Dahl, 1966]
[A semantics of multiple inheritance, Cardelli, 1992]
[Subtyping is not a good "Match" for object-oriented languages, Bruce et al., 1997]
[Advanced compiler design and implementation, Muchnick, 1997]
[A brief history of just-in-time, Aycock, 1997]
[Eclipse Modeling Framework, Budinsky et al., 2003]
[GMF, http://www.eclipse.org/modeling/gmp/]
[Domain-specific modeling: enabling full code generation, Kelly et al., 2008]
[On Model Typing, Steel et al., 2007]
[Generic model refactorings, Moha et al., 2009]
[Templatable metamodels for semantic variation points, Cuccuru et al., 2007]
[Generic meta-modelling with concepts, templates and mixin layers, de Lara et al., 2010]
[Xtext, http://www.eclipse.org/Xtext/]
[ANTLR: A predicated-LL(k) parser generator, Parr et al., 1995]
[A pattern matching compiler for multiple target languages, Moreau et al., 2003]
[A structured approach to proving compiler optimizations based on dataflow analysis, Bertotet al., 2006]
[Genericity versus inheritance, Meyer, 1986]
[Typing in Model Management, Vignaga et al., 2009]
Domain
Specific
Modeling
Optimization
[Automatic Program Parallelization, Banerjeeet al, 1993]
Function
typing in
MDE Typing in MDE
![Page 18: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/18.jpg)
• Introduction: From Software Language “Craft” to Software Language Engineering
• Compilation, MDE and Programming Languages
• Typing in MDE
18
![Page 19: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/19.jpg)
19
DSL2 DSL3
DSL4
DSL1
DSL2 DSL3
DSL4
DSL1
DSL2 DSL3
DSL4
DSL1
<<conformsTo>>
<<conformsTo>><<conformsTo>>
<<conformsTo>>
<<conformsTo>><<conformsTo>><<conformsTo>>
<<conformsTo>><<conformsTo>>
<<conformsTo>>
<<conformsTo>>
<<conformsTo>>
<<represents>>
<<represents>><<represents>>
![Page 20: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/20.jpg)
20
DSL2 DSL3
DSL4
DSL1
DSL2 DSL3
DSL4
DSL1
DSL2 DSL3
DSL4
DSL1 Model Typing
ModelType1
ModelType2 Model
Type3 ModelType4
![Page 21: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/21.jpg)
21
DSL2 DSL3
DSL4
DSL1
DSL2 DSL3
DSL4
DSL1
DSL2 DSL3
DSL4
DSL1 Model Typing
ModelType1
ModelType2 Model
Type3 ModelType4
Define a type system allowing substitutability of models, reusability of model operations and operations typing
![Page 22: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/22.jpg)
Typing in MDE
• Type models with respect to:
▫ Their model elements
▫ Their model operations
• Type model operations with respect to:
▫ The type of their parameters (models or other transformations)
22
![Page 23: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/23.jpg)
Typing in MDE
• Type of a model:
MT = (C, O) s.t. C a set of classes and O a set of model operations
• Type of a model operation:
OT = T1 x … x Tn → Tr s.t. T1, …, Tn, Tn = MT or OT
23
![Page 24: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/24.jpg)
Type vs Metamodel vs Language
• Model typing with respect to:
▫ Their model elements
Looks like a metamodel
▫ Their model operations
Not so much
• Metamodel + Model operations = Abstract syntax + Semantics = Language
24
![Page 25: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/25.jpg)
Substitutability and Reuse
Genericity• Already existing approaches
• Parameterize languages with other languages
• Parameters have to match a structure on which operations are defined
[Generic model refactorings, Moha et al., 2009]
[Templatable metamodels for semantic variation points, Cuccuru et al., 2007]
[Generic meta-modelling with concepts, templates and mixin layers, de Lara et al., 2010]
25
![Page 26: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/26.jpg)
Substitutability and Reuse
Genericity• Operations defined on a structure
• Languages which match this structure can reuse the operations
26
A
B C
Str1
A
B C
D
L1
var a: L1::A init L1::A.new
op<L1>(a)
operation op<T:Str1>(a: T::A)
is do
…
![Page 27: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/27.jpg)
Substitutability and Reuse
Inheritance• Inherit structure and operations from “super-
languages”
• Define languages incrementally
• Need to define when a language is a subtype of an other
[On Model Typing, Steel et al., 2007]
27
![Page 28: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/28.jpg)
Substitutability and Reuse
Inheritance• Allow to define a new language
from existing one(s)
▫ Allow to reuse operations defined on “super-languages”
28
var a2: L2::A init L2::A.new
a2.op()
A
B C
L1
A
B C
D
L2
<<inherits>>
class L1::A {
operation op() is do
…
![Page 29: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/29.jpg)
Substitutability and Reuse
Inheritance• Allow to define a new language
from existing one(s)
▫ Allow to reuse operations defined on “super-languages”
▫ Allow a type hierarchy
29
var a2: L2::A init L2::A.new
a2.op()
class L1::A {
operation op() is do
…
var a4: L4::A init L4::A.new
a4.op()
L1
L2 L3
L5L4
<<inherits>>
<<inherits>>
![Page 30: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/30.jpg)
Covariance, Contravariance
30
Mammal FoodMammal m := Mammal.new
Food f1 := Food.new
Food f2 = m.getFood()
m.setFood(f1)
food
![Page 31: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/31.jpg)
Covariance, Contravariance
31
Mammal FoodMammal m := Mammal.new
Food f1 := Food.new
Food f2 = m.getFood()
m.setFood(f1)
food
![Page 32: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/32.jpg)
Covariance, Contravariance
32
Mammal Food
Herbivore Plant
Mammal m := Mammal.new
Food f1 := Food.new
Food f2 = m.getFood()
m.setFood(f1)
Mammal m := Herbivore.new
Food f1 := Food.new
Food f2 = m.getFood()
m.setFood(f1)
food
food
![Page 33: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/33.jpg)
Covariance, Contravariance
33
Mammal Food
Herbivore Plant
Mammal m := Mammal.new
Food f1 := Food.new
Food f2 = m.getFood()
m.setFood(f1)
Mammal m := Herbivore.new
Food f1 := Food.new
Food f2 = m.getFood()
m.setFood(f1)
food
food
![Page 34: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/34.jpg)
Covariance, Contravariance
34
L1
A’
L2
A B
B’ C
![Page 35: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/35.jpg)
Substitutability and Reuse
Adaptation• When languages are too different for inheritance
or genericity
• Differences may include:
▫ Renaming
▫ Gathering and separation of concepts
▫ …
• Need to know when an adaptation is possible
[IGraphAdapters@Cairn]
[An experiment of a MDE approach for the design of reusable DSL tools, Kerboeuf et al., IDM2011]
35
![Page 36: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/36.jpg)
Conclusion and Perspectives
• Multiplication of languages brings a need for Software Language Engineering
• MDE, compilers research and programming languages communities have experience in languages definition and tooling
• One of the challenges SLE must face is the need for reasoning on sets of languages
• We propose to define a type system for models, model operations, etc.
• And to validate this type system with real use cases from compilation community
36
![Page 37: SLE meets MDE and Compilationcompilfr.ens-lyon.fr/wp-content/uploads/2011/04/Guy.pdf · syntax, concrete syntax, semantic domain, ... •Automate process whenever possible •Coping](https://reader034.vdocuments.us/reader034/viewer/2022051914/6005923c05fb4528c2618f5d/html5/thumbnails/37.jpg)
Questions, discussions ?
37