First-class Attribute Grammars
Oege de Moor, Kevin Backhouse, S. Doaitse Swierstra · 2000
This paper is a contribution to the ongoing quest for modular descriptions of language processors, with the specific aim of rapidly prototyping domain-specific languages [31]. Some might argue that this problem has been solved in the '80s, which saw a proliferation of language processors based on attribute grammars [11, 17, 22, 33]. Others might argue that functional programming languages such as ML are adequate for the purpose, without any further extensions. We do not agree with either viewpoint: attribute grammars, despite their many attractions, are not even in wide-spread use in the academic community. This may be due to restrictions imposed by attribute definition languages, which result in a lack of compositionality. Functional programming languages tend to yield descriptions that are compact, but they can become rather entangled as well. In this paper we would like to argue for a blend of both styles, by embedding attribute grammars as a set of features in a programming language. In doing so, we hope to overcome the restrictions of typical attribute grammar based systems, in particular regarding their modularity. There exists a well-known encoding of attribute grammars into programming languages that have lazy data structures [15, 25]. This encoding has been dismissed on the following grounds: