Skip to main content

Attribute Grammar Macros

  • Conference paper

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 7554))

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

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   54.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   72.00
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Baars, A.I., Doaitse Swierstra, S., Viera, M.: Typed transformations of typed abstract syntax. In: TLDI 2009, pp. 15–26. ACM (2009)

    Google Scholar 

  2. Baars, A.I., Doaitse Swierstra, S., Viera, M.: Typed transformations of typed grammars: The left corner transform. In: LDTA 2009. ENTCS (2009)

    Google Scholar 

  3. 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)

    Article  MathSciNet  Google Scholar 

  4. de Moor, O., Backhouse, K., Doaitse Swierstra, S.: First-class attribute grammars. Informatica (Slovenia) 24(3) (2000)

    Google Scholar 

  5. Dijkstra, A., Fokker, J., Doaitse Swierstra, S.: The architecture of the Utrecht Haskell compiler. In: Haskell 2009, pp. 93–104. ACM (2009)

    Google Scholar 

  6. Heeren, B., Hage, J., Doaitse Swierstra, S.: Scripting the type inference process. In: ICFP 2003, pp. 3–13. ACM Press (2003)

    Google Scholar 

  7. Kiselyov, O., Lämmel, R., Schupke, K.: Strongly typed heterogeneous collections. In: Haskell 2004, pp. 96–107. ACM Press (2004)

    Google Scholar 

  8. Leavenworth, B.M.: Syntax macros and extended translation. Commun. ACM 9(11), 790–793 (1966)

    Article  Google Scholar 

  9. Maddox, W.: Semantically-sensitive macroprocessing. Technical report, Berkeley, CA, USA (1989)

    Google Scholar 

  10. McBride, C.: Faking it simulating dependent types in Haskell. J. Funct. Program. 12(5), 375–392 (2002)

    Article  MathSciNet  Google Scholar 

  11. Schrijvers, T., Oliveira, B.C.d.S.: Monads, zippers and views: virtualizing the monad stack. In: ICFP 2011, pp. 32–44. ACM (2011)

    Google Scholar 

  12. Doaitse Swierstra, S.: Parser combinators: from toys to tools. In: Haskell Workshop (2000)

    Google Scholar 

  13. 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)

    Chapter  Google Scholar 

  14. 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)

    Chapter  Google Scholar 

  15. 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)

    Article  MathSciNet  Google Scholar 

  16. 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)

    Google Scholar 

  17. Wirth, N.: Compiler construction. International computer science series. Addison-Wesley (1996)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics