Xtext at Eclipse DemoCamp London in June 2009

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

2 comments

Comments 1 - 2 of 2 previous next Post a comment

Post a comment
Embed Video
Edit your comment Cancel

1 Favorite & 1 Group

Xtext at Eclipse DemoCamp London in June 2009 - Presentation Transcript

  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.
  3. Rd2-c2
  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. 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
  7. "ishop at c8 captures knight at h3 " c8 x h3
  8. 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
  9. 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';
  10. ik at Modell m m ra G Superclass Subclass Class LL(*) Parser ecore meta model editor Xtext framework (customizable with Google Guice)
  11. 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
  12. 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); ! }
  13. Entities (2/2) entity CustomerInfo ! (id=CUST_ID, sequenceName=CUST_SEQ) { ! ! String emailAddress (notNull, length = 128) ! }
  14. DSLs in real world scenarios modeling data describe architectures configuration business rules documentation data mappings navigation on object graphs constraints knitting patterns ...
  15. Demo ! Graphical EMF model ! Enhanced with textual DSL (with Xtext) ! Validation ! Code Generation ! Changes textual DSL
  16. Language development has never been so easy.
  17. amoun% &nit' (am) ingredient' *rocedur)
  18. 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
  19. Where to go next? www.xtext.org twitter: Xtext xtext.itemis.com twitter: itemis me www.1160pm.net Heiko Behrens twitter: HBehrens

+ Heiko BehrensHeiko Behrens, 4 months ago

custom

967 views, 1 favs, 1 embeds more stats

Introduction to Xtext via chess notation, some real more

More info about this document

© All Rights Reserved

Go to text version

  • Total Views 967
    • 965 on SlideShare
    • 2 from embeds
  • Comments 2
  • Favorites 1
  • Downloads 24
Most viewed embeds
  • 2 views on file://

more

All embeds
  • 2 views on file://

less

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

Cancel
File a copyright complaint
Having problems? Go to our helpdesk?

Categories

Groups / Events