Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Domain Specific Languages      Two Types of Language Engineering    Technologies for Language Engineering             DSM-i...
Domain Specific Languages             Two Types of Language Engineering           Technologies for Language Engineering    ...
Domain Specific Languages     What are DSLs?          Two Types of Language Engineering     An Example DSL        Technolog...
Domain Specific Languages     What are DSLs?            Two Types of Language Engineering     An Example DSL          Techn...
Domain Specific Languages     What are DSLs?          Two Types of Language Engineering     An Example DSL        Technolog...
Domain Specific Languages     What are DSLs?          Two Types of Language Engineering     An Example DSL        Technolog...
Domain Specific Languages     What are DSLs?          Two Types of Language Engineering     An Example DSL        Technolog...
Domain Specific Languages     What are DSLs?           Two Types of Language Engineering     An Example DSL         Technol...
Domain Specific Languages     What are DSLs?               Two Types of Language Engineering     An Example DSL            ...
Domain Specific Languages          Two Types of Language Engineering     λ − Calculus        Technologies for Language Engi...
Domain Specific Languages           Two Types of Language Engineering     λ − Calculus         Technologies for Language En...
Domain Specific Languages          Two Types of Language Engineering     λ − Calculus        Technologies for Language Engi...
Domain Specific Languages          Two Types of Language Engineering     λ − Calculus        Technologies for Language Engi...
Domain Specific Languages           Two Types of Language Engineering     λ − Calculus         Technologies for Language En...
Domain Specific Languages           Two Types of Language Engineering     λ − Calculus         Technologies for Language En...
Domain Specific Languages           Two Types of Language Engineering     λ − Calculus         Technologies for Language En...
Domain Specific Languages           Two Types of Language Engineering     λ − Calculus         Technologies for Language En...
Domain Specific Languages           Two Types of Language Engineering     λ − Calculus         Technologies for Language En...
Domain Specific Languages          Two Types of Language Engineering     λ − Calculus        Technologies for Language Engi...
Domain Specific Languages            Two Types of Language Engineering     λ − Calculus          Technologies for Language ...
Domain Specific Languages          Two Types of Language Engineering     λ − Calculus        Technologies for Language Engi...
Domain Specific Languages          Two Types of Language Engineering     λ − Calculus        Technologies for Language Engi...
Domain Specific Languages          Two Types of Language Engineering     λ − Calculus        Technologies for Language Engi...
Domain Specific Languages          Two Types of Language Engineering     λ − Calculus        Technologies for Language Engi...
Domain Specific Languages          Two Types of Language Engineering     λ − Calculus        Technologies for Language Engi...
Domain Specific Languages          Two Types of Language Engineering     λ − Calculus        Technologies for Language Engi...
Domain Specific Languages          Two Types of Language Engineering     λ − Calculus        Technologies for Language Engi...
Domain Specific Languages           Two Types of Language Engineering     λ − Calculus         Technologies for Language En...
Domain Specific Languages           Two Types of Language Engineering     λ − Calculus         Technologies for Language En...
Domain Specific Languages            Two Types of Language Engineering     The XMF Family          Technologies for Languag...
Domain Specific Languages          Two Types of Language Engineering     The XMF Family        Technologies for Language En...
Domain Specific Languages          Two Types of Language Engineering     The XMF Family        Technologies for Language En...
Domain Specific Languages           Two Types of Language Engineering     The XMF Family         Technologies for Language ...
Domain Specific Languages          Two Types of Language Engineering     The XMF Family        Technologies for Language En...
Domain Specific Languages          Two Types of Language Engineering     The XMF Family        Technologies for Language En...
Domain Specific Languages           Two Types of Language Engineering     The XMF Family         Technologies for Language ...
Domain Specific Languages          Two Types of Language Engineering     The XMF Family        Technologies for Language En...
Domain Specific Languages           Two Types of Language Engineering     The XMF Family         Technologies for Language ...
Domain Specific Languages           Two Types of Language Engineering         Technologies for Language Engineering        ...
Domain Specific Languages          Two Types of Language Engineering        Technologies for Language Engineering          ...
Domain Specific Languages          Two Types of Language Engineering        Technologies for Language Engineering          ...
Domain Specific Languages          Two Types of Language Engineering        Technologies for Language Engineering          ...
Domain Specific Languages          Two Types of Language Engineering        Technologies for Language Engineering          ...
Domain Specific Languages           Two Types of Language Engineering         Technologies for Language Engineering        ...
Upcoming SlideShare
Loading in …5
×

