SlideShare ist ein Scribd-Unternehmen logo
1 von 26
L0081 - 2010-11-08
Redistribution and other use of this material requires written permission from The RCP Company.
ITU - MDD – XText
This presentation describes the use of XText.
This presentation assumes a good knowledge of Data Modeling and Grammars
as previously presented.
This presentation is developed for MDD 2010 course at ITU, Denmark.
L0081 - 2010-11-08
2
 Parse trees are very detailed:
 every step in a derivation is a node
 After the parsing phase is done, the details of derivation are not needed for later
phases
 Semantic Analyzer removes intermediate productions to create an (abstract)
syntax tree – known as an AST
expr
term
factor
ID: x
expr
ID: x
Parse Tree: Abstract Syntax Tree:
Abstract Syntax Trees
L0080 - 2010-11-08
3
Parsing an Expression assignment => ID “=“ expression;
expression => expression “+” term
| expression “-” term
| term
term => term “*” factor
| term “/” factor
| factor
factor => “(“ expression “)”
| ID
| NUMBER
ID ~ y expresssion ~ (2*x + 5)*x - 7
expression ~ (2*x + 5)*x term ~ 7
assignment ~ y = (2*x + 5)*x - 7
factor ~ 7term ~ (2*x + 5)*x
NUMBER ~ 7term ~ (2*x + 5) factor ~ x
ID ~ xfactor ~ (2*x + 5)
expression ~ 2*x + 5
expression ~ 2*x term ~ 5
factor ~ 5term ~ 2*x
NUMBER ~ 5factor ~ xterm ~ 2
ID ~ x
factor ~ 2
NUMBER ~ 2
L0081 - 2010-11-08
4
Building a AST
assignment => ID “=“ expression;
expression => expression “+” term
| expression “-” term
| term
term => term “*” factor
| term “/” factor
| factor
factor => “(“ expression “)”
| ID
| NUMBER
ID ~ y expresssion ~ (2*x + 5)*x - 7
expression ~ (2*x + 5)*x term ~ 7
assignment ~ y = (2*x + 5)*x - 7
factor ~ 7term ~ (2*x + 5)*x
NUMBER ~ 7term ~ (2*x + 5) factor ~ x
ID ~ xfactor ~ (2*x + 5)
expression ~ 2*x + 5
expression ~ 2*x term ~ 5
factor ~ 5term ~ 2*x
NUMBER ~ 5factor ~ xterm ~ 2
ID ~ x
factor ~ 2
NUMBER ~ 2
Assignment(y)
Expression(-)
Expression(*)
NUMBER(7)
Expression(+)
Expression(*)
NUMBER(2)
NUMBER
ID(x)
ID(x)
L0081 - 2010-11-08
5
Level of Details
 How detailed should a grammar be?
 Should the grammar be rich – i.e. contain all details?
 Or should the grammar be as thin as possible?
 In general use a thin grammar to avoid too many keywords
 For XText, use a rich grammar as this is used to provide context assist
 Other similar questions:
 Should you model dates?
 How about ranges?
Flight : 'flight' ID '{' ( ('from'|'to') '=' STRING ';' )* '}'
Flight : 'flight' ID '{' ( ID '=' STRING ';' )* '}'
L0081 - 2010-11-08
6
Line feed or Explicit Terminators
 Should you have an explicit “statement” terminator or use line feeds?
 Statement Terminator such as “;” or “.”
 Pro: much easier to detect errors in the input
 Con: normally not natural for the user
 Statement Terminator such as line feed
 Pro: much easier to detect errors in the input
 Con: cannot divide a logical line over multiple physical lines
 No Statement Terminators
 Pro: very natural for many users
 Con: difficult to detect errors in the input
 In general use a statement terminator – not a statement separator!
 In our scenario, it properly makes good sense to use line feeds
 And indentions for scoping
L0081 - 2010-11-08
7
What is XText exactly
 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.
 The Basic Idea?
 Augment an EBNF grammar
 Roll it through XText
 Have an Eclipse Editor
 The XText tool bench
 Grammar is defined in an EBNF-like format in the Xtext editor.
 The editor provides code completion and constraint checking for the
grammars themselves
 Grammar is a collection of Rules. Rules start with their name followed by “:”
and ending with “;”
L0081 - 2010-11-08
8
Getting Started with XText
 Create a new XText project with the New… wizard
L0081 - 2010-11-08
9
The XText File Structure
 Three projects!
 You can make changes to the files in the src files,
but not the files in the src-gen folders
Your grammar rules
Workflow description
used to create editor
Generated ECore model
Generated ECore
classes
L0081 - 2010-11-08
10
An XText Model File (.xtext)
 Identify of model
 Include of base declarations and terminals
 Directive to create model
 NS URI of model
 It is also possible to import an existing model
grammar org.xtext.example.MyDsl with org.eclipse.xtext.common.Terminals
generate myDsl "http://www.xtext.org/example/MyDsl"
Model :
Type*;
…
L0081 - 2010-11-08
11
Generating Files from a Model
 To generate an Eclipse editor from a a model (.xtext)
 Select the workflow file (.mwe2)
 Use “Run As…”  “MWE2 WorkFlow”
L0081 - 2010-11-08
12
The Basic XText Concepts
 The AST is a ECore model
 The rules of the input grammar are used to create the AST (more or less
automatically) or interface to an existing imported model (=AST)
 So we must identify
 The entities of the model
 The attributes of the model
 The relations – containment and references – of the model
 The input language of XText is a augmented EBNF (almost )
L0081 - 2010-11-08
13
Example
 Grammar for a (very) simple type system
