elevator simulator dsl project
DESCRIPTION
Elevator Simulator DSL Project. Presented by Miguel Garzón and Stéphane Leblanc. Elevator Simulator. Framework to test the behaviors of elevators in different scenarios Open Source (LGPL) Java Project Authors: Neil McKellar and Chris Dailey - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/1.jpg)
1
Elevator SimulatorDSL Project
Presented by
Miguel Garzón and
Stéphane Leblanc
![Page 2: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/2.jpg)
2
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
http://elevatorsim.sourceforge.net/
![Page 3: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/3.jpg)
3
Elevator Simulator DSL
• Domain Specific Language (DSL) over the Elevator Simulator API
• Allow to create elevator simulation scenarios
![Page 4: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/4.jpg)
4
Introductory Example
• View the example
![Page 5: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/5.jpg)
5
![Page 6: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/6.jpg)
6
Goals of the DSL
1. Easy to read2. Concise3. Easy to write4. Maintainable5. Easy to parse
![Page 7: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/7.jpg)
7
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
![Page 8: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/8.jpg)
8
DSL Metamodel (1)
![Page 9: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/9.jpg)
9
• User VariablesDSL Metamodel (2)
![Page 10: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/10.jpg)
10
DSL Overview – Metamodel (3)
![Page 11: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/11.jpg)
11
DSL Creation Technology (1)
JET
![Page 12: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/12.jpg)
12
DSL Creation Technology (2)
• Eclipse IDEThe Elevator Simulator DSL is deeply integrated
with Eclipse. Our DSL comes in the form of an Eclipse Plug-in.
![Page 13: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/13.jpg)
13
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.
![Page 14: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/14.jpg)
14
xText
Xtext- Generated Artefacts
BNF GRAMMAR SEMANTIC MODEL(ECORE)
EDITOR PARSER
OPTIONAL
Generates
Generates
![Page 15: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/15.jpg)
15
xText
Xtext- Generated Artefacts
BNF GRAMMAR
SEMANTIC MODEL(ECORE)
EDITOR PARSER
EMF Model Code
![Page 16: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/16.jpg)
16
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 as @generated NOT is
not overwritten.
![Page 17: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/17.jpg)
17
xText
Xtext- DSL Processing
BNF GRAMMAR SEMANTIC
MODEL(ECORE)
EDITOR PARSER
Generated Java ClassESIM file
Interpreted Generated
![Page 18: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/18.jpg)
18
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.
![Page 19: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/19.jpg)
19
JET (Java Emitter Templates) <%@ jet package="org.intranet.sim.dsl.codegen"
class="ScenarioGenerator" imports="org.intranet.sim.dsl.scenarioGenerator.*" skeleton="generator.skeleton" %>
<% Model model = (Model) argument; Scenario scenario = model.getScenario(); String displayName = scenario.getDisplayName(); String className = scenario.getName(); ...%> public class <%=className%> extends Simulator{ … }
![Page 20: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/20.jpg)
20
Xtext Features (1)
• Code Completion • Syntax Highlighting• Linking• Scoping • IntelliSense • Quick Fix• Warnings
![Page 21: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/21.jpg)
21
Xtext Features (2)
• Test cases: (for testing the editor)
![Page 22: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/22.jpg)
22
Xtext Features –Validation (1)
• Semantic Validation:From OCL constraints defined in the Ecore Model,
validation code is generated.
![Page 23: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/23.jpg)
23
Extension Points• Eclipse provides the concept of "extension
points“. • Elevator Sim provides menu actions, icons to
enhance the user experience.– org.eclipse.ui.actionSets
![Page 24: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/24.jpg)
24
Editor Sample Usage
![Page 25: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/25.jpg)
25
Intelisense: Select a Variable
![Page 26: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/26.jpg)
26
Syntactic Error: Grammatically
Incorrect
![Page 27: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/27.jpg)
27
Semantic Error: Makes No SenseSemantic Error: Makes No Sense
![Page 28: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/28.jpg)
28
Deprecated
![Page 29: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/29.jpg)
29
Quick Fix
![Page 30: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/30.jpg)
30
Strategies for Language Evolution (1)
• Incremental Migrations[FowlerMig]
V2.0V1.1V1.0
![Page 31: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/31.jpg)
31
Strategies for Language Evolution (2)
• Model-based migrations [FowlerMig]
V2.0
V1.1
V1.0
![Page 32: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/32.jpg)
32
Strategies for Language Evolution (3)
• Maintain backward compatibility (Selected)
V2.0V1.1V1.0
![Page 33: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/33.jpg)
33
Conclusion
• Elevator Simulator DSL simplifies the creation of scenarios
• Powered by XText• Allows for model interpretation and for code
generation
![Page 34: Elevator Simulator DSL Project](https://reader035.vdocument.in/reader035/viewer/2022081513/568160bf550346895dcfe514/html5/thumbnails/34.jpg)
34
References
• [FowlerDsl] Martin, Fowler, Domain-specific language, ISBN 0321712943
• [FowlerMig] Fowler, Martin, DSL Migration, 2009/02/05http://martinfowler.com/bliki/DslMigration.html
• Bell, Peter, DSL Evolution, 2009/12/22http://www.infoq.com/articles/dsl-evolution
• Tolvanen, JP, DSL in Practice, 2008/12/07, Software Engineering Radio, episode 119http://www.se-radio.net/?s=DSL