writing custom domain specific languages (dsls)
DESCRIPTION
My talk for JSConf 2014: When writing complex business logic, it is critically important to maintain clean code though the judicious applications of Test Driven Development and Domain Driven Design. However, even these powerful techniques fall short of solving the problem at the heart of building complex software: building what the customer actually wants. Domain Specific Languages (DSLs) allow us to capture complex business requirements in code written in the language of the customer. Once an ubiquitous language between you and your customer is defined and implemented as a DSL, the code can quite literally be given back to the customer to edit and refine. This is not a theory, or a myth. I have done this under real-world constraints and deadlines, and you can as well. JavaScript’s ability to blend Object Oriented and Functional Programming paradigms makes it an ideal language for authoring custom DSLs. Unfortunately, too often developers are unclear on how to identify when a custom DSL is an appropriate solution, and when it is, how to go about writing one. I will take you through the process of developing a few different custom DSLs from planning to implementation, as well as how to performance tune and debug your new custom language. My hope is that you will gain a powerful tool for managing complex software that will keep you sane, and your customers happy.TRANSCRIPT
![Page 1: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/1.jpg)
Writing Custom DSLs
Neil Green
![Page 2: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/2.jpg)
Today’s Talk
• The Evolutionary History of DSLs• What a DSL is and what it is for• Defining your DSL’s Grammar• Implementing your DSL
![Page 3: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/3.jpg)
The Evolutionary History of DSLs
![Page 4: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/4.jpg)
How Can We Create a Machine Language that Reads Like a Human Language?
?
![Page 5: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/5.jpg)
Punch CardsHow Humans First Spoke to Machines
![Page 6: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/6.jpg)
Low Level Languages
![Page 7: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/7.jpg)
Higher Level Languages
![Page 8: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/8.jpg)
High Level Languages
![Page 9: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/9.jpg)
Object Oriented Languages
![Page 10: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/10.jpg)
Domain Modeling
![Page 11: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/11.jpg)
User Interface
Model Database
Models as Data Transfer
![Page 12: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/12.jpg)
User Interface
Domain Model(Business Logic) Database
Models as Business Logic
![Page 13: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/13.jpg)
MVC Pattern
ViewModel
Controller
![Page 14: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/14.jpg)
View
Domain Model
Controller
MVC for Complex Applications
![Page 15: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/15.jpg)
Creating A Domain Model
1. Understand your domain2. Model your domain3. Implement your domain
![Page 16: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/16.jpg)
Understand Your Domain
Speak with the customer
Develop a mutual language
Implement the Model
Diagram a Model
NounsClasses
VerbsMethods
![Page 17: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/17.jpg)
Model the Domain
![Page 18: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/18.jpg)
Implement the Domain Model
Speculative Implementation(guessing based on assumptions)
![Page 19: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/19.jpg)
Implement the Domain Model
Write Test
Write Code to
Pass Test
Refactor Code
![Page 20: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/20.jpg)
Implementing the Domain Model
Behavior Driven Development
Write Tests
Write Tests Alone
Write Test with
Customer
Test Driven Development
![Page 21: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/21.jpg)
Language of Test = Language of Domain
![Page 22: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/22.jpg)
Have the Customer Express Expectations Directly in Code
![Page 23: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/23.jpg)
What a DSL is and what it is for
![Page 24: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/24.jpg)
Domain Specific Language
1. Grammar2. Implementation3. Rules
![Page 25: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/25.jpg)
Common DSLs
General DSLs• SQL• Regular Expression• Unix shell scripts
JavaScript DSLs• jQuery• D3js• Gulp• Mocha/Chai
![Page 26: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/26.jpg)
DSLs Make Complex Problems Simpler
select * from Table
![Page 27: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/27.jpg)
DSLs Also Simplify Business Problems
• Automotive• Banking• Consumer• Education• Engineering• Energy• Oil and Gas• Financial (Finance)• Food and beverage• Government
• Healthcare• Insurance• Manufacturing• Media• Online• Real estate• Retail• Technology• Telecommunications• Transportation (Travel)
![Page 28: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/28.jpg)
Business DSLs get their Grammar from the customer NOT THE PROGRAMMER
Business DSLs are for customers Technical DSLs are for programmers
![Page 29: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/29.jpg)
Defining your DSL’s Grammar
![Page 30: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/30.jpg)
Defining the Grammar
Programmer
Customer
Domain Model
![Page 31: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/31.jpg)
The Alarm Problem Domain
![Page 32: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/32.jpg)
“Hey Paul, how's it going? Yesterday our office admin came in early to setup for the companies weekly status meeting, but he couldn't remember the code to turn off the alarm. The cops had to come out and he tried to explain he was an employee because he had a key, but they didn’t believe him and ended up calling me. We have the same meeting every Monday morning, so can we just not have the alarm set so he doesn't need the alarm code to get in?”
![Page 33: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/33.jpg)
“Hey Paul, what's up? I know I asked you to not have the alarm set for our weekly status meetings, but during memorial day I was worried that we had the alarm off when we should have had it on. I had a friend of mine who's business got robbed on July 4th, 'cause I guess they figured no one would be there.”
![Page 34: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/34.jpg)
![Page 35: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/35.jpg)
GrammarHey Paul, how's it going? Yesterday our office admin came in early to setup for the companies weekly status meeting, but he couldn't remember the code to turn off the alarm. The cops had to come out and he tried to explain he was an employee because he had a key, but they didn’t believe him and ended up calling me. We have the same meeting every Monday morning, so can we just not have the alarm set so he doesn't need the alarm code to get in?
Hey Paul, what's up? I know I asked you to not have the alarm set for our weekly status meetings, but during memorial day I was worried that we had the alarm off when we should have had it on. I had a friend of mine who's business got robbed on July 4th, 'cause I guess they figured no one would be there.
![Page 36: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/36.jpg)
GrammarHey Paul, how's it going? Yesterday our office admin came in early to setup for the companies weekly status meeting, but he couldn't remember the code to turn off the alarm. The cops had to come out and he tried to explain he was an employee because he had a key, but they didn’t believe him and ended up calling me. We have the same meeting every Monday morning, so can we just not have the alarm set so he doesn't need the alarm code to get in?
Hey Paul, what's up? I know I asked you to not have the alarm set for our weekly status meetings, but during memorial day I was worried that we had the alarm off when we should have had it on. I had a friend of mine who's business got robbed on July 4th, 'cause I guess they figured no one would be there.
![Page 37: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/37.jpg)
Grammar
• Our• Office admin • Code• Alarm• Yesterday • Early • Weekly • Every Monday morning• Memorial day • July 4th
• Not• Should• Set• Off• On
VerbsNouns
![Page 38: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/38.jpg)
Grammar
• Our Company• Office admin Employee & Role• Code• Alarm
• Not• Should• Set On• On• Off
VerbsNouns (things)
• Yesterday Day• Early 6:00am – 9:00am• Weekly Every & Week • Every Monday morning Every & Day & 9:00am–12:00pm• Memorial day (Idiom)• July 4th (Idiom)
Nouns (time)
![Page 39: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/39.jpg)
Idiom
• New Year’s Day• Birthday of Martin Luther King, Jr.• Washington’s Birthday• Memorial Day• Independence Day (“July 4th”)• Labor Day• Columbus Day• Veterans Day• Thanksgiving Day• Christmas Day
Federal Holiday
![Page 40: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/40.jpg)
Grammar
• Company• Employee• Role• Code• Alarm
• Not• Should• On• Off
VerbsNouns (things)
• Day• 6:00am, 9:00am, 12:00pm• Every• Week • Federal Holiday
Nouns (time)
![Page 41: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/41.jpg)
Grammar
Alarm on weekdays* 8:00am-6:00pm Alarm off Mondays 6:00am-8:00amAlarm on federal holidays
* Weekdays = Every Monday - Friday
![Page 42: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/42.jpg)
Grammar
The Alarm should be on every weekday between 8:00am-6:00pm, but the alarm should be off Mondays from 6:00am-8:00am. Also, the alarm should be on for federal holidays.
![Page 43: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/43.jpg)
Verify Grammar
“Yeah, this is pretty good, only thing is, we don’t close for
Columbus day”
![Page 44: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/44.jpg)
Grammar
The Alarm should be on every weekday between 8:00am-6:00pm, but the alarm should be off Mondays from 6:00am-8:00am. Also, the alarm should be on for federal holidays, but not for Columbus Day
![Page 45: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/45.jpg)
Grammar
• Company• Employee• Role• Code• Alarm
• Not• Should• On• Off
VerbsNouns (things)
• Day• Every• Week • Weekday; “Mondays”• Federal Holiday; “Columbus Day”• 6:00am, 8:00am, 12:00pm, 6:00pm
Nouns (time)
![Page 46: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/46.jpg)
Grammar
• Alarm • Not• On• Off
VerbsNouns (things)
• Weekdays; “Mondays”• Federal Holiday; “Columbus Day”• 6:00am, 8:00am, 12:00pm, 6:00pm
Nouns (time)
![Page 47: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/47.jpg)
(security guard by day, programmer by night)
Implementing the Grammar
![Page 48: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/48.jpg)
Implementing the Grammar
• Compiler?• Lexer?• Parser?
• Tokenizer?• Interpretor?• Symbol table?
![Page 49: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/49.jpg)
Implementing the Grammar
Method Chaining!(Fluent Interface)
![Page 50: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/50.jpg)
Implementing the Grammar
Alarm on weekdays 8:00am-6:00pm Alarm off Mondays 6:00am-8:00amAlarm on federal holidaysAlarm off Columbus Day
![Page 51: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/51.jpg)
Implementing the Grammar
Alarm.on().weekdays(‘8:00am’, ’6:00pm’); Alarm.off().Mondays(‘6:00am’, ‘8:00am’);Alarm.on().federal().holidays();Alarm.off(‘Columbus Day’);
![Page 52: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/52.jpg)
Implementing the Grammar
alarm = new AlarmDsl();
alarm.on().weekdays(‘8:00am’, ’6:00pm’); alarm.off().Mondays(‘6:00am’, ‘8:00am’);alarm.on().federal().holidays();alarm.off(‘Columbus Day’);
alarm.buildConfiguredDomainModel()
![Page 53: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/53.jpg)
Configuring the Domain
Using objects:
new AlarmSchedule({ on: true, startTime: ‘8:00am’, endTime: ‘6:00am’});
![Page 54: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/54.jpg)
Configuring the Domain
Using functions:
AlarmSchedule.isOn = isTimeBetween(
timeRange(‘8:00am’, ‘6:00am’));
![Page 55: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/55.jpg)
Paul’s Written a Custom DSL!!!
![Page 56: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/56.jpg)
How to Write a Custom DSL
1. Review Conversation with Customer2. Remove meaningless words3. Separate nouns and verbs 4. Identify Idioms 5. Review grammar with Customer6. Implement the Grammar
![Page 57: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/57.jpg)
Implementing your DSL
![Page 58: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/58.jpg)
New Domain: Shipping
![Page 59: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/59.jpg)
Shipping Problem Domain
• Customer• Destination• Order • Item• Box• Delivery Date• Shipping Cost
• Dimensions• Weight• Fragility• Address• International• Carrier • Rate
![Page 60: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/60.jpg)
Shipping Domain Model
![Page 61: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/61.jpg)
Shipping DSL Grammar
when shipping domestically
if delivery date is flexible ship as cheaply as possible
if delivery date is specified pass shipping cost on to customer
when shipping internationally
then ship as cheaply as possible
![Page 62: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/62.jpg)
Shipping DSL Grammar
when domestically
if flexible cheaply
if specified pass
when internationally
then cheaply
![Page 63: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/63.jpg)
Shipping DSL Grammar
when().domestically().
if().flexible().cheaply().
if().specified().pass().
when().internationally().
then().cheaply
![Page 64: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/64.jpg)
Shipping DSL Grammar
dslBuilder.
when().domestically().
if().flexible().cheaply().
if().specified().pass().
when().internationally().
then().cheaply()
.build();
![Page 65: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/65.jpg)
Parsing the Grammar
![Page 66: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/66.jpg)
Parsing the Grammar
![Page 67: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/67.jpg)
Parsing the Grammar
![Page 68: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/68.jpg)
Parsing the Grammar
![Page 69: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/69.jpg)
Parsing the Grammar
![Page 70: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/70.jpg)
Parsing the Grammar
![Page 71: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/71.jpg)
Parsing the Grammar
![Page 72: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/72.jpg)
The DSL Builder
![Page 73: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/73.jpg)
![Page 74: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/74.jpg)
![Page 75: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/75.jpg)
![Page 76: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/76.jpg)
![Page 77: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/77.jpg)
JSON of the DSL Builder Rules
![Page 78: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/78.jpg)
Shipping DSL Grammar with Drones!)
when shipping with drones
if weather is favorable send as cheaply as possible
otherwise ship domestically
when shipping domestically
if delivery date is flexible ship as cheaply as possible
if delivery date is specified pass shipping cost on to customer
when shipping internationally
then ship as cheaply as possible
![Page 79: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/79.jpg)
How to Learn More
![Page 80: Writing Custom Domain Specific Languages (DSLs)](https://reader033.vdocuments.net/reader033/viewer/2022061219/5482a57fb4af9fa50d8b4861/html5/thumbnails/80.jpg)
Thanks!!!