Model : Type*;
Type: SimpleType | Entity;
SimpleType: ‘datatype' ID;
Entity : 'entity' ID ('extends' ID)? '{'
Property*
'}';
Property: 'property' ID ':' ID ('[]')?;
datatype A
datatype B
entity E {
property a : A
property b : B[]
}
entity F extends E {
property c : A
}
Model
Type
SimpleType Entity
Property
*
*
Super-type
L0081 - 2010-11-08
14
 XText rules are EBNF plus type information
 Type Rules
 For each rule XText creates an entity in the logical model
 Each rule property results in a property in the logical model
 String Rules
 String rules are parsed to be a string
 These are in effect custom lexer rules as they recognize string patterns
 Enum Rules
 Limited set of alternatives
 Mapped to an enumeration in the logical model
 Native Rules
 A lexer rule that is mapped directly to an ANTLR rule
 Mapped to a String
Different Kinds of XText Rules
L0081 - 2010-11-08
15
 Class of type rule defaults to name of rule 
 Can be overruled via “{ClassName}” construct
 A type rule can be abstract
 An abstract type rule is basically a collection of OR-ed alternatives: R1 | R2 |
R3
 Mapped to an abstract metaclass

The or-ed alternatives become concrete subclasses

Common properties of the alternatives are lifted into the abstract
superclass
Abstract Type Rules
Model : Type*;
Type: SimpleType | Entity;
SimpleType: ‘datatype' ID;
Entity : 'entity' ID ('extends' ID)? '{'
Property*
'}';
Property: 'property' ID ':' ID ('[]')?;
L0081 - 2010-11-08
16
Example with Type Rules
 Every rule corresponds to en entity
 “Or” rules becomes abstract classes with the entities of the sub-rules as child
classes
 Above we have Type as an abstract super class for SimpleType and Entity
Model : Type*;
Type: SimpleType | Entity;
SimpleType: 'type' ID;
Entity : 'entity' ID ('extends' ID)? '{'
Property*
'}';
Property: 'property' ID ':' ID ('[]')?;
L0081 - 2010-11-08
17
Some built-in String Rules (Terminals)
 The definition of the central terminals
 Really part of lexical analysis!
 Specific terminals can be “hidden” in the grammar or for specific rules, meaning
they are recognized but ignored during parsing…
 Very useful if you want a line-oriented grammar
terminal ID : '^'?('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*;
terminal INT returns ecore::EInt: ('0'..'9')+;
terminal STRING:
'"' ( '' ('b'|'t'|'n'|'f'|'r'|'"'|"'"|'') | !(''|'"') )* '"' |
"'" ( '' ('b'|'t'|'n'|'f'|'r'|'"'|"'"|'') | !(''|"'") )* "'"
;
terminal ML_COMMENT: '/*' -> '*/';
terminal SL_COMMENT : '//' !('n'|'r')* ('r'? 'n')?;
terminal WS : (' '|'t'|'r'|'n')+;
L0081 - 2010-11-08
18
 A type rule has a rule composition – made of a number of elements
 It may contain keywords (using string literal syntax)
 It also contains properties which will result in properties of the type class

The property type is derived from the called rule
 There are different kinds
of properties

= (single assign)

+= (multiple assign/add)

?= (boolean assign)
 There are different property
cardinalities
 ? (0..1)
 * (0..n)
 + (1..n)
 nothing (1..1)
Properties (Attributes and Relations) in Type Rules
Entity :
'entity' name=ID ('extends' extends=ID)? '{'
properties+=Property*
'}';
Property:
'property' name=ID ':' type=ID (many?='[]')?;
Results in containment relation
“List<Property> properties”
Results in simple attribute
“String: name”
L0081 - 2010-11-08
19
Example of Properties
 Simple property:
 name of SimpleType
 “Many” reference – containment
 elements of Model
 properties of Entity
 Boolean property
 many of Property
Model :
(elements+=Type)*;
Type:
SimpleType | Entity;
SimpleType:
'type' name=ID;
Entity :
'entity' name=ID ('extends' extends=ID)? '{'
properties+=Property*
'}';
Property:
'property' name=ID ':' type=ID (many?='[]')?;
L0081 - 2010-11-08
20
 By default, rules results in a logical model with a tree of entities via containment
 You can reference other elements via a reference rule
 In textual languages a reference has to be by name
 During linking, Xtext “dereferences” these by name-references
 Why References?
 Used in the logical model for references
 XText also uses references for context assist
Reference Relations
Entity :
'entity' name=ID ('extends' extends=[Entity])? '{'
properties+=Property*
'}';
Results in containment relation
“List<Property> properties”
Results in reference relation
“Entity extends”
L0081 - 2010-11-08
21
Example of References
 extends of Entity
 type of Property
Model :
(elements+=Type)*;
Type:
SimpleType | Entity;
SimpleType:
'type' name=ID;
Entity :
'entity' name=ID ('extends' extends=[Entity])? '{'
properties+=Property*
'}';
Property:
'property' name=ID ':' type=[Type] (many?='[]')?;
L0081 - 2010-11-08
22
 A Enum Rule is used to define a limited set of defined alternatives
 It is mapped to an enumeration in the logical model
 It is declared via the Enum keyword and contains Enum Literals
 An Enum Literal has a token name and a string representation
 It can be used just like any other rule
 Properties will get the enumeration type
Enumeration Rules
enum Color:
RED=“red” | GREEN=“green” | BLUE=“blue” ;
Shape: name=ID ( ‘color’ color=Color)? … ;
L0081 - 2010-11-08
23
 A native rule contains a string which is passed to ANTLR without further
processing it.
 It is typically used to define lexer rules that cannot be expressed using Xtext
syntax
 E.g. whitespace-aware lexer rules, such as define custom comment syntax
Native Rules
L0081 - 2010-11-08
24
Importing an Existing Model
 To import an model instead of generating it..
 Simple change to the xtext grammar file:
 Depending on the starting point a simple change to the MWE2 file:
 Not so with the generated MWE2 file 
 Easier to start with the wizard “XText Project from existing ECore Models”
grammar com.rcpcompany.mdd2010.DSL with org.eclipse.xtext.common.Terminals
import "platform:/resource/com.rcpcompany.mdd2010.model/model/Travel.ecore"
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
…
fragment = org.eclipse.xtext.generator.ecore.EcoreGeneratorFragment {
genModels =
"platform:/resource/com.rcpcompany.mdd2010.model/model/Travel.genmodel"
}
L0081 - 2010-11-08
25
More Information
XText and friends
 “Build your own textual DSL with Tools from the Eclipse Modeling Project”
 http://www.eclipse.org/articles/article.php?file=Article-BuildYourOwnDSL/index.html

Older, slightly out-dated, article on how to create your first XText project
 Documentation for XText
 http://www.eclipse.org/Xtext/documentation/
L0081 - 2010-11-08
26
Exercise 1
 Make sure you grammar is on proper EBNF form
 Do you think you can make an interesting editor from the grammar?
 Create an XText project if not already done
 Convert your EBNF grammar into an XText model
 What can you do to your grammar to make it more suitable for XText

Weitere ähnliche Inhalte

Was ist angesagt?

CLASS OBJECT AND INHERITANCE IN PYTHON
CLASS OBJECT AND INHERITANCE IN PYTHONCLASS OBJECT AND INHERITANCE IN PYTHON
CLASS OBJECT AND INHERITANCE IN PYTHONLalitkumar_98
 
Learn Concept of Class and Object in C# Part 3
Learn Concept of Class and Object in C#  Part 3Learn Concept of Class and Object in C#  Part 3
Learn Concept of Class and Object in C# Part 3C# Learning Classes
 
Pi j2.3 objects
Pi j2.3 objectsPi j2.3 objects
Pi j2.3 objectsmcollison
 
Variables in python
Variables in pythonVariables in python
Variables in pythonJaya Kumari
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteTushar B Kute
 
class and objects
class and objectsclass and objects
class and objectsPayel Guria
 
Lecture 8 abstract class and interface
Lecture   8 abstract class and interfaceLecture   8 abstract class and interface
Lecture 8 abstract class and interfacemanish kumar
 
Chapter 8 - Exceptions and Assertions Edit summary
Chapter 8 - Exceptions and Assertions  Edit summaryChapter 8 - Exceptions and Assertions  Edit summary
Chapter 8 - Exceptions and Assertions Edit summaryEduardo Bergavera
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).pptAlok Kumar
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with JavaJussi Pohjolainen
 
