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 3 generation templates language workbenches building grammars or pseudo-grammars using workbench DSLs generation
SLIDE 4
Xtext (openArchitectureWare) a tool that supports language oriented programming Intentional Software (Charles Simonyi) MPS (JetBrains)
language workbenches
SLIDE 5 class Foo { private int id; . . . . . . }
Editable Representation Storage Representation Executable Representation Parse Compile
compilation since cs-101
SLIDE 6
SLIDE 7
first java ide to edit the abstract syntax directly enables refactoring
“post- ide’s”
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
Text Field
Projections
SLIDE 9
grammars
SLIDE 11
the DSL
events doorClosed D1CL drawOpened D2OP end commands unlockPanel PNUL lockPanel PNLK end
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
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
Xtext project
SLIDE 15
Xtext artifacts
DSL source generated source meta-data for editor plug-in editor plug-in generators
SLIDE 16
SLIDE 17
ANTLR grammar
SLIDE 18
ANTLR grammar
. . .
SLIDE 19
code generation
SLIDE 20
templates
SLIDE 21
template file
SLIDE 22
template
SLIDE 23
main()
SLIDE 24
templates
SLIDE 25
eclipse editor
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 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
establishing profiles
SLIDE 30
discounts
SLIDE 31
discount
SLIDE 32
discount implementation
SLIDE 33
getDiscount()
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 36
new MPS project
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
concept declaration
SLIDE 39
concept editor
SLIDE 40
concept editor
SLIDE 41
smart help
SLIDE 42
discount
SLIDE 43
reduction rule mapping
SLIDE 44
reduction template
SLIDE 45
discount template
SLIDE 46
using the editor
SLIDE 47
code generation
SLIDE 48
SLIDE 49
grammar? encapsulated within
SLIDE 50
refactoring
SLIDE 51
find usages
SLIDE 52
found usages
SLIDE 53
MPS is written in MPS
SLIDE 54
SLIDE 55
composition
SLIDE 56
composing DSLs
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!
soon
? commercial
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 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/