The following paper was submitted to the Haskell 2010.
: First Class Syntax, Semantics, and Their Composition
: How to assemble a compiler on the fly
: Marcos Viera, S. Doaitse Swierstra, Atze Dijkstra and Arthur Baars
: The idea of having an extendible language is appealing and raises the
question how to construct extensible
compilers. In recent years we have developed a collection of
techniques which together make
this possible in Haskell: transformation of typed abstract
syntax trees makes it possible to construct parsers on the fly in a
type-safe way, parser combinators make it possible to construct
parsers dynamically, and first-class attribute grammars make it possible to define semantics in a compositional way.
In this paper we show how, using a small example language and its extension, these
techniques come together in constructing compilers out of a collection of pre-compiled, statically type-checked, possibly mutually
dependent ``language-definition fragments''. This way of constructing a compiler brings syntax macros for free.