SlideShare a Scribd company logo
1 of 23
L0080 - 2010-11-02
Redistribution and other use of this material requires written permission from The RCP Company.
ITU - MDD – Textural Languages and Grammars
This presentation describes the use and design of textural domain specific
language - DSL. It has two basic purposes:
Introduce you to some of the more important design criteria in language
design
Introduce you to BNF
This presentation is developed for MDD 2010 course at ITU, Denmark.
Some materials are taken from Artur Boronat, University of Leicester with permissions.
L0080 - 2010-11-02
2
Textual DSLs versus Graphical DSLs
 With both textual and graphical syntax you can
 model any meta model
 verify constraints in real time
 (Eclipse) write ordinary EMF models
 Graphical Editors are good to show structural relationships
 Graphical Editors are sexy and often appeals to management
 Textual Editors are better for „algorithmic“ aspects, or hierarchical models
 Textual Editors integrate better with CVS etc. (diff, merge)
 Textual Editors often provides better support for quick assist and quick fixes
 If you must work with a DSL many hours every day, consider textual DSLs over
graphical DSLs!’
L0080 - 2010-11-02
3
What is needed for a successful DSL
 You must know
 The intended audience
 The expressiveness of the language
 The extendibility of the language
L0080 - 2010-11-02
4
The intended audience
 Who will be using the language
 Temporary help in a call center
 Full-time Clerks
 Accountants
 Engineers – like yourselves
 Any mismatch between the language and the audience is likely to alienate your
audience
 Keywords:
 concise vs. redundant
 intuitive
 simple to write and read
(host “heimdal”
(ipif 192.167.54.55)
(disk:type SSD 500GB))
Define host name = “heimdal”
with IP interface
IPv4 address = 192.167.54.55
end IP address
with disk
type = SSD
size = 500GB
end disk
End host
L0080 - 2010-11-02
5
The expressiveness of the language
 What type of information must be expressed in the language:
 Simple static information
 Complex network of objects
 Algorithms
 Must the DSL be Turing complete?
 What type of constructs must be supported
 Lists
 Tables
 Recursive data structures
 Variables
 Macros
 Conditions and loops
 Functions
 Comments
E = MC2
L0080 - 2010-11-02
6
The extendibility of the language
 Can you be absolute certain that the language will never be extended?
 “The last language…”
 Backward compatibility
 If your grammar is successful, then it will be used – so what should you do
with all the existing “stuff” when you need to extend your grammar with new
functionality
 Open versus closed grammars
 An open grammar can be extended in the future with new constructs or
statements in a natural manner
 A closed grammar can be very difficult to extend while retaining backward
compatibility
heimdal 192.167.54.55 SSD 500
(host “heimdal”
(ipif 192.167.54.55)
(disk type SSD 500GB))
L0080 - 2010-11-02
7
Internal versus External DSLs
 Textual DSLs are normally divided into two distinct groups:
 Internal DSL (or extension language)

Using the syntax and semantics of a host language or system – e.g. Java
or Excel

You can argument that any API is in itself an DSL
 External DSL

A completely new language
L0080 - 2010-11-02
8
Some Examples
Internal DSL
 4GL – attempt in the 1990s to raise the productivity of programmers by adding
more high-level constructs to 3GL languages (such as C, Pascal, etc)
 JSP – current attempt to ease the creation of web pages by adding Java as an
embedded scripting language
 Some languages that have been designed to be a good host language for DSL:
 Tcl
 Python
 Groovy
 Ruby
final IFormCreator detailsSection = myForm.addSection("Details",
table.getBinding().getSingleSelection());
detailsSection.addObjectMessages();
detailsSection.addField("contact.name(w=200)");
detailsSection.addField("logoFileName(w=200)");
detailsSection.addField("loyalty").arg(Constants.ARG_PREFERRED_CONTROL,
RadioGroup.class.getName());
# Assume $remote_server, $my_user_id, $my_password, and $my_command
# were read in earlier in the script.
spawn telnet $remote_server expect "username:"
send "$my_user_idr" expect "password:"
send "$my_passwordr" expect "%"
send "$my_commandr" expect "%"
set results $expect_out(buffer)
send "exitr" expect eof
L0080 - 2010-11-02
9
 Consists of two layers
 a lexical layer
 a grammar layer
 Lexical syntax: the spelling of
words and punctuation
 Grammars: the key formalism for
describing syntax; universal progra
mming language
Example
 if (<expr>) <statement>
 if <expr> then <statement>
 <statement> if <expr>
 (if <expr> <statement>)
Formal Syntax of an DSL
if
expression statement
!=
a
constantvariable
if (a != null) b = a.getArg();
“If” “(“ “a” “!=“ “null” “)” “b” “=“ “a” “.” “getArg” “(“ “)” “;”
assignment
a expression
null
… …
L0080 - 2010-11-02
10
 Tokens/Terminals: units in programming language
 Lexical syntax: correspondence between the written representation (spelling) and
the tokens or terminals in a grammar
 Keywords:
 alphabetic character sequences
 unit in a language - if , while
 Punctuation
 Like ‘(‘, ‘)’, ‘:=‘
 Whitespace
Lexical Syntax
if (a != null) b = a.getArg();
“If” “(“ “a” “!=“ “null” “)” “b” “=“ “a” “.” “getArg” “(“ “)” “;”
L0080 - 2010-11-02
11
 Concrete syntax: describes its written representation, including lexical details
such as the placement of keywords and punctuation marks
 Context-free grammar or grammars: notation for specifying concrete syntax
 Context-free means that the understanding of the next token may not depend on
the current context
 Example from PL/1 of a context dependent grammar:

IF IF THEN THEN ELSE ELSE;

Legal if “IF” is a Boolean variable and “THEN” and “ELSE” are valid
procedures
 Most modern languages have a context-free grammar
 Notable exceptions are C and C++!!!
Context-Free Grammars
L0080 - 2010-11-02
12
 Grammar has four parts
 A set of tokens or terminals

atomic symbols that can not be sub-divided
 A set of nonterminals

Identifiers or variables representing constructs
 A set of rules (called productions)

identify the component of construct

<nonterminal >::= terminal | <nonterminal>
 A starting nonterminal

represents a main construct
Describing Context-Free Grammars
assignment => ID = expression;
expression => expression + term
| expression - term
| term
term => term * factor
| term / factor
| factor
factor => ( expression )
| ID
| NUMBER
L0080 - 2010-11-02
13
 The productions are rules for building strings
 Parse Trees: show how a string can be built
Notation to write grammar
 Backus-Naur Form (BNF)
 Extended BNF (EBNF)
Writing Grammars
L0080 - 2010-11-02
14
Backus-Naur Form (Backus Normal Form)
 Grammar Rules or Productions: define symbols.
 Non-terminal Symbols: anything that is defined on the left-side of some
production.
 Terminal Symbols: things that are not defined by productions. They can be
literals, symbols, and other lexemes of the language defined by lexical rules.
 Identifiers: id::= [A-Za-z_]*
 Delimiters: ;
 Operators: = + - * / %
assignment_stmt ::= id = expression;
The non-terminal symbol being
defined.
The definition (production)
L0080 - 2010-11-02
15
 Different notations (same meaning):
 assignment_stmt ::= id = expression + term
 <assignment-stmt> => <id> = <expr> + <term>
 AssignmentStmt → id = expression + term
::=, =>, → mean "consists of" or "defined as"
 Alternatives ( " | " ):
 Concatenation:
Backus-Naur Form (Backus Normal Form)
expression => expression + term
| expression - term
| term
number => DIGIT number | DIGIT
L0080 - 2010-11-02
16
Backus-Naur Form (Backus Normal Form)
 Another way to write alternatives:
 Null symbol,: ε or @
used to allow a production to match nothing.
 Example: a variable is an identifier followed by an optional subscript
Expression => expression + term
=> expression - term
=> term
variable => identifier subscript
subscript => [ expression ] | e
L0080 - 2010-11-02
17
 Here is a grammar for assignment with arithmetic operations, e.g. y = (2*x +
5)*x - 7;
Arithmetic Grammar
assignment => ID = expression;
expression => expression + term
| expression - term
| term
term => term * factor
| term / factor
| factor
factor => ( expression )
| ID
| NUMBER
L0080 - 2010-11-02
18
Example of a Parse Tree
if
expression statement
!=
a
constantvariable
“If” “(“ “a” “!=“ “null” “)” “b” “=“ “a” “.” “getArg” “(“ “)” “;”
assignment
a expression
null
… …
L0080 - 2010-11-02
19
 Grammar Rules:
expr => expr + expr | expr ∗ expr
| ( expr ) | NUMBER
 Expression: 2 + 3 * 4
 Two possible parse trees:
