building DSLs with language workbenches NEAL FORD software architect - - PowerPoint PPT Presentation

building dsls with language workbenches
SMART_READER_LITE
LIVE PREVIEW

building DSLs with language workbenches NEAL FORD software architect - - PowerPoint PPT Presentation

Thought Works Thought Works building DSLs with language workbenches NEAL FORD software architect / meme wrangler Thought Works nford@thoughtworks.com 3003 Summit Boulevard, Atlanta, GA 30319 www.nealford.com www.thoughtworks.com


slide-1
SLIDE 1

ThoughtWorks ThoughtWorks

NEAL FORD software architect / meme wrangler

ThoughtWorks

nford@thoughtworks.com

3003 Summit Boulevard, Atlanta, GA 30319

www.nealford.com www.thoughtworks.com memeagora.blogspot.com

building DSLs with language workbenches

slide-2
SLIDE 2

ThoughtWorks

slide-3
SLIDE 3

generation templates language workbenches building grammars or pseudo-grammars using workbench DSLs generation

  • verview
slide-4
SLIDE 4

Xtext (openArchitectureWare) a tool that supports language oriented programming Intentional Software (Charles Simonyi) MPS (JetBrains)

language workbenches

slide-5
SLIDE 5

class Foo { private int id; . . . . . . }

Editable Representation Storage Representation Executable Representation Parse Compile

compilation since cs-101

slide-6
SLIDE 6
slide-7
SLIDE 7

first java ide to edit the abstract syntax directly enables refactoring

“post- ide’s”

slide-8
SLIDE 8

workbenches

class Foo { private int id; . . . . . . }

Executable Representation Workbench Versioning Storage Editable Representation Storage Representation

Tab Tab Tab

Document Window

Label

Menu Text Field Text Field Text Field Text Field Text Field Text Field

Label Label

  • Label

Text Field

Projections

slide-9
SLIDE 9

grammars

slide-10
SLIDE 10
  • Ms. Grant’s secret panel
slide-11
SLIDE 11

the DSL

events doorClosed D1CL drawOpened D2OP end commands unlockPanel PNUL lockPanel PNLK end

slide-12
SLIDE 12

the grammar

list : eventList commandList; eventList : 'events' eventDec* 'end'; eventDec : identifier identifier; commandList : 'commands' commandDec* 'end'; commandDec : identifier identifier;

events doorClosed D1CL drawOpened D2OP end commands unlockPanel PNUL lockPanel PNLK end

slide-13
SLIDE 13

you provide a grammar in their format framework/tool for development of external textual DSLs based on openArchitectureWare Xtext produces: ANTLR grammar, parser, abstract syntax tree meta-model, and Eclipse editor

slide-14
SLIDE 14

Xtext project

slide-15
SLIDE 15

Xtext artifacts

DSL source generated source meta-data for editor plug-in editor plug-in generators

slide-16
SLIDE 16
slide-17
SLIDE 17

ANTLR grammar

slide-18
SLIDE 18

ANTLR grammar

. . .

slide-19
SLIDE 19

code generation

slide-20
SLIDE 20

templates

slide-21
SLIDE 21

template file

slide-22
SLIDE 22

template

slide-23
SLIDE 23

main()

slide-24
SLIDE 24

templates

slide-25
SLIDE 25

eclipse editor

slide-26
SLIDE 26

heavily Eclipse based (editors, project structure, etc.) most mature of the text-based DSL tools still extricating itself from

  • penArchitectureware & MDA background

nice editor projection (acts like source file) efficient generation of DSL, grammar, code generation, & templates

Xtext

slide-27
SLIDE 27
slide-28
SLIDE 28

...but the other guys do the same thing competition is brutal! incentives to encourage repeat customers... easy to define & change flexible business rules

bakery life

slide-29
SLIDE 29

establishing profiles

slide-30
SLIDE 30

discounts

slide-31
SLIDE 31

discount

slide-32
SLIDE 32

discount implementation

slide-33
SLIDE 33

getDiscount()

slide-34
SLIDE 34

used internally to build new products internal project by JetBrains based on lessons learned with IntelliJ actively used now for 3+ years created by Sergey Dmitriev & Konstantin Solomatov

slide-35
SLIDE 35
slide-36
SLIDE 36

new MPS project

slide-37
SLIDE 37

also editors, code generators fundamental building block like a class: data, behavior, encapsulation properties, events, methods, and links implemented in base language

concepts

slide-38
SLIDE 38

concept declaration

slide-39
SLIDE 39

concept editor

slide-40
SLIDE 40

concept editor

slide-41
SLIDE 41

smart help

slide-42
SLIDE 42

discount

slide-43
SLIDE 43

reduction rule mapping

slide-44
SLIDE 44

reduction template

slide-45
SLIDE 45

discount template

slide-46
SLIDE 46

using the editor

slide-47
SLIDE 47

code generation

slide-48
SLIDE 48
slide-49
SLIDE 49

grammar? encapsulated within

slide-50
SLIDE 50

refactoring

slide-51
SLIDE 51

find usages

slide-52
SLIDE 52

found usages

slide-53
SLIDE 53

MPS is written in MPS

slide-54
SLIDE 54
slide-55
SLIDE 55

composition

slide-56
SLIDE 56

composing DSLs

slide-57
SLIDE 57

comparisons

Xtext MPS Intentional grammar EBNF/antlr encapsulated ? environment Eclipse MPS ? code generation via Eclipse via MPS or IntelliJ internal projections EMF & text text-like (for now) rich project ecosystem Eclipse MPS ? availability now!

  • pen source

soon

  • pen source

? commercial

slide-58
SLIDE 58

ThoughtWorks

This work is licensed under the Creative Commons Attribution-Noncommercial-Share Alike 2.5 License. http://creativecommons.org/licenses/by-nc-sa/2.5/

questions?

please fill out the session evaluations slides & samples available at nealford.com

NEAL FORD software architect / meme wrangler

ThoughtWorks

nford@thoughtworks.com

3003 Summit Boulevard, Atlanta, GA 30319

www.nealford.com www.thoughtworks.com memeagora.blogspot.com

slide-59
SLIDE 59

resources

ThoughtWorks

MPS http://www.jetbrains.com/mps/ Intentional Softare http://www.intentsoft.com/ Xtext http://wiki.eclipse.org/Xtext Martin Fowler’s DSL Work in Progress http://martinfowler.com/dslwip/