SlideShare ist ein Scribd-Unternehmen logo
1 von 37
Downloaden Sie, um offline zu lesen
http://live.eclipse.org/node/705

Eclipse Live Webinar on


     Sven Efftinge, Heiko Behrens
                 itemis
Agenda
      What is Xtext?
   DSLs - An Example
Underlying Technology
     Advanced Topics
Questions & Answers
?
What is
A Language Framework
Yet another
 Parser Generator?



JavaCC
Yet another
 Parser Generator?

                      t ha t!
               than
           ore
      it’sm
No,
JavaCC
How does Xtext
      relate to ...

IDE Meta-tooling Platform (IMP)


Dynamic Language Toolkit (DLTK)
How does Xtext
      relate to ...

IDE Meta-tooling Platform (IMP) !
                             at
                      an th
              o re th
      t is m
 Xt ex Language Toolkit (DLTK)
Dynamic
Is it a language workbench?


JetBrains Meta Programming System




 Intentional Domain Workbench       Microsoft Oslo
Is it a language workbench?

                           le te ly
                        m p        rc e!
                it’s co     s  ou
             ut          en
JetBrains Meta Programming System
          ,b          op
    Y es         a nd
          as ed
 t ex t-b
 Intentional Domain Workbench       Microsoft Oslo
Xtext is a complete environment
for development of textual
 - programming languages and
 - domain-specific languages.
It is implemented in Java and is
based on Eclipse, EMF, and Antlr.
Domain-Specific Language (DSL)
A DSL is a formal, processable language
  targeting at a specific viewpoint or
     aspect of a software system.
Its semantics, flexibility and notation is
 designed in order to support working
with that viewpoint as good as possible.
Rd2-c2
“ Queen to c7.
              Check.”




  “ Rd2-c2 ,
rook at d2 moves to c2.”
Moves in Chess:
!ook at a1 moves to a5.
    P
    iece           S   q uare      A
                                   ction
                                           De   stin ation


"ishop at c8 captures knight at h3.n
    P
    iece             S   q uare  io
                                           Action
                                                             D
                                                             es tinat


# b1 x c3
Piece S   qua re ction stination
              AD      e


$2 - g4
                       ation
S A D
quar
    e   ction e   stin
Rook     a1    move      a5
              Bishop   c8   capture    h3   Knight
              Knight   b1   capture    c3   Queen
               Pawn    g2    move      g4


    Game                     Move
                         Source                      «enum»
WhitePlayer
                       * Destination                  Piece
BlackPlayer
                         Piece
"ishop at c8 captures knight at h3

           " c8 x h3
Model (textfile)
White: "Mayfield"
Black: "Trinks"

pawn at e2 moves to e4
pawn at f7 moves to g5

K b1 - c3
f7 - f5

queen at d1 moves to h5
// 1-0
DEMO
Underlying Technology
ar
Model




                                    m
                                   m
                               ra
                               G
                             Generator



        Runtime
                  Superclass




                  Subclass              Class




 LL(*) Parser   ecore meta model                editor
Java Persistence API (JPA)
package templates;

import java.io.Serializable;
import java.util.*;
import javax.persistence.*;

@SuppressWarnings("serial")
@Entity
public class Customer implements Serializable {
!    private Long id;
!    private String name;
!    private Address address;
!    private Set<Order> orders = new HashSet<Order>();
!    // No-arg constructor
!    public Customer() {
!    }
!    @Id
!    public Long getId() {                               entity Customer {
!    !     return id;
!    }                                                   ! property name : String
!    public void setId(Long id) {                        ! property address : Address
!    !     this.id = id;
!    }                                                   ! property orders : Order[]
!    public String getName() {
!    !     return name;                                  }
!    }
!    public void setName(String name) {
!    !     this.name = name;
!    }
!    public Address getAddress() {
!    !     return address;
!    }
!    public void setAddress(Address address) {
!    !     this.address = address;
!    }
!    @OneToMany
!    public Collection<Order> getOrders() {
!    !     return orders;
!    }
!    public void setOrders(Set<Order> orders) {
!    !     this.orders = orders;
!    }
}
DEMO
ar
Model




                                    m
                                   m
                               ra
                               G
                                                Generator Fragments
                             Generator



        Runtime
                  Superclass




                  Subclass              Class




 LL(*) Parser   ecore meta model                      editor
