O'Reilly logo

Domain Specific Languages by Martin Fowler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. Code Generation

So far in my discussion of implementing DSLs, I’ve talked about parsing some DSL text, usually with the aim of populating a Semantic Model, and putting interesting behavior in that model. In many cases, once we can populate the Semantic Model our work is done—we can just execute the Semantic Model to get the behavior we’re looking for.

While executing the Semantic Model directly is usually the easiest thing to do, there are plenty of times when you can’t do that. You may need your DSL-specified logic to execute in a very different environment, one where it’s difficult or impossible to build a Semantic Model or a parser. It’s in these situations that you can reach for code generation. By using code generation, you ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required