CS3 page · Project overview · Phase 1 · Phase 2 · Samples · Testing


CS3 Individual Programming Project

Phase 1

In this part of the project you write a lexer for µOCCAM, using flex, and a parser, using bison. The grammar is described in Chapter 1 of the µOCCAM manual. Your program should read text from the standard input and determine whether or not it is valid µOCCAM code. This recogniser forms the front end for the compiler you will build in phase 2.

At this stage your solution only needs to deal with syntactic issues. For example, you do not have to make certain whether a procedure call has the right number of arguments, or if a channel is used where there should be an integer. This sort of check will form part of the second stage of the project. If you are unsure whether or not your program should include a particular check, just ask.

Getting started

In the opening lecture you saw a tiny example of a recogniser for µOCCAM -- one that only accepted very few programs. This is the code you should start with. It works, but only just, and offers ample opportunity for improvement. Start as follows.

The tiny example contains just three files:
lexer.l specifies the lexer;
parser.y specifies the parser;
Makefile describes how make should build the occam program using these two source files.
Study these files and expand them to handle the rest of the µOCCAM language. As well as adding extra keywords and grammar rules, you will need to keep track of indentation. Try to add just one feature at a time, and always keep a separate copy of your best effort so far.


The best way to find out how good is your recogniser is to test it on valid and invalid µOCCAM programs. You can do this using the ipp test program, as follows.

Then run ipp -1 (or just ipp1) to get a summary of your recogniser's performance on the sample µOCCAM code. A detailed log file is written to ipplog. For more information, including a host of configuration options, see the full program description.

There is a catalogue of examples provided by students. During this stage of the practical you must contribute at least one test program to this.


To submit your code, execute the ipp1submit command. This will hand in all text files in your ~/ipp1/ directory. You can submit as many times as you like -- only the last version will be kept, with a record of the time of submission. You must submit your work by 12 noon on Tuesday 14 November.

Here are the necessary steps, in detail.

The submission program will give errors if there is no ~/ipp1/ directory, or if it is readable by anyone other than yourself. If it fails for any other reason, please email me with a copy of the error message.

Finally, remember that there are also marks for contributing at least one test program to the catalogue.


Once submitted, your source code will be placed in a directory of its own. The make command will be executed in that directory to build your compiler. The resulting executable occam will be run once with each of a batch of test µOCCAM files as input. Your program's return code in each case (0 or 1) will be recorded and compared with the correct answer.

Credit for the practical is assessed over a range of areas, including the following.

The last item is the most substantial.

Separately from the assessment, your submitted files may undergo a certain amount of analysis to discount plagiarism.