COMPILER DESIGN

Project 1

Due on February 15th,1999.

  1. Read the language reference manual for Java in the compiler design course home page LRM In Postscript (local copy).

    Tutorial is in Tutorial .

    Language Refernce Manual and other useful material is in LRM

    A book by James Gosling, Bill Joy and Guy Steele, "The Java Language Specification" Addison Wesley describes the syntax and semantics of Java.

    A book by Tim Lindholm and Frank Yellin, "The Java Virtual Machine Specification", Addison Wesley describes virtual Macine.

  2. Write five sample Java programs which utilizes different features of the language.

  3. Write a lex program and yacc program that takes any Java program that prints(reports) statistics about the program as well as cross references for the given Java Program. The statistics information includes
    1. Number of Keywords and how many of each type are used.
    2. Number of assignent statements.
    3. Number of conditional statements.
    4. Number of iteration (for, while) statements.
    5. Number of function calls.
    6. Nesting Depth of while statements.

    The cross reference includes
    1. Identifiers- which lines they are defined and which lines they are used.
    2. function names - which lines they are defined and where they are used.

    For hints: you may want to look at java beautifier programs . They can be found http://www.cs.rpi.edu/~moorthy/Courses/compiler/JB/.