Kiama is a lightweight language processing library for the Scala programming language. It provides Scala programmers with embedded domain-specific languages for attribute grammars and strategy-based term rewriting. This paper provides an introduction to the use of Kiama to solve typical language processing problems by developing analysers and evaluators for a simply-typed lambda calculus. The embeddings of the attribute grammar and rewriting processing paradigms both rely on pattern matching from the base language and each add a simple functional interface that hides details such as attribute caching, circularity checking and strategy representation. The similarities between embeddings for the two processing paradigms show that they have more in common than is usually realised.


Pattern Match Abstract Syntax Lambda Calculus Attribute Grammar Lazy Evaluation 
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.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Odersky, M., Spoon, L., Venners, B.: Programming in Scala. Artima Press (2008)Google Scholar
  2. 2.
    Odersky, M.: Scala language specification, Version 2.7. Programming Methods Laboratory, EPFL, Switzerland (2009)Google Scholar
  3. 3.
    Kastens, U., Sloane, A.M., Waite, W.M.: Generating Software from Specifications. Jones and Bartlett, Sudbury (2007)Google Scholar
  4. 4.
    Hedin, G., Magnusson, E.: Jastadd: an aspect-oriented compiler construction system. Sci. Comput. Program. 47, 37–58 (2003)CrossRefzbMATHGoogle Scholar
  5. 5.
    Visser, E.: Program transformation with Stratego/XT: Rules, strategies, tools, and systems in StrategoXT-0.9. In: Lengauer, C., et al. (eds.) Domain-Specific Program Generation. LNCS, vol. 3016, pp. 216–238. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  6. 6.
    Lämmel, R., Visser, J.: A Strafunski Application Letter. In: Dahl, V. (ed.) PADL 2003. LNCS, vol. 2562, pp. 357–375. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  7. 7.
    Lämmel, R., Peyton Jones, S.: Scrap your boilerplate: a practical design pattern for generic programming. ACM SIGPLAN Notices 38, 26–37 (2003); Proceedings of the ACM SIGPLAN Workshop on Types in Language Design and Implementation (TLDI 2003)CrossRefGoogle Scholar
  8. 8.
    Sloane, A.M., Kats, L.C.L., Visser, E.: A pure object-oriented embedding of attribute grammars. In: Vinju, J., Ekman, T. (eds.) Proceedings of the 9th Workshop on Language Descriptions, Tools and Applications (to appear in ENTCS) (2010)Google Scholar
  9. 9.
    Deransart, P., Jourdan, M., Lorho, B.: Attribute Grammars: Definitions, Systems and Bibliography. LNCS, vol. 323. Springer, Heidelberg (1988)zbMATHGoogle Scholar
  10. 10.
    Paakki, J.: Attribute grammar paradigms—a high-level methodology in language implementation. ACM Comput. Surv. 27, 196–255 (1995)CrossRefGoogle Scholar
  11. 11.
    Jourdan, M.: An optimal-time recursive evaluator for attribute grammars. In: Paul, M., Robinet, B. (eds.) Programming 1984. LNCS, vol. 167, pp. 167–178. Springer, Heidelberg (1984)CrossRefGoogle Scholar
  12. 12.
    Reynolds, J.C.: Theories of Programming Languages. Camridge University Press, Camridge (1998)CrossRefzbMATHGoogle Scholar
  13. 13.
    Hedin, G.: Reference Attributed Grammars. Informatica (Slovenia) 24, 301–317 (2000)zbMATHGoogle Scholar
  14. 14.
    Dolstra, E., Visser, E.: Building interpreters with rewriting strategies. In: Proceedings of the 2nd Workshop on Language Descriptions, Tools and Applications. Electronic Notes in Theoretical Computer Science, vol. 65, pp. 57–76 (2002)Google Scholar
  15. 15.
    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
  16. 16.
    Kats, L., Sloane, A.M., Visser, E.: Decorated attribute grammars: Attribute evaluation meets strategic programming. In: de Moor, O., Schwartzbach, M.I. (eds.) CC 2009. LNCS, vol. 5501, pp. 142–157. Springer, Heidelberg (2009)CrossRefGoogle Scholar
  17. 17.
    Boyland, J.T.: Descriptional Composition of Compiler Components. PhD thesis, University of California, Berkeley, Available as technical report UCB//CSD-96-916 (1996)Google Scholar
  18. 18.
    Magnusson, E., Ekman, T., Hedin, G.: Extending attribute grammars with collection attributes - evaluation and applications. In: Proceedings of the Seventh IEEE International Working Conference on Source Code Analysis and Manipulation. IEEE Press, Los Alamitos (2007)Google Scholar
  19. 19.
    van den Brand, M.G.J., van Deursen, A., Heering, J., Jong, H., Jonge, M., Kuipers, T., Klint, P., Moonen, L., Olivier, P.A., Scheerder, J., Vinju, J.J., Visser, E., Visser, J.: The ASF+SDF meta-environment: A component-based language development environment. In: Wilhelm, R. (ed.) CC 2001. LNCS, vol. 2027, pp. 365–370. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  20. 20.
    Bravenboer, M., Visser, E.: Concrete syntax for objects. In: Schmidt, D.C. (ed.) Proceedings of the 19th ACM SIGPLAN Conference on Object-Oriented Programing, Systems, Languages, and Applications (OOPSLA 2004), Vancouver, Canada, pp. 365–383. ACM Press, New York (2004)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Anthony M. Sloane
    • 1
  1. 1.Department of ComputingMacquarie UniversitySydneyAustralia

Personalised recommendations