Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Jazoon 2010 - Building DSLs with Eclipse
1. Building DSLs with Eclipse
Peter Friese, itemis
@peterfriese
@xtext
www.itemis.de
(c) 2009 Peter Friese. Distributed under the EDL V1.0 - http://www.eclipse.org/org/documents/edl-v10.php
More info: http://www.peterfriese.de / http://www.itemis.com
9. DSL
A language...
...that lets you express your intention
... that solves one problem
... that doesn’t get in your way
... that fits your situation
... that’s formal and processable
... that’s simple and easy to learn
25. 1)Create ANTLR grammar
2)Generate lexer / parser
3)Parser will create parse tree
4)Transform parse tree to semantic model
5)Iterate model
6)Pass model element(s) to template
26. Lack of symbolic integration
Writing parsers / generators is complicated
IDE support is inferior / non-existent
40. Building DSLs
1. Analyze problem domain
2. Map concepts of problem domain to language
3. (Optional: write interpreter)
4. (Optional: write generator)
44. Mapping concepts
entity Speaker {
String speakerId
String name
Entity
String bio
String organization
String country
Data Provider String smallImageURL
String largeImageURL
Tab bar
}
Session[] talks
Tab bar button entity Session {
String talkId
String title
Table view String abstract
String ^type
View title
String location
String startTime
String endTime
Table cell Speaker[] speakers
Topic[] topics
}
entity Topic {
String topicId
String themeId
String name
}
45. Mapping concepts
Entity contentprovider AllSessions
returns Session[]
Data Provider fetches XML
from "http://jipa.netcetera.ch/talks.xml"
Tab bar selects "feed.entry"
Tab bar button contentprovider AllSpeakers
returns Speaker[]
fetches XML
Table view from "http://jipa.netcetera.ch/speakers.xml"
selects "feed.entry"
View title
Table cell
46. Mapping concepts
contentprovider AllSessions
returns Session[]
fetches XML
Entity from "http://query.yahooapis.com/v1/public/
yql?q=use%20%22http%3A%2F%2FHeikoBehrens.net
Data Provider %2Fjazoon%2Ftalks.xml%22%20as%20talks%3B%0Aselect
%20*%20from%20talks%20where%20omitDetails
Tab bar %3D1&debug=true"
selects "query.results.talks.talk"
Tab bar button contentprovider SessionsByTopic(String id)
returns Session[]
Table view fetches XML
from ("http://query.yahooapis.com/v1/public/
View title yql?q=use%20%22http%3A%2F%2FHeikoBehrens.net
%2Fjazoon%2Ftalks.xml%22%20as%20s%3B%0Aselect%20*
Table cell %20from%20s%20where%20topicId%20%3D
%20%22"id"%22&diagnostics=true&debug=true&debug=true
")
selects "query.results.talks.talk"
47. Mapping concepts
Entity
Data Provider tableview ScheduleList(Session[] sessions) {
title= "Schedule"
Tab bar section {
cell Subtitle foreach sessions as session {
Tab bar button text= session.title
details= session.startTime
action= SessionDetails(
Table view SessionById(session.talkId))
}
View title }
}
Table cell
52. Protected regions
Debugger Editor
Outlets
Profiler
Cartridges
Polymorphism
Type safe
Produces any Can run standalone
kind of text Eclipse-based (ANT / Maven)