Microsoft Visual Studio 2008 DSL Tools
First of all install the Microsoft Visual Studio 2008 (at least Professional Edition).
Then download and install
Visual Studio 2008 Software Development Kit
(select the most suitable version for your studio according to the installed Service Pack).
Select File > New > Project ... from the main menu.
Choose Domain-specific Language Designer project.
Fill in the project name (e.g. StateMachineLanguage).
Select Minimal language template.
Fill in the extension for language model files (e.g. sml).
Fill in the name of the company (e.g. JKU).
Created solution is shown on the next picture.
The help for DSL Tools (press F1) is located under the node Visual Studio SDK/Domain-Specific Language Tools.
The main DSL tools are:
DSL Toolbox contains following tools:
- DSL Designer - simple toolbar with a few buttons (Bring tree here, Show map lines, Zoom and DSL Details buttons).
- DSL Diagram - here all the drawing happens.
- DSL Toolbox - tool buttons for basic building elements.
- DSL Explorer - displays several kinds of information from DSL in a tree view.
- DSL Details - detail window for DSL properties.
- Properties - standard Property window.
Abstract syntax - Classes and relationships
There is always one element marked as a root element.
All elements must be directly or indirectly embedded in the root element created a tree-like structure via embedding relationship.
- Domain Class - represents a concept from a domain, can contain domain properties.
- Named Domain Class - represents a named concept from a domain, it is a domain class with the name property.
- Embedding Relationship - has-a relationship between two domain classes, shown as solid line, forms tree structure.
- Reference Relationship - reference between two domain classes, shown as dashed line.
- Inheritance - is-a relationship between two domain classes or relationships.
Graphical concrete syntax - Diagram elements
- Geometry Shape - standard geometry shape (e.g. circle, rectangle).
- Image Shape - shape based on image.
- Compartment Shape - shape with subparts (e.g. class inside class diagram).
- Port Shape - known from component diagrams.
- Swimlane - horizontal or vertical line that divides the diagram into partitions, useful for categorization of elements.
- Connector - visual link between shapes.
Connection between abstract and concrete syntax
If you want to place any element or shape to a diagram drag it from the toolbox.
It you want to make a connection between elements select a tool from the toolbox and start to drag in a diagram.
- Diagram Element Map - maps domain classes and relationships to shapes (shape map or connector map).
Decorators are labels, icons, or expand/collapse chevrons that you can add to a shape or connector to customize its appearance on the diagram. You can add multiple decorators to a shape.
Domain type is registered type which can be used as a domain property type.
You can run the solution now using Debug > Start Debugging (or press F5).
Do not forget to run Transform All Templates within the Solution Explorer after every change in the language definition.
Created State Machine Language is shown on the next picture.
The project contains example of validator (see the Dsl/Validation/StateMachineConstraints.cs) and
one simple artifact generator (see Debugging/StateMachineLanguageReport.tt) which generates output for the input file Sample.sml.
If you want to turn on validation in your DSL set the appropriate level of validation in DSL Explorer under the node Editor/Validation.
Thanks goes to all of you for the active participation. Enjoy the design of a DSL.