Chapter 6. Advanced complier extensibility approaches

 

In this chapter

  • Cracking open the Boo compiler
  • Quasi-quotation and meta-methods
  • Extending the compiler
  • Changing the language

Boo offers a rich set of extensibility mechanisms that you can use. We’ll look at them for a couple of reasons: to make sure you understand what is possible, and to expose you to the way they can be used to create easily readable, intuitive, and natural DSLs.

But before we can start talking about compiler extensibility, we need to look at the compiler itself and define some common terms. A lot of Boo’s capabilities are exposed in ways that only make sense if you understand these concepts. I’ll assume compilers aren’t your area of expertise and make sure that you can understand and use the capabilities we’ll look at.

You won’t need this knowledge on a day-to-day basis. You can build most DSLs without going deep into the compiler, but it’s important to understand how things work under the hood. There are some situations when it’s easier to go into the compiler and make a change than work around the problem with the tools that are exposed on the surface.

The basic structure of the Boo compiler is the pipeline—it’s how the compiler transforms bits of text in a file into executable code.

6.1. The compiler pipeline

When the compiler starts to compile a set of files, it runs a set of steps to produce the final assembly. This series of steps is called the compiler pipeline.

6.2. Meta-methods

6.3. Quasi-quotation

6.4. AST macros

6.5. AST attributes

6.6. Compiler steps

6.7. Summary

sitemap