CS 250 - Programming Languages                                 Spring 2004

Assignment 4 -- Due March 12.

Read appropriate sections of chapters 4 and 5, and answer the following questions. You may turn them in either in hardcopy or by e-mail to allen@bowdoin.edu

You may complete this assignment either alone or in teams of two.

The goal here is twofold.  First, you should understand the extensions to the Jay lexical, concrete and abstract syntax, type checking functions (V), and semantic functions (M) for new language Jay+Methods that appear in sections 4.7 and 5.2.  

Second, you should complete the implementation of these extensions so that it will properly parse Jay programs that contain methods, such as the program K.jay that appears in Figure 5.4.  The following files are available for your use as a starting point:
  1. the Jay TokenStream.java class
  2. the Jay recursive descent parser ConcreteSyntax.java
  3. the Jay abstract syntax Program.java (already completed)
  4. the Jay type checking functions V in the file StaticTypeCheck.java (already completed)
  5. the Jay semantic functions M in the file Semantics.java, (already completed)
  6. the driver program interpreter.java (already completed), and
  7. the Jay program K.jay which is an electronic copy of the Jay+Methods program shown in Figure 4.5 and again in Figure 5.3, and can be used as input to your testing activities
To test this interpreter, copy all these files to your cs250 directory, make the appropriate extensions, and then run the driver program with the command:

% java interpreter K.jay

See if the program parses correctly by checking the parser output against the file parser.output.  

Check that the interpreter is correct by confirming that the program K.jay has no syntax errors or type errors, and its output is the same as the final state given by the variables h and i in Figure 5.4 and in the listing interpreter.output. That is, the final state should be:
sigma = {<h, 5>, <i, 10>}

Since problem 5.16 has two remaining programming parts, you may want to form a team and complete it in the following way: 

        person 1.  Lexical syntax (TokenStream.java)
        person 2.  Recursive descent parser (ConcreteSyntax.java)

Note 1: If you work in a team, be sure to clearlly mark which part each team member did.