SlideShare une entreprise Scribd logo
1  sur  21
Télécharger pour lire hors ligne
developing domain specific languages


          Heiko Behrens
          Eclipse DemoCamp 2009
          London 29.07.2009


          E-Mail   Heiko.Behrens@itemis.de
          Blog     www.1160pm.net
Xtext?
   Xtext is a framework for development of
             external textual DSLs.

       A domain specific language (DSL)
            in the context of modeling
        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
Grammar (similar to EBNF)
 Game:
 !   "White:" whitePlayer=STRING
 !   "Black:" blackPlayer=STRING
 !   (moves+=Move)+;
 !

 Move:
 !   AlgebraicMove | SpokenMove;

 AlgebraicMove:
 !   (piece=Piece)? source=Square (captures?='x'|'-') dest=Square;
 !

 SpokenMove:
 !   piece=Piece 'at' source=Square
 !   (captures?='captures' capturedPiece=Piece 'at' | 'moves to')
 !   dest=Square;
 !

 terminal Square:
 !   ('a'..'h')('1'..'8');
 !

 enum Piece:
 !   pawn    =   'P'   |   pawn     =   'pawn'     |
 !   knight =    'N'   |   knight   =   'knight'   |
 !   bishop =    'B'   |   bishop   =   'bishop'   |
 !   rook    =   'R'   |   rook     =   'rook'     |
 !   queen =     'Q'   |   queen    =   'queen'    |
 !   king    =   'K'   |   king     =   'king';
ik
                                         at
Modell




                                       m
                                     m
                                ra
                               G

                          Superclass




                          Subclass              Class




 LL(*) Parser          ecore meta model                 editor
         Xtext framework (customizable with Google Guice)
Demo
• Model          File
• Xtext       Grammar for writing simple chess games
• Derived           meta model
• Java        program that works with textual models
• Xpand-based                    generator




© itemis AG 2009 – All rights reserved                 10
Entities (1/2)
@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);
!   }
Entities (2/2)


entity CustomerInfo
! (id=CUST_ID, sequenceName=CUST_SEQ) {
!
! String emailAddress (notNull, length = 128)
!
}
DSLs in real world scenarios
             modeling data
        describe architectures
              configuration
             business rules
             documentation
             data mappings
      navigation on object graphs
               constraints
            knitting patterns
                    ...
Demo
! Graphical EMF model
! Enhanced with textual DSL (with Xtext)
! Validation
! Code Generation
! Changes textual DSL
Language development has never been so easy.
amoun%
     &nit' (am)
               ingredient'



                *rocedur)
Demo
 recipe:
 "pizza without yeast"

 ingredients:
 125g curd
 1     egg
 20ml oil
 40ml milk
 5g    salt
 250g flour
 1x ! soda

 procedure:
 "Combine all ingredients. Make it a ball.
 Knead 10 times. Put dough on a greased cookie sheet
 and roll."




© itemis AG 2009 – All rights reserved                 17
Where to go next?
                www.xtext.org
                twitter: Xtext



                xtext.itemis.com
                twitter: itemis



    me          www.1160pm.net
Heiko Behrens   twitter: HBehrens

Contenu connexe

En vedette (8)

MDSD on iPhone - EclipseCon 2010
MDSD on iPhone - EclipseCon 2010MDSD on iPhone - EclipseCon 2010
MDSD on iPhone - EclipseCon 2010
 
Physics Holi
Physics HoliPhysics Holi
Physics Holi
 
Tableau report sample
Tableau report sampleTableau report sample
Tableau report sample
 
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with EclipseEclipseCon2011 Cross-Platform Mobile Development with Eclipse
EclipseCon2011 Cross-Platform Mobile Development with Eclipse
 
Virtual Community
Virtual CommunityVirtual Community
Virtual Community
 
Usnco1999 2007
Usnco1999 2007Usnco1999 2007
Usnco1999 2007
 
Powder Metallurgy
Powder MetallurgyPowder Metallurgy
Powder Metallurgy
 
Basics Of Automobile
Basics Of AutomobileBasics Of Automobile
Basics Of Automobile
 

Similaire à Xtext at Eclipse DemoCamp London in June 2009

how to hack with pack and unpack
how to hack with pack and unpackhow to hack with pack and unpack
how to hack with pack and unpack
David Lowe
 
Jsonsaga 100605143125-phpapp02
Jsonsaga 100605143125-phpapp02Jsonsaga 100605143125-phpapp02
Jsonsaga 100605143125-phpapp02
Ramamohan Chokkam
 
Adventures In Data Compilation
Adventures In Data CompilationAdventures In Data Compilation
Adventures In Data Compilation
Naughty Dog
 

Similaire à Xtext at Eclipse DemoCamp London in June 2009 (20)

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
 
Xtext Webinar
Xtext WebinarXtext Webinar
Xtext Webinar
 
Xtext Webinar
Xtext WebinarXtext Webinar
Xtext Webinar
 
iOS Visual F/X Using GLSL
iOS Visual F/X Using GLSLiOS Visual F/X Using GLSL
iOS Visual F/X Using GLSL
 
SVGo: a Go Library for SVG generation
SVGo: a Go Library for SVG generationSVGo: a Go Library for SVG generation
SVGo: a Go Library for SVG generation
 
