CS 421: Programming Languages and Compilers

Note: Because MPs have been moved back by two days, the exact schedule of topics for MPS may need adjusting, and might result in the shifting some topics a week later, and possibly the addtion of one more MP. The WAs are similarly is a state of some flux.

Note: The late penalty is 20% of the total number of points on the base part of the assignment, plus 20% of the total points possible on the extra credit, if you attempt the extra credit, when it exists. It is not 20% of the number of points you earn.

Machine Problems for Fall 2022
MP No.:
Link:
Topic: Issued: Due at 23:59 CT
(11:59pm CT) on:
Automatic extension
(with 20% penalty)
until 23:59pm CT (11:59pm CT) on:
MP1 OCaml: Basic OCaml Aug 23, 2022 Aug 30, 2022 Sep 1, 2022
MP2 Pattern Matching and Recursion Aug 30, 2022 Sep 6, 2022 Sep 8, 2022
MP3 Patterns of Recursion, Higher-order Functions Sep 6, 2022 Sep 13, 2022 Sep 15, 2022
MP4 Continuations and Continuation-Passing Style Sep 13, 2022 Sep 20, 2022 Sep 22, 2022
MP5 Working with ADTs: Implementing CPS Transformation Sep 20, 2022 Oct 4, 2022 Oct 6, 2022
MP6 A Unification-Based Type Inferencer Oct 4, 2022 Oct 11, 2022 Oct 13, 2022
MP7 Unification Algorithm Oct 11, 2022 Oct 18, 2022 Oct 20, 2022
MP8 A Lexer for PicoML Oct 18, 2022 Oct 25, 2022 Oct 27, 2022
MP9 A Parser for PicoML Oct 25, 2022 Nov 1, 2022 Nov 3, 2022
MP10 An Evaluator for PicoML Nov 1, 2022 Nov 15, 2022 Nov 17, 2022
MP11 A Transition Semantics Evaluator for CPS Nov 15, 2022 Nov 29, 2022 Dec 1, 2022

Web Assignment (WA) Problems for Fall 2022
WA No." Topic: Issued: Due at 23:59 CT (11:59pm CT) on: Automatic extension
(with 20% penalty)
until 23:59 CT (11:59pm CT) on:
WA1 Evaluation and Evironments Aug 25, 2022 Sep 1, 2022 Sep 3, 2022
WA2 Order of Evaluation Sep 1, 2022 Sep 8, 2022 Sep 10, 2022
WA3 Evaluating the Application of a Function TBA TBA TBA
WA4 CSP Transformation; Working with Mathematical Specifications TBA TBA TBA
WA5 Algebraic Datatypes TBA TBA TBA
WA6 Polymorphic Type Inference TBA TBA TBA
WA7 Incremental Unification Algorithm TBA TBA TBA
WA8 Regular Expressions TBA TBA TBA
WA9 Parse Trees TBA TBA TBA
WA10 Natural and Transition Semantics TBA TBA TBA
WA11 Lambda Calculus TBA TBA TBA
WA12 Hoare Logic TBA TBA TBA

Instructions for Submitting Assignments ---- This needs revision below here!
  • All assignments, both MPs and WAs, will be available through PrairieLearn and will be collected there.
  • When you do an MP in PrairieLearn, you will do your work for each problem in a VSCode Workspace. The introductory webpage for the problem gives you instructions for how to do the problem, includeing the problem statement. To actually do the problem, you will need to click the button "Open workspace", which will open a new tab in your browser running the VSCode editor/programming environment. It will present you with a directory, the ability to open and edit files in that directory, and an ability to start a terminal window, running linux, in which you can run ocaml, to build and test your code. The directory provided will contain a file with a name (typically problem.ml) and infrastructure to help you test your code. The file problem.ml is just a stub. To build your answer, you need to delete or comment out the stub code and add your own. The next section Guide for Doing MPs contains further information about how to test your code.
    Before submitting an MP assignment, you MUST make sure that your MP compiles with the student grading script supplied with the assignment. If your MP fails to compile with the student grading script, your assignment will get NO CREDIT. There will be no partial credit for assignments that fail to compile.
  • You may do multiple commits of either the MPs or the WAs. Your score will be the best of all your submissiosn, but the score of late submissions will have a late penalty applied, meaning it will only help your assignment score if you received less than 80% before the on-time due date. Work submitted before the late deadline will not be subject to the late penalty, but work submitted after will.
Guide for Doing MPs
A guide for how to attack an MP:
  1. For each problem in the assignment, go into the VSCode Workstation for the problem, and start a terminal window. To make sure you have all the necessary pieces, in that terminal window, start by executing make. This will create the grader executable. Run the executable (./grader). Examine the failing test cases for places where errors were produced by your code. At this point, everything should compile, but the score will be 0.
  2. Read and understand the problem from the assignment on which you wish to begin working. (Usually, working from top to bottom makes most sense.) There is a tests file in this directory. This is an important file containing a partial set of test cases; you'll want to add more cases to test your code more thoroughly. Reread the problem from the main webpage for the problem, examining any sample output given. Open the tests file in the WORKSPACE 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.
  3. If necessary, reread the statement of the problem once more. Place your code for the solution in problem.ml (or problem.mll or problem.mly as specified by the assignment instructions) 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. Consider submitting your partial result so that you will at least get credit for what you have accomplished so far, in case something happens to interfere with your completing the rest of the assignment. You can submit one problem at a time in earlier assignments. In later assignments, problems tend to be pieces of functions. It is still worth your while to do incremental submissions.
  4. 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. Each problem is submitted in PrairieLearn indepentantly of the others, but some later assignments have only one problem.
  5. When you have finished all problems (or given up and left the problem with the stub version originally provided), you will need to submit your code to PrairieLearn.

Interactive Debugging
In addition to running "make" and "grader", you probably want to test and debug 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 "common.cmo";; at the OCaml prompt, if there is such a file inthe WORKSPACE directory. (This loads in the common stuff that we give you in compiled form by default).
  4. Type #use "problem.ml";; at the OCaml prompt, where problem is the name of the problem, which is typically the name function being implemented. 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...
  6. With each MP, you will be given a solution in compiled form. You may interactively test the solution to a problem, after having loaded "common.cmo" if there is one, by loading the solution file by typing #load "solution.cmo";;. After that, if you are supposed to write a function called, say splat, and wish to find out what it does on an input, say 39.2, you may execute the solution's version of splat by typing Solution.splat 39.2;;. Notice the capitalization.