Lab enabling the beginners to learn how to use the DSL tools in one day.
Objective of this Lab.
The objective of this Lab is to create a specialized language by using the domain-specific language (DSL) Tools, and to customize it by using code that is based on the Visual Studio SDK. The DSL Tools are especially beneficial when you want to create a vertical language that is suitable for your business, and from the models that the language manipulates, generate the code for your business Framework. Nevertheless, because it is difficult to ensure that everyone who takes this training knows the professional tasks that are addressed by the targeted business Framework, we will settle for a horizontal (that is, technical) DSL that lets us learn how to use different aspects of DSL Tools.
As an example, with the DSL for state machines that you'll create, you'll be able to express the creation of a Line, taking into account the creation from the center and one extremity rather than from both extremities when the user presses the 'C' key:
In addition to providing training, this document also shows an approach to DSL design.
PrerequisitesBefore you start this Lab, ensure that Visual Studio 2008 SDK 1.1 is installed on your computer. This can be downloaded for free from
http://msdn.com/vsx In addition, to simplify the creation of your code generators, download and install a T4 editor from
http://www.t4editor.net/. A T4 editor provides syntactic coloring to aid in the editing of your T4 templates, including IntelliSense for the professional version of it.
OverviewThe approach adopted in this Lab is the following:
#Creation of a DSL from an “Empty” DSL model. (45 steps: this chapter)
#Creation of a metamodel for finite-state automata: this metamodel includes the StateMachine, State, and Transition concepts. For now we will assume that the states do not have substates (27 steps).
#Specification of graphical notation with our DSL (51 steps).
#Test of our DSL in the test version of Visual Studio.
#Improvement of the MMI of the DSL.
#Addition of consistency rules to the model.
#Addition of validation rules to the model.
#Creation of a code generator that targets a Framework for implementation of finite-state automata.
#Test of our DSL on a few amusing examples.
#Addition of a setup to distribute our DSL.
The text for the Lab is available in thedowload tab