Composable
    Code Generator
! generator is composed of “fragments”
! fragments can contribute to:
 ! Manifest.MF
 ! plugin.xml
 ! Guice modules
! Add your own fragments
ar
Model




                                    m
                                   m
                               ra
                               G
                             Generator



        Runtime




                                                         Google Guice
                  Superclass




                  Subclass              Class




 LL(*) Parser   ecore meta model                editor
licensed by http://www.wordle.net/
MyCustomLabelProvider




            licensed by http://www.wordle.net/
Dependency Injection with
            Googlee




!No dependency to concrete implementation
!No explicit construction
!Easy testing
!Easy composition
Configuration of Components
            in Xtext
/**
  * used to register components to be used within the IDE.
  */
public class DomainmodelUiModule
! ! extends GeneratedDomainmodelUiModule {
!
! @Override
! public Class<? extends ILabelProvider> bindILabelProvider() {
! ! return MySpecialLabelProvider.class;
! }
}
DEMO
Advanced Topics
Integration with EMF
                                                  eclipse

                                 Any EMF-based   modeling
Code Generator    GMF Editor                                P R O J E C T
                                  Component




                 <<abstract>>                    XMI
                                 XMIResource
                  Resource




                 XtextResource                   Text




    Parser          Linker         Serializer




ValueConverter   ScopeProvider     Formatter
Working with Xtext
// initialization and setup (only needed in standalone mode)
new EntityStandaloneSetup().createInjectorAndDoEMFRegistration();

// standard EMF API usage
ResourceSet resourceSet = new ResourceSet();
Resource resource = resourceSet.getResource(uriToModelFile, true);
Model model = (Model) resource.getContents().get(0);

// print the name of all types to the console
for (Type type : model.getElements()) {
  System.out.println(type.getName());
}
Eclipse Helios
•Model Index
• Grammar Mixins
• Base Language
• UI Features
Questions & Answers

Weitere ähnliche Inhalte

Was ist angesagt?

Scala the good and bad parts
Scala the good and bad partsScala the good and bad parts
Scala the good and bad partsbenewu
 
Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scalaStratio
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & LanguagesGaditek
 
Functional programming in TypeScript
Functional programming in TypeScriptFunctional programming in TypeScript
Functional programming in TypeScriptbinDebug WorkSpace
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming LanguageCihad Horuzoğlu
 
Swift Tutorial Part 2. The complete guide for Swift programming language
Swift Tutorial Part 2. The complete guide for Swift programming languageSwift Tutorial Part 2. The complete guide for Swift programming language
Swift Tutorial Part 2. The complete guide for Swift programming languageHossam Ghareeb
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8Talha Ocakçı
 
Introduction to functional programming with java 8
Introduction to functional programming with java 8Introduction to functional programming with java 8
Introduction to functional programming with java 8JavaBrahman
 
Functions, anonymous functions and the function type
Functions, anonymous functions and the function typeFunctions, anonymous functions and the function type
Functions, anonymous functions and the function typeChang John
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaSujit Majety
 
Advanced Javascript
Advanced JavascriptAdvanced Javascript
Advanced JavascriptDhruvin Shah
 
Core Java Tutorial
Core Java TutorialCore Java Tutorial
Core Java TutorialJava2Blog
 
Kotlin & arrow: the functional way
Kotlin & arrow:  the functional wayKotlin & arrow:  the functional way
Kotlin & arrow: the functional waynluaces
 
Functional programming
Functional programmingFunctional programming
Functional programmingijcd
 
Immutable data structures - A Primer
Immutable data structures - A PrimerImmutable data structures - A Primer
Immutable data structures - A PrimerbinDebug WorkSpace
 
GeekNight 22.0 Multi-paradigm programming in Scala and Akka
GeekNight 22.0 Multi-paradigm programming in Scala and AkkaGeekNight 22.0 Multi-paradigm programming in Scala and Akka
GeekNight 22.0 Multi-paradigm programming in Scala and AkkaGeekNightHyderabad
 

Was ist angesagt? (20)