Classes in c++ (OOP Presentation)
Classes in c++ (OOP Presentation)Classes in c++ (OOP Presentation)
Classes in c++ (OOP Presentation)Majid Saeed
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVAAbhilash Nair
 
Implementation of oop concept in c++
Implementation of oop concept in c++Implementation of oop concept in c++
Implementation of oop concept in c++Swarup Kumar Boro
 
C++ Object oriented concepts & programming
C++ Object oriented concepts & programmingC++ Object oriented concepts & programming
C++ Object oriented concepts & programmingnirajmandaliya
 
Programming in c++
Programming in c++Programming in c++
Programming in c++Baljit Saini
 
Abstract data types
Abstract data typesAbstract data types
Abstract data typesHoang Nguyen
 

Was ist angesagt? (20)

CLASS OBJECT AND INHERITANCE IN PYTHON
CLASS OBJECT AND INHERITANCE IN PYTHONCLASS OBJECT AND INHERITANCE IN PYTHON
CLASS OBJECT AND INHERITANCE IN PYTHON
 
Learn Concept of Class and Object in C# Part 3
Learn Concept of Class and Object in C#  Part 3Learn Concept of Class and Object in C#  Part 3
Learn Concept of Class and Object in C# Part 3
 
Pi j2.3 objects
Pi j2.3 objectsPi j2.3 objects
Pi j2.3 objects
 
Variables in python
Variables in pythonVariables in python
Variables in python
 
Oops in java
Oops in javaOops in java
Oops in java
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
 
class and objects
class and objectsclass and objects
class and objects
 
Lecture 8 abstract class and interface
Lecture   8 abstract class and interfaceLecture   8 abstract class and interface
Lecture 8 abstract class and interface
 
Oops
OopsOops
Oops
 
Chapter 8 - Exceptions and Assertions Edit summary
Chapter 8 - Exceptions and Assertions  Edit summaryChapter 8 - Exceptions and Assertions  Edit summary
Chapter 8 - Exceptions and Assertions Edit summary
 
Chapter 05 classes and objects
Chapter 05 classes and objectsChapter 05 classes and objects
Chapter 05 classes and objects
 
Oop c++class(final).ppt
Oop c++class(final).pptOop c++class(final).ppt
Oop c++class(final).ppt
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Classes in c++ (OOP Presentation)
Classes in c++ (OOP Presentation)Classes in c++ (OOP Presentation)
Classes in c++ (OOP Presentation)
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Implementation of oop concept in c++
Implementation of oop concept in c++Implementation of oop concept in c++
Implementation of oop concept in c++
 
C++ Object oriented concepts & programming
C++ Object oriented concepts & programmingC++ Object oriented concepts & programming
C++ Object oriented concepts & programming
 
Programming in c++
Programming in c++Programming in c++
Programming in c++
 
