CS712/CS812
Project Phase 1
Spring 2004
Due Sunday February 8
This phase concerns the design of a simple object-oriented language.
Your design should support the following functionality:
- An integer type.
- Integer operations: assignment, addition, subtraction, multiplication,
division, and negation.
- Reference types.
- Object definition, including integer fields, reference fields,
methods (with parameters and return values), and single inheritance.
You should support the overriding of methods and the hiding of fields
in the superclass.
You should support both integer and reference parameters and both
integer and reference return values.
- Object creation and object deletion, with corresponding constructors and
destructors.
- Assignment of reference type. You must support the assignment of
superclass references to and from subclass references.
- Comparison operators for integer types: equality, less than and greater
than.
- A comparison operator for reference types: equality.
- A logical negation operator defined on the type of the result of
a comparison operator (might be integer, or you could introduce a Boolean
type).
- A method call operator, with parameter evaluation and return value
generation.
- A mechanism for outputing an integer to stdout.
- A selection control-flow construct, such as if-then-else.
- A loop control-flow construct, such as a while-loop.
- A "main" function construct, including a namespace for storing reference
and integer variables.
- A field reference operator.
- Integer constants.
- Names that can denote "main" function variables or method parameters.
- A null reference constant.
- A "this" reference.
- Parenthesized expressions.
- A comment construct.
You can require that programs be completely specified in a single file.
If you are working in a pair then you should add a floating-point
type to the language.
This should include:
- Floating-point operations: assignment, addition, subtraction,
multiplication, division, and negation.
- Floating-point fields, floating-point method parameters and
floating-point method return values.
- Comparison operators for floating-point types: equality,
less than and greater than.
- A mechanism for outputing a floating-point value to stdout.
- Floating-point variables in the "main" function namespace.
- Floating-point constants.
The key criteria for grading is the completeness of your design.
You should specify both the syntax and the semantics.
The syntax should be specified using the appropriate formal notation.
The semantics can be specified informally, using English.
Be sure to consider error situations when you are describing the semantics.
(For example, what should the compiler do if the user assigns a reference
to an integer?)
However, your language should "make sense".
That is, it should be possible to write reasonable programs with it.
You should include example programs as an appendix in your design document:
- A recursive method to compute the n-th element of the Fibonacci sequence.
- A method to compute the modulus function of two integer arguments.
- A method that iteratively (using a loop, not recursion) computes the
factorial function of its argument.
- A simple object-oriented example (such as, point, shape, circle, etc.),
illustrating inheritance, object creation, object deletion, etc.
- Any additional examples necessary to make sure your example programs
cover all features of the language.
The deliverable for this phase is a well-organized and well-written
document.
The quality of the organization and writing will be worth 20% of the
grade.
The rest of the grade is based upon the completeness of your design.
Your document should be turned in electronically.
I will accept any reasonable format, including PDF, Postscript and
Microsoft Word.
You should submit the document file from turing.unh.edu using my "submit"
script.
To turn in this assignment, type:
~cs712/bin/submit phase1 filename
Submissions can be checked by typing (also on turing.unh.edu):
~cs712/bin/scheck phase1
To receive full credit for the assignment, you must turn in your
files prior to 8am on Monday February 9.
Late submissions will be accepted at a penalty of 2 points for
one day late, 5 points for two days late, 10 points for three days
late, 20 points for four days late, and 40 points for five days late.
No program may be turned in more than 5 days late.
Remember: you (with possibly an approved partner) are expected to do your
own work on this assignment!
Last modified on January 22, 2004.
Comments and questions should be directed to
hatcher@unh.edu