Assignment 5

CS 550 Programming Languages
Instructor: Jeremy Johnson 
Due date: Mon. May 18 at midnight

Object Oriented Mini Language (100 points)

In this assignment you will implement an object oriented (classes and methods and inheritence) version of the mini language.

Consider the extended mini language and interpreter from assignment 2, 3, and 4. (i.e. lists are supported and functions are first class values that can be assigned to variables, passed to functions and returned by function) and nested scope is supported in a similar way to the scheme interpreter discussed in lecture 4. Environments are stored as a list of frames, where frames contain a list of bindings. Static scope is used so functions store the environment in which they were defined. In this assignment you are to further extend the language and interpreter to support classes and object oriented programming. A class definition should have the following syntax.


Class name (p1,...,pn)
  
End

The statement list defines the methods (method_1,...,method_n) and attributes in the class. The class definition provides a constructor with parameters p1,...,pn, called by name(p1,...,pn). The constructor returns an object which can access the methods and attributes of the class initialized by the constructor using the familiar dot notation. Class methods can access the attributes. Here is an example.

       Class list(init)
       L := init;
       Cons := proc(x) return cons(x,L) end;
       Car := proc() return car(L) end;
       Cdr := proc() return cdr(L) end;
       end;

       L := list([]);
       L.Cons(3);
       L.Cons(2);
       L.Cons(1);
       x := L.Car();  // = 1
       M := L.Cdr(); // = [2,3]

Inheritance should be supported using the syntax

Class name (p1,...,pn) : supername
  
End

There is no multiple inheritance in this language; Only single inheritance must be supported. Objects in the subclass (derived class) should be able to access methods and attributes from its superclass, however, they can be redefined in the subclass.

What to do

Modify the mini language interpreter from Assignment 4 (the one with support for first class functions) to
  1. A description of the syntax and semantics of your object oriented mini language
  2. An overview of your implementation.
  3. Documented source code
  4. Sample input and output files
You must test your interpreter on several mini language programs which define and use classes (including inheritance).

How to submit

Students should submit their solution electronically using webct. Only one submission is required per group. The group leader for the assignment should submit the assignment. Submit a gzipped tar file, called A5.tar.gz (the tar file should contain a directory called A5 which contains the files). The tar file should contain source code, instructions how to run your programs, sample input and output files, description and README files. The README file should describe all files that are included, contain instructions how to build and use the code, and outline how the code works. The README file should also contain your name and your group members. You should also indicate how you tested your code. If your program is not working, you should clearly state this in the README file. Code should be documented (clear specifications and comments for any tricky parts of the code).