Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
A DSTL To
Bridge Concrete and
Abstract Syntax
Adolfo Sánchez-Barbudo Herrera, Edward D. Willink and
Richard F. Paige
Agenda
● Scope
● Problem
● Solution
● Comparative Study
2
Scope
● Complex Textual Modeling Languages
○ CS is textual (particularly, defined by a grammar)
○ AS is model-based (parti...
Agenda
● Scope
● Problem
● Solution
● Comparative Study
4
Problem
● Related works (e.g. Xtext) allow to map CS grammars to AS meta-models, but...
● let … in x.y -- an OCL expressio...
Problem II
CallExpCS:
PrimaryExpCS ( ('.' | '->') NameExpCS)*
NameExpCS:
SimpleNameCS (RoundedBracketClauseCS)?
SimpleName...
Problem III
● Support to non-simple (i.e. 1-1) CS2AS mappings
○ e.g. a NameExpCS may map to a VariableExp and PropertyCall...
Agenda
● Scope
● Problem
● Solution
● Comparative Study
8
Solution
Generates
Manual
artefact
Generated
artefact
AS
MM
conformsTo
AS
Model
conformsTo
Textual
Input
CS
Grammar
CS
MM
...
Solution II
● (External) DSTL to bridge CS and AS (meta-models).
● Why is domain-specific
○ Just one input domain and one ...
DSTL: Helpers
● To define contextual operations
helpers {
NameExpCS::parentAsCallExpCS() : CallExpCS =
let container = sel...
DSTL: Mappings
● To define mappings between CS and AS (meta-)classes
mappings {
map PropertyCallExp from NameExpCS
when is...
DSTL: Mappings II
● Multi-way mappings (same NameExpCS mapped to different outcomes)
mappings {
map PropertyCallExp from N...
DSTL: Disambiguation Rules
● To define disambiguation rules
disambiguation {
NameExpCS {
isOpCallExpWithImplicitSource := ...
Name Resolution
● Activity to solve AS cross-references, which involve a name-based lookup
○ From an AS element another na...
Name Resolution II
● Current Scope
class C1 {
prop p1 : String;
op getP1(): String = p1;
}
:
Expression
InOCL
:
Property
C...
Name Resolution III
● Exported Scope
class C1 {
prop p1 : String;
op getP1(): String
= p1;
}
class C2 {
prop c1 : C1;
op g...
Name Resolution IV
● Nested Scope (name oclusssion)
-- valid expression which
-- evaluates to false
let v = ‘foo’
in let v...
DSTL: Name Resolution
● To define name resolution
targets {
NamedElement using name; -- ’name’: property used to identify ...
DSTL: Name Resolution II
● Slightly more complex name resolution
providers {
Class {
in current-scope provides
occluding o...
DSTL: Name Resolution III
● Expressions to perform name-based lookups
trace.lookup(Variable, 'self')
Kind of target to loo...
Agenda
● Scope
● Problem
● Solution
● Comparative Study
22
Comparative Study: Gra2Mol
● Gra2Mol
○ DSTL can be used for the same purpose: bridging CS and AS syntax
○ Map arbitrary gr...
Qualitative Study
● Gra2Mol pros:
○ Query Language is more concise (few and effort-saving navigation operators)
○ Provides...
Quantitative Study: Example
company :
’company’ STRING ’{’ department* ’}’ EOF;
department :
’department’ STRING ’{’
depar...
Quantitative Study: Gra2Mol
rule 'mapDepartment'
from department d
to Department
queries
mElem : /d/department_manager/#em...
Quantitative Study: CS2AS DSTL
mappings {
map Department from department {
name := name;
manager := department_manager.emp...
Quantitative Study: Inputs Generator
● Nd: No
of (top level) departments
● Ns: No
of subdeparments
○ per departement/subde...
Quantitative Study: Results
● CS2AS tx execution measured
● Overall: 10-fold improvement
● Input topology does not impact ...
Thanks you very much !!!!
asbh500@york.ac.uk / me@adolfosbh.co
@adolfosbh
Questions ?
30
Próxima SlideShare
Cargando en…5
×

A DSTL to bridge concrete and abstract syntax

Introduction to a Model-to-Model Domain specific transformation language, that is used to map CS metamodels to AS metamodels

  • Inicia sesión para ver los comentarios

  • Sé el primero en recomendar esto

A DSTL to bridge concrete and abstract syntax

  1. 1. A DSTL To Bridge Concrete and Abstract Syntax Adolfo Sánchez-Barbudo Herrera, Edward D. Willink and Richard F. Paige
  2. 2. Agenda ● Scope ● Problem ● Solution ● Comparative Study 2
  3. 3. Scope ● Complex Textual Modeling Languages ○ CS is textual (particularly, defined by a grammar) ○ AS is model-based (particularly, defined by a meta-model) ○ Complex Language = AS definition can not be directly inferred from CS definition ● Examples ○ Languages specified by OMG, such as OCL and QVT languages. ○ OCL specification defines the CS via a grammar (Clause 9.3) ○ OCL specification defines the AS via a meta-model (Clause 8) ○ OCL specification describes how to obtain AS from CS (Clause 9.4) 3
  4. 4. Agenda ● Scope ● Problem ● Solution ● Comparative Study 4
  5. 5. Problem ● Related works (e.g. Xtext) allow to map CS grammars to AS meta-models, but... ● let … in x.y -- an OCL expression ○ ‘y’ is a navigation (i.e. a PropertyCallExp in the AS) ○ ‘x’ ? → It depends on the context y: Property CallExp x: VariableExp ownedSource x: Property CallExp self: VariableExp y: Property CallExp ownedSource ownedSource ‘x’ is a variable name ‘x’ is a property name (i.e self.x.y) 5
  6. 6. Problem II CallExpCS: PrimaryExpCS ( ('.' | '->') NameExpCS)* NameExpCS: SimpleNameCS (RoundedBracketClauseCS)? SimpleNameCS: ID; RoundedBracketClauseCS: '(' (ExpCS (',' ExpCS)* )? ')' OCLExpression Operation CallExp Variable Exp Property CallExp Problem: Syntactically, it can not be determined if a simple name corresponds to a PropertyCallExp or VariableExp 6
  7. 7. Problem III ● Support to non-simple (i.e. 1-1) CS2AS mappings ○ e.g. a NameExpCS may map to a VariableExp and PropertyCallExp (output pattern) ● Support to cross-references computation ○ e.g. an OCLExpression is a TypedElement: it requires a type cross-reference to be computed ● Name resolution ○ Special case of cross-reference computation ○ e.g. a VariableExp requires to refer to a Variable. ● CS Disambiguation ○ e.g. a NameExpCS may map to either an OperationCallExp, or a PropertyCallExp, or a VariableExp 7
  8. 8. Agenda ● Scope ● Problem ● Solution ● Comparative Study 8
  9. 9. Solution Generates Manual artefact Generated artefact AS MM conformsTo AS Model conformsTo Textual Input CS Grammar CS MM Parser CS Model conformsTo (e.g. like Xtext) M2M tx from to CS2AS Bridge (modelware) 9
  10. 10. Solution II ● (External) DSTL to bridge CS and AS (meta-models). ● Why is domain-specific ○ Just one input domain and one output domain (no in-place tx) ○ Specific constructs for name resolution ○ Specific guards semantics for disambiguation rules ● Features: ○ Declarative (M2M) language ○ Resuses Essential OCL as expressions language ○ Currently, four sections ■ helpers ■ mappings ■ disambiguation rules ■ name resolution 10
  11. 11. DSTL: Helpers ● To define contextual operations helpers { NameExpCS::parentAsCallExpCS() : CallExpCS = let container = self.oclContainer() in if container.oclIsKindOf(CallExpCS) then container.oclAsType(CallExpCS) else null endif NameExpCS::isNameExpOfACallExpCS() : Boolean = let parentCallExpCS = parentAsCallExpCS() in parentCallExpCS <> null and parentCallExpCS.nameExp = self } body result context 11
  12. 12. DSTL: Mappings ● To define mappings between CS and AS (meta-)classes mappings { map PropertyCallExp from NameExpCS when isPropCallExpWithImplicitSource { ownedSource := let referredVar = trace.lookup(Variable, 'self') in VariableExp { referredVariable = referredVar, type = referredVar.type } referredProperty := trace.lookupExported(Property, trace.ownedSource.type, expName), type := trace.referredProperty?.type} } Mapping guard AS property initialization To access AS domain from the CS one Lookup expressions Target AS term Source CS term 12
  13. 13. DSTL: Mappings II ● Multi-way mappings (same NameExpCS mapped to different outcomes) mappings { map PropertyCallExp from NameExpCS when isPropCallExpWithImplicitSource { … } map PropertyCallExp from NameExpCS when isPropCallExpWithExplicitSource { … } map OperationCallExp from NameExpCS when isOpCallExpWithExplicitSource { … } map OperationCallExp from NameExpCS when isOpCallExpWithExplicitSource { … } map VariableExp from NameExpCS when isVariableExp { … } } Same source (CS) Different targets (AS) 13
  14. 14. DSTL: Disambiguation Rules ● To define disambiguation rules disambiguation { NameExpCS { isOpCallExpWithImplicitSource := roundedBrackets <> null and not isNameExpOfACallExpCS() isOpCallExpWithExplicitSource := roundedBrackets <> null and isNameExpOfACallExpCS() isPropCallExpWithExplicitSource := roundedBrackets = null and isNameExpOfACallExpCS() isVariableExp := … isPropCallExpWithImplicitSource := … } } CS element to disambiguate Disambiguation rule name Boolean-valued expression Important: Order matters 14
  15. 15. Name Resolution ● Activity to solve AS cross-references, which involve a name-based lookup ○ From an AS element another named AS element needs to be found in the model. ○ Declaratively, it’s matter of how named elements are contributed to lookup scopes. ○ Scopes are key data structures that keep all visible named element within that scope. ● Scopes: ○ Current Scope ○ Exported Scope ○ Nested Scopes 15
  16. 16. Name Resolution II ● Current Scope class C1 { prop p1 : String; op getP1(): String = p1; } : Expression InOCL : Property CallExp class C2 { op getP1() : String = p1; } : Expression InOCL : Property CallExp C1: Class p1: Property getP1: Operation referredProperty C2: Class getP1: Operation referredProperty 16
  17. 17. Name Resolution III ● Exported Scope class C1 { prop p1 : String; op getP1(): String = p1; } class C2 { prop c1 : C1; op getP1() : String = c1.p1; } : Expression InOCL : Property CallExp : Expression InOCL : Property CallExp C1: Class p1: Property getP1: Operation referredProperty getP1: Operation referredProperty : Property CallExp referredProperty C2: Class c1: Property 17
  18. 18. Name Resolution IV ● Nested Scope (name oclusssion) -- valid expression which -- evaluates to false let v = ‘foo’ in let v = ‘bar’ in v = ‘foo’ ‘foo’: String LiteralExp : LetExp : LetExp v: Variable v: Variable ‘bar’: String LiteralExp ‘foo’: String LiteralExp ‘=’: Operation CallExp : Variable Exp ‘v’ -> Variable (‘foo’) ‘v’ -> Variable (‘bar’)parent nested 18
  19. 19. DSTL: Name Resolution ● To define name resolution targets { NamedElement using name; -- ’name’: property used to identify ’targets’ Property; -- ’using’ is optional: extends a fully defined ’target’ element } inputs { SimpleNameCS using name; -- ’name’: property used to match ’targets’ } providers { Class { in current-scope provides occluding ownedProperties; in exported-scope provides ownedProperties; } } 19
  20. 20. DSTL: Name Resolution II ● Slightly more complex name resolution providers { Class { in current-scope provides occluding ownedProperties occluding getAllSuperClasses().ownedProperties; in exported-scope provides ownedProperties occluding getAllSuperClasses().ownedProperties; } } 20
  21. 21. DSTL: Name Resolution III ● Expressions to perform name-based lookups trace.lookup(Variable, 'self') Kind of target to look up trace.lookupExported(Property,trace.ownedSource.type, expName) The lookup input (a String)Lookup in current scope Lookup in a exported scope Kind of target to look up Actual element providing the exported scope The lookup input (a SimpleNameCS) 21
  22. 22. Agenda ● Scope ● Problem ● Solution ● Comparative Study 22
  23. 23. Comparative Study: Gra2Mol ● Gra2Mol ○ DSTL can be used for the same purpose: bridging CS and AS syntax ○ Map arbitrary grammars to arbitrary AS meta-models Source Target Nature Query Language Gra2Mol Grammar Terms AS MM Terms Declarative Structure-Shy (Xpath Like) CS2AS DSTL CS MM Terms AS MM Terms Declarative Statically Typed (Essent. OCL) 23
  24. 24. Qualitative Study ● Gra2Mol pros: ○ Query Language is more concise (few and effort-saving navigation operators) ○ Provides a language extensibility mechanism ● CS2AS DSTL pros: ○ OCL has more expressive power (beyond simple model navigation) ○ AS model can be navigated (Gra2Mol QL only operates at CS level) ○ No coupling with a parsing technology ○ Declarative name resolution section saves encoding lookup algorithms ■ to resolve name-based cross-references ○ Ordering-based disambiguation rules description ■ to overcome their admitted limitation of having to define exclusive rule guards. 24
  25. 25. Quantitative Study: Example company : ’company’ STRING ’{’ department* ’}’ EOF; department : ’department’ STRING ’{’ department_manager department_employees department* ’}’; department_manager : ’manager’ employee; department_employees : (’employee’ employee)*; employee : STRING ’{’ ’address’ STRING ’salary’ FLOAT (’mentor’ STRING)? ’}’; 25
  26. 26. Quantitative Study: Gra2Mol rule 'mapDepartment' from department d to Department queries mElem : /d/department_manager/#employee; eElem : /d/department_employees/#employee; dElem : /d/#department; mappings name = removeQuotes d.STRING; manager = mElem; employees = eElem; subdepts = dElem; end_rule 26
  27. 27. Quantitative Study: CS2AS DSTL mappings { map Department from department { name := name; manager := department_manager.employee.trace; employees := department_employees.employee.trace; subdepts := deparment.trace; } } 27
  28. 28. Quantitative Study: Inputs Generator ● Nd: No of (top level) departments ● Ns: No of subdeparments ○ per departement/subdepartment ● Ne: No of employees ○ per departement/subdepartment ● Ds: Depth level of (sub)departments ID Size (bytes) Elements Nd Ns Ne Ds 1 1,238 22 3 0 3 1 2 6,105 97 3 3 4 2 3 149,951 701 1 1 3 100 4 42,805 708 1 100 3 2 5 223,848 3061 4 4 5 4 6 1,018,254 11901 10 4 10 4 7 9,794,276 109341 10 5 10 5 28
  29. 29. Quantitative Study: Results ● CS2AS tx execution measured ● Overall: 10-fold improvement ● Input topology does not impact to our solution 29
  30. 30. Thanks you very much !!!! asbh500@york.ac.uk / me@adolfosbh.co @adolfosbh Questions ? 30

×