The Interpreter
- Due:
- 11:00 pm, Wednesday May 5, 2021
Max grace days: 0
Overview
For this assignment you will write an interpreter. Among other things, this involves implementing the operational semantics specification of Cool. You will track enough information to generate legitimate run-time errors (for example, dispatch on void). You do not have to worry about "malformed input" because the semantic analyzer has already ruled out bad programs.
The Specification
You must create three artifacts:
A program that takes a single command-line argument (for example,
file.cl-type
). That argument will be an ASCII text Cool class map, implementation map, and AST file. Your program must execute (that is, interpret) the Cool program described by that input. If your program is calledinterp
, invokinginterp file.cl-type
should yield the same output ascool file.cl
. Your program will consist of a number of OCaml files.You will only be given
.cl-type
files from programs that pass the semantic analysis phase of the reference interpreter. You are not responsible for correctly handling(1+\"hello\")
programs.A plain ASCII text file called
README
describing your design decisions. See the grading rubric. A few paragraphs should suffice.
Error Reporting
To report an error, write the string
ERROR: line_number: Exception: message
to standard output and terminate the program. You may write whatever you want in the message, but it should be fairly indicative. Example erroneous input:
class Main inherits IO {\
my_void_io : IO ; -- no initializer => void value
main() : Object {
my_void_io.out_string("Hello, world.\n")
} ;
} ;
Corresponding example error report output:
ERROR: 4: Exception: dispatch on void
Commentary
You will have to handle all of the internal functions, for example, IO.out_string
.
You can do basic testing as follows:
linux> cool --type file.cl
linux> cool file.cl >& reference-output
linux> my-interp file.cl-type >& my-output
linux> diff my-output reference-output
Note that this time, whitespace and newlines matter for normal output. This is because you are specifically being asked to implement IO and substring functions.
You should implement all of the operational semantics rules in the Reference Manual. You will also have to implement all of the built-in functions on the five Basic Classes.
Getting the Assignment
The starter code for the assignment is on the Linux server at the path:
/export/home/public/schwesin/csc310/interpreter-handout
Turning in the Assignment
You must turn in a zip file containing these files:
README
— your README filesource_files
— your implementation, includingmain.ml
- TODO
There is a makefile provided with this assignment. To submit the assignment, execute the command:
make submit
from within the assignment directory.
Grading Criteria
Grading (out of 100 points):
- 70 points — for autograder tests
- 70 points 50% or greater passing test cases
- 55 points between 25% and 49% passing test cases
- 35 points between 10% and 24% passing test cases
- 20 points between 5% and 9% passing test cases
- 0 points less than 5% passing test cases
- 15 points — for a clear description in your README
- 15 — thorough discussion of design decisions; a few paragraphs of coherent English sentences should be fine
- 8 — vague or hard to understand; omits important details
- 0 — little to no effort, or submitted an RTF/DOC/PDF file instead of plain TXT
- 15 points — for code cleanliness
- 15 — code is mostly clean and well-commented
- 8 — code is sloppy and/or poorly commented in places
- 0 — little to no effort to organize and document code
Extra Credit
You can receive extra credit for your final course grade by passing more than 50% of the test cases:
- 5%: 90% or greater passing test cases
- 3%: between 75% and 89% passing test cases
- 1%: between 50% and 74% passing test cases