CPSC 425 Spring 2006
HW 2: More Grammars and Syntax

Read Webber sections 3.1-3.4.
  1. Exercise 3.1 (a), (b), (c)

  2. Go to the online Java Language Specification at http://java.sun.com/docs/books/jls/second_edition/html/j.title.doc.html, and use this document to answer the following questions. (You may find the index helful.) Answer each with an English explanation, but refer to the grammar productions that support your answers.

    1. What is the structure of a Java identifier?

    2. Which of the following statements is/are legal in Java?

      1. x;
      2. 5;
      3. x=z=y;

    3. Which has higher precedence, && or ||?

  3. Go to http://www.99-bottles-of-beer.net. This site contains programs in 880 different languages to print all verses of the song "99 bottles of beer on the wall." Browse through some of them and choose a version in a language you don't know that is very different from Java. Print the program, then find out enough about the language (many of the pages have links to pages that describe the languages) to understand how the program works. Write this explanation (do not just print pages from the language manual; explain what is going on in your actual program) and be prepared to explain it to the class.