Structures in c++
Structures in c++Structures in c++
Structures in c++
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 

Andere mochten auch

Presentatie 3 A Communicatie
Presentatie 3 A CommunicatiePresentatie 3 A Communicatie
Presentatie 3 A CommunicatieMarketing Penguin
 
The association between gut microbiota and body weight
The association between gut microbiota and body weightThe association between gut microbiota and body weight
The association between gut microbiota and body weightAshwath Venkatasubramanian
 
Màrqueting Mix. Preu i distribució
Màrqueting Mix. Preu i distribucióMàrqueting Mix. Preu i distribució
Màrqueting Mix. Preu i distribucióIMET Club Emprendre
 
Labor Heidrich Zeugnis English Translation
Labor Heidrich Zeugnis English TranslationLabor Heidrich Zeugnis English Translation
Labor Heidrich Zeugnis English TranslationFriedrich Griessel
 
Encuentro1 Actividad 1
Encuentro1 Actividad 1Encuentro1 Actividad 1
Encuentro1 Actividad 1Trini Bora
 
Halloween Horror Show
Halloween Horror ShowHalloween Horror Show
Halloween Horror ShowLeo Zalki
 
Pilot selection anthropometry a comparison with measures taken by a single a...
Pilot selection anthropometry  a comparison with measures taken by a single a...Pilot selection anthropometry  a comparison with measures taken by a single a...
Pilot selection anthropometry a comparison with measures taken by a single a...Leishman Associates
 
Surgical workload at the role 3 multinational medical unit, kandahar airfield...
Surgical workload at the role 3 multinational medical unit, kandahar airfield...Surgical workload at the role 3 multinational medical unit, kandahar airfield...
Surgical workload at the role 3 multinational medical unit, kandahar airfield...Leishman Associates
 
Web User Experience in 2021
Web User Experience in 2021Web User Experience in 2021
Web User Experience in 2021Drew Gorton
 
სხვიტორი-სავანე
სხვიტორი-სავანესხვიტორი-სავანე
სხვიტორი-სავანეlazana
 
Guy Danon Beyond 2010
Guy Danon Beyond 2010Guy Danon Beyond 2010
Guy Danon Beyond 2010eventwithme
 
Darbo kodeksas
Darbo kodeksasDarbo kodeksas
Darbo kodeksasgintarine
 
TeliaSonera
TeliaSoneraTeliaSonera
TeliaSoneraFarhad
 
Presentatie Nationaal Alumni Congres 04112010
Presentatie Nationaal Alumni Congres  04112010Presentatie Nationaal Alumni Congres  04112010
Presentatie Nationaal Alumni Congres 04112010Lode Broekman
 

Andere mochten auch (19)

OCL tutorial
OCL tutorial OCL tutorial
OCL tutorial
 
Presentatie 3 A Communicatie
Presentatie 3 A CommunicatiePresentatie 3 A Communicatie
Presentatie 3 A Communicatie
 
The association between gut microbiota and body weight
The association between gut microbiota and body weightThe association between gut microbiota and body weight
The association between gut microbiota and body weight
 
Màrqueting Mix. Preu i distribució
Màrqueting Mix. Preu i distribucióMàrqueting Mix. Preu i distribució
Màrqueting Mix. Preu i distribució
 
Labor Heidrich Zeugnis English Translation
Labor Heidrich Zeugnis English TranslationLabor Heidrich Zeugnis English Translation
Labor Heidrich Zeugnis English Translation
 
Encuentro1 Actividad 1
Encuentro1 Actividad 1Encuentro1 Actividad 1
Encuentro1 Actividad 1
 
Halloween Horror Show
Halloween Horror ShowHalloween Horror Show
Halloween Horror Show
 
Pilot selection anthropometry a comparison with measures taken by a single a...
Pilot selection anthropometry  a comparison with measures taken by a single a...Pilot selection anthropometry  a comparison with measures taken by a single a...
Pilot selection anthropometry a comparison with measures taken by a single a...
 
Surgical workload at the role 3 multinational medical unit, kandahar airfield...
Surgical workload at the role 3 multinational medical unit, kandahar airfield...Surgical workload at the role 3 multinational medical unit, kandahar airfield...
Surgical workload at the role 3 multinational medical unit, kandahar airfield...
 
Web User Experience in 2021
Web User Experience in 2021Web User Experience in 2021
Web User Experience in 2021
 
სხვიტორი-სავანე
სხვიტორი-სავანესხვიტორი-სავანე
სხვიტორი-სავანე
 
Guy Danon Beyond 2010
Guy Danon Beyond 2010Guy Danon Beyond 2010
Guy Danon Beyond 2010
 
Darbo kodeksas
Darbo kodeksasDarbo kodeksas
Darbo kodeksas
 
Irregular verbs
Irregular verbsIrregular verbs
Irregular verbs
 
TeliaSonera
TeliaSoneraTeliaSonera
TeliaSonera
 
Yuqi-Resume
Yuqi-ResumeYuqi-Resume
Yuqi-Resume
 
Presentatie Nationaal Alumni Congres 04112010
Presentatie Nationaal Alumni Congres  04112010Presentatie Nationaal Alumni Congres  04112010
Presentatie Nationaal Alumni Congres 04112010
 
Slidesnotes
SlidesnotesSlidesnotes
Slidesnotes
 
CartaTrabajoCancilléria
CartaTrabajoCancillériaCartaTrabajoCancilléria
CartaTrabajoCancilléria
 

Ähnlich wie ITU - MDD - XText

Domänenspezifische Sprachen mit Xtext
Domänenspezifische Sprachen mit XtextDomänenspezifische Sprachen mit Xtext
Domänenspezifische Sprachen mit XtextDr. Jan Köhnlein
 
