CS 421: Programming Languages and Compilers
Machine Problems for Spring 2013
Topic: Total Points Issued: Due at 9:30am CST (Central Standard Time) on: Automatic extension
(with 20% penalty)
until 9:30am on:
MP0OCaml: Basic OCaml18 (ungraded)Tuesday, Jan 15Thursday, Jan 17(None)
MP1OCaml: Pattern Matching and Recursion40Thursday, Jan 17Thursday, Jan 24 (see news on homepage)Thursday, Jan 24
MP2Abstract Syntax Trees45Thursday, Jan 24Tuesday, Jan 29Thursday, Jan 31
MP3A Lexer for MiniJava30Thursday, Jan 31Tuesday, Feb 5Thursday, Feb 7
HW4Bottom-Up Parsing40Wednesday, Feb 6Tuesday, Feb 12Thursday, Feb 14
HW5Top-Down Parsing50Tuesday, Feb 12Sunday, Feb 17 (9:00am)(none)
MP6Interpreter for MiniJava, part 150Wednesday, Feb 20Tuesday, Feb 26Thursday, Feb 28
MP7Interpreter for MiniJava, part 250Thursday, Feb 28Tuesday, Mar 5Thursday, Mar 7
MP8Minijava Compiler60Thursday, Mar 7Thursday, Mar 14Saturday, Mar 16
MP9MiniOCaml Interpreter - Substitution Model40Tuesday, Mar 26Sunday, March 31(none)
MP10MiniOCaml Interpreter - Environment Model40Tuesday, April 2Tuesday, April 9Thursday, April 11
MP11Line-drawing combinators30Tuesday, April 9Tuesday, April 16Thursday, April 18
MP12Type-checking explicitly-typed MiniOCaml30Wednesday, April 17Tuesday, April 23Thursday, April 25

Guide for Doing MPs
A guide for how to attack an MP:
  1. Download mpXgrader.tar.gz and untar it (tar xzf mpXgrader.tar.gz where X is the number of the MP). This will create an mpXgrader directory. Go into that directory.
  2. Copy the mpX-skeleton.ml file as mpX.ml. To make sure you have all the necessary pieces, start by executing make. This will create the grader executable. Run the executable (./grader). Examine the failing test cases for places where errors produced by your code. At this point, everything should compile, but the score will be 0.
  3. Read and understand the problem for the handout that you wish to begin working on. (Usually, working from top to bottom makes most sense.) There is a tests file in this directory. This is an important file containing the an incomplete set of test cases; you'll want to add more cases to test your code more thoroughly. Reread the problem from the handout, examining any sample output given. Open the tests file in the mpXgrader directory. Find the test cases given for that problem. Add your own test cases by following the same pattern as of the existing test cases. Try to get a good coverage of your function's behaviour. You should even try to have enough cases to guarantee that you will catch any errors. (This is not always possible, but a desirable goal.) And yes, test cases should be written even before starting the implementation of your function. This is a good software development practice.
  4. If necessary, reread the stament of the problem once more. Place your code for the solution in mpX.ml, replacing the stub found there for it. Implement your function. Try to do this in a step-wise fashion. When you think you have a solution (or enough of a part of one to compile and be worth testing), save you work and execute make and the ./grader again. Examine the passing and failing test cases again. Each failure is an instance where your code failed to give the right output for the given input, and you will need to examine your code to figure out why. When you are finished making a round of corrections, run make, followed by ./grader again. Continue until you find no more errors.
  5. When your code no longer generates any errors for the problem on which you were working, return to steps 3) and 4) to proceed with the next problem you wish to solve, until there are no more problems to be solved.

Interactive Debugging
In addition to running "make" and "grader", you probably want to test your code interactively at the top level:
  1. Enter the directory with your source file.
  2. Type ocaml at the command line.
  3. Type #load "mpXcommon.cmo";; at the OCaml prompt, where X is the number of the assignment (this loads in the common stuff that we give you by defualt).
  4. Type #use "mpX.ml";; at the OCaml prompt, where X is the number of the assignment. This loads in your code, and adds the functions you have defined to the identifiers recognized at top level.
  5. Type in commands followed by ';;' at the OCaml prompt to test your code interactively. Anything that you can do in a code file, you can do interactively. For example, you can define identifiers using 'let x = ...', etc...
In order to run our solution do the following:
  1. Enter the directory with your source file.
  2. Type ocaml at the command line.
  3. Type #load_rec "solution.cmo";; at the OCaml prompt, where X is the number of the assignment (this loads in the common stuff that we give you by defualt).
  4. To run function f, type in Solution.f [parameters];;"