SlideShare ist ein Scribd-Unternehmen logo
1 von 90
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

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.

Hinweis der Redaktion

  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