Attribute grammar macros

  • Authors:
  • Marcos Viera;Doaitse Swierstra

  • Affiliations:
  • Instituto de Computación, Universidad de la República, Montevideo, Uruguay;Department of Computer Science, Utrecht University, Utrecht, The Netherlands

  • Venue:
  • SBLP'12 Proceedings of the 16th Brazilian conference on Programming Languages
  • Year:
  • 2012

Quantified Score

Hi-index 0.00

Visualization

Abstract

Having extensible languages is appealing, but raises the question of how to construct extensible compilers and how to compose compilers out of a collection of pre-compiled components. Being able to deal with attribute grammar fragments as first-class values makes it possible to describe semantics in a compositional way; this leads naturally to a plug-in architecture, in which a core compiler can be constructed as a (collection of) pre-compiled component(s), and to which extra components can safely be added as need arises. We extend AspectAG, a Haskell library for building strongly typed first-class attribute grammars, with a set of combinators that make it easy to describe semantics in terms of already existing semantics in a macro-like style, just as syntax macros extend the syntax of a language. We also show how existing semantics can be redefined, thus adapting some aspects from the behavior defined by the macros.