Modular Name Analysis for Java Using JastAdd

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.

[1]  William M. Waite,et al.  An abstract data type for name analysis , 1991, Acta Informatica.

[2]  S. Doaitse Swierstra,et al.  Higher order attribute grammars , 1989, PLDI '89.

[3]  Eelco Visser,et al.  Composing Source-to-Source Data-Flow Transformations with Rewriting Strategies and Dependent Dynamic Rewrite Rules , 2005, CC.

[4]  Guy L. Steele,et al.  The Java Language Specification , 1996 .

[5]  Görel Hedin An Overview of Door Attribute Grammars , 1994, CC.

[6]  Scott A. Vorthmann Modelling and Specifying Name Visibility and Binding Semantics , 1993 .

[7]  Martin Odersky ECOOP 2004 – Object-Oriented Programming , 2004, Lecture Notes in Computer Science.

[8]  Guy L. Steele,et al.  Java Language Specification, Second Edition: The Java Series , 2000 .

[9]  Eric Van Wyk,et al.  Forwarding in Attribute Grammars for Modular Language Design , 2002, CC.

[10]  Donald E. Knuth,et al.  Semantics of context-free languages , 1968, Mathematical systems theory.

[11]  Torbjörn Ekman,et al.  Rewritable Reference Attributed Grammars , 2004, ECOOP.

[12]  William G. Griswold,et al.  An Overview of AspectJ , 2001, ECOOP.

[13]  Jørgen Lindskov Knudsen ECOOP 2001 — Object-Oriented Programming , 2001, Lecture Notes in Computer Science.

[14]  James Gosling,et al.  The Java Language Specification, 3rd Edition , 2005 .

[15]  Guy L. Steele,et al.  Java(TM) Language Specification, The (3rd Edition) (Java (Addison-Wesley)) , 2005 .

[16]  Joao Paulo Saraiva,et al.  Purely Functional Implementation of Attribute Grammars , 1999 .

[17]  Görel Hedin,et al.  JastAdd--an aspect-oriented compiler construction system , 2003, Sci. Comput. Program..

[18]  Anthony M. Sloane Eli: translator construction made easy , 2003 .

[19]  James Gosling The Java Language Specification - Second Edition , 2000 .