Linq in C# 3.0: An Overview
Linq in C# 3.0: An OverviewLinq in C# 3.0: An Overview
Linq in C# 3.0: An Overviewpradeepkothiyal
 
Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Robert Pickering
 
An Annotation Framework for Statically-Typed Syntax Trees
An Annotation Framework for Statically-Typed Syntax TreesAn Annotation Framework for Statically-Typed Syntax Trees
An Annotation Framework for Statically-Typed Syntax TreesRay Toal
 
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptxStatic abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptxMarco Parenzan
 
Designing A Syntax Based Retrieval System03
Designing A Syntax Based Retrieval System03Designing A Syntax Based Retrieval System03
Designing A Syntax Based Retrieval System03Avelin Huo
 
Introduction To Csharp
Introduction To CsharpIntroduction To Csharp
Introduction To Csharpsarfarazali
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#singhadarsh
 
XPath - XML Path Language
XPath - XML Path LanguageXPath - XML Path Language
XPath - XML Path Languageyht4ever
 
A Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X TransformationA Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X TransformationCoen De Roover
 

Ähnlich wie ITU - MDD - XText (20)

Xml and Co.
Xml and Co.Xml and Co.
Xml and Co.
 
Xml session
Xml sessionXml session
Xml session
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Domänenspezifische Sprachen mit Xtext
Domänenspezifische Sprachen mit XtextDomänenspezifische Sprachen mit Xtext
Domänenspezifische Sprachen mit Xtext
 
Linq in C# 3.0: An Overview
Linq in C# 3.0: An OverviewLinq in C# 3.0: An Overview
Linq in C# 3.0: An Overview
 
Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#
 
Xml and DTD's
Xml and DTD'sXml and DTD's
Xml and DTD's
 
XPath Injection
XPath InjectionXPath Injection
XPath Injection
 
An Annotation Framework for Statically-Typed Syntax Trees
An Annotation Framework for Statically-Typed Syntax TreesAn Annotation Framework for Statically-Typed Syntax Trees
An Annotation Framework for Statically-Typed Syntax Trees
 
O9schema
O9schemaO9schema
O9schema
 
Schema
SchemaSchema
Schema
 
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptxStatic abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
Static abstract members nelle interfacce di C# 11 e dintorni di .NET 7.pptx
 
Designing A Syntax Based Retrieval System03
Designing A Syntax Based Retrieval System03Designing A Syntax Based Retrieval System03
Designing A Syntax Based Retrieval System03
 
Introduction To Csharp
Introduction To CsharpIntroduction To Csharp
Introduction To Csharp
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
XPath - XML Path Language
XPath - XML Path LanguageXPath - XML Path Language
XPath - XML Path Language
 
C# programming
C# programming C# programming
C# programming
 
A Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X TransformationA Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X Transformation
 
Grammarware Memes
Grammarware MemesGrammarware Memes
Grammarware Memes
 
Unit 5 xml (1)
Unit 5   xml (1)Unit 5   xml (1)
Unit 5 xml (1)
 

Mehr von Tonny Madsen

L0043 - Interfacing to Eclipse Standard Views
L0043 - Interfacing to Eclipse Standard ViewsL0043 - Interfacing to Eclipse Standard Views
L0043 - Interfacing to Eclipse Standard ViewsTonny Madsen
 
L0037 - Basic Eclipse Configuration
L0037 - Basic Eclipse ConfigurationL0037 - Basic Eclipse Configuration
L0037 - Basic Eclipse ConfigurationTonny Madsen
 
L0036 - Creating Views and Editors
L0036 - Creating Views and EditorsL0036 - Creating Views and Editors
L0036 - Creating Views and EditorsTonny Madsen
 
L0020 - The Basic RCP Application
L0020 - The Basic RCP ApplicationL0020 - The Basic RCP Application
L0020 - The Basic RCP ApplicationTonny Madsen
 
L0018 - SWT - The Standard Widget Toolkit
L0018 - SWT - The Standard Widget ToolkitL0018 - SWT - The Standard Widget Toolkit
L0018 - SWT - The Standard Widget ToolkitTonny Madsen
 
L0016 - The Structure of an Eclipse Plug-in
L0016 - The Structure of an Eclipse Plug-inL0016 - The Structure of an Eclipse Plug-in
L0016 - The Structure of an Eclipse Plug-inTonny Madsen
 
L0001 - The Terminology of the Eclipse Platform
L0001 - The Terminology of the Eclipse PlatformL0001 - The Terminology of the Eclipse Platform
L0001 - The Terminology of the Eclipse PlatformTonny Madsen
 
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...Tonny Madsen
 
PROSA - Eclipse Is Just What?
PROSA - Eclipse Is Just What?PROSA - Eclipse Is Just What?
PROSA - Eclipse Is Just What?Tonny Madsen
 
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the FutureEclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the FutureTonny Madsen
 
Eclipse Demo Camp 2010 - UI Bindings - An Introduction
Eclipse Demo Camp 2010 - UI Bindings - An IntroductionEclipse Demo Camp 2010 - UI Bindings - An Introduction
Eclipse Demo Camp 2010 - UI Bindings - An IntroductionTonny Madsen
 
ITU - MDD – Model-to-Model Transformations
ITU - MDD – Model-to-Model TransformationsITU - MDD – Model-to-Model Transformations
ITU - MDD – Model-to-Model TransformationsTonny Madsen
 
IDA - Eclipse Workshop II (In Danish)
IDA - Eclipse Workshop II (In Danish)IDA - Eclipse Workshop II (In Danish)
IDA - Eclipse Workshop II (In Danish)Tonny Madsen
 