Scala the good and bad parts
Scala the good and bad partsScala the good and bad parts
Scala the good and bad parts
 
Kotlin L → ∞
Kotlin L → ∞Kotlin L → ∞
Kotlin L → ∞
 
Functional programming in scala
Functional programming in scalaFunctional programming in scala
Functional programming in scala
 
Programming Paradigm & Languages
Programming Paradigm & LanguagesProgramming Paradigm & Languages
Programming Paradigm & Languages
 
Metaprogramming with javascript
Metaprogramming with javascriptMetaprogramming with javascript
Metaprogramming with javascript
 
Functional programming in TypeScript
Functional programming in TypeScriptFunctional programming in TypeScript
Functional programming in TypeScript
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming Language
 
Swift Tutorial Part 2. The complete guide for Swift programming language
Swift Tutorial Part 2. The complete guide for Swift programming languageSwift Tutorial Part 2. The complete guide for Swift programming language
Swift Tutorial Part 2. The complete guide for Swift programming language
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8
 
Introduction to functional programming with java 8
Introduction to functional programming with java 8Introduction to functional programming with java 8
Introduction to functional programming with java 8
 
Functions, anonymous functions and the function type
Functions, anonymous functions and the function typeFunctions, anonymous functions and the function type
Functions, anonymous functions and the function type
 
Scala
ScalaScala
Scala
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
00 intro to java
00 intro to java00 intro to java
00 intro to java
 
Advanced Javascript
Advanced JavascriptAdvanced Javascript
Advanced Javascript
 
Core Java Tutorial
Core Java TutorialCore Java Tutorial
Core Java Tutorial
 
Kotlin & arrow: the functional way
Kotlin & arrow:  the functional wayKotlin & arrow:  the functional way
Kotlin & arrow: the functional way
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
Immutable data structures - A Primer
Immutable data structures - A PrimerImmutable data structures - A Primer
Immutable data structures - A Primer
 
GeekNight 22.0 Multi-paradigm programming in Scala and Akka
GeekNight 22.0 Multi-paradigm programming in Scala and AkkaGeekNight 22.0 Multi-paradigm programming in Scala and Akka
GeekNight 22.0 Multi-paradigm programming in Scala and Akka
 

Ähnlich wie Xtext Webinar

Extension and Evolution
Extension and EvolutionExtension and Evolution
Extension and EvolutionEelco Visser
 
Introduction to D programming language at Weka.IO
Introduction to D programming language at Weka.IOIntroduction to D programming language at Weka.IO
Introduction to D programming language at Weka.IOLiran Zvibel
 
PIL - A Platform Independent Language
PIL - A Platform Independent LanguagePIL - A Platform Independent Language
PIL - A Platform Independent Languagezefhemel
 
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
 
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...Tudor Dragan
 
Domänenspezifische Sprachen mit Xtext
Domänenspezifische Sprachen mit XtextDomänenspezifische Sprachen mit Xtext
Domänenspezifische Sprachen mit XtextDr. Jan Köhnlein
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLsintelliyole
 
Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Guillaume Laforge
 
The craft of meta programming on JVM
The craft of meta programming on JVMThe craft of meta programming on JVM
The craft of meta programming on JVMIgor Khotin
 
Game development
Game developmentGame development
Game developmentAsido_
 
Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011Jimmy Schementi
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...Maarten Balliauw
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy CodeRowan Merewood
 
Going to Mars with Groovy Domain-Specific Languages
Going to Mars with Groovy Domain-Specific LanguagesGoing to Mars with Groovy Domain-Specific Languages
Going to Mars with Groovy Domain-Specific LanguagesGuillaume Laforge
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoRodolfo Carvalho
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Guillaume Laforge
 
IronPython and Dynamic Languages on .NET by Mahesh Prakriya
 IronPython and Dynamic Languages on .NET by Mahesh Prakriya IronPython and Dynamic Languages on .NET by Mahesh Prakriya
IronPython and Dynamic Languages on .NET by Mahesh Prakriyacodebits
 

Ähnlich wie Xtext Webinar (20)

Xtext Webinar
Xtext WebinarXtext Webinar
Xtext Webinar
 
Extension and Evolution
Extension and EvolutionExtension and Evolution
Extension and Evolution
 
