Decorated Attribute Grammars: Attribute Evaluation Meets Strategic Programming

  • Lennart C. L. Kats
  • Anthony M. Sloane
  • Eelco Visser
Part of the Lecture Notes in Computer Science book series (LNCS, volume 5501)

Abstract

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.

References

  1. 1.
    Aster project home page, http://strategoxt.org/Stratego/Aster
  2. 2.
    Baars, A., Swierstra, D., Löh, A.: UU AG System User Manual. Department of Computer Science, Utrecht University (September 2003)Google Scholar
  3. 3.
    Bird, R.: Using circular programs to eliminate multiple traversals of data. Acta Informatica 21(3), 239–250 (1984)CrossRefMATHGoogle Scholar
  4. 4.
    Boyland, J.: Descriptional Composition of Compiler Components. PhD thesis (1996)Google Scholar
  5. 5.
    Boyland, J.: Remote attribute grammars. Journal of the ACM (JACM) 52(4), 627–687 (2005)MathSciNetCrossRefMATHGoogle Scholar
  6. 6.
    Boyland, J., Graham, S.L.: Composing tree attributions. In: POPL 1994, pp. 375–388. ACM, New York (1994)Google Scholar
  7. 7.
    van den Brand, M.G.J., de Jong, H., Klint, P., Olivier, P.: Efficient annotated terms. Software, Practice & Experience 30(3), 259–291 (2000)CrossRefGoogle Scholar
  8. 8.
    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
  9. 9.
    Ekman, T., Hedin, G.: Rewritable reference attributed grammars. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 144–169. Springer, Heidelberg (2004)Google Scholar
  10. 10.
    Farnum, C.: Pattern-based tree attribution. In: POPL 1992, pp. 211–222 (1992)Google Scholar
  11. 11.
    Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design patterns: elements of reusable object-oriented software. Addison-Wesley Professional, Reading (1995)MATHGoogle Scholar
  12. 12.
    Hedin, G.: Reference attributed grammars. Informatica (Slovenia) 24(3), 301–317 (2000)MATHGoogle Scholar
  13. 13.
    Hedin, G., Magnusson, E.: JastAdd – an aspect-oriented compiler construction system. Science of Computer Programming 47(1), 37–58 (2003)CrossRefMATHGoogle Scholar
  14. 14.
    Jalili, F.: A general linear time evaluator for attribute grammars. ACM SIGPLAN Notices 18(9), 35–44 (1983)CrossRefGoogle Scholar
  15. 15.
    Kastens, U., Waite, W.M.: Modularity and reusability in attribute grammars. Acta Informatica 31(7), 601–627 (1994)CrossRefMATHGoogle Scholar
  16. 16.
    Kats, L.C.L., Kalleberg, K.T., Visser, E.: Generating editors for embedded languages. Integrating SGLR into IMP. In: LDTA 2008 (April 2008)Google Scholar
  17. 17.
    Kats, L.C.L., Sloane, A.M., Visser, E.: Decorated attribute grammars – Attribute evaluation meets strategic programming. Extended technical report TUD-SERG-2008-038a. Software Engineering Research Group, Delft University of Technology (2008), http://swerl.tudelft.nl/bin/view/Main/TechnicalReports#2008-038
  18. 18.
    Kiczales, G., et al.: Aspect-oriented programming. In: Aksit, M., Matsuoka, S. (eds.) ECOOP 1997. LNCS, vol. 1241, pp. 220–242. Springer, Heidelberg (1997)CrossRefGoogle Scholar
  19. 19.
    Knuth, D.E.: Semantics of context-free languages. Math. Syst. Theory 2(2), 127–145 (1968)MathSciNetCrossRefMATHGoogle Scholar
  20. 20.
    Laemmel, R., Visser, E., Visser, J.: Strategic programming meets adaptive programming. In: Proceedings of Aspect-Oriented Software Development (AOSD 2003), Boston, USA, pp. 168–177. ACM Press, New York (2003)Google Scholar
  21. 21.
    Lämmel, R.: Typed generic traversal with term rewriting strategies. Journal of Logic and Algebraic Programming 54(1), 1–64 (2003)MathSciNetCrossRefMATHGoogle Scholar
  22. 22.
    Magnusson, E., Ekman, T., Hedin, G.: Extending attribute grammars with collection attributes – evaluation and applications. In: Proc. of the Int. Working Conference on Source Code Analysis and Manipulation, pp. 69–80 (2007)Google Scholar
  23. 23.
    Magnusson, E., Hedin, G.: Circular reference attributed grammars - their evaluation and applications. Science of Computer Programming 68(1), 21–37 (2007)MathSciNetCrossRefMATHGoogle Scholar
  24. 24.
    de Moor, O., Backhouse, K., Swierstra, S.: First-class attribute grammars. Informatica 24(3), 329–341 (2000)MATHGoogle Scholar
  25. 25.
    Nilsson-Nyman, E., Ekman, T., Hedin, G., Magnusson, E.: Declarative intraprocedural flow analysis of Java source code. In: LDTA 2008 (2008)Google Scholar
  26. 26.
    Paakki, J.: Attribute grammar paradigms - a high-level methodology in language implementation. ACM Computing Surveys (CSUR) 27(2), 196–255 (1995)CrossRefGoogle Scholar
  27. 27.
    van Rossum, G.: Python Reference Manual. iUniverse (2000)Google Scholar
  28. 28.
    Steele, G.: Growing a language. Higher Order Symb. Comp. 12(3), 221–236 (1999)CrossRefGoogle Scholar
  29. 29.
    Van Wyk, E., Bodin, D., Gao, J., Krishnan, L.: Silver: an extensible attribute grammar system. In: LDTA 2007. ENTCS, vol. 203, pp. 103–116. Elsevier Science, Amsterdam (2008)Google Scholar
  30. 30.
    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
  31. 31.
    Van Wyk, E., Krishnan, L., Bodin, D., Johnson, E.: Adding domain-specific and general purpose language features to Java with the Java language extender. In: Companion to OOPSLA 2006, pp. 728–729. ACM, New York (2006)Google Scholar
  32. 32.
    Visser, E.: Meta-programming with concrete object syntax. In: Batory, D., Consel, C., Taha, W. (eds.) GPCE 2002. LNCS, vol. 2487, pp. 299–315. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  33. 33.
    Visser, E., Benaissa, Z.-e.-A., Tolmach, A.: Building program optimizers with rewriting strategies. In: International Conference on Functional Programming (ICFP 1998), pp. 13–26. ACM, New York (1998)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2009

Authors and Affiliations

  • Lennart C. L. Kats
    • 1
  • Anthony M. Sloane
    • 1
    • 2
  • Eelco Visser
    • 1
  1. 1.Software Engineering Research GroupDelft University of TechnologyThe Netherlands
  2. 2.Department of ComputingMacquarie UniversitySydneyAustralia

Personalised recommendations