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.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Baars, A.I., Doaitse Swierstra, S., Viera, M.: Typed transformations of typed abstract syntax. In: TLDI 2009, pp. 15–26. ACM (2009)
Baars, A.I., Doaitse Swierstra, S., Viera, M.: Typed transformations of typed grammars: The left corner transform. In: LDTA 2009. ENTCS (2009)
Bravenboer, M., Kalleberg, K.T., Vermaas, R., Visser, E.: Stratego/XT 0.17. A language and toolset for program transformation. Science of Computer Programming 72(1-2), 52–70 (2008)
de Moor, O., Backhouse, K., Doaitse Swierstra, S.: First-class attribute grammars. Informatica (Slovenia) 24(3) (2000)
Dijkstra, A., Fokker, J., Doaitse Swierstra, S.: The architecture of the Utrecht Haskell compiler. In: Haskell 2009, pp. 93–104. ACM (2009)
Heeren, B., Hage, J., Doaitse Swierstra, S.: Scripting the type inference process. In: ICFP 2003, pp. 3–13. ACM Press (2003)
Kiselyov, O., Lämmel, R., Schupke, K.: Strongly typed heterogeneous collections. In: Haskell 2004, pp. 96–107. ACM Press (2004)
Leavenworth, B.M.: Syntax macros and extended translation. Commun. ACM 9(11), 790–793 (1966)
Maddox, W.: Semantically-sensitive macroprocessing. Technical report, Berkeley, CA, USA (1989)
McBride, C.: Faking it simulating dependent types in Haskell. J. Funct. Program. 12(5), 375–392 (2002)
Schrijvers, T., Oliveira, B.C.d.S.: Monads, zippers and views: virtualizing the monad stack. In: ICFP 2011, pp. 32–44. ACM (2011)
Doaitse Swierstra, S.: Parser combinators: from toys to tools. In: Haskell Workshop (2000)
Doaitse Swierstra, S.: Combinator Parsing: A Short Tutorial. In: Bove, A., Barbosa, L.S., Pardo, A., Pinto, J.S. (eds.) LerNet 2008. LNCS, vol. 5520, pp. 252–300. Springer, Heidelberg (2009)
Van Wyk, E., de Moor, O., Backhouse, K., Kwiatkowski, P.: Forwarding in Attribute Grammars for Modular Language Design. In: Horspool, R.N. (ed.) CC 2002. LNCS, vol. 2304, pp. 128–142. Springer, Heidelberg (2002)
Van Wyk, E., Bodin, D., Gao, J., Krishnan, L.: Silver: an extensible attribute grammar system. Science of Computer Programming 75(1-2), 39–54 (2010)
Viera, M., Doaitse Swierstra, S., Swierstra, W.: Attribute grammars fly first-class: how to do aspect oriented programming in Haskell. In: ICFP 2009, pp. 245–256. ACM (2009)
Wirth, N.: Compiler construction. International computer science series. Addison-Wesley (1996)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2012 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Viera, M., Swierstra, D. (2012). Attribute Grammar Macros. In: de Carvalho Junior, F.H., Barbosa, L.S. (eds) Programming Languages. Lecture Notes in Computer Science, vol 7554. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-33182-4_12
Download citation
DOI: https://doi.org/10.1007/978-3-642-33182-4_12
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-33181-7
Online ISBN: 978-3-642-33182-4
eBook Packages: Computer ScienceComputer Science (R0)