Upload
judson
View
47
Download
1
Tags:
Embed Size (px)
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 Presentation
Citation preview
1
Elevator SimulatorDSL Project
Presented by
Miguel Garzón and
Stéphane Leblanc
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/
3
Elevator Simulator DSL
• Domain Specific Language (DSL) over the Elevator Simulator API
• Allow to create elevator simulation scenarios
4
Introductory Example
• View the example
5
6
Goals of the DSL
1. Easy to read2. Concise3. Easy to write4. Maintainable5. Easy to parse
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
8
DSL Metamodel (1)
9
• User VariablesDSL Metamodel (2)
10
DSL Overview – Metamodel (3)
11
DSL Creation Technology (1)
JET
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.
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.
14
xText
Xtext- Generated Artefacts
BNF GRAMMAR SEMANTIC MODEL(ECORE)
EDITOR PARSER
OPTIONAL
Generates
Generates
15
xText
Xtext- Generated Artefacts
BNF GRAMMAR
SEMANTIC MODEL(ECORE)
EDITOR PARSER
EMF Model Code
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.
17
xText
Xtext- DSL Processing
BNF GRAMMAR SEMANTIC
MODEL(ECORE)
EDITOR PARSER
Generated Java ClassESIM file
Interpreted Generated
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.
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{ … }
20
Xtext Features (1)
• Code Completion • Syntax Highlighting• Linking• Scoping • IntelliSense • Quick Fix• Warnings
21
Xtext Features (2)
• Test cases: (for testing the editor)
22
Xtext Features –Validation (1)
• Semantic Validation:From OCL constraints defined in the Ecore Model,
validation code is generated.
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
24
Editor Sample Usage
25
Intelisense: Select a Variable
26
Syntactic Error: Grammatically
Incorrect
27
Semantic Error: Makes No SenseSemantic Error: Makes No Sense
28
Deprecated
29
Quick Fix
30
Strategies for Language Evolution (1)
• Incremental Migrations[FowlerMig]
V2.0V1.1V1.0
31
Strategies for Language Evolution (2)
• Model-based migrations [FowlerMig]
V2.0
V1.1
V1.0
32
Strategies for Language Evolution (3)
• Maintain backward compatibility (Selected)
V2.0V1.1V1.0
33
Conclusion
• Elevator Simulator DSL simplifies the creation of scenarios
• Powered by XText• Allows for model interpretation and for code
generation
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