IDA - Eclipse Workshop I (In Danish)
IDA - Eclipse Workshop I (In Danish)IDA - Eclipse Workshop I (In Danish)
IDA - Eclipse Workshop I (In Danish)Tonny Madsen
 
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...Tonny Madsen
 
ITU - MDD - Eclipse Plug-ins
ITU - MDD - Eclipse Plug-insITU - MDD - Eclipse Plug-ins
ITU - MDD - Eclipse Plug-insTonny Madsen
 
eclipse.dk - Eclipse RCP Under the Hood
eclipse.dk - Eclipse RCP Under the Hoodeclipse.dk - Eclipse RCP Under the Hood
eclipse.dk - Eclipse RCP Under the HoodTonny Madsen
 
EclipseCon '08 - BoF - Building a local Eclipse user group
EclipseCon '08 - BoF - Building a local Eclipse user groupEclipseCon '08 - BoF - Building a local Eclipse user group
EclipseCon '08 - BoF - Building a local Eclipse user groupTonny Madsen
 

Mehr von Tonny Madsen (20)

L0043 - Interfacing to Eclipse Standard Views
L0043 - Interfacing to Eclipse Standard ViewsL0043 - Interfacing to Eclipse Standard Views
L0043 - Interfacing to Eclipse Standard Views
 
L0037 - Basic Eclipse Configuration
L0037 - Basic Eclipse ConfigurationL0037 - Basic Eclipse Configuration
L0037 - Basic Eclipse Configuration
 
L0036 - Creating Views and Editors
L0036 - Creating Views and EditorsL0036 - Creating Views and Editors
L0036 - Creating Views and Editors
 
L0033 - JFace
L0033 - JFaceL0033 - JFace
L0033 - JFace
 
L0020 - The Basic RCP Application
L0020 - The Basic RCP ApplicationL0020 - The Basic RCP Application
L0020 - The Basic RCP Application
 
L0018 - SWT - The Standard Widget Toolkit
L0018 - SWT - The Standard Widget ToolkitL0018 - SWT - The Standard Widget Toolkit
L0018 - SWT - The Standard Widget Toolkit
 
L0016 - The Structure of an Eclipse Plug-in
L0016 - The Structure of an Eclipse Plug-inL0016 - The Structure of an Eclipse Plug-in
L0016 - The Structure of an Eclipse Plug-in
 
L0001 - The Terminology of the Eclipse Platform
L0001 - The Terminology of the Eclipse PlatformL0001 - The Terminology of the Eclipse Platform
L0001 - The Terminology of the Eclipse Platform
 
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
 
PROSA - Eclipse Is Just What?
PROSA - Eclipse Is Just What?PROSA - Eclipse Is Just What?
PROSA - Eclipse Is Just What?
 
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the FutureEclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
 
Eclipse Demo Camp 2010 - UI Bindings - An Introduction
Eclipse Demo Camp 2010 - UI Bindings - An IntroductionEclipse Demo Camp 2010 - UI Bindings - An Introduction
Eclipse Demo Camp 2010 - UI Bindings - An Introduction
 
ITU - MDD – Model-to-Model Transformations
ITU - MDD – Model-to-Model TransformationsITU - MDD – Model-to-Model Transformations
ITU - MDD – Model-to-Model Transformations
 
IDA - Eclipse Workshop II (In Danish)
IDA - Eclipse Workshop II (In Danish)IDA - Eclipse Workshop II (In Danish)
IDA - Eclipse Workshop II (In Danish)
 
IDA - Eclipse Workshop I (In Danish)
IDA - Eclipse Workshop I (In Danish)IDA - Eclipse Workshop I (In Danish)
IDA - Eclipse Workshop I (In Danish)
 
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
 
ITU - MDD - EMF
ITU - MDD - EMFITU - MDD - EMF
ITU - MDD - EMF
 
ITU - MDD - Eclipse Plug-ins
ITU - MDD - Eclipse Plug-insITU - MDD - Eclipse Plug-ins
ITU - MDD - Eclipse Plug-ins
 
eclipse.dk - Eclipse RCP Under the Hood
eclipse.dk - Eclipse RCP Under the Hoodeclipse.dk - Eclipse RCP Under the Hood
eclipse.dk - Eclipse RCP Under the Hood
 
EclipseCon '08 - BoF - Building a local Eclipse user group
EclipseCon '08 - BoF - Building a local Eclipse user groupEclipseCon '08 - BoF - Building a local Eclipse user group
EclipseCon '08 - BoF - Building a local Eclipse user group
 

Kürzlich hochgeladen

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 

Kürzlich hochgeladen (20)

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 

ITU - MDD - XText

  • 1. L0081 - 2010-11-08 Redistribution and other use of this material requires written permission from The RCP Company. ITU - MDD – XText This presentation describes the use of XText. This presentation assumes a good knowledge of Data Modeling and Grammars as previously presented. This presentation is developed for MDD 2010 course at ITU, Denmark.
  • 2. L0081 - 2010-11-08 2  Parse trees are very detailed:  every step in a derivation is a node  After the parsing phase is done, the details of derivation are not needed for later phases  Semantic Analyzer removes intermediate productions to create an (abstract) syntax tree – known as an AST expr term factor ID: x expr ID: x Parse Tree: Abstract Syntax Tree: Abstract Syntax Trees
  • 3. L0080 - 2010-11-08 3 Parsing an Expression assignment => ID “=“ expression; expression => expression “+” term | expression “-” term | term term => term “*” factor | term “/” factor | factor factor => “(“ expression “)” | ID | NUMBER ID ~ y expresssion ~ (2*x + 5)*x - 7 expression ~ (2*x + 5)*x term ~ 7 assignment ~ y = (2*x + 5)*x - 7 factor ~ 7term ~ (2*x + 5)*x NUMBER ~ 7term ~ (2*x + 5) factor ~ x ID ~ xfactor ~ (2*x + 5) expression ~ 2*x + 5 expression ~ 2*x term ~ 5 factor ~ 5term ~ 2*x NUMBER ~ 5factor ~ xterm ~ 2 ID ~ x factor ~ 2 NUMBER ~ 2
  • 4. L0081 - 2010-11-08 4 Building a AST assignment => ID “=“ expression; expression => expression “+” term | expression “-” term | term term => term “*” factor | term “/” factor | factor factor => “(“ expression “)” | ID | NUMBER ID ~ y expresssion ~ (2*x + 5)*x - 7 expression ~ (2*x + 5)*x term ~ 7 assignment ~ y = (2*x + 5)*x - 7 factor ~ 7term ~ (2*x + 5)*x NUMBER ~ 7term ~ (2*x + 5) factor ~ x ID ~ xfactor ~ (2*x + 5) expression ~ 2*x + 5 expression ~ 2*x term ~ 5 factor ~ 5term ~ 2*x NUMBER ~ 5factor ~ xterm ~ 2 ID ~ x factor ~ 2 NUMBER ~ 2 Assignment(y) Expression(-) Expression(*) NUMBER(7) Expression(+) Expression(*) NUMBER(2) NUMBER ID(x) ID(x)
  • 5. L0081 - 2010-11-08 5 Level of Details  How detailed should a grammar be?  Should the grammar be rich – i.e. contain all details?  Or should the grammar be as thin as possible?  In general use a thin grammar to avoid too many keywords  For XText, use a rich grammar as this is used to provide context assist  Other similar questions:  Should you model dates?  How about ranges? Flight : 'flight' ID '{' ( ('from'|'to') '=' STRING ';' )* '}' Flight : 'flight' ID '{' ( ID '=' STRING ';' )* '}'
  • 6. L0081 - 2010-11-08 6 Line feed or Explicit Terminators  Should you have an explicit “statement” terminator or use line feeds?  Statement Terminator such as “;” or “.”  Pro: much easier to detect errors in the input  Con: normally not natural for the user  Statement Terminator such as line feed  Pro: much easier to detect errors in the input  Con: cannot divide a logical line over multiple physical lines  No Statement Terminators  Pro: very natural for many users  Con: difficult to detect errors in the input  In general use a statement terminator – not a statement separator!  In our scenario, it properly makes good sense to use line feeds  And indentions for scoping
  • 7. L0081 - 2010-11-08 7 What is XText exactly  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.  The Basic Idea?  Augment an EBNF grammar  Roll it through XText  Have an Eclipse Editor  The XText tool bench  Grammar is defined in an EBNF-like format in the Xtext editor.  The editor provides code completion and constraint checking for the grammars themselves  Grammar is a collection of Rules. Rules start with their name followed by “:” and ending with “;”
  • 8. L0081 - 2010-11-08 8 Getting Started with XText  Create a new XText project with the New… wizard
  • 9. L0081 - 2010-11-08 9 The XText File Structure  Three projects!  You can make changes to the files in the src files, but not the files in the src-gen folders Your grammar rules Workflow description used to create editor Generated ECore model Generated ECore classes
  • 10. L0081 - 2010-11-08 10 An XText Model File (.xtext)  Identify of model  Include of base declarations and terminals  Directive to create model  NS URI of model  It is also possible to import an existing model grammar org.xtext.example.MyDsl with org.eclipse.xtext.common.Terminals generate myDsl "http://www.xtext.org/example/MyDsl" Model : Type*; …
  • 11. L0081 - 2010-11-08 11 Generating Files from a Model  To generate an Eclipse editor from a a model (.xtext)  Select the workflow file (.mwe2)  Use “Run As…”  “MWE2 WorkFlow”
  • 12. L0081 - 2010-11-08 12 The Basic XText Concepts  The AST is a ECore model  The rules of the input grammar are used to create the AST (more or less automatically) or interface to an existing imported model (=AST)  So we must identify  The entities of the model  The attributes of the model  The relations – containment and references – of the model  The input language of XText is a augmented EBNF (almost )
  • 13. L0081 - 2010-11-08 13 Example  Grammar for a (very) simple type system Model : Type*; Type: SimpleType | Entity; SimpleType: ‘datatype' ID; Entity : 'entity' ID ('extends' ID)? '{' Property* '}'; Property: 'property' ID ':' ID ('[]')?; datatype A datatype B entity E { property a : A property b : B[] } entity F extends E { property c : A } Model Type SimpleType Entity Property * * Super-type
  • 14. L0081 - 2010-11-08 14  XText rules are EBNF plus type information  Type Rules  For each rule XText creates an entity in the logical model  Each rule property results in a property in the logical model  String Rules  String rules are parsed to be a string  These are in effect custom lexer rules as they recognize string patterns  Enum Rules  Limited set of alternatives  Mapped to an enumeration in the logical model  Native Rules  A lexer rule that is mapped directly to an ANTLR rule  Mapped to a String Different Kinds of XText Rules
  • 15. L0081 - 2010-11-08 15  Class of type rule defaults to name of rule   Can be overruled via “{ClassName}” construct  A type rule can be abstract  An abstract type rule is basically a collection of OR-ed alternatives: R1 | R2 | R3  Mapped to an abstract metaclass  The or-ed alternatives become concrete subclasses  Common properties of the alternatives are lifted into the abstract superclass Abstract Type Rules Model : Type*; Type: SimpleType | Entity; SimpleType: ‘datatype' ID; Entity : 'entity' ID ('extends' ID)? '{' Property* '}'; Property: 'property' ID ':' ID ('[]')?;
  • 16. L0081 - 2010-11-08 16 Example with Type Rules  Every rule corresponds to en entity  “Or” rules becomes abstract classes with the entities of the sub-rules as child classes  Above we have Type as an abstract super class for SimpleType and Entity Model : Type*; Type: SimpleType | Entity; SimpleType: 'type' ID; Entity : 'entity' ID ('extends' ID)? '{' Property* '}'; Property: 'property' ID ':' ID ('[]')?;
  • 17. L0081 - 2010-11-08 17 Some built-in String Rules (Terminals)  The definition of the central terminals  Really part of lexical analysis!  Specific terminals can be “hidden” in the grammar or for specific rules, meaning they are recognized but ignored during parsing…  Very useful if you want a line-oriented grammar terminal ID : '^'?('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*; terminal INT returns ecore::EInt: ('0'..'9')+; terminal STRING: '"' ( '' ('b'|'t'|'n'|'f'|'r'|'"'|"'"|'') | !(''|'"') )* '"' | "'" ( '' ('b'|'t'|'n'|'f'|'r'|'"'|"'"|'') | !(''|"'") )* "'" ; terminal ML_COMMENT: '/*' -> '*/'; terminal SL_COMMENT : '//' !('n'|'r')* ('r'? 'n')?; terminal WS : (' '|'t'|'r'|'n')+;
  • 18. L0081 - 2010-11-08 18  A type rule has a rule composition – made of a number of elements  It may contain keywords (using string literal syntax)  It also contains properties which will result in properties of the type class  The property type is derived from the called rule  There are different kinds of properties  = (single assign)  += (multiple assign/add)  ?= (boolean assign)  There are different property cardinalities  ? (0..1)  * (0..n)  + (1..n)  nothing (1..1) Properties (Attributes and Relations) in Type Rules Entity : 'entity' name=ID ('extends' extends=ID)? '{' properties+=Property* '}'; Property: 'property' name=ID ':' type=ID (many?='[]')?; Results in containment relation “List<Property> properties” Results in simple attribute “String: name”
  • 19. L0081 - 2010-11-08 19 Example of Properties  Simple property:  name of SimpleType  “Many” reference – containment  elements of Model  properties of Entity  Boolean property  many of Property Model : (elements+=Type)*; Type: SimpleType | Entity; SimpleType: 'type' name=ID; Entity : 'entity' name=ID ('extends' extends=ID)? '{' properties+=Property* '}'; Property: 'property' name=ID ':' type=ID (many?='[]')?;
  • 20. L0081 - 2010-11-08 20  By default, rules results in a logical model with a tree of entities via containment  You can reference other elements via a reference rule  In textual languages a reference has to be by name  During linking, Xtext “dereferences” these by name-references  Why References?  Used in the logical model for references  XText also uses references for context assist Reference Relations Entity : 'entity' name=ID ('extends' extends=[Entity])? '{' properties+=Property* '}'; Results in containment relation “List<Property> properties” Results in reference relation “Entity extends”
  • 21. L0081 - 2010-11-08 21 Example of References  extends of Entity  type of Property Model : (elements+=Type)*; Type: SimpleType | Entity; SimpleType: 'type' name=ID; Entity : 'entity' name=ID ('extends' extends=[Entity])? '{' properties+=Property* '}'; Property: 'property' name=ID ':' type=[Type] (many?='[]')?;
  • 22. L0081 - 2010-11-08 22  A Enum Rule is used to define a limited set of defined alternatives  It is mapped to an enumeration in the logical model  It is declared via the Enum keyword and contains Enum Literals  An Enum Literal has a token name and a string representation  It can be used just like any other rule  Properties will get the enumeration type Enumeration Rules enum Color: RED=“red” | GREEN=“green” | BLUE=“blue” ; Shape: name=ID ( ‘color’ color=Color)? … ;
  • 23. L0081 - 2010-11-08 23  A native rule contains a string which is passed to ANTLR without further processing it.  It is typically used to define lexer rules that cannot be expressed using Xtext syntax  E.g. whitespace-aware lexer rules, such as define custom comment syntax Native Rules
  • 24. L0081 - 2010-11-08 24 Importing an Existing Model  To import an model instead of generating it..  Simple change to the xtext grammar file:  Depending on the starting point a simple change to the MWE2 file:  Not so with the generated MWE2 file   Easier to start with the wizard “XText Project from existing ECore Models” grammar com.rcpcompany.mdd2010.DSL with org.eclipse.xtext.common.Terminals import "platform:/resource/com.rcpcompany.mdd2010.model/model/Travel.ecore" import "http://www.eclipse.org/emf/2002/Ecore" as ecore … fragment = org.eclipse.xtext.generator.ecore.EcoreGeneratorFragment { genModels = "platform:/resource/com.rcpcompany.mdd2010.model/model/Travel.genmodel" }
  • 25. L0081 - 2010-11-08 25 More Information XText and friends  “Build your own textual DSL with Tools from the Eclipse Modeling Project”  http://www.eclipse.org/articles/article.php?file=Article-BuildYourOwnDSL/index.html  Older, slightly out-dated, article on how to create your first XText project  Documentation for XText  http://www.eclipse.org/Xtext/documentation/
  • 26. L0081 - 2010-11-08 26 Exercise 1  Make sure you grammar is on proper EBNF form  Do you think you can make an interesting editor from the grammar?  Create an XText project if not already done  Convert your EBNF grammar into an XText model  What can you do to your grammar to make it more suitable for XText