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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Ekman, T., Hedin, G.: The JastAdd compiler compiler system, http://jastadd.cs.lth.se
Ekman, T., Hedin, G.: Rewritable Reference Attributed Grammars. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 147–171. Springer, Heidelberg (2004)
Gosling, J., Joy, B., Steele, G., Bracha, G.: The Java Language Specification, 2nd edn. Addison-Wesley, Boston (2000)
Gosling, J., Joy, B., Steele, G., Bracha, G.: The Java Language Specification, 3rd edn. Addison-Wesley, Boston (2005)
Hedin, G.: An overview of door attribute grammars. In: Fritzson, P.A. (ed.) CC 1994. LNCS, vol. 786, pp. 31–51. Springer, Heidelberg (1994)
Hedin, G.: Reference attribute grammars. Informatica (Slovenia) 24(3) (2000)
Hedin, G., Magnusson, E.: JastAdd: an aspect-oriented compiler construction system. Science of Computer Programming 47(1), 37–58 (2003)
Kastens, U., Waite, W.M.: An abstract data type for name analysis. Acta Informatica 28(6), 539–558 (1991)
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)
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)
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)
Saraiva, J.: Purely functional implementation of attribute grammars. PhD thesis, Utrecht University, The Netherlands (1999)
Sloane, A., Waite, W.M., Kastens, U.: Eli - translator construction made easy, http://eli-project.sourceforge.net/
van den Brand, M., Klint, P.: The ASF+SDF MetaEnvironment, http://www.cwi.nl/htbin/sen1/twiki/bin/view/SEN1/MetaEnvironment
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)
Visser, E., Bravenboer, M., Vermaas, R.: Stratego: Strategies for Program Transformation, http://www.program-transformation.org/Stratego/WebHome
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)
Vorthmann, S.A.: Modelling and specifying name visibility and binding semantics. Technical Report CMU//CS-93-158 (1993)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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)