Eclipse meets e4
Eclipse meets e4Eclipse meets e4
Eclipse meets e4
 
Introduction to D programming language at Weka.IO
Introduction to D programming language at Weka.IOIntroduction to D programming language at Weka.IO
Introduction to D programming language at Weka.IO
 
PIL - A Platform Independent Language
PIL - A Platform Independent LanguagePIL - A Platform Independent Language
PIL - A Platform Independent Language
 
Tml for Objective C
Tml for Objective CTml for Objective C
Tml for Objective C
 
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
 
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
 
Domänenspezifische Sprachen mit Xtext
Domänenspezifische Sprachen mit XtextDomänenspezifische Sprachen mit Xtext
Domänenspezifische Sprachen mit Xtext
 
Smoothing Your Java with DSLs
Smoothing Your Java with DSLsSmoothing Your Java with DSLs
Smoothing Your Java with DSLs
 
Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007Groovy Update - JavaPolis 2007
Groovy Update - JavaPolis 2007
 
The craft of meta programming on JVM
The craft of meta programming on JVMThe craft of meta programming on JVM
The craft of meta programming on JVM
 
Game development
Game developmentGame development
Game development
 
Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011Iron Languages - NYC CodeCamp 2/19/2011
Iron Languages - NYC CodeCamp 2/19/2011
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
 
Living With Legacy Code
Living With Legacy CodeLiving With Legacy Code
Living With Legacy Code
 
Going to Mars with Groovy Domain-Specific Languages
Going to Mars with Groovy Domain-Specific LanguagesGoing to Mars with Groovy Domain-Specific Languages
Going to Mars with Groovy Domain-Specific Languages
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX Go
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008
 
IronPython and Dynamic Languages on .NET by Mahesh Prakriya
 IronPython and Dynamic Languages on .NET by Mahesh Prakriya IronPython and Dynamic Languages on .NET by Mahesh Prakriya
IronPython and Dynamic Languages on .NET by Mahesh Prakriya
 

Mehr von Sven Efftinge

Parsing Expression With Xtext
Parsing Expression With XtextParsing Expression With Xtext
Parsing Expression With XtextSven Efftinge
 
Language Engineering With Xtext
Language Engineering With XtextLanguage Engineering With Xtext
Language Engineering With XtextSven Efftinge
 
Auto-GWT : Better GWT Programming with Xtend
Auto-GWT : Better GWT Programming with XtendAuto-GWT : Better GWT Programming with Xtend
Auto-GWT : Better GWT Programming with XtendSven Efftinge
 
Codegeneration With Xtend
Codegeneration With XtendCodegeneration With Xtend
Codegeneration With XtendSven Efftinge
 
Domain Specific Languages (EclipseCon 2012)
Domain Specific Languages (EclipseCon 2012)Domain Specific Languages (EclipseCon 2012)
Domain Specific Languages (EclipseCon 2012)Sven Efftinge
 
Xtend @ EclipseCon 2012
Xtend @ EclipseCon 2012Xtend @ EclipseCon 2012
Xtend @ EclipseCon 2012Sven Efftinge
 
This Is Not Your Father's Java
This Is Not Your Father's JavaThis Is Not Your Father's Java
This Is Not Your Father's JavaSven Efftinge
 
Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Sven Efftinge
 
Xtext at MDD Day 2010
Xtext at MDD Day 2010Xtext at MDD Day 2010
Xtext at MDD Day 2010Sven Efftinge
 
Dependency Injection for Eclipse developers
Dependency Injection for Eclipse developersDependency Injection for Eclipse developers
Dependency Injection for Eclipse developersSven Efftinge
 
Challenges In Dsl Design
Challenges In Dsl DesignChallenges In Dsl Design
Challenges In Dsl DesignSven Efftinge
 
Code Generation in Agile Projects
Code Generation in Agile ProjectsCode Generation in Agile Projects
Code Generation in Agile ProjectsSven Efftinge
 
Bessere Softwareentwicklung (Itemis Wintercon)
Bessere Softwareentwicklung (Itemis Wintercon)Bessere Softwareentwicklung (Itemis Wintercon)
Bessere Softwareentwicklung (Itemis Wintercon)Sven Efftinge
 
