Your SlideShare is downloading. ×
0
Java DSLs with Xtext
Java DSLs with Xtext
Java DSLs with Xtext
Java DSLs with Xtext
Java DSLs with Xtext
Java DSLs with Xtext
Java DSLs with Xtext
Java DSLs with Xtext
Java DSLs with Xtext
Java DSLs with Xtext
Java DSLs with Xtext
Java DSLs with Xtext
Java DSLs with Xtext
Java DSLs with Xtext
Java DSLs with Xtext
Java DSLs with Xtext
Java DSLs with Xtext
Java DSLs with Xtext
Java DSLs with Xtext
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Java DSLs with Xtext

565

Published on

Slides of my talk at EclipseCon 2013 (Boston)

Slides of my talk at EclipseCon 2013 (Boston)

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
565
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
10
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  1. Java DSLs with Xtext Jan KoehnleinMittwoch, 27. März 13
  2. Mittwoch, 27. März 13
  3. Mittwoch, 27. März 13
  4. public class Customer implements Serializable { private String name; private Address address; private List<Item> purchase; public String getName() { return name; } public void setName(String name) { this.name = name; } public Address getAddress() { return address; } public void setAddress(Address address) { this.address = address; } public List<Item> getPurchase() { return purchase; } public void setPurchase(List<Item> items) { this.purchase = purchase; } }Mittwoch, 27. März 13
  5. @Entity public class Customer implements Serializable { @Id private String name; private Address address; private List<Item> purchase; public String getName() { return name; } public void setName(String name) { this.name = name; } @Column(name="ADDR", nullable=false) public Address getAddress() return address; } public void setAddress(Address address) { this.address = address; } @ManyToMany public List<Item> getPurchase() { return purchase; } public void setPurchase(List<Item> items) { this.purchase = purchase; } }Mittwoch, 27. März 13
  6. Domain-Specific LanguagesMittwoch, 27. März 13
  7. DSL Java entity Customer { @Entity name: String public class Customer implements Serializable { @Id address: Address private String name; purchase: Item* private Address address; private List<Item> purchase; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Column(name="ADDR", nullable=false) Code public Address getAddress() { } return address; public void setAddress(Address address) { Generation this.address = address; } @ManyToMany public List<Item> getPurchase() { return purchase; } public void setPurchase(List<Item> items) { this.purchase = purchase; } }Mittwoch, 27. März 13
  8. ? Methods Logic Arithmetics BehaviorMittwoch, 27. März 13
  9. entity Customer { name: String address: Address purchase: Item* double sales() { double result = 0.0; for(Item item: purchase) result += item.getPrice(); return result; } }Mittwoch, 27. März 13
  10. Expressions Complex Syntax Typesystem Compiler / InterpreterMittwoch, 27. März 13
  11. Integration Patterns Manually written code Generated codeMittwoch, 27. März 13
  12. Reusable powerful expression library language Java‘s Typesystem Access to Java-elements Compile to Java CodeMittwoch, 27. März 13
  13. DSLs for JavaMittwoch, 27. März 13
  14. grammar inheritance Grammar (Parser, Lexer) Linker Type System JvmModel MyLanguage Interpreter / Advanced Editor Eclipse Integration Debugger JvmModelInferrerMittwoch, 27. März 13
  15. Model Inference Class Customer entity Customer { name: String Field name address: Address purchasedItems: Item* Method getName double sales() { purchasedItems returnType String .map[price] .reduce[a,b|a+b] } Method setName } parameter name type StringMittwoch, 27. März 13
  16. Model Inference entity Customer { name: String address: Address purchasedItems: Item* double sales() { Method sales purchasedItems .map[price] returnType double .reduce[a,b|a+b] } body Expression }Mittwoch, 27. März 13
  17. class ScriptingJvmModelInferrer extends AbstractModelInferrer { @Inject extension JvmTypesBuilder def dispatch void infer(Script script, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) { acceptor.accept(script.toClass(MyClass)) .initializeLater [ // the class gets one main method members += script.toMethod( main, script.newTypeRef(Void::TYPE)) [ parameters += script.toParameter("args", script.newTypeRef(typeof(String)) .addArrayTypeDimension) static = true varArgs = true // Associate the script as the body of the main method body = script ] ] } }Mittwoch, 27. März 13
  18. The 7 Languages Scripting Language DSL for MongoDB Http Routing Language Templates Language DSL for Guice Build Language TortoiseMittwoch, 27. März 13
  19. Find more at www.eclipse.org/Xtext/7languages.htmlMittwoch, 27. März 13

×