expr
expr expr
expr
+
*expr
expr
expr
+
*expr
exprexprNUMBER
(2)
NUMBER
(3)
NUMBER
(4)
NUMBER
(2)
NUMBER
(3)
NUMBER
(4)
Ambiguity
L0080 - 2010-11-02
20
 The standard metalanguage: Extended BNF
 Terminal symbols of the language are quoted
 [ and ] include optional symbols
 { and } indicate repetition
 ( and ) are used to group items
 | definition-separator-symbol stands for or. In EBNF we need to quote ( and )
literals as '(' ... ')’
 * repetition symbol
 = defining symbol
 ; terminator symbol
EBNF – Extended BNF
L0080 - 2010-11-02
21
BNF versus EBNF
BNF:
EBNF:
expression ::= expression + term
| expression - term
| term
term ::= term * factor
| term / factor
| factor
factor ::= ( expression )
| id
| number
expression ::= term { (‘+’|’-’) term }
term ::= factor { (‘*’|’/’) factor }
factor ::= '(' expression ')'
| id | number
L0080 - 2010-11-02
22
More Information
 “Model-Driven Software Development” by Thomas Stahl and Markus Völter
 Chapter 8.1 “DSL Construction”

Good high-level introduction to DSLs
 “Domain-Specific Languages: An Annotated Bibliography”
 http://homepages.cwi.nl/~arie/papers/dslbib/

Not very interesting except for the very long annotated bibliography!
 “BNF and EBNF: What are they and how do they work?” by Lars Marius Garshol -
http://www.garshol.priv.no/download/text/bnf.html
 About Backus-Naur Form and parsing
 “Internal Domain-Specific Languages”
 http://fragmental.tw/research-on-dsls/domain-specific-languages-dsls/internal-dsls/

Outlines use of DSL in Java and Ruby
L0080 - 2010-11-02
23
Exercise 1
 Design a textual language (grammar) for a travel package.
 How would you like to specify a travel package in text?
 Do you think, you can teach a travel administrator to use the language?
 Is the grammar open – i.e. can it be extended in the future?
 For the grammar you can use ID, STRING and NUMBER as terminators where
relevant

More Related Content

What's hot

POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
Introduction of c programming unit-ii ppt
Introduction of  c programming unit-ii pptIntroduction of  c programming unit-ii ppt
Introduction of c programming unit-ii pptJStalinAsstProfessor
 
Meta Languages Railroad Diagrams Student Version
Meta Languages Railroad Diagrams Student VersionMeta Languages Railroad Diagrams Student Version
Meta Languages Railroad Diagrams Student VersionKelly Bauer
 
C101 – Intro to Programming with C
C101 – Intro to Programming with CC101 – Intro to Programming with C
C101 – Intro to Programming with Cgpsoft_sk
 
Introduction of c_language
Introduction of c_languageIntroduction of c_language
Introduction of c_languageSINGH PROJECTS
 
C++ programming intro
C++ programming introC++ programming intro
C++ programming intromarklaloo
 
PLUG : Presentation Layer Universal Generator
PLUG : Presentation Layer Universal GeneratorPLUG : Presentation Layer Universal Generator
PLUG : Presentation Layer Universal GeneratorEmmanuel Fuchs
 
Lectura 3.5 word normalizationintwitter finitestate_transducers
Lectura 3.5 word normalizationintwitter finitestate_transducersLectura 3.5 word normalizationintwitter finitestate_transducers
Lectura 3.5 word normalizationintwitter finitestate_transducersMatias Menendez
 
A Role of Lexical Analyzer
A Role of Lexical AnalyzerA Role of Lexical Analyzer
A Role of Lexical AnalyzerArchana Gopinath
 
Compier Design_Unit I_SRM.ppt
Compier Design_Unit I_SRM.pptCompier Design_Unit I_SRM.ppt
Compier Design_Unit I_SRM.pptApoorv Diwan
 
Chapter1 c programming data types, variables and constants
Chapter1 c programming   data types, variables and constantsChapter1 c programming   data types, variables and constants
Chapter1 c programming data types, variables and constantsvinay arora
 
C presentation book
C presentation bookC presentation book
C presentation bookkrunal1210
 
Report on c and c++
Report on c and c++Report on c and c++
Report on c and c++oggyrao
 

What's hot (19)

POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
C material
C materialC material
C material
 
Introduction of c programming unit-ii ppt
Introduction of  c programming unit-ii pptIntroduction of  c programming unit-ii ppt
Introduction of c programming unit-ii ppt
 
Meta Languages Railroad Diagrams Student Version
Meta Languages Railroad Diagrams Student VersionMeta Languages Railroad Diagrams Student Version
Meta Languages Railroad Diagrams Student Version
 
C101 – Intro to Programming with C
C101 – Intro to Programming with CC101 – Intro to Programming with C
C101 – Intro to Programming with C
 
Introduction of c_language
Introduction of c_languageIntroduction of c_language
Introduction of c_language
 
Syntax
SyntaxSyntax
Syntax
 
CProgrammingTutorial
CProgrammingTutorialCProgrammingTutorial
CProgrammingTutorial
 
C++ programming intro
C++ programming introC++ programming intro
C++ programming intro
 
Lexical analyzer
Lexical analyzerLexical analyzer
Lexical analyzer
 
PLUG : Presentation Layer Universal Generator
PLUG : Presentation Layer Universal GeneratorPLUG : Presentation Layer Universal Generator
PLUG : Presentation Layer Universal Generator
 
Lectura 3.5 word normalizationintwitter finitestate_transducers
Lectura 3.5 word normalizationintwitter finitestate_transducersLectura 3.5 word normalizationintwitter finitestate_transducers
Lectura 3.5 word normalizationintwitter finitestate_transducers
 
A Role of Lexical Analyzer
A Role of Lexical AnalyzerA Role of Lexical Analyzer
A Role of Lexical Analyzer
 
Compier Design_Unit I_SRM.ppt
Compier Design_Unit I_SRM.pptCompier Design_Unit I_SRM.ppt
Compier Design_Unit I_SRM.ppt
 
Chapter1 c programming data types, variables and constants
Chapter1 c programming   data types, variables and constantsChapter1 c programming   data types, variables and constants
Chapter1 c programming data types, variables and constants
 
C presentation book
C presentation bookC presentation book
C presentation book
 
Lexical analysis - Compiler Design
Lexical analysis - Compiler DesignLexical analysis - Compiler Design
Lexical analysis - Compiler Design
 
Report on c and c++
Report on c and c++Report on c and c++
Report on c and c++
 
Normalization
NormalizationNormalization
Normalization
 

Similar to ITU - MDD - Textural Languages and Grammars

Convention-Based Syntactic Descriptions
Convention-Based Syntactic DescriptionsConvention-Based Syntactic Descriptions
Convention-Based Syntactic DescriptionsRay Toal
 
Concepts of JetBrains MPS
Concepts of JetBrains MPSConcepts of JetBrains MPS
Concepts of JetBrains MPSVaclav Pech
 
TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesTI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesEelco Visser
 
Cs6660 compiler design may june 2016 Answer Key
Cs6660 compiler design may june 2016 Answer KeyCs6660 compiler design may june 2016 Answer Key
Cs6660 compiler design may june 2016 Answer Keyappasami
 
Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Robert Pickering
 
groovy DSLs from beginner to expert
groovy DSLs from beginner to expertgroovy DSLs from beginner to expert
groovy DSLs from beginner to expertPaul King
 
Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Vitaly Baum
 
Building scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftBuilding scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftTalentica Software
 
Software Internationalization Crash Course
Software Internationalization Crash CourseSoftware Internationalization Crash Course
Software Internationalization Crash CourseWill Iverson
 
AestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in ScalaAestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in ScalaDmitry Buzdin
 
Compiler Engineering Lab#5 : Symbol Table, Flex Tool
Compiler Engineering Lab#5 : Symbol Table, Flex ToolCompiler Engineering Lab#5 : Symbol Table, Flex Tool
Compiler Engineering Lab#5 : Symbol Table, Flex ToolMashaelQ
 
BUILDING BASIC STRECH SQL COMPILER
BUILDING BASIC STRECH SQL COMPILERBUILDING BASIC STRECH SQL COMPILER
BUILDING BASIC STRECH SQL COMPILERAjeet Dubey
 
Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...IndicThreads
 
Internationalisation And Globalisation
Internationalisation And GlobalisationInternationalisation And Globalisation
Internationalisation And GlobalisationAlan Dean
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Bilal Amjad
 

Similar to ITU - MDD - Textural Languages and Grammars (20)

Convention-Based Syntactic Descriptions
Convention-Based Syntactic DescriptionsConvention-Based Syntactic Descriptions
Convention-Based Syntactic Descriptions
 
Concepts of JetBrains MPS
Concepts of JetBrains MPSConcepts of JetBrains MPS
Concepts of JetBrains MPS
 
TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesTI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific Languages
 
python and perl
python and perlpython and perl
python and perl
 
Cs6660 compiler design may june 2016 Answer Key
Cs6660 compiler design may june 2016 Answer KeyCs6660 compiler design may june 2016 Answer Key
Cs6660 compiler design may june 2016 Answer Key
 
Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#Combinators, DSLs, HTML and F#
Combinators, DSLs, HTML and F#
 
groovy DSLs from beginner to expert
groovy DSLs from beginner to expertgroovy DSLs from beginner to expert
groovy DSLs from beginner to expert
 
Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)Building DSLs On CLR and DLR (Microsoft.NET)
Building DSLs On CLR and DLR (Microsoft.NET)
 
PDF Localization
PDF  LocalizationPDF  Localization
PDF Localization
 
Building scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thriftBuilding scalable and language independent java services using apache thrift
Building scalable and language independent java services using apache thrift
 
Compilers Design
Compilers DesignCompilers Design
Compilers Design
 
Software Internationalization Crash Course
Software Internationalization Crash CourseSoftware Internationalization Crash Course
Software Internationalization Crash Course
 
DSL explained _
DSL explained _DSL explained _
DSL explained _
 
AestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in ScalaAestasIT - Internal DSLs in Scala
AestasIT - Internal DSLs in Scala
 
Interm codegen
Interm codegenInterm codegen
Interm codegen
 
Compiler Engineering Lab#5 : Symbol Table, Flex Tool
Compiler Engineering Lab#5 : Symbol Table, Flex ToolCompiler Engineering Lab#5 : Symbol Table, Flex Tool
Compiler Engineering Lab#5 : Symbol Table, Flex Tool
 
BUILDING BASIC STRECH SQL COMPILER
BUILDING BASIC STRECH SQL COMPILERBUILDING BASIC STRECH SQL COMPILER
BUILDING BASIC STRECH SQL COMPILER
 
Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...Building scalable and language-independent Java services using Apache Thrift ...
Building scalable and language-independent Java services using Apache Thrift ...
 
Internationalisation And Globalisation
Internationalisation And GlobalisationInternationalisation And Globalisation
Internationalisation And Globalisation
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
 

More from 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
 

More from 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
 
ITU - MDD - XText
ITU - MDD - XTextITU - MDD - XText
ITU - MDD - XText
 
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
 

Recently uploaded

Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
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
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
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
 
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
 

