Megamodels of
Programming Technologies
Ralf Lämmel and Andrei Varanovich
Software Languages Team
University of Koblenz-Landau
Germany
Acknowledgement: Scientific co
llaboration with inspiration
from Dragan Gasevic and Jean-M
arie Favre. Thanks also to
© 2010-2011, Ralf Lämmel and 101companies
© 2010-2011, Ralf Lämmel and 101companies
We have
a problem.
EMF
SQL
TENEO
Java
XSD
DOM
Antlr
OWL
UML
XMI
Ecore
SQL DDL
XLST
Saxon
Hibernate
Awk
Json
Yacc
JAXP
Rest
OWL
RDF
ATOM
SparQL
XSLT
DTD
BNF
XSD
OCL
Prolog
grep
MOF
OMG
QVT
jDOM
Rose
Protegé
XQuery
ODM
XMLSpy
JPA
JAXB
JDBC
ODBC
MySQL
ArgoUML
Jean
Jena
Jena
Ralf
Dragan
TXL
VLDB
EMF.gen
ORACLE
TCS
XText
Teneo
Jersey
GWT
Sesame
Stratego
XPATH
JeanBeans
UTF8
ASCII
RDFa
RDF(S)
RDFS
CFG
LALR
ER
SLE2010
xerces
xalan
saxon
sax
sed
XSD
JMI
JMF
SBVR
© 2010-2011, Ralf Lämmel and 101companies
EMF
SQL
TENEO
Java
XSD
DOM
Antlr
OWL
UML
XMI
Ecore
SQL DDL
XLST
Saxon
Hibernate
Awk
Json
Yacc
JAXP
Rest
OWL
RDF
ATOM
SparQL
XSLT
DTD
BNF
XSD
OCL
Prolog
grep
MOF
OMG
QVT
jDOM
Rose
Protegé
XQuery
ODM
XMLSpy
JPA
JAXB
JDBC
ODBC
MySQL
ArgoUML
Jean
Jena
Jena
Ralf
Dragan
TXL
VLDB
EMF.gen
ORACLE
TCS
XText
Teneo
Jersey
GWT
Sesame
Stratego
XPATH
JeanBeans
UTF8
ASCII
RDFa
RDF(S)
RDFS
CFG
LALR
ER
SLE2010
xerces
xalan
saxon
sax
sed
XSD
JMI
JMF
SBVR
Issues with
programming technologies
•
Silos of knowledge
•
Combining technologies
•
Complexity of technologies
•
Entering a new space
© 2010-2011, Ralf Lämmel and 101companies
Why would you study computer science,
if your ultimate destiny is
to
get lost in space and technology
?
© 2010-2011, Ralf Lämmel and 101companies
Popular faculty opinion 1
Practice is terribly complex.
University should not bother.
© 2010-2011, Ralf Lämmel and 101companies
Popular faculty opinion 2
Practice is too complex.
University can not bother.
© 2010-2011, Ralf Lämmel and 101companies
Popular faculty opinion 3
Practice is incidentally complex.
University must not bother.
© 2010-2011, Ralf Lämmel and 101companies
Proposed opinion shift
Practice is amazingly complex and does not go away.
© 2010-2011, Ralf Lämmel and 101companies
EMF
SQL
TENEO
Java
XSD
DOM
Antlr
OWL
UML
XMI
Ecore
SQL DDL
XLST
Saxon
Hibernate
Awk
Json
Yacc
JAXP
Rest
OWL
RDF
ATOM
SparQL
XSLT
DTD
BNF
XSD
OCL
Prolog
grep
MOF
OMG
QVT
jDOM
Rose
Protegé
XQuery
ODM
XMLSpy
JPA
JAXB
JDBC
ODBC
MySQL
ArgoUML
Jean
Jena
Jena
Ralf
Dragan
TXL
VLDB
EMF.gen
ORACLE
TCS
XText
Teneo
Jersey
GWT
Sesame
Stratego
XPATH
JeanBeans
UTF8
ASCII
RDFa
RDF(S)
RDFS
CFG
LALR
ER
SLE2010
xerces
xalan
saxon
sax
sed
XSD
JMI
JMF
SBVR
•
Silos of knowledge
•
Combining technologies
•
Complexity of technologies
•
Entering a new space
•
Teaching technologies?
Issues with
programming technologies
•
Analogy
•
Examples
•
Abstraction
Our Approach
© 2010-2011, Ralf Lämmel and 101companies
Analogy
, examples, abstraction
MOF
XSD
RDFS
SQL.DDL
EBNF
OCL
XPath
QVT
XQuery
SPARQL
SQL
Protégé
Topbeard
XMLSpy
VS-XML
ArgoUML
Rose
MySQL
Oracle
XSLT
TXL
ASF
MetaEnv.
XML
VLDB
MoDELS
ECMDA
ICSW
ESWC
VLDB
SIGMOD
CC
POPL
Meta
language
Navigation
Query
Transfo.
Toolkit
Conferences
Sesame
© 2010-2011, Ralf Lämmel and 101companies
Analogy
in space travel
XMI
modelware
XMLware
javaware
JDBC
Dataware
JDOM
Ontware
Jena
Hibernate
EMF.gen
JMI
Teneo
JAXB
JPA
© 2010-2011, Ralf Lämmel and 101companies
Analogy,
examples
, abstraction
company "meganalysis" {
!
department "Research" {
!
!
manager "Craig" {
!
!
!
address "Redmond"
!
!
!
salary 123456
!
!
}
!
!
employee "Erik" {
!
!
!
address "Utrecht"
!
!
!
salary 12345
!
!
}
!
!
employee "Ralf" {
!
!
!
address "Koblenz"
!
!
!
salary 1234
!
!
}
!
}
!
department "Development" {
!
!
manager "Ray" {
!
!
!
address "Redmond"
!
!
!
salary 234567
!
!
}
...
Total
salaries
salaries
Cut
Store
companies
Navigate
© 2010-2011, Ralf Lämmel and 101companies
Total salaries in XQuery
Cut salaries in SQL DML
UPDATE employee
SET salary = salary / 2;
<result>
{sum(//salary)}
</result>
© 2010-2011, Ralf Lämmel and 101companies
Variation points for examples
X vs. O vs. R vs.
λ
etc.
Static typing vs. dynamic typing
Textual vs. abstract vs. visual syntax
GPPL vs. DSL vs. embedding vs. API
Instance- vs. operation-based mapping
Type checking vs. inference vs. reasoning
Code first vs. schema first vs. mapping only
In-memory processing vs. push vs. pull parsing
Pure vs. impure transformations (or in between)
Code vs. generative vs. model-driven vs. mapping
© 2010-2011, Ralf Lämmel and 101companies
Analogy, examples,
abstraction
What’s the taxonomy of programming technologies?
What’s the
essence
of technology
xyz
?
© 2010-2011, Ralf Lämmel and 101companies
© 2010-2011, Ralf Lämmel and 101companies
Abstraction with megamodels
An XSLT transformation
© 2010-2011, Ralf Lämmel and 101companies
Remember
Tombstone diagrams?
http://en.wikipedia.org/wiki/T-diagram
"Used for describing
complicated processes for
bootstrapping, porting, and
self-compiling of compilers,
interpreters, and
© 2010-2011, Ralf Lämmel and 101companies
© 2010-2011, Ralf Lämmel and 101companies
© 2010-2011, Ralf Lämmel and 101companies
Selected programming technologies
JDBC: Generic database access with Java
Hibernate: Object/relational mapping with Java
JAXB: XML-data binding with Java
xsd.exe, too: Typed database access with .NET
Entity Framework: Object/relational mapping with .NET
xsd.exe: XML-data binding with .NET
© 2010-2011, Ralf Lämmel and 101companies
Selected 101companies implementations
101implementation:jdbc
101implementation:hibernate
101implementation:jaxbComposition
101implementation:xsdDataSet
101implementation:ef
101implementation:xsdClasses
© 2010-2011, Ralf Lämmel and 101companies
© 2010-2011, Ralf Lämmel and 101companies
Running example:
XML-data binding for C# with xsd.exe
Involved entities: languages, artifacts, and technologies
Relationships between those entities
Additional aspects:
Use generated classes
Runtime de-serialization
XML transformation
© 2010-2011, Ralf Lämmel and 101companies
Involved languages
2
Ralf L¨
ammel and Andrei Varanovich
function) [[
·
]] :
S
→
(
U
→
B
) where
U
⊇
L
is again a suitable universe (in fact,
a language) from which to draw elements for inquiring membership for
L
and
B
denotes the Boolean value domain
{
T
,
F
}
. Thus, the generalized solution to the
membership problem for
L
⊆
U
specified by
s
∈
S
is stated as follows:
∀
x
∈
U. x
∈
L
⇐⇒
[[
s
]]
x
=
T
For instance, a context-free grammar
G
is interpreted as follows:
[[
G
]]
x
=
�
T
,
if
root
(
G
)
⇒
+
G
x
F
,
otherwise
Inspired by the grammar view, we also say that [[
s
]] denotes an acceptor for
L
.
Any acceptor for
L
with associated universe
U
⊇
L
should be a function of type
U
→
B
. Among all conceivable acceptors, [[
s
]] stands out by being essentially
derived from a specification. In practice, we may indeed consider acceptors that
are essentially black boxes, i.e., they are not declared to be derived from a
specification. For instance, a parser in a compiler may be handwritten or its
status may simply be unknown.
3
Megamodels
Megamodels
mm
= (“
import
”
name
)
∗
“
megamodel
”
name
“
{
”
dec
∗
“
}
”
Declarations
dec
= “
language
”
name
|
“
artifact
”
name
|
name rel name
|
“
constraint
”
name
“:”
name
+
|
“
transformation
”
name
“:”
name
+
“
→
”
name
Relationships
rel
= “
∈
”
|
“
⊂
”
|
“
⊆
”
| · · ·
Languages involved in XML-data binding for C# with
xsd.exe
:
language
C
#
language
XSD
Artifacts involved in XML-data binding for C# with
xsd.exe
:
artifact
aSchema
artifact
anObjectModel
artifact
aProgram
aSchema
∈
XSD
anObjectModel
∈
C
#
aProgram
∈
C
#
© 2010-2011, Ralf Lämmel and 101companies
Involved artifacts
(part I)
3
language
C
#
language
XSD
Artifacts:
artifact
aSchema
artifact
anObjectModel
aSchema
∈
XSD
anObjectModel
∈
C
#
Technology:
transformation
xsd
.
exe
:
XSD
→
C
#
Relationships:
xsd
.
exe
(
aSchema
)
�→
anObjectModel
The aspect of using the generated classes:
artifact
aProgram
aProgram
∈
C
#
constraint
uses
:
C
#
×
C
#
uses
(
aProgram
,
anObjectModel
)
The aspect of runtime de-serialization:
language
XML
language
RuntimeObjects
transformation
XmlSerializer
.
Deserialize
:
XML
→
RuntimeObjects
anXmlDoc
∈
XML
anObject
∈
RuntimeObjects
anXmlDoc
:
aSchema
anObject
:
anObjectModel
XmlSerializer
.
Deserialize
(
anXmlDoc
)
�→
anObject
The aspect of XML transformation through objects:
constraint
a
ff
ects
:
C
#
×
RuntimeObjects
transformation
XmlSerializer
.
Serialize
:
RuntimeObjects
→
XML
anXmlDoc
�
∈
XML
anXmlDoc
�
:
aSchema
a
ff
ects
(
aProgram
,
anObject
)
© 2010-2011, Ralf Lämmel and 101companies
The
xsd
.
exe
class generator
(Involved technology (part I))
3
language
C
#
language
XSD
Artifacts:
artifact
aSchema
artifact
anObjectModel
aSchema
∈
XSD
anObjectModel
∈
C
#
Technology:
transformation
xsd
.
exe
:
XSD
→
C
#
Relationships:
xsd
.
exe
(
aSchema
)
�→
anObjectModel
The aspect of using the generated classes:
artifact
aProgram
aProgram
∈
C
#
constraint
uses
:
C
#
×
C
#
uses
(
aProgram
,
anObjectModel
)
The aspect of runtime de-serialization:
language
XML
language
RuntimeObjects
transformation
XmlSerializer
.
Deserialize
:
XML
→
RuntimeObjects
anXmlDoc
∈
XML
anObject
∈
RuntimeObjects
anXmlDoc
:
aSchema
anObject
:
anObjectModel
XmlSerializer
.
Deserialize
(
anXmlDoc
)
�→
anObject
The aspect of XML transformation through objects:
constraint
a
ff
ects
:
C
#
×
RuntimeObjects
transformation
XmlSerializer
.
Serialize
:
RuntimeObjects
→
XML
anXmlDoc
�
∈
XML
anXmlDoc
�
:
aSchema
a
ff
ects
(
aProgram
,
anObject
)
XmlSerializer
.
Serialize
(
anObject
)
�→
anXmlDoc
�
3
Artifacts:
artifact
aSchema
artifact
anObjectModel
aSchema
∈
XSD
anObjectModel
∈
C
#
Technology:
transformation
xsd
.
exe
:
XSD
→
C
#
Relationships:
xsd
.
exe
(
aSchema
)
�→
anObjectModel
The aspect of using the generated classes:
artifact
aProgram
aProgram
∈
C
#
constraint
uses
:
C
#
×
C
#
uses
(
aProgram
,
anObjectModel
)
Runtime (de-)serialization:
© 2010-2011, Ralf Lämmel and 101companies
Language acceptors
(Involved technology (part II))
3
def
= (“
∀
”
name
“
∈
”
name
“
.
”)
+
rel
“=
def
”
rel
Languages involved in XML-data binding for C# with
xsd.exe
:
language
C
#
language
XSD
Artifacts:
artifact
aSchema
artifact
anObjectModel
aSchema
∈
XSD
anObjectModel
∈
C
#
Technology:
transformation
xsd
.
exe
:
XSD
→
C
#
Relationships:
xsd
.
exe
(
aSchema
)
�→
anObjectModel
Language acceptors:
language
Any
constraint
acceptXsd
.
exe
:
Any
constraint
acceptCsharp
.
exe
:
Any
∀
x
∈
Any
. x
∈
XSD
=
def
acceptXsd
.
exe
(
x
)
∀
x
∈
Any
. x
∈
C
# =
def
acceptCsharp
.
exe
(
x
)
The aspect of using the generated classes:
artifact
aProgram
aProgram
∈
C
#
constraint
uses
:
C
#
×
C
#
uses
(
aProgram
,
anObjectModel
)
The aspect of runtime de-serialization:
language
XML
language
RuntimeObjects
transformation
XmlSerializer
.
Deserialize
:
XML
→
RuntimeObjects
anXmlDoc
∈
XML
anObject
∈
RuntimeObjects
anXmlDoc
:
aSchema
anObject
:
anObjectModel
© 2010-2011, Ralf Lämmel and 101companies
The aspect of
using the generated classes
3
language
C
#
language
XSD
Artifacts:
artifact
aSchema
artifact
anObjectModel
aSchema
∈
XSD
anObjectModel
∈
C
#
Technology:
transformation
xsd
.
exe
:
XSD
→
C
#
Relationships:
xsd
.
exe
(
aSchema
)
�→
anObjectModel
The aspect of using the generated classes:
artifact
aProgram
aProgram
∈
C
#
constraint
uses
:
C
#
×
C
#
uses
(
aProgram
,
anObjectModel
)
The aspect of runtime de-serialization:
language
XML
language
RuntimeObjects
transformation
XmlSerializer
.
Deserialize
:
XML
→
RuntimeObjects
anXmlDoc
∈
XML
anObject
∈
RuntimeObjects
anXmlDoc
:
aSchema
anObject
:
anObjectModel
XmlSerializer
.
Deserialize
(
anXmlDoc
)
�→
anObject
The aspect of XML transformation through objects:
constraint
a
ff
ects
:
C
#
×
RuntimeObjects
transformation
XmlSerializer
.
Serialize
:
RuntimeObjects
→
XML
anXmlDoc
�
∈
XML
anXmlDoc
�
:
aSchema
a
ff
ects
(
aProgram
,
anObject
)
© 2010-2011, Ralf Lämmel and 101companies
The aspect of
runtime de-serialization
3
language
C
#
language
XSD
Artifacts:
artifact
aSchema
artifact
anObjectModel
aSchema
∈
XSD
anObjectModel
∈
C
#
Technology:
transformation
xsd
.
exe
:
XSD
→
C
#
Relationships:
xsd
.
exe
(
aSchema
)
�→
anObjectModel
The aspect of using the generated classes:
artifact
aProgram
aProgram
∈
C
#
constraint
uses
:
C
#
×
C
#
uses
(
aProgram
,
anObjectModel
)
The aspect of runtime de-serialization:
language
XML
language
RuntimeObjects
transformation
XmlSerializer
.
Deserialize
:
XML
→
RuntimeObjects
anXmlDoc
∈
XML
anObject
∈
RuntimeObjects
anXmlDoc
:
aSchema
anObject
:
anObjectModel
XmlSerializer
.
Deserialize
(
anXmlDoc
)
�→
anObject
The aspect of XML transformation through objects:
constraint
affects
:
C
#
×
RuntimeObjects
transformation
XmlSerializer
.
Serialize
:
RuntimeObjects
→
XML
anXmlDoc
�
∈
XML
anXmlDoc
�
:
aSchema
affects
(
aProgram
,
anObject
)
© 2010-2011, Ralf Lämmel and 101companies
The aspect of
XML transformation
3
language
C
#
language
XSD
Artifacts:
artifact
aSchema
artifact
anObjectModel
aSchema
∈
XSD
anObjectModel
∈
C
#
Technology:
transformation
xsd
.
exe
:
XSD
→
C
#
Relationships:
xsd
.
exe
(
aSchema
)
�→
anObjectModel
The aspect of using the generated classes:
artifact
aProgram
aProgram
∈
C
#
constraint
uses
:
C
#
×
C
#
uses
(
aProgram
,
anObjectModel
)
The aspect of runtime de-serialization:
language
XML
language
RuntimeObjects
transformation
XmlSerializer
.
Deserialize
:
XML
→
RuntimeObjects
anXmlDoc
∈
XML
anObject
∈
RuntimeObjects
anXmlDoc
:
aSchema
anObject
:
anObjectModel
XmlSerializer
.
Deserialize
(
anXmlDoc
)
�→
anObject
The aspect of XML transformation through objects:
constraint
a
ff
ects
:
C
#
×
RuntimeObjects
transformation
XmlSerializer
.
Serialize
:
RuntimeObjects
→
XML
anXmlDoc
�
∈
XML
anXmlDoc
�
:
aSchema
a
ff
ects
(
aProgram
,
anObject
)
© 2010-2011, Ralf Lämmel and 101companies
The aspect of
a constrained target language:
4
Ralf L¨
ammel and Andrei Varanovich
The aspect of XML transformation:
constraint
a
ff
ects
:
C
#
×
RuntimeObjects
transformation
XmlSerializer
.
Serialize
:
RuntimeObjects
→
XML
anXmlDoc
�
∈
XML
anXmlDoc
�
:
aSchema
a
ff
ects
(
aProgram
,
anObject
)
XmlSerializer
.
Serialize
(
anObject
)
�→
anXmlDoc
�
The aspect of a constrained target language:
constraint
O
/
X
:
C
#
O
/
X
(
anObjectModel
)
An alternative form of expression:
language
C
#
−
O
/
X
C
#
−
O
/
X
⊂
C
#
anObjectModel
∈
C
#
−
O
/
X
Query language-based definition of target language:
language
C
#
−
QL
constraint
C
#
−
QL
−
interpreter
:
C
#
−
QL
×
C
#
ox
.
csharpQl
∈
C
#
−
QL
∀
x
∈
C
#
. x
∈
C
#
−
O
/
X
=
def
C
#
−
QL
−
interpreter
(
ox
.
csharpQl
, x
)
Megamodel for the query language:
language
PT
-- Prolog terms
language
PTG
-- Prolog term grammars
constraint
PTG
−
acceptor
:
PTG
×
PT
artifact
csharpQl
.
ptg
-- a grammar for
C
#
−
QL
csharpQl
.
ptg
∈
PTG
∀
x
∈
PT
. x
:
csharpQl
.
ptg
=
def
PTG
−
acceptor
(
csharpQl
.
ptg
, x
)
∀
x
∈
PT
. x
∈
C
#
−
QL
=
def
x
:
csharpQl
.
ptg
4
Ralf L¨
ammel and Andrei Varanovich
The aspect of XML transformation:
constraint
a
ff
ects
:
C
#
×
RuntimeObjects
transformation
XmlSerializer
.
Serialize
:
RuntimeObjects
→
XML
anXmlDoc
�
∈
XML
anXmlDoc
�
:
aSchema
a
ff
ects
(
aProgram
,
anObject
)
XmlSerializer
.
Serialize
(
anObject
)
�→
anXmlDoc
�
The aspect of a constrained target language:
constraint
O
/
X
:
C
#
O
/
X
(
anObjectModel
)
An alternative form of expression:
language
C
#
−
O
/
X
C
#
−
O
/
X
⊂
C
#
anObjectModel
∈
C
#
−
O
/
X
Query language-based definition of target language:
language
C
#
−
QL
constraint
C
#
−
QL
−
interpreter
:
C
#
−
QL
×
C
#
ox
.
csharpQl
∈
C
#
−
QL
∀
x
∈
C
#
. x
∈
C
#
−
O
/
X
=
def
C
#
−
QL
−
interpreter
(
ox
.
csharpQl
, x
)
Megamodel for the query language:
language
PT
-- Prolog terms
language
PTG
-- Prolog term grammars
constraint
PTG
−
acceptor
:
PTG
×
PT
artifact
csharpQl
.
ptg
-- a grammar for
C
#
−
QL
csharpQl
.
ptg
∈
PTG
∀
x
∈
PT
. x
:
csharpQl
.
ptg
=
def
PTG
−
acceptor
(
csharpQl
.
ptg
, x
)
∀
x
∈
PT
. x
∈
C
#
−
QL
=
def
x
:
csharpQl
.
ptg
Alternatively:
© 2010-2011, Ralf Lämmel and 101companies
Query language-based
definition of target language
4
Ralf L¨
ammel and Andrei Varanovich
The aspect of XML transformation:
constraint
a
ff
ects
:
C
#
×
RuntimeObjects
transformation
XmlSerializer
.
Serialize
:
RuntimeObjects
→
XML
anXmlDoc
�
∈
XML
anXmlDoc
�
:
aSchema
a
ff
ects
(
aProgram
,
anObject
)
XmlSerializer
.
Serialize
(
anObject
)
�→
anXmlDoc
�
The aspect of a constrained target language:
constraint
O
/
X
:
C
#
O
/
X
(
anObjectModel
)
An alternative form of expression:
language
C
#
−
O
/
X
C
#
−
O
/
X
⊂
C
#
anObjectModel
∈
C
#
−
O
/
X
Query language-based definition of target language:
language
C
#
−
QL
constraint
C
#
−
QL
−
evaluator
:
C
#
−
QL
×
C
#
ox
.
csharpQl
∈
C
#
−
QL
∀
x
∈
C
#
. x
∈
C
#
−
O
/
X
=
def
C
#
−
QL
−
evaluator
(
ox
.
csharpQl
, x
)
Megamodel for the query language:
language
PT
-- Prolog terms
language
PTG
-- Prolog term grammars
constraint
runPtg
.
pro
:
PTG
×
PT
artifact
csharpQl
.
ptg
-- a grammar for
C
#
−
QL
csharpQl
.
ptg
∈
PTG
∀
x
∈
PT
. x
:
csharpQl
.
ptg
=
def
runPtg
.
pro
(
csharpQl
.
ptg
, x
)
© 2010-2011, Ralf Lämmel and 101companies
ox.csharpQl
and([
or(map(
match('This source code was auto-generated by xsd'),
collect(comment))),
not(null(collect(attribute('System.Xml.Serialization.*')))),
and(map(
test(classDeclaration),
collect(typeDeclaration))),
null(collect(methodDeclaration)),
and(map(
not(null(attribute('System.SerializableAttribute'))),
collect(classDeclaration)
))
]).
© 2010-2011, Ralf Lämmel and 101companies
bquery(not(B)) :- bquery(B).
bquery(and(Bs)) :- queries(Bs).
bquery(or(Bs)) :- queries(Bs).
bquery(null(L)) :- lquery(L).
bquery(test(S)) :- sort(S).
bquery(match(A)) :- atom(A).
queries(Bs) :- star(bquery,Bs).
queries(map(B,L)) :- bquery(B), lquery(L).
lquery(S) :- sort(S).
lquery(collect(L)) :- lquery(L).
lquery(attribute(A)) :- atom(A).
sort(comment).
sort(typeDeclaration).
sort(classDeclaration).
sort(methodDeclaration).
C#-QL
© 2010-2011, Ralf Lämmel and 101companies
Megamodel
for the query language
4
Ralf L¨
ammel and Andrei Varanovich
The aspect of XML transformation:
constraint
a
ff
ects
:
C
#
×
RuntimeObjects
transformation
XmlSerializer
.
Serialize
:
RuntimeObjects
→
XML
anXmlDoc
�
∈
XML
anXmlDoc
�
:
aSchema
a
ff
ects
(
aProgram
,
anObject
)
XmlSerializer
.
Serialize
(
anObject
)
�→
anXmlDoc
�
The aspect of a constrained target language:
constraint
O
/
X
:
C
#
O
/
X
(
anObjectModel
)
An alternative form of expression:
language
C
#
−
O
/
X
C
#
−
O
/
X
⊂
C
#
anObjectModel
∈
C
#
−
O
/
X
Query language-based definition of target language:
language
C
#
−
QL
constraint
C
#
−
QL
−
evaluator
:
C
#
−
QL
×
C
#
ox
.
csharpQl
∈
C
#
−
QL
∀
x
∈
C
#
. x
∈
C
#
−
O
/
X
=
def
C
#
−
QL
−
evaluator
(
ox
.
csharpQl
, x
)
Megamodel for the query language:
language
PT
-- Prolog terms
language
PTG
-- Prolog term grammars
constraint
runPtg
.
pro
:
PTG
×
PT
artifact
csharpQl
.
ptg
-- a grammar for
C
#
−
QL
csharpQl
.
ptg
∈
PTG
∀
x
∈
PT
. x
:
csharpQl
.
ptg
=
def
runPtg
.
pro
(
csharpQl
.
ptg
, x
)
© 2010-2011, Ralf Lämmel and 101companies
Megamodels -- language summary
Syntax
Megamodels
Entities
Relationships
Definitions
Bindings (omitted)
Entity parameters (omitted)
Static semantics = coherence checks on relationships
Dynamic semantics = constraint/transformation execution
Inference = match parametric models with actual projects
© 2010-2011, Ralf Lämmel and 101companies
Megamodels
2
Ralf L¨
ammel and Andrei Varanovich
function) [[
·
]] :
S
→
(
U
→
B
) where
U
⊇
L
is again a suitable universe (in fact,
a language) from which to draw elements for inquiring membership for
L
and
B
denotes the Boolean value domain
{
T
,
F
}
. Thus, the generalized solution to the
membership problem for
L
⊆
U
specified by
s
∈
S
is stated as follows:
∀
x
∈
U. x
∈
L
⇐⇒
[[
s
]]
x
=
T
For instance, a context-free grammar
G
is interpreted as follows:
[[
G
]]
x
=
�
T
,
if
root
(
G
)
⇒
+
G
x
F
,
otherwise
Inspired by the grammar view, we also say that [[
s
]] denotes an acceptor for
L
.
Any acceptor for
L
with associated universe
U
⊇
L
should be a function of type
U
→
B
. Among all conceivable acceptors, [[
s
]] stands out by being essentially
derived from a specification. In practice, we may indeed consider acceptors that
are essentially black boxes, i.e., they are not declared to be derived from a
specification. For instance, a parser in a compiler may be handwritten or its
status may simply be unknown.
3
Megamodels
Megamodels:
mm
= (“
import
”
name
)
∗
“
megamodel
”
name
“
{
”
(
entity
|
rel
|
def
|
bind
)
∗
“
}
”
Entities:
entity
= “
language
”
name
|
“
artifact
”
name
|
“
constraint
”
name
“:”
{
name
“
×
”
}
+
|
“
transformation
”
name
“:”
{
name
“
×
”
}
+
“
→
”
{
name
“
×
”
}
+
Relationships:
rel
=
name
“:”
name
|
name
“
∈
”
name
|
name
“
⊂
”
name
|
name
“
⊆
”
name
|
name
“(”
{
name
“
,
”
}
+
“)”
|
name
“(”
{
name
“
,
”
}
+
“)” “
�→
”
name
|
name
“(”
{
name
“
,
”
}
+
“)” “
�→
” “(”
{
name
“
,
”
}
+
“)”
Definitions:
© 2010-2011, Ralf Lämmel and 101companies
Entities
2
Ralf L¨
ammel and Andrei Varanovich
function) [[
·
]] :
S
→
(
U
→
B
) where
U
⊇
L
is again a suitable universe (in fact,
a language) from which to draw elements for inquiring membership for
L
and
B
denotes the Boolean value domain
{
T
,
F
}
. Thus, the generalized solution to the
membership problem for
L
⊆
U
specified by
s
∈
S
is stated as follows:
∀
x
∈
U. x
∈
L
⇐⇒
[[
s
]]
x
=
T
For instance, a context-free grammar
G
is interpreted as follows:
[[
G
]]
x
=
�
T
,
if
root
(
G
)
⇒
+
G
x
F
,
otherwise
Inspired by the grammar view, we also say that [[
s
]] denotes an acceptor for
L
.
Any acceptor for
L
with associated universe
U
⊇
L
should be a function of type
U
→
B
. Among all conceivable acceptors, [[
s
]] stands out by being essentially
derived from a specification. In practice, we may indeed consider acceptors that
are essentially black boxes, i.e., they are not declared to be derived from a
specification. For instance, a parser in a compiler may be handwritten or its
status may simply be unknown.
3
Megamodels
Megamodels:
mm
= (“
import
”
name
)
∗
“
megamodel
”
name
“
{
”
(
entity
|
rel
|
def
|
bind
)
∗
“
}
”
Entities:
entity
= “
language
”
name
|
“
artifact
”
name
|
“
constraint
”
name
“:”
{
name
“
×
”
}
+
|
“
transformation
”
name
“:”
{
name
“
×
”
}
+
“
→
”
{
name
“
×
”
}
+
Relationships:
rel
=
name
“:”
name
|
name
“
∈
”
name
|
name
“
⊂
”
name
|
name
“
⊆
”
name
|
name
“(”
{
name
“
,
”
}
+
“)”
|
name
“(”
{
name
“
,
”
}
+
“)” “
�→
”
name
|
name
“(”
{
name
“
,
”
}
+
“)” “
�→
” “(”
{
name
“
,
”
}
+
“)”
Definitions:
© 2010-2011, Ralf Lämmel and 101companies
Relationships
2
Ralf L¨
ammel and Andrei Varanovich
function) [[
·
]] :
S
→
(
U
→
B
) where
U
⊇
L
is again a suitable universe (in fact,
a language) from which to draw elements for inquiring membership for
L
and
B
denotes the Boolean value domain
{
T
,
F
}
. Thus, the generalized solution to the
membership problem for
L
⊆
U
specified by
s
∈
S
is stated as follows:
∀
x
∈
U. x
∈
L
⇐⇒
[[
s
]]
x
=
T
For instance, a context-free grammar
G
is interpreted as follows:
[[
G
]]
x
=
�
T
,
if
root
(
G
)
⇒
+
G
x
F
,
otherwise
Inspired by the grammar view, we also say that [[
s
]] denotes an acceptor for
L
.
Any acceptor for
L
with associated universe
U
⊇
L
should be a function of type
U
→
B
. Among all conceivable acceptors, [[
s
]] stands out by being essentially
derived from a specification. In practice, we may indeed consider acceptors that
are essentially black boxes, i.e., they are not declared to be derived from a
specification. For instance, a parser in a compiler may be handwritten or its
status may simply be unknown.
3
Megamodels
Megamodels:
mm
= (“
import
”
name
)
∗
“
megamodel
”
name
“
{
”
(
entity
|
rel
|
def
|
bind
)
∗
“
}
”
Entities:
entity
= “
language
”
name
|
“
artifact
”
name
|
“
constraint
”
name
“:”
{
name
“
×
”
}
+
|
“
transformation
”
name
“:”
{
name
“
×
”
}
+
“
→
”
{
name
“
×
”
}
+
Relationships:
rel
=
name
“:”
name
|
name
“
∈
”
name
|
name
“
⊂
”
name
|
name
“
⊆
”
name
|
name
“(”
{
name
“
,
”
}
+
“)”
|
name
“(”
{
name
“
,
”
}
+
“)” “
�→
”
name
|
name
“(”
{
name
“
,
”
}
+
“)” “
�→
” “(”
{
name
“
,
”
}
+
“)”
Definitions:
© 2010-2011, Ralf Lämmel and 101companies
Definitions
3
def
= (“
∀
”
name
“
∈
”
name
“
.
”)
+
rel
“=
def
”
rel
Languages involved in XML-data binding for C# with
xsd.exe
:
language
C
#
language
XSD
Artifacts:
artifact
aSchema
artifact
anObjectModel
aSchema
∈
XSD
anObjectModel
∈
C
#
Technology:
transformation
xsd
.
exe
:
XSD
→
C
#
Relationships:
xsd
.
exe
(
aSchema
)
�→
anObjectModel
Language acceptors:
language
Any
constraint
XSD
−
acceptor
:
Any
constraint
C
#
−
acceptor
:
Any
∀
x
∈
Any
. x
∈
XSD
=
def
XSD
−
acceptor
(
x
)
∀
x
∈
Any
. x
∈
C
# =
def
C
#
−
acceptor
(
x
)
The aspect of using the generated classes:
artifact
aProgram
aProgram
∈
C
#
constraint
uses
:
C
#
×
C
#
uses
(
aProgram
,
anObjectModel
)
The aspect of runtime de-serialization:
language
XML
language
RuntimeObjects
transformation
XmlSerializer
.
Deserialize
:
XML
→
RuntimeObjects
anXmlDoc
∈
XML
anObject
∈
RuntimeObjects
anXmlDoc
:
aSchema
anObject
:
anObjectModel
© 2010-2011, Ralf Lämmel and 101companies