Final handout

You lucky people! Here is some more free information - a working solution to the problem posed earlier today.

The website now contains versions of the grammar and support files that will allow you to build and execute the enhanced Parva compiler, in the files freej.zip (Java) and free2c.zip (C#) which you are free to copy and unpack.

The code generator and the PVM classes have not altered, but the Parva.atg grammar has been extensively modified, as has the symbol table handler.

This compiler can handle classes whose fields are objects of other classes declared earlier, as long as the "declare before use" restriction is satisfied, as exemplified in the previous handout.

One other enhancement has been made, so as to demonstrate a further example of parsing and code generation. An expression can now contain a function size(X), which will return the number of fields in a class if X is the pointer to an object on the heap, or the number of elements in the array if X is the pointer to an array on the heap.

Moving right along ....

I appreciate that some of the approach you have adopted today may differ from the route I have followed, but the questions in the examination itself have to be based on a common starting point.

So to prepare yourself to answer the examination tomorrow, you are encouraged to study this grammar and table handler in depth and, if you like, to experiment with them further. Questions in the examination will probe this understanding, and you might be called on to make some modifications and extensions to one or other or all of the grammar, table handler, code generator and interpreter. You may well have thought of important issues that you might feel my solution overlooks, and you should spend some time comparing your work with mine to get to the bottom of this - perhaps by trying out any further test examples you may have derived, to see whether my system handles (or rejects) them correctly.

As before, you are quite at liberty to continue discussions with your class mates, but not with staff or demonstrators.

That gives me a lot of scope, does it not? And, as you know by now, I have a vivid imagination. Do you?

Have fun, but get a good night's sleep, and don't be late tomorrow!

You will receive printed copies of this same compiler tomorrow, as well as machine readable copies of the entire system, and the questions themselves. You could use these questions to create your solutions in machine readable form if you wish.


Home  © P.D. Terry