CL3 to CPS/L3 Translation
Introduction
For this second assignment — the first graded one — you have to implement the translation of CL3 to CPS/L3 presented in the lecture.
You should proceed in two steps: first implement the "simple" variant, and once it works, implement the optimized one.
Initial setup
To start working on the assignment, you should clone once again our git repository, using the following command:
$ git clone https://cs420.epfl.ch/l3.git
This new clone will appear in a new directory called l3
, different from the l3-warmup
used for the first assignment.
Note: The reason why we ask you to clone our repository again, instead of simply merging it into last week's clone, is that we committed our solution to the first assignment to our repository. Therefore, if you just tried to merge it with your own, your solution and ours would conflict. However, we will not provide solutions to the assignments in the future, so no additional clone will be needed.
Overview
If you explore the fresh clone of our repository, you will first notice that it contains a complete version of the L3 parser in L3Parser.scala
, as well as a working int-print
function in integers.l3
. We suggest that you spend some time comparing your solution to ours.
Apart from our solution, our repository contains some stubs for this second assignment. In particular, notice that the definition of the compiler back-end in Main.scala
does not run CL3Interpreter
anymore. Rather, it first runs the phase CL3ToCPSTranslator
— that you will have to implement — and then an interpreter for the CPS language called CPSInterpreterHigh
.
Also, you may notice that between translation and interpretation, there is an additional (optional) step, called treeChecker
. Its purpose is to go through your generated CPS tree, check that all names 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.
The focus of this assignment is of course the CL3ToCPSTranslator
phase, located in the file of the same name. Right now, it is basically empty. In the beginning of the lab, we will develop together a skeleton for the code, and give a few illustrative examples. Your presence during the lab session is therefore strongly recommended!
Testing and submission
When you are done editing, you can run the tests using sbt's test
command, as described in the previous assignment.
Once everything is working, you should submit your solution to our server. Notice that you can submit several times if you want, only the latest submission will be taken into account. However, it is impossible to submit once the deadline is over, so make sure to submit often, even if your solution is not yet complete! In particular, for this assignment, we strongly recommend that you do one submission once the simple version of the translation works.
To create the archive of your project, use sbt's packageSrc
command. This will create an archive of the sources of your compiler, called l3c_2.13-2020-sources.jar
in the target/scala-2.13
directory. This is the file that you should submit to our submission server.
Grading
A total of 80 points are assigned to this project part, out of a total of 500 for the whole semester. Your submission will be graded based on:
- its correctness, i.e. whether it passes all the functional tests that were made available to you,
- its completeness, i.e. whether you covered all the cases as required, and implemented the optimized version of the translation, correctly handling all the cases.
The style of your code will be evaluated, but not graded for this assignment. Please pay attention to the style remarks that are made to you, however, as starting with the fourth assignment, style will be graded.