Fowler’s Lair DSL
H. Conrad Cunningham
16 April 2022
Browser Advisory: The HTML version of this textbook requires a browser that supports the display of MathML. A good choice as of April 2022 is a recent version of Firefox from Mozilla.
The Lair DSL case study is based on Martin Fowler’s One Lair and Twenty Ruby DSLs, Chapter 3, in The ThoughtWorks Anthology: Essays on Software Technology and Innovation, Pragmatic Bookshelf, 2008 [1].
list of DSL Patterns from Martin Fowler’s Domain Specific Languages [2]
The original DSLs were developed in Ruby [11,12] by Martin Fowler. All of Fowler’s source code is in this folder or in file LairDSLsRuby.zip.
Fowler elaborates his patterns-based approach to domain-specific languages in his 2010 book by that name [2].
The Lua [5,8] and Python [9,10] versions were developed by H. Conrad Cunningham.
Python’s weak syntactic support for lambdas does not allow the relatively direct approach to be used as in Ruby, Scala, and Lua.
I have not yet developed a Python Lair DSL using these techniques.
I have not yet developed a Python Lair DSL using these techniques.
There is no corresponding example in Fowler’s chapter.
Note: These programs require the Lua LPEG library [Ierusalimschy2009; [7]], which can be installed via luarocks. The library version must be compatible with whatever version of Lua is being used.
Note: These programs require the Python package Parsita [3], a parser combinator library similar to Scala’s.
I thank Martin Fowler for developing the interesting Lair case study and DSL examples [1] and for writing his book on domain-specific languages [2]. I thank Fowler, Thoughtworks, and Pragmatic Bookshelf for making the chapter and source code available.
I developed the Lua versions for my CSci 658 (Software Language Engineering) course in Fall 2013. I thank Roberto Ierusalimschy and the LabLua team at PUC-Rio for developing the interesting minimalistic Lua language [8], LPEG parsing library [4,7], and other resources. I also thank Ierusalimschy for writing the helpful book Programing in Lua [6].
I developed the Python versions for my CSci 658 course in Spring 2018. I thank those who support Python and its extensive ecosystem. I also think David Hagen for developing the parsing combinator library Parsita [3].
I thank the students in the Scala-, Lua-, and Python-based versions of the Software Language Engineering course for their patience with sometimes immature examples and for their feedback.
I retired from the full-time faculty in May 2019. As one of my post-retirement projects, I am continuing work on textbooks related to the courses I taught during myt 30 years as a computer science faculty member. In Spring 2022, I began refining the existing content, integrating additional separately developed materials, reformatting the documents (e.g., using CSS), constructing a unified bibliography (e.g., using citeproc), and improving the build workflow and use of Pandoc. I adapted this index page from a portion of my Spring 2018 course notes.
I maintain this chapter as text in Pandoc’s dialect of Markdown using embedded LaTeX markup for the mathematical formulas and then translate the document to HTML, PDF, and other forms as needed.