Assignment 2: CL3 to CPS Translation

Due date: 17th March 2015, 13:00

(graded, individual assignment) 

In this first graded assignment, we are asking you to implement the optimized CPS transformations you have seen in the course.

The source code that enables you to start working on this assignment is already available in the git repository. Just do:

 git commit -a                # commit anything you still have for assignment1 git fetch                    # get all changes from the remote repository git merge origin/Assignment2 # and resolve any conflict 
If you want to discard your solution and use ours,  replace the last command with    git checkout origin/Assignment2 git checkout -b Assignment2 --track origin/Assignment2 git merge master --strategy ours # assuming you were developing on master

You will notice that l3.Main from the new project doesn’t run the CL3Interpreter anymore but first runs the CPS translator and then an interpreter for your CPS representation. The new source files also contain a complete L3Parser class with correct syntactic sugar conversions, which you can compare with your own implementation from last week.

Also, you may notice that between translation and interpretation, there is an additional step called SymbolicCPSTreeChecker. The purpose of this module is to go through your generated CPS tree, check that all names used are defined exactly once, and emit useful warnings in case they are not. Take advantage of this output to track any bugs you may have in the translation. Notice that, since SymbolicCPSTreeChecker.apply returns Unit, we have to pass it to the passThrough function to integrate it in the pipeline.

You will find that methods nonTail, tail and cond in l3.CL3ToCPSTranslator directly correspond to translations that were explained during the lecture. Transformation for let is already given to you as an example. Your task is to complete these methods by adding the missing cases. Important: take the time to understand the helper methods that are provided, and use them as frequently as possible!  It will save you time and help you avoid common errors.

When you are done editing, the commands to submit the source files are:

 git add ...                  # files modified, as shown by "git status" git commit git push origin master 

Important notes: The git interface will only see the master branch for testing. Therefore, to run tests, you need to keep your work on master, whether or not you use branches for development. Also the git repository won’t allow you to force-push, therefore you can only roll back previous commits using git revert. Therefore, it’s better do use a development branch and only push to master when you are sure you will not need to revert your commits.

Testing

Unlike for the previous assignment, very few test cases are given to you. You should fill in the tests, as they guide you through the implementation. The tests that you write may also get you small bonuses while grading.

Reference tests will be available in the Repository application, so commit your changes often and use your tokens to test.

To test a commit. Go to the “Tests” tab. Select “Assignment 2: CL3 to CPS translation” in the title bar. By default, the title bar will be set to “Assignment 1: L3 Desugaring”. Select “run tests!” on your preferred commit. Look at the output of the test and not just the displayed message, to know the result of your test.

The tests for the graded assignments are hidden and are only meant as guidance on whether everything worked well on compiling and executing the assignment.

Important information about grading:The grade will still be given manually, based on the correctness of your implementation, so you may end up with an assignment that passes all tests graded at 70 points (of 100) for not treating important corner cases. On the contratry, you may also find an implementation that fails a few tests because it took a slightly different translation graded at 100 points, as the alternative translation was correct. So do your best to have a correct implementation and think about all corner cases! Additionally, functional correctness of your solution is not enough to achieve full grade. You need to implement all optimizations explained in the lecture (unless otherwise instructed), and write reasonably efficient code.