Advertisement

Attribute Grammar Macros

  • Marcos Viera
  • Doaitse Swierstra
Part of the Lecture Notes in Computer Science book series (LNCS, 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.

Keywords

Base Rule Semantic Function Type Check Attribute Grammar Abstract Syntax Tree 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 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. 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. 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)MathSciNetCrossRefGoogle Scholar
  4. 4.
    de Moor, O., Backhouse, K., Doaitse Swierstra, S.: First-class attribute grammars. Informatica (Slovenia) 24(3) (2000)Google Scholar
  5. 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. 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. 7.
    Kiselyov, O., Lämmel, R., Schupke, K.: Strongly typed heterogeneous collections. In: Haskell 2004, pp. 96–107. ACM Press (2004)Google Scholar
  8. 8.
    Leavenworth, B.M.: Syntax macros and extended translation. Commun. ACM 9(11), 790–793 (1966)zbMATHCrossRefGoogle Scholar
  9. 9.
    Maddox, W.: Semantically-sensitive macroprocessing. Technical report, Berkeley, CA, USA (1989)Google Scholar
  10. 10.
    McBride, C.: Faking it simulating dependent types in Haskell. J. Funct. Program. 12(5), 375–392 (2002)MathSciNetzbMATHCrossRefGoogle Scholar
  11. 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. 12.
    Doaitse Swierstra, S.: Parser combinators: from toys to tools. In: Haskell Workshop (2000)Google Scholar
  13. 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)CrossRefGoogle Scholar
  14. 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)CrossRefGoogle Scholar
  15. 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)MathSciNetzbMATHCrossRefGoogle Scholar
  16. 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. 17.
    Wirth, N.: Compiler construction. International computer science series. Addison-Wesley (1996)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Marcos Viera
    • 1
  • Doaitse Swierstra
    • 2
  1. 1.Instituto de ComputaciónUniversidad de la RepúblicaMontevideoUruguay
  2. 2.Department of Computer ScienceUtrecht UniversityUtrechtThe Netherlands

Personalised recommendations