JastAdd is an open-source system for generating compilers and other language-based tools. Its declarative specification language is based on reference attribute grammars and object-orientation. This allows tools to be implemented as composable extensible modules, as exemplified by JastAddJ, a complete extensible Java compiler. This tutorial gives an introduction to JastAdd and its core attribute grammar mechanisms, and how to use them when solving key problems in building language-based tools. A simple state machine language is used as a running example, showing the essence of name analysis, adding graphs to the abstract syntax tree, and computing circular properties like reachability. Exercises are included, and code for the examples is available online.


attribute grammars language-based tools reference attributes object-oriented model 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. [ÅEH10]
    Åkesson, J., Ekman, T., Hedin, G.: Implementation of a Modelica compiler using JastAdd attribute grammars. Science of Computer Programming 73(1-2), 21–38 (2010)MathSciNetCrossRefzbMATHGoogle Scholar
  2. [Boy96]
    Boyland, J.T.: Descriptional Composition of Compiler Components. PhD thesis, University of California, Berkeley, Available as technical report UCB//CSD-96-916 (September 1996)Google Scholar
  3. [Boy05]
    Boyland, J.T.: Remote attribute grammars. J. ACM 52(4), 627–687 (2005)MathSciNetCrossRefzbMATHGoogle Scholar
  4. [CK94]
    Chidamber, S.R., Kemerer, C.F.: A metrics suite for object oriented design. IEEE Trans. Softw. Eng. 20(6), 476–493 (1994)CrossRefGoogle Scholar
  5. [DJL88]
    Deransart, P., Jourdan, M., Lorho, B.: Attribute Grammars: Definitions, Systems, and Bibliography. LNCS, vol. 323. Springer, Heidelberg (1988)zbMATHGoogle Scholar
  6. [DSST86]
    Driscoll, J.R., Sarnak, N., Sleator, D.D., Tarjan, R.E.: Making data structures persistent. In: Proceedings of the 18th Annual ACM Symposium on Theory of Computing, STOC 1986, pp. 109–121. ACM, New York (1986)Google Scholar
  7. [EH04]
    Ekman, T., Hedin, G.: Rewritable Reference Attributed Grammars. In: Vetta, A. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 147–171. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  8. [EH06]
    Ekman, T., Hedin, G.: Modular name analysis for java using JastAdd. In: Lämmel, R., Saraiva, J., Visser, J. (eds.) GTTSE 2005. LNCS, vol. 4143, pp. 422–436. Springer, Heidelberg (2006)CrossRefGoogle Scholar
  9. [EH07a]
    Ekman, T., Hedin, G.: Pluggable checking and inferencing of non-null types for Java. Proceedings of TOOLS Europe 2007, Journal of Object Technology 6(9), 455–475 (2007)Google Scholar
  10. [EH07b]
    Ekman, T., Hedin, G.: The Jastadd Extensible Java Compiler. In: OOPSLA 2007, pp. 1–18. ACM, New York (2007)Google Scholar
  11. [Ekm06]
    Ekman, T.: Extensible Compiler Construction. PhD thesis, Lund University, Sweden (June 2006)Google Scholar
  12. [Far86]
    Farrow, R.: Automatic generation of fixed-point-finding evaluators for circular, but well-defined, attribute grammars. In: Proceedings of the SIGPLAN Symposium on Compiler Construction, pp. 85–98. ACM Press, New York (1986)Google Scholar
  13. [Hed94]
    Hedin, G.: An Overview of Door Attribute Grammars. In: Fritzson, P.A. (ed.) CC 1994. LNCS, vol. 786, pp. 31–51. Springer, Heidelberg (1994)CrossRefGoogle Scholar
  14. [Hed00]
    Hedin, G.: Reference Attributed Grammars. Informatica (Slovenia) 24(3), 301–317 (2000)zbMATHGoogle Scholar
  15. [JMo09], Modelon AB (2009),
  16. [Jou84]
    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
  17. [Kas80]
    Kastens, U.: Ordered attribute grammars. Acta Informatica 13(3), 229–256 (1980); See also: Bericht 7/78, Institut für Informatik II, University Karlsruhe (1978)MathSciNetCrossRefzbMATHGoogle Scholar
  18. [KHH+01]
    Kiczales, G., Hilsdale, E., Hugunin, J., Kersten, M., Palm, J., Griswold, W.G.: An overview of AspectJ. In: Lee, S.H. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 327–355. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  19. [KHZ82]
    Kastens, U., Hutt, B., Zimmermann, E.: GAG: A Practical Compiler Generator. LNCS, vol. 141. Springer, Heidelberg (1982)zbMATHGoogle Scholar
  20. [Knu68]
    Knuth, D.E.: Semantics of context-free languages. Mathematical Systems Theory 2(2), 127–145 (1968); Correction: Mathematical Systems Theory 5(1), 95–96 (1971)MathSciNetCrossRefzbMATHGoogle Scholar
  21. [KSV09]
    Kats, L.C.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
  22. [MEH09]
    Magnusson, E., Ekman, T., Hedin, G.: Demand-driven evaluation of collection attributes. Automated Software Engineering 16(2), 291–322 (2009)CrossRefGoogle Scholar
  23. [MH07]
    Magnusson, E., Hedin, G.: Circular Reference Attributed Grammars - Their Evaluation and Applications. Science of Computer Programming 68(1), 21–37 (2007)MathSciNetCrossRefzbMATHGoogle Scholar
  24. [Mod10]
    The Modelica Association (2010),
  25. [NNEHM09]
    Nilsson-Nyman, E., Ekman, T., Hedin, G., Magnusson, E.: Declarative intraprocedural flow analysis of Java source code. Electronic Notes in Theoretical Computer Science 238(5), 155–171 (2009)CrossRefGoogle Scholar
  26. [Paa95]
    Paakki, J.: Attribute grammar paradigms - a high-level methodology in language implementation. ACM Computing Surveys 27(2), 196–255 (1995)CrossRefGoogle Scholar
  27. [PH97]
    Poetzsch-Heffter, A.: Prototyping realistic programming languages based on formal specifications. Acta Informatica 34, 737–772 (1997)MathSciNetCrossRefzbMATHGoogle Scholar
  28. [RT84]
    Reps, T., Teitelbaum, T.: The Synthesizer Generator. In: ACM SIGSOFT/SIGPLAN Symp. on Practical Software Development Environments, pp. 42–48. ACM Press, Pittsburgh (April 1984)CrossRefGoogle Scholar
  29. [SKV09]
    Sloane, A.M., Kats, L.C.L., Visser, E.: A pure object-oriented embedding of attribute grammars. In: Ekman, T., Vinju, J. (eds.) Proceedings of the Ninth Workshop on Language Descriptions, Tools, and Applications, LDTA 2009 (2009)Google Scholar
  30. [UDP+82]
    Uhl, J., Drossopoulou, S., Persch, G., Goos, G., Dausmann, M., Winterstein, G., Kirchgässner, W.: An Attribute Grammar for the Semantic Analysis of ADA. LNCS, vol. 139. Springer, Heidelberg (1982)zbMATHGoogle Scholar
  31. [VSK89]
    Vogt, H.H., Swierstra, S.D., Kuiper, M.F.: Higher order attribute grammars. In: Proceedings of PLDI 1989, pp. 131–145. ACM Press, New York (1989)Google Scholar
  32. [WBGK10]
    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)MathSciNetCrossRefzbMATHGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Görel Hedin
    • 1
  1. 1.Lund UniversitySweden

Personalised recommendations