Recently uploaded (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
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
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.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
 
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
 

ITU - MDD - Textural Languages and Grammars

  • 1. L0080 - 2010-11-02 Redistribution and other use of this material requires written permission from The RCP Company. ITU - MDD – Textural Languages and Grammars This presentation describes the use and design of textural domain specific language - DSL. It has two basic purposes: Introduce you to some of the more important design criteria in language design Introduce you to BNF This presentation is developed for MDD 2010 course at ITU, Denmark. Some materials are taken from Artur Boronat, University of Leicester with permissions.
  • 2. L0080 - 2010-11-02 2 Textual DSLs versus Graphical DSLs  With both textual and graphical syntax you can  model any meta model  verify constraints in real time  (Eclipse) write ordinary EMF models  Graphical Editors are good to show structural relationships  Graphical Editors are sexy and often appeals to management  Textual Editors are better for „algorithmic“ aspects, or hierarchical models  Textual Editors integrate better with CVS etc. (diff, merge)  Textual Editors often provides better support for quick assist and quick fixes  If you must work with a DSL many hours every day, consider textual DSLs over graphical DSLs!’
  • 3. L0080 - 2010-11-02 3 What is needed for a successful DSL  You must know  The intended audience  The expressiveness of the language  The extendibility of the language
  • 4. L0080 - 2010-11-02 4 The intended audience  Who will be using the language  Temporary help in a call center  Full-time Clerks  Accountants  Engineers – like yourselves  Any mismatch between the language and the audience is likely to alienate your audience  Keywords:  concise vs. redundant  intuitive  simple to write and read (host “heimdal” (ipif 192.167.54.55) (disk:type SSD 500GB)) Define host name = “heimdal” with IP interface IPv4 address = 192.167.54.55 end IP address with disk type = SSD size = 500GB end disk End host
  • 5. L0080 - 2010-11-02 5 The expressiveness of the language  What type of information must be expressed in the language:  Simple static information  Complex network of objects  Algorithms  Must the DSL be Turing complete?  What type of constructs must be supported  Lists  Tables  Recursive data structures  Variables  Macros  Conditions and loops  Functions  Comments E = MC2
  • 6. L0080 - 2010-11-02 6 The extendibility of the language  Can you be absolute certain that the language will never be extended?  “The last language…”  Backward compatibility  If your grammar is successful, then it will be used – so what should you do with all the existing “stuff” when you need to extend your grammar with new functionality  Open versus closed grammars  An open grammar can be extended in the future with new constructs or statements in a natural manner  A closed grammar can be very difficult to extend while retaining backward compatibility heimdal 192.167.54.55 SSD 500 (host “heimdal” (ipif 192.167.54.55) (disk type SSD 500GB))
  • 7. L0080 - 2010-11-02 7 Internal versus External DSLs  Textual DSLs are normally divided into two distinct groups:  Internal DSL (or extension language)  Using the syntax and semantics of a host language or system – e.g. Java or Excel  You can argument that any API is in itself an DSL  External DSL  A completely new language
  • 8. L0080 - 2010-11-02 8 Some Examples Internal DSL  4GL – attempt in the 1990s to raise the productivity of programmers by adding more high-level constructs to 3GL languages (such as C, Pascal, etc)  JSP – current attempt to ease the creation of web pages by adding Java as an embedded scripting language  Some languages that have been designed to be a good host language for DSL:  Tcl  Python  Groovy  Ruby final IFormCreator detailsSection = myForm.addSection("Details", table.getBinding().getSingleSelection()); detailsSection.addObjectMessages(); detailsSection.addField("contact.name(w=200)"); detailsSection.addField("logoFileName(w=200)"); detailsSection.addField("loyalty").arg(Constants.ARG_PREFERRED_CONTROL, RadioGroup.class.getName()); # Assume $remote_server, $my_user_id, $my_password, and $my_command # were read in earlier in the script. spawn telnet $remote_server expect "username:" send "$my_user_idr" expect "password:" send "$my_passwordr" expect "%" send "$my_commandr" expect "%" set results $expect_out(buffer) send "exitr" expect eof
  • 9. L0080 - 2010-11-02 9  Consists of two layers  a lexical layer  a grammar layer  Lexical syntax: the spelling of words and punctuation  Grammars: the key formalism for describing syntax; universal progra mming language Example  if (<expr>) <statement>  if <expr> then <statement>  <statement> if <expr>  (if <expr> <statement>) Formal Syntax of an DSL if expression statement != a constantvariable if (a != null) b = a.getArg(); “If” “(“ “a” “!=“ “null” “)” “b” “=“ “a” “.” “getArg” “(“ “)” “;” assignment a expression null … …
  • 10. L0080 - 2010-11-02 10  Tokens/Terminals: units in programming language  Lexical syntax: correspondence between the written representation (spelling) and the tokens or terminals in a grammar  Keywords:  alphabetic character sequences  unit in a language - if , while  Punctuation  Like ‘(‘, ‘)’, ‘:=‘  Whitespace Lexical Syntax if (a != null) b = a.getArg(); “If” “(“ “a” “!=“ “null” “)” “b” “=“ “a” “.” “getArg” “(“ “)” “;”
  • 11. L0080 - 2010-11-02 11  Concrete syntax: describes its written representation, including lexical details such as the placement of keywords and punctuation marks  Context-free grammar or grammars: notation for specifying concrete syntax  Context-free means that the understanding of the next token may not depend on the current context  Example from PL/1 of a context dependent grammar:  IF IF THEN THEN ELSE ELSE;  Legal if “IF” is a Boolean variable and “THEN” and “ELSE” are valid procedures  Most modern languages have a context-free grammar  Notable exceptions are C and C++!!! Context-Free Grammars
  • 12. L0080 - 2010-11-02 12  Grammar has four parts  A set of tokens or terminals  atomic symbols that can not be sub-divided  A set of nonterminals  Identifiers or variables representing constructs  A set of rules (called productions)  identify the component of construct  <nonterminal >::= terminal | <nonterminal>  A starting nonterminal  represents a main construct Describing Context-Free Grammars assignment => ID = expression; expression => expression + term | expression - term | term term => term * factor | term / factor | factor factor => ( expression ) | ID | NUMBER
  • 13. L0080 - 2010-11-02 13  The productions are rules for building strings  Parse Trees: show how a string can be built Notation to write grammar  Backus-Naur Form (BNF)  Extended BNF (EBNF) Writing Grammars
  • 14. L0080 - 2010-11-02 14 Backus-Naur Form (Backus Normal Form)  Grammar Rules or Productions: define symbols.  Non-terminal Symbols: anything that is defined on the left-side of some production.  Terminal Symbols: things that are not defined by productions. They can be literals, symbols, and other lexemes of the language defined by lexical rules.  Identifiers: id::= [A-Za-z_]*  Delimiters: ;  Operators: = + - * / % assignment_stmt ::= id = expression; The non-terminal symbol being defined. The definition (production)
  • 15. L0080 - 2010-11-02 15  Different notations (same meaning):  assignment_stmt ::= id = expression + term  <assignment-stmt> => <id> = <expr> + <term>  AssignmentStmt → id = expression + term ::=, =>, → mean "consists of" or "defined as"  Alternatives ( " | " ):  Concatenation: Backus-Naur Form (Backus Normal Form) expression => expression + term | expression - term | term number => DIGIT number | DIGIT
  • 16. L0080 - 2010-11-02 16 Backus-Naur Form (Backus Normal Form)  Another way to write alternatives:  Null symbol,: ε or @ used to allow a production to match nothing.  Example: a variable is an identifier followed by an optional subscript Expression => expression + term => expression - term => term variable => identifier subscript subscript => [ expression ] | e
  • 17. L0080 - 2010-11-02 17  Here is a grammar for assignment with arithmetic operations, e.g. y = (2*x + 5)*x - 7; Arithmetic Grammar assignment => ID = expression; expression => expression + term | expression - term | term term => term * factor | term / factor | factor factor => ( expression ) | ID | NUMBER
  • 18. L0080 - 2010-11-02 18 Example of a Parse Tree if expression statement != a constantvariable “If” “(“ “a” “!=“ “null” “)” “b” “=“ “a” “.” “getArg” “(“ “)” “;” assignment a expression null … …
  • 19. L0080 - 2010-11-02 19  Grammar Rules: expr => expr + expr | expr ∗ expr | ( expr ) | NUMBER  Expression: 2 + 3 * 4  Two possible parse trees: expr expr expr expr + *expr expr expr + *expr exprexprNUMBER (2) NUMBER (3) NUMBER (4) NUMBER (2) NUMBER (3) NUMBER (4) Ambiguity
  • 20. L0080 - 2010-11-02 20  The standard metalanguage: Extended BNF  Terminal symbols of the language are quoted  [ and ] include optional symbols  { and } indicate repetition  ( and ) are used to group items  | definition-separator-symbol stands for or. In EBNF we need to quote ( and ) literals as '(' ... ')’  * repetition symbol  = defining symbol  ; terminator symbol EBNF – Extended BNF
  • 21. L0080 - 2010-11-02 21 BNF versus EBNF BNF: EBNF: expression ::= expression + term | expression - term | term term ::= term * factor | term / factor | factor factor ::= ( expression ) | id | number expression ::= term { (‘+’|’-’) term } term ::= factor { (‘*’|’/’) factor } factor ::= '(' expression ')' | id | number
  • 22. L0080 - 2010-11-02 22 More Information  “Model-Driven Software Development” by Thomas Stahl and Markus Völter  Chapter 8.1 “DSL Construction”  Good high-level introduction to DSLs  “Domain-Specific Languages: An Annotated Bibliography”  http://homepages.cwi.nl/~arie/papers/dslbib/  Not very interesting except for the very long annotated bibliography!  “BNF and EBNF: What are they and how do they work?” by Lars Marius Garshol - http://www.garshol.priv.no/download/text/bnf.html  About Backus-Naur Form and parsing  “Internal Domain-Specific Languages”  http://fragmental.tw/research-on-dsls/domain-specific-languages-dsls/internal-dsls/  Outlines use of DSL in Java and Ruby
  • 23. L0080 - 2010-11-02 23 Exercise 1  Design a textual language (grammar) for a travel package.  How would you like to specify a travel package in text?  Do you think, you can teach a travel administrator to use the language?  Is the grammar open – i.e. can it be extended in the future?  For the grammar you can use ID, STRING and NUMBER as terminators where relevant