Domain-Specific Languages in der Praxis
Domain-Specific Languages in der PraxisDomain-Specific Languages in der Praxis
Domain-Specific Languages in der PraxisSven Efftinge
 

Mehr von Sven Efftinge (20)

Parsing Expression With Xtext
Parsing Expression With XtextParsing Expression With Xtext
Parsing Expression With Xtext
 
Language Engineering With Xtext
Language Engineering With XtextLanguage Engineering With Xtext
Language Engineering With Xtext
 
Future of Xtext
Future of XtextFuture of Xtext
Future of Xtext
 
Auto-GWT : Better GWT Programming with Xtend
Auto-GWT : Better GWT Programming with XtendAuto-GWT : Better GWT Programming with Xtend
Auto-GWT : Better GWT Programming with Xtend
 
Codegeneration With Xtend
Codegeneration With XtendCodegeneration With Xtend
Codegeneration With Xtend
 
Gwt and Xtend
Gwt and XtendGwt and Xtend
Gwt and Xtend
 
Domain Specific Languages (EclipseCon 2012)
Domain Specific Languages (EclipseCon 2012)Domain Specific Languages (EclipseCon 2012)
Domain Specific Languages (EclipseCon 2012)
 
Xtend @ EclipseCon 2012
Xtend @ EclipseCon 2012Xtend @ EclipseCon 2012
Xtend @ EclipseCon 2012
 
Eclipse Xtend
Eclipse XtendEclipse Xtend
Eclipse Xtend
 
This Is Not Your Father's Java
This Is Not Your Father's JavaThis Is Not Your Father's Java
This Is Not Your Father's Java
 
Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]Getting the most out of Java [Nordic Coding-2010]
Getting the most out of Java [Nordic Coding-2010]
 
Xtext at MDD Day 2010
Xtext at MDD Day 2010Xtext at MDD Day 2010
Xtext at MDD Day 2010
 
Dependency Injection for Eclipse developers
Dependency Injection for Eclipse developersDependency Injection for Eclipse developers
Dependency Injection for Eclipse developers
 
Challenges In Dsl Design
Challenges In Dsl DesignChallenges In Dsl Design
Challenges In Dsl Design
 
Code Generation in Agile Projects
Code Generation in Agile ProjectsCode Generation in Agile Projects
Code Generation in Agile Projects
 
Xtext Eclipse Con
Xtext Eclipse ConXtext Eclipse Con
Xtext Eclipse Con
 
Generic Editor
Generic EditorGeneric Editor
Generic Editor
 
Eclipse Banking Day
Eclipse Banking DayEclipse Banking Day
Eclipse Banking Day
 
Bessere Softwareentwicklung (Itemis Wintercon)
Bessere Softwareentwicklung (Itemis Wintercon)Bessere Softwareentwicklung (Itemis Wintercon)
Bessere Softwareentwicklung (Itemis Wintercon)
 
Domain-Specific Languages in der Praxis
Domain-Specific Languages in der PraxisDomain-Specific Languages in der Praxis
Domain-Specific Languages in der Praxis
 

