DSLs - PowerPoint PPT Presentation

About This Presentation
Title:

DSLs

Description:

A computer programming language of limited expressiveness focused on a particular domain ... Brownie Example. take(MicrowaveableDish) do. melt((1/4).cup.butter) ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 21
Provided by: danie117
Category:
Tags: brownie | dsls

less

Transcript and Presenter's Notes

Title: DSLs


1
DSLs
  • Daniel Frey

2
Roadmap
  • Introduction
  • Definitions
  • Pros/Cons
  • Samples

3
Introduction
  • Sample
  • My way of experiencing DSLs
  • Focus on language oriented DSLs

4
Introduction / 2
  • Why do we need DSLs?

5
Definitions
  • DSL
  • A computer programming language of limited
    expressiveness focused on a particular domain

6
Definition / 2
  • computer programming language
  • language nature
  • limited expressiveness
  • domain focus

7
Styles of DSLs
  • Internal
  • External
  • Language Workbenches

8
(No Transcript)
9
Language Workbench
10
Sample
  • Input File
  • 1234567890123456789012345678901234567890123456789
    01234567890
  • SVCLFOWLER 10101MS0120050313..............
    ...........
  • SVCLHOHPE 10201DX0320050315..............
    ..........
  • SVCLTWO x10301MRP220050329..............
    .............
  • USGE10301TWO x50214..7050329.............
    ..........

11
DSL 1
  • lt?xml version"1.0" encoding"utf-8" ?gt
  • ltReaderConfigurationgt
  • ltMapping Code "SVCL" TargetClass
    "dsl.ServiceCall"gt
  • ltField name "CustomerName" start "4" end
    "18"/gt
  • ltField name "CustomerID" start "19" end
    "23"/gt
  • ltField name "CallTypeCode" start "24" end
    "27"/gt
  • ltField name "DateOfCallString" start "28"
    end "35"/gt
  • lt/Mappinggt
  • ltMapping Code "USGE" TargetClass
    "dsl.Usage"gt
  • ltField name "CustomerID" start "4" end
    "8"/gt
  • ltField name "CustomerName" start "9" end
    "22"/gt
  • ltField name "Cycle" start "30" end
    "30"/gt
  • ltField name "ReadDate" start "31" end
    "36"/gt
  • lt/Mappinggt
  • lt/ReaderConfigurationgt

12
Syntax
  • Abstract Syntax - concrete syntax

13
DSL 2
  • mapping SVCL dsl.ServiceCall
  • 4-18 CustomerName
  • 19-23 CustomerID
  • 24-27 CallTypeCode
  • 28-35 DateOfCallString
  • mapping USGE dsl.Usage
  • 4-8 CustomerID
  • 9-22 CustomerName
  • 30-30 Cycle
  • 31-36 ReadDate

14
DSL 3
  • mapping('SVCL', ServiceCall) do
  • extract 4..18, 'customer_name'
  • extract 19..23, 'customer_ID'
  • extract 24..27, 'call_type_code'
  • extract 28..35, 'date_of_call_string'
  • end
  • mapping('USGE', Usage) do
  • extract 9..22, 'customer_name'
  • extract 4..8, 'customer_ID'
  • extract 30..30, 'cycle'
  • extract 31..36, 'read_date'
  • end

15
Brownie Example
  • take(MicrowaveableDish) do
  • melt((1/4).cup.butter)
  • mix with gt 6.tablespoon.cocoa
  • add 1.cup.sugar, 2.egg, (1/2).teaspoon.vanilla,
    (1/3).cup.flour, (1/4).teaspoon.salt
  • mix
  • bake in gt BakingPan, for gt 40.minutes, at
    gt 325.degrees
  • end

16
RSpec
  • Demo

17
Pro/Cons
Evolving into Generality!
18
Different DSLs
  • Why do we need DSLs?
  • Represent easily businessrules in code

19
Different kinds of DSL
  • Video

20
Domain Experts
  • Read and understand
  • Not necessarly write!
Write a Comment
User Comments (0)
About PowerShow.com