SlideShare une entreprise Scribd logo
1  sur  90
Télécharger pour lire hors ligne
Building DSLs with
      Eclipse
                            Peter Friese, itemis

                                   @peterfriese
                                    @xtext




(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
What is a DSL?
Domain
Language
Suppose...
You’d want to core an apple...
... for your kids.
?
Right tool for the job?
Your trusty swiss army knife!
Because you can use it for other stuff, too.
      E.g., opening a bottle of wine.
Suppose...
You’d want to core a few more apples...
... for an apple cake.
Still the best tool for the job?
Better use this one.
and this one:
BUT

avoid the unitasker!
BUT

avoid the unitasker!
... a DSL is ...
A specific tool
for a specific job
A specific tool
for a specific job
Samples for DSLs
SQL
select name, salary
 from employees
 where salary > 2000
 order by salary
ANT
<project name="MyProject" default="dist" basedir=".">
  <property name="src" location="src"/>
  <property name="build" location="build"/>
  <property name="dist" location="dist"/>

  <target name="init">
    <mkdir dir="${build}"/>
  </target>

  <target name="compile" depends="init">
    <javac srcdir="${src}" destdir="${build}"/>
  </target>

  <target name="dist" depends="compile">
    <mkdir dir="${dist}/lib"/>
    <jar jarfile="${dist}/lib/MyProject.jar"
         basedir="${build}"/>
  </target>

  <target name="clean">
    <delete dir="${build}"/>
    <delete dir="${dist}"/>
  </target>
</project>
<project name="MyProject" default="dist" basedir=".">
  <property name="src" location="src"/>
  <property name="build" location="build"/>
  <property name="dist" location="dist"/>

 <target name="init">
   <mkdir dir="${build}"/>
 </target>

 <target name="compile" depends="init">
   <javac srcdir="${src}" destdir="${build}"/>
 </target>

 <target name="dist" depends="compile">
   <mkdir dir="${dist}/lib"/>
   <jar jarfile="${dist}/lib/MyProject.jar"
        basedir="${build}"/>
 </target>

  <target name="clean">
    <delete dir="${build}"/>
    <delete dir="${dist}"/>
  </target>
</project>
External
   or
Internal
Internal DSLs
Mailer.mail()
 .to(“you@gmail.com”)
 .from(“me@gmail.com”)
 .subject(“Writing DSLs in Java”)
 .body(“...”)
 .send();
Simple
Limited
External DSLs
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
Flexible
Adaptable
Complicated
Why not use a DSL...




... for building DSLs?
Demo 1
@SuppressWarnings("serial")
@Entity
@Table(name = "CUSTOMER_INFO")
public class CustomerInfo implements Serializable {

	   @Id
	   @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "idSeq")
	   @SequenceGenerator(name = "idSeq", sequenceName = "CUST_SEQ", allocationSize = 1)
	   @Column(name = "CUST_ID", nullable = false)
	   private String customerId;

	   public void setCustomerId(String customerId) {
	   	   this.customerId = customerId;
	   }

	   public String getCustomerId() {
	   	   return customerId;
	   }

	   @Column(name = "EMAIL", nullable = false, length = 128)
	   private String emailAddress;

	   public String getEmailAddress() {
	   	   return emailAddress;
	   }

	   public void setEmailAddress(String emailAddress) {
	   	   String oldValue = emailAddress;
	   	   this.emailAddress = emailAddress;
	   	   firePropertyChangedEvent("emailAddress", oldValue, this.emailAddress);
	   }
@SuppressWarnings("serial")
@Entity
@Table(name = "CUSTOMER_INFO")
public class CustomerInfo implements Serializable {

	   @Id
	   @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "idSeq")
	   @SequenceGenerator(name = "idSeq", sequenceName = "CUST_SEQ", allocationSize = 1)
	   @Column(name = "CUST_ID", nullable = false)
	   private String customerId;

	   public void setCustomerId(String customerId) {
	   	   this.customerId = customerId;
	   }

	   public String getCustomerId() {
	   	   return customerId;
	   }

	   @Column(name = "EMAIL", nullable = false, length = 128)
	   private String emailAddress;

	   public String getEmailAddress() {
	   	   return emailAddress;
	   }

	   public void setEmailAddress(String emailAddress) {
	   	   String oldValue = emailAddress;
	   	   this.emailAddress = emailAddress;
	   	   firePropertyChangedEvent("emailAddress", oldValue, this.emailAddress);
	   }
entity CustomerInfo
	 (id=CUST_ID, sequenceName=CUST_SEQ)
{
	
	 String emailAddress (notNull, length = 128)
	
}
entity CustomerInfo
	 (id=CUST_ID, sequenceName=CUST_SEQ)
{
	
	 String emailAddress (notNull, length = 128)
	
}




               Bean
                         DAO
              (POJO)
Underlying Technology
Model




G
 ra
      m
       m
           ar
ar
Model




               m
              m
          ra
          G
        Generator
ar
Model




                                    m
                                   m
                               ra
                               G
                             Generator



        Runtime
                  Superclass




                  Subclass              Class




 LL(*) Parser   ECore meta model                Editor
ar
Model




                                    m
                                   m
                               ra
                               G
                             Generator



        Runtime
                  Superclass




                  Subclass              Class




 LL(*) Parser   ECore meta model                Editor
Grammar (similar to EBNF)
 grammar org.xtext.example.Entity with org.eclipse.xtext.common.Terminals

 generate entity "http://www.xtext.org/example/Entity"

 Model:
   (types+=Type)*;

 Type:
   TypeDef | Entity;

 TypeDef:
   "typedef" name=ID ("mapsto" mappedType=JAVAID)?;

 JAVAID:
   name=ID("." ID)*;

 Entity:
   "entity" name=ID ("extends" superEntity=[Entity])?
   "{"
     (attributes+=Attribute)*
   "}";

 Attribute:
   type=[Type] (many?="*")? name=ID;
grammar org.xtext.example.Entity
    with org.eclipse.xtext.common.Terminals            Meta model inference
generate entity
    "http://www.xtext.org/example/Entity"
                                              entity
Model:
  (types+=Type)*;
                                                                       Model
Type:
  TypeDef | Entity;
                                                                          types
TypeDef:                                                                *
                                                                    Type
  "typedef" name=ID
                                                                 name: EString
  ("mapsto" mappedType=JAVAID)?;
                                                                                                superEntity
JAVAID:
  name=ID("." ID)*;                                      TypeDef                    Entity


Entity:                                       mappedType                                attributes
  "entity" name=ID
                                                                                  Attribute
  ("extends" superEntity=[Entity])?                       JAVAID
                                                                               name: EString
  "{"                                                  name: EString
                                                                               many: EBoolean
    (attributes+=Attribute)*
  "}";                                                                                  type

Attribute:
  type=[Type] (many?="*")? name=ID;
grammar org.xtext.example.Entity
    with org.eclipse.xtext.common.Terminals            Meta model inference
generate entity
    "http://www.xtext.org/example/Entity"
                                              entity                   Rules -> Classes
Model:
  (types+=Type)*;
                                                                       Model
Type:
  TypeDef | Entity;
                                                                          types
TypeDef:                                                                *
                                                                    Type
  "typedef" name=ID
                                                                 name: EString
  ("mapsto" mappedType=JAVAID)?;
                                                                                                superEntity
JAVAID:
  name=ID("." ID)*;                                      TypeDef                    Entity


Entity:                                       mappedType                                attributes
  "entity" name=ID
                                                                                  Attribute
  ("extends" superEntity=[Entity])?                       JAVAID
                                                                               name: EString
  "{"                                                  name: EString
                                                                               many: EBoolean
    (attributes+=Attribute)*
  "}";                                                                                  type

Attribute:
  type=[Type] (many?="*")? name=ID;
grammar org.xtext.example.Entity
    with org.eclipse.xtext.common.Terminals            Meta model inference
generate entity
    "http://www.xtext.org/example/Entity"
                                              entity
Model:
  (types+=Type)*;
                                                                       Model
Type:
  TypeDef | Entity;
                                                                          types
TypeDef:                                                                *
                                                                    Type
  "typedef" name=ID
                                                                 name: EString
  ("mapsto" mappedType=JAVAID)?;
                                                                                                superEntity
JAVAID:
  name=ID("." ID)*;                                      TypeDef                    Entity


Entity:                                       mappedType                                attributes
  "entity" name=ID
                                                                                  Attribute
  ("extends" superEntity=[Entity])?                       JAVAID
                                                                               name: EString
  "{"                                                  name: EString
                                                                               many: EBoolean
    (attributes+=Attribute)*
  "}";                                                                                  type

Attribute:
  type=[Type] (many?="*")? name=ID;
grammar org.xtext.example.Entity
    with org.eclipse.xtext.common.Terminals            Meta model inference
generate entity
    "http://www.xtext.org/example/Entity"
                                              entity            Alternatives -> Hierarchy
Model:
  (types+=Type)*;
                                                                       Model
Type:
  TypeDef | Entity;
                                                                          types
TypeDef:                                                                *
                                                                    Type
  "typedef" name=ID
                                                                 name: EString
  ("mapsto" mappedType=JAVAID)?;
                                                                                                superEntity
JAVAID:
  name=ID("." ID)*;                                      TypeDef                    Entity


Entity:                                       mappedType                                attributes
  "entity" name=ID
                                                                                  Attribute
  ("extends" superEntity=[Entity])?                       JAVAID
                                                                               name: EString
  "{"                                                  name: EString
                                                                               many: EBoolean
    (attributes+=Attribute)*
  "}";                                                                                  type

Attribute:
  type=[Type] (many?="*")? name=ID;
grammar org.xtext.example.Entity
    with org.eclipse.xtext.common.Terminals            Meta model inference
generate entity
    "http://www.xtext.org/example/Entity"
                                              entity
Model:
  (types+=Type)*;
                                                                       Model
Type:
  TypeDef | Entity;
                                                                          types
TypeDef:                                                                *
                                                                    Type
  "typedef" name=ID
                                                                 name: EString
  ("mapsto" mappedType=JAVAID)?;
                                                                                                superEntity
JAVAID:
  name=ID("." ID)*;                                      TypeDef                    Entity


Entity:                                       mappedType                                attributes
  "entity" name=ID
                                                                                  Attribute
  ("extends" superEntity=[Entity])?                       JAVAID
                                                                               name: EString
  "{"                                                  name: EString
                                                                               many: EBoolean
    (attributes+=Attribute)*
  "}";                                                                                  type

Attribute:
  type=[Type] (many?="*")? name=ID;
grammar org.xtext.example.Entity
    with org.eclipse.xtext.common.Terminals            Meta model inference
generate entity
    "http://www.xtext.org/example/Entity"
                                              entity               Assignment -> Feature
Model:
  (types+=Type)*;
                                                                       Model
Type:
  TypeDef | Entity;
                                                                          types
TypeDef:                                                                *
                                                                    Type
  "typedef" name=ID
                                                                 name: EString
  ("mapsto" mappedType=JAVAID)?;
                                                                                                superEntity
JAVAID:
  name=ID("." ID)*;                                      TypeDef                    Entity


Entity:                                       mappedType                                attributes
  "entity" name=ID
                                                                                  Attribute
  ("extends" superEntity=[Entity])?                       JAVAID
                                                                               name: EString
  "{"                                                  name: EString
                                                                               many: EBoolean
    (attributes+=Attribute)*
  "}";                                                                                  type

Attribute:
  type=[Type] (many?="*")? name=ID;
grammar org.xtext.example.Entity
    with org.eclipse.xtext.common.Terminals            Meta model inference
generate entity
    "http://www.xtext.org/example/Entity"
                                              entity
Model:
  (types+=Type)*;
                                                                       Model
Type:
  TypeDef | Entity;
                                                                          types
TypeDef:                                                                *
                                                                    Type
  "typedef" name=ID
                                                                 name: EString
  ("mapsto" mappedType=JAVAID)?;
                                                                                                superEntity
JAVAID:
  name=ID("." ID)*;                                      TypeDef                    Entity


Entity:                                       mappedType                                attributes
  "entity" name=ID
                                                                                  Attribute
  ("extends" superEntity=[Entity])?                       JAVAID
                                                                               name: EString
  "{"                                                  name: EString
                                                                               many: EBoolean
    (attributes+=Attribute)*
  "}";                                                                                  type

Attribute:
  type=[Type] (many?="*")? name=ID;
Demo 2
Poll "Simple poll"

	 question "What's your name?" name

	   question "How do you feel today?" howareyou
	   	 () "Fine" fine
	   	 () "Great" great
	   	 () "Bad" bad
	   	 () "Not too bad" not2bad
	   	
	   	
	   question "What's your favourite food?" food
	   	 [] "Pizza" pizza
	   	 [] "Pasta" pasta
	   	 [] "Sushi" sushi
	   	 [] "Mexican" mexican
Pimp My Write
Tooltips
                Scoping
  Outline
                           Label Provider
   Validation         Hyperlinking / Navigation
                                       AST
Code Formatting
                      Content Assist
            Folding
                               Quick Fix
     Datatype Converter
                              Parser
   Syntax Highlighting
Tooltips
                Scoping
  Outline

                      Hyperlinking / Navigation
                                       AST
Code Formatting
                      Content Assist
            Folding
                               Quick Fix
     Datatype Converter
                              Parser
   Syntax Highlighting
Tooltips
                Scoping
  Outline
                          Label Provider
   Validation         Hyperlinking / Navigation
                                       AST
Code Formatting
                      Content Assist
            Folding
                               Quick Fix
     Datatype Converter
                              Parser
   Syntax Highlighting
Conclusion
Abstraction
Use a DSL to develop your tools
Support
Newsgroup
Community Forum
Professional Support
Heiko     Sven       Moritz    Peter    Dennis     Jan        Patrick Sebastian   Michael     Knut
Behrens   Efftinge   Eysholdt   Friese   Hübner   Köhnlein   Schönbach Zarnekow     Clay     Wannheden

                                                                                   Individual
Twitter: @xtext
http://www.xtext.org

Contenu connexe

Tendances

jQuery - Tips And Tricks
jQuery - Tips And TricksjQuery - Tips And Tricks
jQuery - Tips And TricksLester Lievens
 
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRaimonds Simanovskis
 
QA Lab: тестирование ПО. Яков Крамаренко: "KISS Automation"
QA Lab: тестирование ПО. Яков Крамаренко: "KISS Automation"QA Lab: тестирование ПО. Яков Крамаренко: "KISS Automation"
QA Lab: тестирование ПО. Яков Крамаренко: "KISS Automation"GeeksLab Odessa
 
Omnisearch in AEM 6.2 - Search All the Things
Omnisearch in AEM 6.2 - Search All the ThingsOmnisearch in AEM 6.2 - Search All the Things
Omnisearch in AEM 6.2 - Search All the ThingsJustin Edelson
 
JavaScript Unit Testing with Jasmine
JavaScript Unit Testing with JasmineJavaScript Unit Testing with Jasmine
JavaScript Unit Testing with JasmineRaimonds Simanovskis
 
Why Every Tester Should Learn Ruby
Why Every Tester Should Learn RubyWhy Every Tester Should Learn Ruby
Why Every Tester Should Learn RubyRaimonds Simanovskis
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript TutorialBui Kiet
 
SilverStripe CMS JavaScript Refactoring
SilverStripe CMS JavaScript RefactoringSilverStripe CMS JavaScript Refactoring
SilverStripe CMS JavaScript RefactoringIngo Schommer
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesAnkit Rastogi
 
Stubる - Mockingjayを使ったHTTPクライアントのテスト -
Stubる - Mockingjayを使ったHTTPクライアントのテスト -Stubる - Mockingjayを使ったHTTPクライアントのテスト -
Stubる - Mockingjayを使ったHTTPクライアントのテスト -Kenji Tanaka
 
Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptVisual Engineering
 
QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...
QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...
QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...GeeksLab Odessa
 
Testing your javascript code with jasmine
Testing your javascript code with jasmineTesting your javascript code with jasmine
Testing your javascript code with jasmineRubyc Slides
 

Tendances (20)

Akka tips
Akka tipsAkka tips
Akka tips
 
jQuery - Tips And Tricks
jQuery - Tips And TricksjQuery - Tips And Tricks
jQuery - Tips And Tricks
 
Java Script Best Practices
Java Script Best PracticesJava Script Best Practices
Java Script Best Practices
 
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and JasmineRails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
Rails-like JavaScript Using CoffeeScript, Backbone.js and Jasmine
 
Rails on Oracle 2011
Rails on Oracle 2011Rails on Oracle 2011
Rails on Oracle 2011
 
QA Lab: тестирование ПО. Яков Крамаренко: "KISS Automation"
QA Lab: тестирование ПО. Яков Крамаренко: "KISS Automation"QA Lab: тестирование ПО. Яков Крамаренко: "KISS Automation"
QA Lab: тестирование ПО. Яков Крамаренко: "KISS Automation"
 
Omnisearch in AEM 6.2 - Search All the Things
Omnisearch in AEM 6.2 - Search All the ThingsOmnisearch in AEM 6.2 - Search All the Things
Omnisearch in AEM 6.2 - Search All the Things
 
JavaScript Unit Testing with Jasmine
JavaScript Unit Testing with JasmineJavaScript Unit Testing with Jasmine
JavaScript Unit Testing with Jasmine
 
Why Every Tester Should Learn Ruby
Why Every Tester Should Learn RubyWhy Every Tester Should Learn Ruby
Why Every Tester Should Learn Ruby
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
 
SilverStripe CMS JavaScript Refactoring
SilverStripe CMS JavaScript RefactoringSilverStripe CMS JavaScript Refactoring
SilverStripe CMS JavaScript Refactoring
 
Ten useful JavaScript tips & best practices
Ten useful JavaScript tips & best practicesTen useful JavaScript tips & best practices
Ten useful JavaScript tips & best practices
 
Stubる - Mockingjayを使ったHTTPクライアントのテスト -
Stubる - Mockingjayを使ったHTTPクライアントのテスト -Stubる - Mockingjayを使ったHTTPクライアントのテスト -
Stubる - Mockingjayを使ったHTTPクライアントのテスト -
 
Core concepts-javascript
Core concepts-javascriptCore concepts-javascript
Core concepts-javascript
 
JavaScript Basics and Trends
JavaScript Basics and TrendsJavaScript Basics and Trends
JavaScript Basics and Trends
 
Workshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScriptWorkshop 1: Good practices in JavaScript
Workshop 1: Good practices in JavaScript
 
Akka in-action
Akka in-actionAkka in-action
Akka in-action
 
QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...
QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...
QA Lab: тестирование ПО. Станислав Шмидт: "Self-testing REST APIs with API Fi...
 
Java Annotations and Pre-processing
Java  Annotations and Pre-processingJava  Annotations and Pre-processing
Java Annotations and Pre-processing
 
Testing your javascript code with jasmine
Testing your javascript code with jasmineTesting your javascript code with jasmine
Testing your javascript code with jasmine
 

Similaire à Building DSLs With Eclipse

Jazoon 2010 - Building DSLs with Eclipse
Jazoon 2010 - Building DSLs with EclipseJazoon 2010 - Building DSLs with Eclipse
Jazoon 2010 - Building DSLs with EclipsePeter Friese
 
Overcoming The Impedance Mismatch Between Source Code And Architecture
Overcoming The Impedance Mismatch Between Source Code And ArchitectureOvercoming The Impedance Mismatch Between Source Code And Architecture
Overcoming The Impedance Mismatch Between Source Code And ArchitecturePeter Friese
 
Your Entity, Your Code
Your Entity, Your CodeYour Entity, Your Code
Your Entity, Your CodeDrupalDay
 
Persisting Data on SQLite using Room
Persisting Data on SQLite using RoomPersisting Data on SQLite using Room
Persisting Data on SQLite using RoomNelson Glauber Leal
 
Domänenspezifische Sprachen mit Xtext
Domänenspezifische Sprachen mit XtextDomänenspezifische Sprachen mit Xtext
Domänenspezifische Sprachen mit XtextDr. Jan Köhnlein
 
Building DSLs with Xtext - Eclipse Modeling Day 2009
Building DSLs with Xtext - Eclipse Modeling Day 2009Building DSLs with Xtext - Eclipse Modeling Day 2009
Building DSLs with Xtext - Eclipse Modeling Day 2009Heiko Behrens
 
Paintfree Object-Document Mapping for MongoDB by Philipp Krenn
Paintfree Object-Document Mapping for MongoDB by Philipp KrennPaintfree Object-Document Mapping for MongoDB by Philipp Krenn
Paintfree Object-Document Mapping for MongoDB by Philipp KrennJavaDayUA
 
Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!Oliver Gierke
 
Building a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to SpaceBuilding a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to SpaceMaarten Balliauw
 
Implementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord modelsImplementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord modelsKostyantyn Stepanyuk
 
API first with Swagger and Scala by Slava Schmidt
API first with Swagger and Scala by  Slava SchmidtAPI first with Swagger and Scala by  Slava Schmidt
API first with Swagger and Scala by Slava SchmidtJavaDayUA
 
Oop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalOop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalMichael Stal
 
Http4s, Doobie and Circe: The Functional Web Stack
Http4s, Doobie and Circe: The Functional Web StackHttp4s, Doobie and Circe: The Functional Web Stack
Http4s, Doobie and Circe: The Functional Web StackGaryCoady
 

Similaire à Building DSLs With Eclipse (20)

Jazoon 2010 - Building DSLs with Eclipse
Jazoon 2010 - Building DSLs with EclipseJazoon 2010 - Building DSLs with Eclipse
Jazoon 2010 - Building DSLs with Eclipse
 
Overcoming The Impedance Mismatch Between Source Code And Architecture
Overcoming The Impedance Mismatch Between Source Code And ArchitectureOvercoming The Impedance Mismatch Between Source Code And Architecture
Overcoming The Impedance Mismatch Between Source Code And Architecture
 
Spine JS
Spine JSSpine JS
Spine JS
 
Your Entity, Your Code
Your Entity, Your CodeYour Entity, Your Code
Your Entity, Your Code
 
Your Entity, Your Code
Your Entity, Your CodeYour Entity, Your Code
Your Entity, Your Code
 
Persisting Data on SQLite using Room
Persisting Data on SQLite using RoomPersisting Data on SQLite using Room
Persisting Data on SQLite using Room
 
Grammarware Memes
Grammarware MemesGrammarware Memes
Grammarware Memes
 
Using the Windows 8 Runtime from C++
Using the Windows 8 Runtime from C++Using the Windows 8 Runtime from C++
Using the Windows 8 Runtime from C++
 
Domänenspezifische Sprachen mit Xtext
Domänenspezifische Sprachen mit XtextDomänenspezifische Sprachen mit Xtext
Domänenspezifische Sprachen mit Xtext
 
Building DSLs with Xtext - Eclipse Modeling Day 2009
Building DSLs with Xtext - Eclipse Modeling Day 2009Building DSLs with Xtext - Eclipse Modeling Day 2009
Building DSLs with Xtext - Eclipse Modeling Day 2009
 
Paintfree Object-Document Mapping for MongoDB by Philipp Krenn
Paintfree Object-Document Mapping for MongoDB by Philipp KrennPaintfree Object-Document Mapping for MongoDB by Philipp Krenn
Paintfree Object-Document Mapping for MongoDB by Philipp Krenn
 
Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!
 
Xtext Eclipse Con
Xtext Eclipse ConXtext Eclipse Con
Xtext Eclipse Con
 
Einführung in TypeScript
Einführung in TypeScriptEinführung in TypeScript
Einführung in TypeScript
 
Building a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to SpaceBuilding a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to Space
 
Prototype Framework
Prototype FrameworkPrototype Framework
Prototype Framework
 
Implementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord modelsImplementation of EAV pattern for ActiveRecord models
Implementation of EAV pattern for ActiveRecord models
 
API first with Swagger and Scala by Slava Schmidt
API first with Swagger and Scala by  Slava SchmidtAPI first with Swagger and Scala by  Slava Schmidt
API first with Swagger and Scala by Slava Schmidt
 
Oop2010 Scala Presentation Stal
Oop2010 Scala Presentation StalOop2010 Scala Presentation Stal
Oop2010 Scala Presentation Stal
 
Http4s, Doobie and Circe: The Functional Web Stack
Http4s, Doobie and Circe: The Functional Web StackHttp4s, Doobie and Circe: The Functional Web Stack
Http4s, Doobie and Circe: The Functional Web Stack
 

Plus de Peter Friese

Building Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsBuilding Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsPeter Friese
 
Firebase & SwiftUI Workshop
Firebase & SwiftUI WorkshopFirebase & SwiftUI Workshop
Firebase & SwiftUI WorkshopPeter Friese
 
Building Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsBuilding Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsPeter Friese
 
Firebase for Apple Developers - SwiftHeroes
Firebase for Apple Developers - SwiftHeroesFirebase for Apple Developers - SwiftHeroes
Firebase for Apple Developers - SwiftHeroesPeter Friese
 
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
 +  = ❤️ (Firebase for Apple Developers) at Swift LeedsPeter Friese
 
async/await in Swift
async/await in Swiftasync/await in Swift
async/await in SwiftPeter Friese
 
Firebase for Apple Developers
Firebase for Apple DevelopersFirebase for Apple Developers
Firebase for Apple DevelopersPeter Friese
 
Building Apps with SwiftUI and Firebase
Building Apps with SwiftUI and FirebaseBuilding Apps with SwiftUI and Firebase
Building Apps with SwiftUI and FirebasePeter Friese
 
Rapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and FirebaseRapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and FirebasePeter Friese
 
Rapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and FirebaseRapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and FirebasePeter Friese
 
6 Things You Didn't Know About Firebase Auth
6 Things You Didn't Know About Firebase Auth6 Things You Didn't Know About Firebase Auth
6 Things You Didn't Know About Firebase AuthPeter Friese
 
Five Things You Didn't Know About Firebase Auth
Five Things You Didn't Know About Firebase AuthFive Things You Didn't Know About Firebase Auth
Five Things You Didn't Know About Firebase AuthPeter Friese
 
Building High-Quality Apps for Google Assistant
Building High-Quality Apps for Google AssistantBuilding High-Quality Apps for Google Assistant
Building High-Quality Apps for Google AssistantPeter Friese
 
Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on Google Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on Google Peter Friese
 
Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on GoogleBuilding Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on GooglePeter Friese
 
What's new in Android Wear 2.0
What's new in Android Wear 2.0What's new in Android Wear 2.0
What's new in Android Wear 2.0Peter Friese
 
Google Fit, Android Wear & Xamarin
Google Fit, Android Wear & XamarinGoogle Fit, Android Wear & Xamarin
Google Fit, Android Wear & XamarinPeter Friese
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android WearPeter Friese
 
Google Play Services Rock
Google Play Services RockGoogle Play Services Rock
Google Play Services RockPeter Friese
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android WearPeter Friese
 

Plus de Peter Friese (20)

Building Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsBuilding Reusable SwiftUI Components
Building Reusable SwiftUI Components
 
Firebase & SwiftUI Workshop
Firebase & SwiftUI WorkshopFirebase & SwiftUI Workshop
Firebase & SwiftUI Workshop
 
Building Reusable SwiftUI Components
Building Reusable SwiftUI ComponentsBuilding Reusable SwiftUI Components
Building Reusable SwiftUI Components
 
Firebase for Apple Developers - SwiftHeroes
Firebase for Apple Developers - SwiftHeroesFirebase for Apple Developers - SwiftHeroes
Firebase for Apple Developers - SwiftHeroes
 
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
 +  = ❤️ (Firebase for Apple Developers) at Swift Leeds
 
async/await in Swift
async/await in Swiftasync/await in Swift
async/await in Swift
 
Firebase for Apple Developers
Firebase for Apple DevelopersFirebase for Apple Developers
Firebase for Apple Developers
 
Building Apps with SwiftUI and Firebase
Building Apps with SwiftUI and FirebaseBuilding Apps with SwiftUI and Firebase
Building Apps with SwiftUI and Firebase
 
Rapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and FirebaseRapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and Firebase
 
Rapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and FirebaseRapid Application Development with SwiftUI and Firebase
Rapid Application Development with SwiftUI and Firebase
 
6 Things You Didn't Know About Firebase Auth
6 Things You Didn't Know About Firebase Auth6 Things You Didn't Know About Firebase Auth
6 Things You Didn't Know About Firebase Auth
 
Five Things You Didn't Know About Firebase Auth
Five Things You Didn't Know About Firebase AuthFive Things You Didn't Know About Firebase Auth
Five Things You Didn't Know About Firebase Auth
 
Building High-Quality Apps for Google Assistant
Building High-Quality Apps for Google AssistantBuilding High-Quality Apps for Google Assistant
Building High-Quality Apps for Google Assistant
 
Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on Google Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on Google
 
Building Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on GoogleBuilding Conversational Experiences with Actions on Google
Building Conversational Experiences with Actions on Google
 
What's new in Android Wear 2.0
What's new in Android Wear 2.0What's new in Android Wear 2.0
What's new in Android Wear 2.0
 
Google Fit, Android Wear & Xamarin
Google Fit, Android Wear & XamarinGoogle Fit, Android Wear & Xamarin
Google Fit, Android Wear & Xamarin
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Wear
 
Google Play Services Rock
Google Play Services RockGoogle Play Services Rock
Google Play Services Rock
 
Introduction to Android Wear
Introduction to Android WearIntroduction to Android Wear
Introduction to Android Wear
 

Dernier

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 

Dernier (20)

Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 

Building DSLs With Eclipse

  • 1. Building DSLs with Eclipse Peter Friese, itemis @peterfriese @xtext (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
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7. What is a DSL?
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 16.
  • 17.
  • 19. You’d want to core an apple...
  • 20. ... for your kids.
  • 21. ? Right tool for the job?
  • 22. Your trusty swiss army knife!
  • 23. Because you can use it for other stuff, too. E.g., opening a bottle of wine.
  • 25. You’d want to core a few more apples...
  • 26. ... for an apple cake.
  • 27. Still the best tool for the job?
  • 32. ... a DSL is ...
  • 33. A specific tool for a specific job
  • 34. A specific tool for a specific job
  • 36. SQL
  • 37. select name, salary from employees where salary > 2000 order by salary
  • 38. ANT
  • 39. <project name="MyProject" default="dist" basedir="."> <property name="src" location="src"/> <property name="build" location="build"/> <property name="dist" location="dist"/> <target name="init"> <mkdir dir="${build}"/> </target> <target name="compile" depends="init"> <javac srcdir="${src}" destdir="${build}"/> </target> <target name="dist" depends="compile"> <mkdir dir="${dist}/lib"/> <jar jarfile="${dist}/lib/MyProject.jar" basedir="${build}"/> </target> <target name="clean"> <delete dir="${build}"/> <delete dir="${dist}"/> </target> </project>
  • 40. <project name="MyProject" default="dist" basedir="."> <property name="src" location="src"/> <property name="build" location="build"/> <property name="dist" location="dist"/> <target name="init"> <mkdir dir="${build}"/> </target> <target name="compile" depends="init"> <javac srcdir="${src}" destdir="${build}"/> </target> <target name="dist" depends="compile"> <mkdir dir="${dist}/lib"/> <jar jarfile="${dist}/lib/MyProject.jar" basedir="${build}"/> </target> <target name="clean"> <delete dir="${build}"/> <delete dir="${dist}"/> </target> </project>
  • 41. External or Internal
  • 43. Mailer.mail() .to(“you@gmail.com”) .from(“me@gmail.com”) .subject(“Writing DSLs in Java”) .body(“...”) .send();
  • 47.
  • 48. 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
  • 52. Why not use a DSL... ... for building DSLs?
  • 53.
  • 55.
  • 56. @SuppressWarnings("serial") @Entity @Table(name = "CUSTOMER_INFO") public class CustomerInfo implements Serializable { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "idSeq") @SequenceGenerator(name = "idSeq", sequenceName = "CUST_SEQ", allocationSize = 1) @Column(name = "CUST_ID", nullable = false) private String customerId; public void setCustomerId(String customerId) { this.customerId = customerId; } public String getCustomerId() { return customerId; } @Column(name = "EMAIL", nullable = false, length = 128) private String emailAddress; public String getEmailAddress() { return emailAddress; } public void setEmailAddress(String emailAddress) { String oldValue = emailAddress; this.emailAddress = emailAddress; firePropertyChangedEvent("emailAddress", oldValue, this.emailAddress); }
  • 57. @SuppressWarnings("serial") @Entity @Table(name = "CUSTOMER_INFO") public class CustomerInfo implements Serializable { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "idSeq") @SequenceGenerator(name = "idSeq", sequenceName = "CUST_SEQ", allocationSize = 1) @Column(name = "CUST_ID", nullable = false) private String customerId; public void setCustomerId(String customerId) { this.customerId = customerId; } public String getCustomerId() { return customerId; } @Column(name = "EMAIL", nullable = false, length = 128) private String emailAddress; public String getEmailAddress() { return emailAddress; } public void setEmailAddress(String emailAddress) { String oldValue = emailAddress; this.emailAddress = emailAddress; firePropertyChangedEvent("emailAddress", oldValue, this.emailAddress); }
  • 58. entity CustomerInfo (id=CUST_ID, sequenceName=CUST_SEQ) { String emailAddress (notNull, length = 128) }
  • 59. entity CustomerInfo (id=CUST_ID, sequenceName=CUST_SEQ) { String emailAddress (notNull, length = 128) } Bean DAO (POJO)
  • 60.
  • 62. Model G ra m m ar
  • 63. ar Model m m ra G Generator
  • 64. ar Model m m ra G Generator Runtime Superclass Subclass Class LL(*) Parser ECore meta model Editor
  • 65. ar Model m m ra G Generator Runtime Superclass Subclass Class LL(*) Parser ECore meta model Editor
  • 66. Grammar (similar to EBNF) grammar org.xtext.example.Entity with org.eclipse.xtext.common.Terminals generate entity "http://www.xtext.org/example/Entity" Model: (types+=Type)*; Type: TypeDef | Entity; TypeDef: "typedef" name=ID ("mapsto" mappedType=JAVAID)?; JAVAID: name=ID("." ID)*; Entity: "entity" name=ID ("extends" superEntity=[Entity])? "{" (attributes+=Attribute)* "}"; Attribute: type=[Type] (many?="*")? name=ID;
  • 67. grammar org.xtext.example.Entity with org.eclipse.xtext.common.Terminals Meta model inference generate entity "http://www.xtext.org/example/Entity" entity Model: (types+=Type)*; Model Type: TypeDef | Entity; types TypeDef: * Type "typedef" name=ID name: EString ("mapsto" mappedType=JAVAID)?; superEntity JAVAID: name=ID("." ID)*; TypeDef Entity Entity: mappedType attributes "entity" name=ID Attribute ("extends" superEntity=[Entity])? JAVAID name: EString "{" name: EString many: EBoolean (attributes+=Attribute)* "}"; type Attribute: type=[Type] (many?="*")? name=ID;
  • 68. grammar org.xtext.example.Entity with org.eclipse.xtext.common.Terminals Meta model inference generate entity "http://www.xtext.org/example/Entity" entity Rules -> Classes Model: (types+=Type)*; Model Type: TypeDef | Entity; types TypeDef: * Type "typedef" name=ID name: EString ("mapsto" mappedType=JAVAID)?; superEntity JAVAID: name=ID("." ID)*; TypeDef Entity Entity: mappedType attributes "entity" name=ID Attribute ("extends" superEntity=[Entity])? JAVAID name: EString "{" name: EString many: EBoolean (attributes+=Attribute)* "}"; type Attribute: type=[Type] (many?="*")? name=ID;
  • 69. grammar org.xtext.example.Entity with org.eclipse.xtext.common.Terminals Meta model inference generate entity "http://www.xtext.org/example/Entity" entity Model: (types+=Type)*; Model Type: TypeDef | Entity; types TypeDef: * Type "typedef" name=ID name: EString ("mapsto" mappedType=JAVAID)?; superEntity JAVAID: name=ID("." ID)*; TypeDef Entity Entity: mappedType attributes "entity" name=ID Attribute ("extends" superEntity=[Entity])? JAVAID name: EString "{" name: EString many: EBoolean (attributes+=Attribute)* "}"; type Attribute: type=[Type] (many?="*")? name=ID;
  • 70. grammar org.xtext.example.Entity with org.eclipse.xtext.common.Terminals Meta model inference generate entity "http://www.xtext.org/example/Entity" entity Alternatives -> Hierarchy Model: (types+=Type)*; Model Type: TypeDef | Entity; types TypeDef: * Type "typedef" name=ID name: EString ("mapsto" mappedType=JAVAID)?; superEntity JAVAID: name=ID("." ID)*; TypeDef Entity Entity: mappedType attributes "entity" name=ID Attribute ("extends" superEntity=[Entity])? JAVAID name: EString "{" name: EString many: EBoolean (attributes+=Attribute)* "}"; type Attribute: type=[Type] (many?="*")? name=ID;
  • 71. grammar org.xtext.example.Entity with org.eclipse.xtext.common.Terminals Meta model inference generate entity "http://www.xtext.org/example/Entity" entity Model: (types+=Type)*; Model Type: TypeDef | Entity; types TypeDef: * Type "typedef" name=ID name: EString ("mapsto" mappedType=JAVAID)?; superEntity JAVAID: name=ID("." ID)*; TypeDef Entity Entity: mappedType attributes "entity" name=ID Attribute ("extends" superEntity=[Entity])? JAVAID name: EString "{" name: EString many: EBoolean (attributes+=Attribute)* "}"; type Attribute: type=[Type] (many?="*")? name=ID;
  • 72. grammar org.xtext.example.Entity with org.eclipse.xtext.common.Terminals Meta model inference generate entity "http://www.xtext.org/example/Entity" entity Assignment -> Feature Model: (types+=Type)*; Model Type: TypeDef | Entity; types TypeDef: * Type "typedef" name=ID name: EString ("mapsto" mappedType=JAVAID)?; superEntity JAVAID: name=ID("." ID)*; TypeDef Entity Entity: mappedType attributes "entity" name=ID Attribute ("extends" superEntity=[Entity])? JAVAID name: EString "{" name: EString many: EBoolean (attributes+=Attribute)* "}"; type Attribute: type=[Type] (many?="*")? name=ID;
  • 73. grammar org.xtext.example.Entity with org.eclipse.xtext.common.Terminals Meta model inference generate entity "http://www.xtext.org/example/Entity" entity Model: (types+=Type)*; Model Type: TypeDef | Entity; types TypeDef: * Type "typedef" name=ID name: EString ("mapsto" mappedType=JAVAID)?; superEntity JAVAID: name=ID("." ID)*; TypeDef Entity Entity: mappedType attributes "entity" name=ID Attribute ("extends" superEntity=[Entity])? JAVAID name: EString "{" name: EString many: EBoolean (attributes+=Attribute)* "}"; type Attribute: type=[Type] (many?="*")? name=ID;
  • 75.
  • 76. Poll "Simple poll" question "What's your name?" name question "How do you feel today?" howareyou () "Fine" fine () "Great" great () "Bad" bad () "Not too bad" not2bad question "What's your favourite food?" food [] "Pizza" pizza [] "Pasta" pasta [] "Sushi" sushi [] "Mexican" mexican
  • 77.
  • 78.
  • 79.
  • 81. Tooltips Scoping Outline Label Provider Validation Hyperlinking / Navigation AST Code Formatting Content Assist Folding Quick Fix Datatype Converter Parser Syntax Highlighting
  • 82. Tooltips Scoping Outline Hyperlinking / Navigation AST Code Formatting Content Assist Folding Quick Fix Datatype Converter Parser Syntax Highlighting
  • 83. Tooltips Scoping Outline Label Provider Validation Hyperlinking / Navigation AST Code Formatting Content Assist Folding Quick Fix Datatype Converter Parser Syntax Highlighting
  • 86. Use a DSL to develop your tools
  • 88. Heiko Sven Moritz Peter Dennis Jan Patrick Sebastian Michael Knut Behrens Efftinge Eysholdt Friese Hübner Köhnlein Schönbach Zarnekow Clay Wannheden Individual
  • 89.

Notes de l'éditeur

  1. itemis = IT + Themis Themis, goddess of justice order knows the future
  2. connect people share contact details your resume on the web (endorsements, who you know, what you&amp;#x2019;ve done)
  3. connect people / friends &amp;#x201C;friend&amp;#x201D; someone / &amp;#x201C;write on their wall&amp;#x201D; share photos fun-oriented
  4. connect people everybody can have their say
  5. Java = GPL You can do everything with Java But is it a good idea to do everything with Java?
  6. concise precise wouldn&amp;#x2019;t change anything
  7. ANT, built on a single transatlantic flight using XML to avoid writing own parser leverage XML parser today, we&amp;#x2019;d do it differently
  8. ANT, built on a single transatlantic flight using XML to avoid writing own parser leverage XML parser today, we&amp;#x2019;d do it differently
  9. It&amp;#x2019;s relatively easy to write an internal DSL
  10. Syntax of host language is the limiting factor for implementing internal DSLs
  11. External DSLs are very flexible - you can exactly adjust them to your needs
  12. You can choose the syntax of your DSL to your liking
  13. However, building external DSLs is complicated
  14. Java = GPL You can do everything with Java But is it a good idea to do everything with Java?
  15. Newsgroup Foren Prof. Support