Chapter 4. Implementing an Internal DSL

Now that I’ve gone through some general issues in implementing DSLs, it’s time to go into the specifics of implementing particular flavors of DSLs. I’ve decided to start with internal DSLs as they are often the most approachable form of DSLs to write. Unlike external DSLs, you don’t need to learn about grammars and language parsing, and unlike language workbenches, you don’t need any special tools. With internal DSLs you work in your regular language environment. As a result, it’s no surprise that there’s been a lot of interest in internal DSLs in the last couple of years.

When you use internal DSLs, you are very much constrained by your host language. Since any expression you use must be a legal expression ...

Get Domain Specific Languages now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.