Skip to main content

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

Abstract

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
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

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Å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)

    Article  MathSciNet  MATH  Google Scholar 

  2. 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. Boyland, J.T.: Remote attribute grammars. J. ACM 52(4), 627–687 (2005)

    Article  MathSciNet  MATH  Google Scholar 

  4. Chidamber, S.R., Kemerer, C.F.: A metrics suite for object oriented design. IEEE Trans. Softw. Eng. 20(6), 476–493 (1994)

    Article  Google Scholar 

  5. Deransart, P., Jourdan, M., Lorho, B.: Attribute Grammars: Definitions, Systems, and Bibliography. LNCS, vol. 323. Springer, Heidelberg (1988)

    MATH  Google Scholar 

  6. 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. Ekman, T., Hedin, G.: Rewritable Reference Attributed Grammars. In: Vetta, A. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 147–171. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

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

    Chapter  Google Scholar 

  9. 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. Ekman, T., Hedin, G.: The Jastadd Extensible Java Compiler. In: OOPSLA 2007, pp. 1–18. ACM, New York (2007)

    Google Scholar 

  11. Ekman, T.: Extensible Compiler Construction. PhD thesis, Lund University, Sweden (June 2006)

    Google Scholar 

  12. 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. Hedin, G.: An Overview of Door Attribute Grammars. In: Fritzson, P.A. (ed.) CC 1994. LNCS, vol. 786, pp. 31–51. Springer, Heidelberg (1994)

    Chapter  Google Scholar 

  14. Hedin, G.: Reference Attributed Grammars. Informatica (Slovenia) 24(3), 301–317 (2000)

    MATH  Google Scholar 

  15. JModelica.org, Modelon AB (2009), http://www.jmodelica.org

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

    Chapter  Google Scholar 

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

    Article  MathSciNet  MATH  Google Scholar 

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

    Chapter  Google Scholar 

  19. Kastens, U., Hutt, B., Zimmermann, E.: GAG: A Practical Compiler Generator. LNCS, vol. 141. Springer, Heidelberg (1982)

    MATH  Google Scholar 

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

    Article  MathSciNet  MATH  Google Scholar 

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

    Chapter  Google Scholar 

  22. Magnusson, E., Ekman, T., Hedin, G.: Demand-driven evaluation of collection attributes. Automated Software Engineering 16(2), 291–322 (2009)

    Article  Google Scholar 

  23. Magnusson, E., Hedin, G.: Circular Reference Attributed Grammars - Their Evaluation and Applications. Science of Computer Programming 68(1), 21–37 (2007)

    Article  MathSciNet  MATH  Google Scholar 

  24. The Modelica Association (2010), http://www.modelica.org

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

    Article  Google Scholar 

  26. Paakki, J.: Attribute grammar paradigms - a high-level methodology in language implementation. ACM Computing Surveys 27(2), 196–255 (1995)

    Article  Google Scholar 

  27. Poetzsch-Heffter, A.: Prototyping realistic programming languages based on formal specifications. Acta Informatica 34, 737–772 (1997)

    Article  MathSciNet  MATH  Google Scholar 

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

    Chapter  Google Scholar 

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

    MATH  Google Scholar 

  31. 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. 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  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2011 Springer-Verlag Berlin Heidelberg

About this chapter

Cite this chapter

Hedin, G. (2011). An Introductory Tutorial on JastAdd Attribute Grammars. In: Fernandes, J.M., Lämmel, R., Visser, J., Saraiva, J. (eds) Generative and Transformational Techniques in Software Engineering III. GTTSE 2009. Lecture Notes in Computer Science, vol 6491. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-18023-1_4

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-18023-1_4

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-18022-4

  • Online ISBN: 978-3-642-18023-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics