Decorated Attribute Grammars: Attribute Evaluation Meets Strategic Programming

Lennart C. L. Kats, Anthony M. Sloane, Eelco Visser. Decorated Attribute Grammars: Attribute Evaluation Meets Strategic Programming. In Oege de Moor, Michael I. Schwartzbach, editors, Compiler Construction, 18th International Conference, CC 2009, Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2009, York, UK, March 22-29, 2009. Proceedings. Volume 5501 of Lecture Notes in Computer Science, pages 142-157, Springer, 2009. [doi]


Attribute grammars are a powerful specification formalism for tree-based computation, particularly for software language processing. Various extensions have been proposed to abstract over common patterns in attribute grammar specifications. These include various forms of copy rules to support non-local dependencies, collection attributes, and expressing dependencies that are evaluated to a fixed point. Rather than implementing extensions natively in an attribute evaluator, we propose attribute decorators that describe an abstract evaluation mechanism for attributes, making it possible to provide such extensions as part of a library of decorators. Inspired by strategic programming, decorators are specified using generic traversal operators. To demonstrate their effectiveness, we describe how to employ decorators in name, type, and flow analysis.