Elevator Simulator DSL Project Presented by Miguel Garzón and Stéphane Leblanc 1
Elevator Simulator Framework to test the behaviors of elevators in different scenarios Open Source (LGPL) Java Project Authors: Neil McKellar and Chris Dailey More details can be found at 2
Elevator Simulator DSL Domain Specific Language (DSL) over the Elevator Simulator API Allow to create elevator simulation scenarios 3
Introductory Example View the example 4
5
Goals of the DSL 1.Easy to read 2.Concise 3.Easy to write 4.Maintainable 5.Easy to parse 6
Target Audience Developers – Who want to create scenarios for the Elevator Simulator – Who want to look at a DSL implementation example Non-programmers not taken into account 7
DSL Metamodel (1) 8
User Variables DSL Metamodel (2) 9
DSL Overview – Metamodel (3) 10
DSL Creation Technology (1) 11
DSL Creation Technology (2) Eclipse IDE The Elevator Simulator DSL is deeply integrated with Eclipse. Our DSL comes in the form of an Eclipse Plug-in. 12
DSL Creation Technology (3) Xtext for definition of BNF Grammar and Metamodel generation. Xtext is an Eclipse-based DSL generator that was released in 2006 and is built on top of Antlr and other famous Eclipse projects. One can create Xtext Projects from ecore model or a grammar definition. 13
xTextxText Xtext- Generated Artefacts OPTIONAL Generates Generates 14
xTextxText Xtext- Generated Artefacts EMF Model Code 15
EMF Code Generation The generated code will consists out of the following: – Interfaces and the Factory to create the Java classes – Concrete implementation of the interfaces defined in model – Utilities Possibility to modify and extend generated code. – Code that is explicitly marked NOT is not overwritten. 16
xTextxText Xtext- DSL Processing Generated Java Class ESIM file Interpreted Generated 17
DSL Creation Technology (4) JET (Java Emitter Templates): For Code Generation. JET will be used to translate our domain specific language into Java classes representing the scenarios that will work with the Elevator Simulator. 18
JET (Java Emitter Templates) <% Model model = (Model) argument; Scenario scenario = model.getScenario(); String displayName = scenario.getDisplayName(); String className = scenario.getName();... %> public class extends Simulator { … } 19
Xtext Features (1) Code Completion Syntax Highlighting Linking Scoping IntelliSense Quick Fix Warnings 20
Xtext Features (2) Test cases: (for testing the editor) 21
Xtext Features –Validation (1) Semantic Validation: From OCL constraints defined in the Ecore Model, validation code is generated. 22
Extension Points Eclipse provides the concept of "extension points“. Elevator Sim provides menu actions, icons to enhance the user experience. – org.eclipse.ui.actionSets 23
Editor Sample Usage 24
Intelisense: Select a Variable 25
Syntactic Error: Grammatically Incorrect 26
Semantic Error: Makes No Sense 27
Deprecated 28
Quick Fix 29
Strategies for Language Evolution (1) Incremental Migrations[FowlerMig] V2.0 V1.1 V1.0 30
Strategies for Language Evolution (2) Model-based migrations [FowlerMig] V2.0 V1.1 V1.0 31
Strategies for Language Evolution (3) Maintain backward compatibility (Selected) V2.0 V1.1 V1.0 32
Conclusion Elevator Simulator DSL simplifies the creation of scenarios Powered by XText Allows for model interpretation and for code generation 33
References [FowlerDsl] Martin, Fowler, Domain-specific language, ISBN [FowlerMig] Fowler, Martin, DSL Migration, 2009/02/ Bell, Peter, DSL Evolution, 2009/12/ Tolvanen, JP, DSL in Practice, 2008/12/07, Software Engineering Radio, episode