DotNetNuke World CSS3
DotNetNuke World CSS3DotNetNuke World CSS3
DotNetNuke World CSS3
 
ES6 is Nigh
ES6 is NighES6 is Nigh
ES6 is Nigh
 
how to hack with pack and unpack
how to hack with pack and unpackhow to hack with pack and unpack
how to hack with pack and unpack
 
SVGo workshop
SVGo workshopSVGo workshop
SVGo workshop
 
In The Land Of Graphs...
In The Land Of Graphs...In The Land Of Graphs...
In The Land Of Graphs...
 
Compass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS DeveloperCompass, Sass, and the Enlightened CSS Developer
Compass, Sass, and the Enlightened CSS Developer
 
CSS3 Transforms Transitions and Animations
CSS3 Transforms Transitions and AnimationsCSS3 Transforms Transitions and Animations
CSS3 Transforms Transitions and Animations
 
Jsonsaga 100605143125-phpapp02
Jsonsaga 100605143125-phpapp02Jsonsaga 100605143125-phpapp02
Jsonsaga 100605143125-phpapp02
 
Adventures In Data Compilation
Adventures In Data CompilationAdventures In Data Compilation
Adventures In Data Compilation
 
Malli: inside data-driven schemas
Malli: inside data-driven schemasMalli: inside data-driven schemas
Malli: inside data-driven schemas
 
Elixir - GDG - Nantes
Elixir - GDG - NantesElixir - GDG - Nantes
Elixir - GDG - Nantes
 
Canvas
CanvasCanvas
Canvas
 
FreeBSD 2014 Flame Graphs
FreeBSD 2014 Flame GraphsFreeBSD 2014 Flame Graphs
FreeBSD 2014 Flame Graphs
 
HTML5, CSS3, and other fancy buzzwords
HTML5, CSS3, and other fancy buzzwordsHTML5, CSS3, and other fancy buzzwords
HTML5, CSS3, and other fancy buzzwords
 
Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...
Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...
Stefan Kanev: Clojure, ClojureScript and Why They're Awesome at I T.A.K.E. Un...
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Dernier (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
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
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 

Xtext at Eclipse DemoCamp London in June 2009

  • 1. developing domain specific languages Heiko Behrens Eclipse DemoCamp 2009 London 29.07.2009 E-Mail Heiko.Behrens@itemis.de Blog www.1160pm.net
  • 2. Xtext? Xtext is a framework for development of external textual DSLs. A domain specific language (DSL) in the context of modeling 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.
  • 4. “ Queen to c7. Check.” “ Rd2-c2 , ” rook at d2 moves to c2.
  • 5. 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
  • 6.
  • 7. 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
  • 8. "ishop at c8 captures knight at h3 " c8 x h3
  • 9. 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
  • 10. Grammar (similar to EBNF) Game: ! "White:" whitePlayer=STRING ! "Black:" blackPlayer=STRING ! (moves+=Move)+; ! Move: ! AlgebraicMove | SpokenMove; AlgebraicMove: ! (piece=Piece)? source=Square (captures?='x'|'-') dest=Square; ! SpokenMove: ! piece=Piece 'at' source=Square ! (captures?='captures' capturedPiece=Piece 'at' | 'moves to') ! dest=Square; ! terminal Square: ! ('a'..'h')('1'..'8'); ! enum Piece: ! pawn = 'P' | pawn = 'pawn' | ! knight = 'N' | knight = 'knight' | ! bishop = 'B' | bishop = 'bishop' | ! rook = 'R' | rook = 'rook' | ! queen = 'Q' | queen = 'queen' | ! king = 'K' | king = 'king';
  • 11. ik at Modell m m ra G Superclass Subclass Class LL(*) Parser ecore meta model editor Xtext framework (customizable with Google Guice)
  • 12. Demo • Model File • Xtext Grammar for writing simple chess games • Derived meta model • Java program that works with textual models • Xpand-based generator © itemis AG 2009 – All rights reserved 10
  • 13. Entities (1/2) @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); ! }
  • 14. Entities (2/2) entity CustomerInfo ! (id=CUST_ID, sequenceName=CUST_SEQ) { ! ! String emailAddress (notNull, length = 128) ! }
  • 15. DSLs in real world scenarios modeling data describe architectures configuration business rules documentation data mappings navigation on object graphs constraints knitting patterns ...
  • 16. Demo ! Graphical EMF model ! Enhanced with textual DSL (with Xtext) ! Validation ! Code Generation ! Changes textual DSL
  • 17. Language development has never been so easy.
  • 18. amoun% &nit' (am) ingredient' *rocedur)
  • 19. Demo recipe: "pizza without yeast" ingredients: 125g curd 1 egg 20ml oil 40ml milk 5g salt 250g flour 1x ! soda procedure: "Combine all ingredients. Make it a ball. Knead 10 times. Put dough on a greased cookie sheet and roll." © itemis AG 2009 – All rights reserved 17
  • 20.
  • 21. Where to go next? www.xtext.org twitter: Xtext xtext.itemis.com twitter: itemis me www.1160pm.net Heiko Behrens twitter: HBehrens