Xtext Webinar

  • 1. http://live.eclipse.org/node/705 Eclipse Live Webinar on Sven Efftinge, Heiko Behrens itemis
  • 2. Agenda What is Xtext? DSLs - An Example Underlying Technology Advanced Topics Questions & Answers
  • 5. Yet another Parser Generator? JavaCC
  • 6. Yet another Parser Generator? t ha t! than ore it’sm No, JavaCC
  • 7. How does Xtext relate to ... IDE Meta-tooling Platform (IMP) Dynamic Language Toolkit (DLTK)
  • 8. How does Xtext relate to ... IDE Meta-tooling Platform (IMP) ! at an th o re th t is m Xt ex Language Toolkit (DLTK) Dynamic
  • 9. Is it a language workbench? JetBrains Meta Programming System Intentional Domain Workbench Microsoft Oslo
  • 10. Is it a language workbench? le te ly m p rc e! it’s co s ou ut en JetBrains Meta Programming System ,b op Y es a nd as ed t ex t-b Intentional Domain Workbench Microsoft Oslo
  • 11. Xtext is a complete environment for development of textual - programming languages and - domain-specific languages. It is implemented in Java and is based on Eclipse, EMF, and Antlr.
  • 12. Domain-Specific Language (DSL) A DSL is a formal, processable language targeting at a specific viewpoint or aspect of a software system. Its semantics, flexibility and notation is designed in order to support working with that viewpoint as good as possible.
  • 14. “ Queen to c7. Check.” “ Rd2-c2 , rook at d2 moves to c2.”
  • 15. Moves in Chess: !ook at a1 moves to a5. P iece S q uare A ction De stin ation "ishop at c8 captures knight at h3.n P iece S q uare io Action D es tinat # b1 x c3 Piece S qua re ction stination AD e $2 - g4 ation S A D quar e ction e stin
  • 16. Rook a1 move a5 Bishop c8 capture h3 Knight Knight b1 capture c3 Queen Pawn g2 move g4 Game Move Source «enum» WhitePlayer * Destination Piece BlackPlayer Piece
  • 17. "ishop at c8 captures knight at h3 " c8 x h3
  • 18. Model (textfile) White: "Mayfield" Black: "Trinks" pawn at e2 moves to e4 pawn at f7 moves to g5 K b1 - c3 f7 - f5 queen at d1 moves to h5 // 1-0
  • 19. DEMO
  • 21. ar Model m m ra G Generator Runtime Superclass Subclass Class LL(*) Parser ecore meta model editor
  • 22. Java Persistence API (JPA) package templates; import java.io.Serializable; import java.util.*; import javax.persistence.*; @SuppressWarnings("serial") @Entity public class Customer implements Serializable { ! private Long id; ! private String name; ! private Address address; ! private Set<Order> orders = new HashSet<Order>(); ! // No-arg constructor ! public Customer() { ! } ! @Id ! public Long getId() { entity Customer { ! ! return id; ! } ! property name : String ! public void setId(Long id) { ! property address : Address ! ! this.id = id; ! } ! property orders : Order[] ! public String getName() { ! ! return name; } ! } ! public void setName(String name) { ! ! this.name = name; ! } ! public Address getAddress() { ! ! return address; ! } ! public void setAddress(Address address) { ! ! this.address = address; ! } ! @OneToMany ! public Collection<Order> getOrders() { ! ! return orders; ! } ! public void setOrders(Set<Order> orders) { ! ! this.orders = orders; ! } }
  • 23. DEMO
  • 24. ar Model m m ra G Generator Fragments Generator Runtime Superclass Subclass Class LL(*) Parser ecore meta model editor
  • 25. Composable Code Generator ! generator is composed of “fragments” ! fragments can contribute to: ! Manifest.MF ! plugin.xml ! Guice modules ! Add your own fragments
  • 26. ar Model m m ra G Generator Runtime Google Guice Superclass Subclass Class LL(*) Parser ecore meta model editor
  • 28. MyCustomLabelProvider licensed by http://www.wordle.net/
  • 29. Dependency Injection with Googlee !No dependency to concrete implementation !No explicit construction !Easy testing !Easy composition
  • 30. Configuration of Components in Xtext /** * used to register components to be used within the IDE. */ public class DomainmodelUiModule ! ! extends GeneratedDomainmodelUiModule { ! ! @Override ! public Class<? extends ILabelProvider> bindILabelProvider() { ! ! return MySpecialLabelProvider.class; ! } }
  • 31. DEMO
  • 33. Integration with EMF eclipse Any EMF-based modeling Code Generator GMF Editor P R O J E C T Component <<abstract>> XMI XMIResource Resource XtextResource Text Parser Linker Serializer ValueConverter ScopeProvider Formatter
  • 34. Working with Xtext // initialization and setup (only needed in standalone mode) new EntityStandaloneSetup().createInjectorAndDoEMFRegistration(); // standard EMF API usage ResourceSet resourceSet = new ResourceSet(); Resource resource = resourceSet.getResource(uriToModelFile, true); Model model = (Model) resource.getContents().get(0); // print the name of all types to the console for (Type type : model.getElements()) { System.out.println(type.getName()); }
  • 35. Eclipse Helios •Model Index • Grammar Mixins • Base Language • UI Features
  • 36.