Skip to Content

Implementing Martin Fowler's state machine DSL in textX

ptags: dsl, textX

Well, you know what they say:

You aren’t making a DSL tool if you haven’t implemented Martin Fowler’s State Machine language using your tool yet ;)

This is a well known DSL example from his book Domain-Specific Languages. If you are doing stuff in the field of DSLs you should definitely read this book. There is an excerpt from the book available on-line so I advise you to read it before watching the video below.

Another book which I also highly recommend is DSL Engineering: Designing, Implementing and Using Domain-Specific Languages by Markus Völter. Also an excelent read, although oriented more towards modeling languages with graphical syntaxes (a.k.a. Domain-Specific Modeling), is the book Domain-Specific Modeling: Enabling Full Code Generation by Steven Kelly and Juha-Pekka Tolvanen.

In the video bellow I am explaining the implementation of the Martin Fowler’s State Machine language in textX by:

  • Specifying the grammar of the language
  • Creating source code generator by generating a nice dot state charts
  • Creating model interpreter in Python

This tutorial is a good overview of textX workflow and capabilities but if you want to see basic introduction together with installation and the first steps I suggest you to watch video introduction to textX first.

Full source code presented in the video is available at the project GitHub repository. I hope you will enjoy watching this video as much I enjoyed playing with this little language.