Dsl overview

1,099 views

Published on

Published in: Technology, Education
  • Be the first to comment

Dsl overview

  1. 1. Domain Specific Languages Two Types of Language Engineering Technologies for Language Engineering DSM-ing as Theory Building An Overview of DSLs Tony ClarkSchool of Engineering and Information Sciences University of Middlesex November 24, 2010 Tony Clark An Overview of DSLs
  2. 2. Domain Specific Languages Two Types of Language Engineering Technologies for Language Engineering DSM-ing as Theory BuildingOutline 1 Domain Specific Languages What are DSLs? An Example DSL A Word about Frameworks General Properties 2 Two Types of Language Engineering λ − Calculus Modelling 3 Technologies for Language Engineering The XMF Family Language Factories 4 DSM-ing as Theory Building Tony Clark An Overview of DSLs
  3. 3. Domain Specific Languages What are DSLs? Two Types of Language Engineering An Example DSL Technologies for Language Engineering A Word about Frameworks DSM-ing as Theory Building General PropertiesWhat Are Domain Specific Languages? Tony Clark An Overview of DSLs
  4. 4. Domain Specific Languages What are DSLs? Two Types of Language Engineering An Example DSL Technologies for Language Engineering A Word about Frameworks DSM-ing as Theory Building General PropertiesTypes of Domain Specific Languages Internal A host language is extended with sub-languages that are used for a specific aspect of the application. The host language is the glue. External An application consists of modules for different aspects. Each module is written in a different language. Textual A programming language or a domain specific configuration file. Graphical Using icons and graphical layout to represent ’initial’ elements. Tony Clark An Overview of DSLs
  5. 5. Domain Specific Languages What are DSLs? Two Types of Language Engineering An Example DSL Technologies for Language Engineering A Word about Frameworks DSM-ing as Theory Building General PropertiesAn Example DSL: Domain (due to Martin Fowler) SVCLFOWLER 10101MS0120050313 SVCLHOHPE 10201DX0320050315 SVCLTWO x10301MRP220050329 USGE10301TWO x50214..7050329 Tony Clark An Overview of DSLs
  6. 6. Domain Specific Languages What are DSLs? Two Types of Language Engineering An Example DSL Technologies for Language Engineering A Word about Frameworks DSM-ing as Theory Building General PropertiesAn Example DSL: A Framework public void ConfigCallReader(Framework f) { f.registerStrategy(ConfigureServiceCall()); f.registerStrategy(ConfigureUsage()); } private ReaderStrategy ConfigureServiceCall() { ReaderStrategy r = new ReaderStrategy("SVCL",ServiceCall); r.addFieldExtractor(4,18,"CustomerName")); r.addFieldExtractor(19,23,"CustomerID")); r.addFieldExtractor(24,27,"CalltypeCode")); r.addFieldExtractor(28,35,"DataOfCallString")); return r; } Tony Clark An Overview of DSLs
  7. 7. Domain Specific Languages What are DSLs? Two Types of Language Engineering An Example DSL Technologies for Language Engineering A Word about Frameworks DSM-ing as Theory Building General PropertiesAn Example DSL: Language To Configure the Framework @Reader CallReader map(SVCL,ServiceCall) 4-18:CustomerName 19-23:CustomerID 24-27:CallTypeCode 28-35:DataOfCallString end map(USGE,Usage) 4-8:CustomerID 9-22:CustomerName 30-30:Cycle 31-36:ReadDate end do ServiceCall Usage end Tony Clark An Overview of DSLs
  8. 8. Domain Specific Languages What are DSLs? Two Types of Language Engineering An Example DSL Technologies for Language Engineering A Word about Frameworks DSM-ing as Theory Building General PropertiesFrameworks: Inversion of Control Tony Clark An Overview of DSLs
  9. 9. Domain Specific Languages What are DSLs? Two Types of Language Engineering An Example DSL Technologies for Language Engineering A Word about Frameworks DSM-ing as Theory Building General PropertiesBenefits and Drawbacks Benefits: Speed of application development. Domain specific tools: quality. Ease of maintenance. Drawbacks: DSL development effort. Lack of tool support. DSL development expertise. DSL maintenence expertise. Tony Clark An Overview of DSLs
  10. 10. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory Buildingλ − Calculus: A Terminal Candidate Tony Clark An Overview of DSLs
  11. 11. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory Buildingλ − Calculus Definition E ::= V variables | fun(V) E functions | E E applications Tony Clark An Overview of DSLs
  12. 12. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory BuildingSimple DSL class Circle(x,y,r) { meth xin(x’) { ret [x-r,x+r].contains(x’); } meth yin(y’) { ret [y-r,y+r].contains(y’); } meth in(x’,y’) { ret self.xin(x’) & self.yin(y’); } } class Doughnut(x,y,r,r’) extends Circle { var c = new Circle(x,y,r’); meth xin(x’) { ret super.xin(x’) & !c.xin(x’); } meth yin(y’) { ret super.yin(y’) & !c.yin(y’); } } Tony Clark An Overview of DSLs
  13. 13. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory BuildingWhat Do Run-Time Values Look Like? Tony Clark An Overview of DSLs
  14. 14. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory Buildingλ − Calculus Extensions: Definitions E ::= V variables | fun(V) E functions | E E applications | let D top-level definitions D ::= V = E value definitions | V(V) = E function definitions Tony Clark An Overview of DSLs
  15. 15. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory BuildingTranslation: Class Definitions class Circle(x,y,r) { ... } class Doughnut(x,y,r,r’) ... { ... } let Circle(x,y,r) = fun(self) ... let Doughnut(x,y,r,r’) = fun(self) ... Tony Clark An Overview of DSLs
  16. 16. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory Buildingλ − Calculus Extensions: Records E ::= V variables | fun(V) E functions | E E applications | let D top-level definitions | let D in E local definitions | { D* } records | E + E addition (overloaded) | E.V field ref D ::= V = E value definitions | V(V) = E function definitions Tony Clark An Overview of DSLs
  17. 17. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory BuildingTranslation: Class Bodies let Circle(x,y,r) = fun(self) { xin(x’) = ...; yin(y’) = ...; in(x’,y’) = ... } let Doughnut(x,y,r,r’) = fun(self) let super = Circle(x,y,r)(self) in let c = ... in super + { xin(x’) = ... yin(y’) = ... } Tony Clark An Overview of DSLs
  18. 18. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory Buildingλ − Calculus Extensions: Recursion E ::= V variables | fun(V) E functions | E E applications | let D top-level definitions | let D in E local definitions | { D* } records | E + E addition (overloaded) | E.V field ref | Y E fixed point: (Y(E))(E’) = E’ D ::= V = E value definitions | V(V) = E function definitions Tony Clark An Overview of DSLs
  19. 19. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory BuildingTranslation: Method Bodies let Circle(x,y,r) = fun(self) { xin(x’) = [x-r,r+x].contains(x’); yin(y’) = [y-r,r+y].contains(y’); in(x’,y’) = (self.xin)(x’) & (self.yin)(y’) } let Doughnut(x,y,r,’) = fun(self) let super = Circle(x,y,r)(self) in let c = Y(Circle(x,y,r’)) in super + { xin(x’) = (super.xin)(x’) & !c.xin(x’) yin(y’) = (super.yin)(y’) & !c.yin(y’) } Tony Clark An Overview of DSLs
  20. 20. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory Buildingλ-calculus: Conclusion Design a domain specific language (e.g. classes, methods etc) Translate it onto the basic λ-calculus. Invent: syntax extensions for λ (e.g. records, definitions, Y). evaluation extensions for λ (not shown, but SECD is a good place to start). Each to implement directly or use a blueprint for translation. To start: write an interpreter for λ and extend it. Tony Clark An Overview of DSLs
  21. 21. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory BuildingObjects: A Terminal Candidate Tony Clark An Overview of DSLs
  22. 22. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory BuildingModelling Languages Tony Clark An Overview of DSLs
  23. 23. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory BuildingA Simple Modelling Language: Abstract Syntax Tony Clark An Overview of DSLs
  24. 24. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory BuildingA Simple Modelling Language: Semantic Domain Tony Clark An Overview of DSLs
  25. 25. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory BuildingA Simple Modelling Language: Concrete Syntax Tony Clark An Overview of DSLs
  26. 26. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory BuildingSemantic Mapping context Class inv instance_has_all_slots: attributes.name = instances.slots.name context Class inv instance_satisfies_constraints: constraints->forAll(c | instances->forAll(o | c.satisfiedBy(o))) context Class inv instances_conform_to_super: parents->forAll(c | c.instances->includesAll(instances)) context Object inv slot_values_are_type_correct: slots->forAll(s | s.value oclIsTypeOf(Object) implies s.value.type.instance->includes(s.value) Tony Clark An Overview of DSLs
  27. 27. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory BuildingSyntax Mapping context Class inv display_name: classBox.className.text.text = name context ClassBox inv name_at_top: className.x = x and className.y = y and className.width = width context ClassName min_height: height >= text.getHeight() Tony Clark An Overview of DSLs
  28. 28. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory BuildingA Language Extension: Default Instances context ClassWithDefault inv default_is_instance: instances->includes(default) context ClassWithDefault inv default_well_formed: slotDescriptor.name->subSet(default.slots.name) context ClassWithDefault inv defaul_slots_OK: slotDescriptor->forAll(d | default.slots->exists(s | s.name = d.name and s.value = d.value)) Tony Clark An Overview of DSLs
  29. 29. Domain Specific Languages Two Types of Language Engineering λ − Calculus Technologies for Language Engineering Modelling DSM-ing as Theory BuildingObject Modelling: Conclusion Design a language in terms of models for abstract syntax, concrete syntax amd semantic domain. Define mappings between them. Know about: class-models (modelling languages often extend this). object-models (a universal semantic domain). Tony Clark An Overview of DSLs
  30. 30. Domain Specific Languages Two Types of Language Engineering The XMF Family Technologies for Language Engineering Language Factories DSM-ing as Theory BuildingXMF XMF language definition features: Reflexive: Meta-Obejct Protocol (MOP) Language definition features: internal and external languages. Access to abstract syntax. Libraries for language processing. XMF-Mosaic: Modelling IDE built using XMF. Graphical languages modelled using meta-models. Tool Models. Tony Clark An Overview of DSLs
  31. 31. Domain Specific Languages Two Types of Language Engineering The XMF Family Technologies for Language Engineering Language Factories DSM-ing as Theory BuildingXMF Example: State Machine Syntax Class @Class StateMachine @Grammar extends OCL.grammar StateMachine ::= ’(’ n=Name ’)’ es=Exp* { [| StateMachine(<n>,<es>) |] }. end end @Class Transition @Grammar extends OCL.grammar Transition ::= ’(’ sn=Name ’,’ tn=Name ’)’ { [| Transition(<sn>,<tn>) |] }. end end @Class State @Grammar extends OCL.grammar State ::= n=Name { [| State(<n>) |] }. end end Tony Clark An Overview of DSLs
  32. 32. Domain Specific Languages Two Types of Language Engineering The XMF Family Technologies for Language Engineering Language Factories DSM-ing as Theory BuildingXMF Example: State Machine Use @Class StateMachineGenerator @Attribute counter:Integer end @Operation mkStateMachine() self.counter := counter + 1; @StateMachine(Off) @State Off end @State On end @Transition(On,Off) end @Transition(Off,On) end end end end Tony Clark An Overview of DSLs
  33. 33. Domain Specific Languages Two Types of Language Engineering The XMF Family Technologies for Language Engineering Language Factories DSM-ing as Theory BuildingLanguage Factories A component-based approach to the definition and construction of languages, tools. Language Factories aim to support: Reuse of common language components. Agile language engineering. Language refactoring. Language analysis including impact analysis. Product Lines for Languages Users: Language Factory Developers Language Factory Users Application Developers Application Users Tony Clark An Overview of DSLs
  34. 34. Domain Specific Languages Two Types of Language Engineering The XMF Family Technologies for Language Engineering Language Factories DSM-ing as Theory BuildingA Language Factory lang: ast: ... grammar: ... semantics eval(env): ... semantics java: ... constraints: ... Tony Clark An Overview of DSLs
  35. 35. Domain Specific Languages Two Types of Language Engineering The XMF Family Technologies for Language Engineering Language Factories DSM-ing as Theory BuildingExample Language component Landing_gear(height:int, speed:float) { stm { state Moving_Up state Moving_Down state Deployed state Stowed transition up from Deployed to Moving_Up height_change[height>500ft and speed>100kn/s] transition down from Stowed to Moving_Down deploy } } Tony Clark An Overview of DSLs
  36. 36. Domain Specific Languages Two Types of Language Engineering The XMF Family Technologies for Language Engineering Language Factories DSM-ing as Theory BuildingXPL: A Calculus for DSL Analysis E ::= V variables | fun(V) E functions | E E applications | { R* } grammars | intern E { S } language use R ::= ... syntax synthesizers S ::= ... strings Tony Clark An Overview of DSLs
  37. 37. Domain Specific Languages Two Types of Language Engineering The XMF Family Technologies for Language Engineering Language Factories DSM-ing as Theory BuildingOther Technologies UML and Profiles EMF, GMF XText Converge MetaEdit+ View based language environments. Tony Clark An Overview of DSLs
  38. 38. Domain Specific Languages Two Types of Language Engineering The XMF Family Technologies for Language Engineering Language Factories DSM-ing as Theory BuildingResearch Problems Modularity and reuse. Text-based systems and parsing. Type systems. Tooling and complexity. Interoperability. Code generation vs models at run-time. Tony Clark An Overview of DSLs
  39. 39. Domain Specific Languages Two Types of Language Engineering Technologies for Language Engineering DSM-ing as Theory BuildingPeter Naur: Programming as Theory Building Naur’s Thesis: Programmers design theories then map them to implementations. Theories allow questions to be asked (wider scope than a run). The theories are the things that capture the domain. Don’t change the program directly, change the theory and calculate the impact. Actually multiple theories for different viewpoints. The initial theory is unattainable, but can be incrementally approximated. Tony Clark An Overview of DSLs
  40. 40. Domain Specific Languages Two Types of Language Engineering Technologies for Language Engineering DSM-ing as Theory BuildingDSM-ing as Theory Building Tony Clark An Overview of DSLs
  41. 41. Domain Specific Languages Two Types of Language Engineering Technologies for Language Engineering DSM-ing as Theory BuildingDSL Architecture Tony Clark An Overview of DSLs
  42. 42. Domain Specific Languages Two Types of Language Engineering Technologies for Language Engineering DSM-ing as Theory BuildingTheory Modelling Tony Clark An Overview of DSLs
  43. 43. Domain Specific Languages Two Types of Language Engineering Technologies for Language Engineering DSM-ing as Theory BuildingExample: Influencing Models Tony Clark An Overview of DSLs
  44. 44. Domain Specific Languages Two Types of Language Engineering Technologies for Language Engineering DSM-ing as Theory BuildingConclusion Domain Specific activities are about theory building and theory transformation. To be effective you need to know your terminal theory well. Terminal theories known to be effective (and universal): λ-calculus object models. Other, less universal, targets are just as effective (e.g. Java). Practical issues: really translate (code generation) simulate the transformation (interpret the model) General problems: tools to support the process. up-front resource and expertise. Tony Clark An Overview of DSLs

×