CS 421: Programming Languages and Compilers

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. It is not 20% of the number of points you earn.

Machine Labs for Fall 2018 (50 minutes total)
Topic PrairieLearn Practice Name Issued Lab Start Date Lab End Date
ML1 OCaml: Basic OCaml Practice Machine Lab 1: OCaml: Basic OCaml Wednesday, Aug 29 Tuesday, Sep 4 Thursday, Sep 6
ML2 Patterns of Recursion, Higher-order Functions Practice Machine Lab 2: Patterns of Recursion, Higher-order Functions Wednesday, Sep 12 Tuesday, Sep 18 Thursday, Sep 20
ML3 Working with ADTs: Implementing CPS Transformation Practice Machine Lab 3: Working with ADTs: Implementing CPS Transformation Wednesday, Oct 3 Tuesday, Oct 9 Thursday, Oct 11
ML4 Unification Algorithm Practice Machine Lab 4: Unification Algorithm Wednesday, Oct 17 Tuesday, Oct 23 Thursday, Oct 25
ML5 A Parser for PicoML Practice Machine Lab 5: A Parser for PicoML Wednesday, Nov 7 Tuesday, Nov 13 Thursday, Nov 15

Machine Problems for Fall 2018
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 Pattern Matching and Recursion Wednesday, Sep 5 Wednesday, Sep 12 Friday, Sep 14
MP2 Higher-Order Functions and Continuation-Passing Style Wednesday, Sep 19 Wednesday, Sep 26 Friday, Sep 28
MP3 A Unification-Based Type Inferencer Wednesday, Oct 10 Wednesday, Oct 17 Friday, Oct 19
MP4 A Lexer for PicoML Wednesday, Oct 24 Wednesday, Oct 31 Friday, Nov 2
MP5 An Evaluator for PicoML Wednesday, Nov 14 Wednesday, Nov 28 Friday, Nov 30
MP6 A Transition Semantics Evaluator for CPS Wednesday, Nov 28 Wednesday, Dec 5 Friday, Dec 7

Web Assignment (WA) Problems for Fall 2018
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 Tuesday, Aug 28 Tuesday, Sep 4 Thursday, Sep 6
WA2 Evaluating the Application of a Function skip skip skip
WA3 Order of Evaluation skip skip skip
WA4 CSP Transformation; Working with Mathematical Specifications skip skip skip
WA5 Algebraic Datatypes skip skip skip
WA6 Polymorphic Type Inference Friday, Oct 19 Sunday, Oct 28 Tuesday, Oct 30
WA7 Incremental Unification Algorithm Wednesday, October 31 Tuesday, November 6 Thursday, November 8
WA8 Regular Expressions Wednesday, October 31 Tuesday, November 6 Thursday, November 8
WA9 Parse Trees, Ambiguous Grammars and Recursive Descent Parsing skip skip skip
WA10 Natural and Transition Semantics Wednesday, Nov 7 Wednesday, Nov 28 Friday, Nov 30
WA11 Lambda Calculus Wednesday, Nov 28 Wednesday, Dec 5 Friday, Dec 7
WA12 Hoare Logic skip skip skip

Signing Up for a Machine Lab

To sign up for a time slot to complete your Machine Lab, do the following:

  1. You can sign up for a time slot to complete your Machine Lab by going to https://cbtf.engr.illinois.edu.
  2. If you do not see CS 421: Programming Languages as one of your courses, you should click Add a course, and then select CS 421: Programming Languages.
  3. Once you have CS 421: Programming Languages added to your courses, select the appropriate Machine Lab that you wish to sign up for.
  4. You should now be able to select a timeslot from those available to go to the testing facility and complete your Machine Lab. Please contact the instructor if you have a conflict as defined by university policy.

Machine Lab Logistics

There are certain things to remember when you're about to go complete a machine lab:

  • The testing facility is located in the basement of Grainger Library, room 057.
  • You have 50 minutes to complete your Machine Lab (as per the CBTF policy).
  • You will be using PrairieLearn, an online testing suite, to obtain your starter file and share your solutions with staff iff you have questions.
  • PrairieLearn works only on Firefox and Chrome. Don't use any browser other than those.
  • You will be provided with scratch paper (which you will turn in before you leave).
  • You will be able to, like on MPs, make and test your code against the grader.
  • If you are unable to make a scheduled ML, you must make alternate arrangements with the instructor.
IMPORTANT

You must bring ONLY your iCard and optionally, a writing utensil. Your iCard will be checked and scanned at the testing facility.

You are NOT allowed to bring backpacks or electronic devices (including watches, cellular devices, etc.) to your workstation. There are shelves at the enterance where a bag may be placed, but the CBTF staff are not respoonsible for its safekeeping..

You can find more information on the procedures and policies of the Computer-Based Testing Facility here.


Working on a Machine Lab

While you are completing your Machine Lab, you will have access to the following materials:

  1. PrairieLearn
  2. The starter files we have provided you with (including files to make a grader)
  3. A text editor
  4. OCaml
  5. make

You may want to review the Guide for Doing MPs and the instructions on Interactive Debugging prior to going to the testing facility.

Instructions will be provided on each question on how to untar and complete each question. For completeness, we have included them here as well.

Instructions on Machine Lab Questions
  1. Download the starter file, located here.
  2. Untar the starter file. This can be done in one of two ways:
    • In your terminal, locate the downloaded starter file, then execute tar -zxf $QUESTION.tar.gz.
    • Using a GUI, untar the starter file.
  3. After untarring, a directory will be created named $QUESTION. (e.g. twoPair)
    • Within the directory are the usual files you can use to make a grader, including an extensive set of tests.
    • We reserve the right to make changes to the provided test suite or run additional tests on submitted code.
  4. Complete the problem below in $QUESTION.ml.
    • If you need to start from scratch, you should make a copy of $QUESTION-skeleton.ml and rename it $QUESTION.ml.
  5. When you have finished the problem and tested it thoroughly, cut and paste the contents of $QUESTION.ml file into the PrairieLearn editor window for the problem. (Note that submitting WA problems may result in your grade being 0%; such a grade on PrairieLearn generally only indicates question completion.)

Guide for Doing MPs
A guide for how to attack an MP:
  1. 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 were produced by your code. At this point, everything should compile, but the score will be 0.
  2. Read and understand the problem for the handout 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 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 mpX 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 mpX.ml (or mpX.mll or mpX.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 incremental uploads.
  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.
  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, where X is the number of the assignment (this loads in the common stuff that we give you in compiled form by default).
  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...
  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", 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.