This is an old revision of the document!


CMPU-331 Compilers (Spring 2019)

Overview

These exercises will generally be relevant to the material currently being presented in the class. They will include both practical programming problems and hand-written exercises. Their intention is to give you a chance to practise new material, to review and sharpen existing skills, and to experiment with new combinations of ideas, with the liberty of not being required to complete the work.

You are encouraged to work together on these exercises. Feel free to discuss them among your peers.

These exercises will not be graded; that said, it is nonetheless strongly recommended that you attempt them, at least in part, as much of what they will cover will appear elsewhere in the course.

Exercises

01: Building a Map

This exercise is a quick refresher in object-oriented programming.

Here is a text file which contains the map for an old-school text adventure game. (Yes, I wrote this. I wrote it as a class homework when I was doing my undergrad CS degree.) As you would expect, the map consists of locations linked by exits and containing objects. Some objects have certain flags (e.g. inert means that the player cannot pick it up; scenery means it isn't listed discretely), and many have synonyms to make it easier for the player. Both objects and locations can have properties (e.g. mass for an object, or dark for a room). There are 10 possible exits for each room: the 8 main directions plus up and down; comments are indicated by a solidus (forward slash, '/') character.

Your task for this exercise is to build an object-oriented program which creates a World object and populates it with locations and objects as described in the file. (If you want to write a little REPL so you can move around the world and examine objects, that would be pretty neat, too.)

Here are some images of the game in 'action'. One Two Three

If you really want to play it (and see what your professor got up to at university), you can get the game here. Two things to note: one, it runs on Windows only; two, it was a second-year student project and – believe it or not – probably still has some bugs.

02: Lexical Analysis

These exercises are designed to help you refresh your memory about some aspects of language and grammar and to help you explore some of the principles of lexical analysis.

Lexical Analysis exercises

03: Parse Table Generation

… coming very, very soon!…