Skip to main content

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

Abstract

Name analysis for Java is challenging with its complex visibility rules involving nested scopes, inheritance, qualified access, and syntactic ambiguities. We show how Java name analysis including ambiguities related to names of variables, fields, and packages, can be implemented in a declarative and modular manner using the JastAdd compiler construction system.

Declarative attributes and context-dependent rewrites enable the implementation to be modularized in the same way as the informal Java language specification. The individual rules in the specification transfer directly to equations in the implementation. Rewrites are used to define new concepts in terms of existing concepts in an iterative manner in the same way as the informal language specification. This enables equations to use both context-free and context-dependent concepts and leads to improved separation of concerns. A full Java 1.4 compiler has been implemented to validate the technique.

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. Ekman, T., Hedin, G.: The JastAdd compiler compiler system, http://jastadd.cs.lth.se

  2. Ekman, T., Hedin, G.: Rewritable Reference Attributed Grammars. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 147–171. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  3. Gosling, J., Joy, B., Steele, G., Bracha, G.: The Java Language Specification, 2nd edn. Addison-Wesley, Boston (2000)

    Google Scholar 

  4. Gosling, J., Joy, B., Steele, G., Bracha, G.: The Java Language Specification, 3rd edn. Addison-Wesley, Boston (2005)

    Google Scholar 

  5. Hedin, G.: An overview of door attribute grammars. In: Fritzson, P.A. (ed.) CC 1994. LNCS, vol. 786, pp. 31–51. Springer, Heidelberg (1994)

    Google Scholar 

  6. Hedin, G.: Reference attribute grammars. Informatica (Slovenia) 24(3) (2000)

    Google Scholar 

  7. Hedin, G., Magnusson, E.: JastAdd: an aspect-oriented compiler construction system. Science of Computer Programming 47(1), 37–58 (2003)

    Article  MATH  MathSciNet  Google Scholar 

  8. Kastens, U., Waite, W.M.: An abstract data type for name analysis. Acta Informatica 28(6), 539–558 (1991)

    Article  MATH  Google Scholar 

  9. Kiczales, G., Hilsdale, E., Hugunin, J., Kersten, M., Palm, J., Griswold, W.G.: An overview of AspectJ. In: Knudsen, J.L. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 327–355. Springer, Heidelberg (2001)

    Chapter  Google Scholar 

  10. Knuth, D.E.: Semantics of context-free languages. Mathematical Systems Theory 2(2), 127–145 (1968); Correction: Mathematical Systems Theory 5(1) 95–96 (March 1971)

    Article  MATH  MathSciNet  Google Scholar 

  11. Olmos, K., Visser, E.: Composing source-to-source data-flow transformations with rewriting strategies and dependent dynamic rewrite rules. In: Bodik, R. (ed.) CC 2005. LNCS, vol. 3443, pp. 204–220. Springer, Heidelberg (2005)

    Chapter  Google Scholar 

  12. Saraiva, J.: Purely functional implementation of attribute grammars. PhD thesis, Utrecht University, The Netherlands (1999)

    Google Scholar 

  13. Sloane, A., Waite, W.M., Kastens, U.: Eli - translator construction made easy, http://eli-project.sourceforge.net/

  14. van den Brand, M., Klint, P.: The ASF+SDF MetaEnvironment, http://www.cwi.nl/htbin/sen1/twiki/bin/view/SEN1/MetaEnvironment

  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)

    Chapter  Google Scholar 

  16. Visser, E., Bravenboer, M., Vermaas, R.: Stratego: Strategies for Program Transformation, http://www.program-transformation.org/Stratego/WebHome

  17. Vogt, H.H., Swierstra, S.D., Kuiper, M.F.: Higher order attribute grammars. In: Proceedings of the SIGPLAN 1989 Conference on Programming language design and implementation, pp. 131–145. ACM Press, New York (1989)

    Chapter  Google Scholar 

  18. Vorthmann, S.A.: Modelling and specifying name visibility and binding semantics. Technical Report CMU//CS-93-158 (1993)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2006 Springer-Verlag Berlin Heidelberg

About this chapter

Cite this chapter

Ekman, T., Hedin, G. (2006). Modular Name Analysis for Java Using JastAdd. In: Lämmel, R., Saraiva, J., Visser, J. (eds) Generative and Transformational Techniques in Software Engineering. GTTSE 2005. Lecture Notes in Computer Science, vol 4143. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11877028_18

Download citation

  • DOI: https://doi.org/10.1007/11877028_18

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-45778-7

  • Online ISBN: 978-3-540-46235-4

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics