RHODES UNIVERSITY


Computer Science 301 - 2007 - Programming Language Translation

You lucky people! Here is some more free information - a complete solution to the problem posed earlier, in fact.

A complete Parva compiler, incorporating the suggested approach to the basic provision of a simple type string, has been supplied to you in a later version of the examination kit.

Much of this code should be familiar, and hopefully is fairly similar to that which you should have developed earlier today. To prepare yourself to answer Section B of the examination tomorrow, you are encouraged to study it in depth. Questions in Section B will probe this understanding, but we are giving few hints as to what to expect, other than that you might be called on to comment on the solution, and perhaps to make some modifications and extensions. During the examination you will receive a machine readable exam "kit" with this same code, as well as listings of the relevant parts of the system which can be used and handed in with your answer book.

As before, you are quite at liberty to experiment with the system and to discuss it with your prac partners, but not with staff or demonstrators.

To assist you in this task, we draw particular attention to the following:

(a) The PRNS opcode of the original PVM is now redundant. It has been left in the system, since code might be generated for the PVM by other applications, like the Assembler used in an earlier practical.

(b) String constants in read and write statements and those that might appear in expressions or variable initialization are handled consistently.

(c) Pay particular attention to the way in which the string pool is constructed and manipulated. Note that the PVM now has a string pool allocation method PVM.addString(str) which creates a new string entry in the pool and returns the index of that entry. This method has been called from within the code generator and also from within the PVM itself.

(d) String values may be extracted from the pool using the PVM.getString(i) method.

(e) Spend some time thinking how any other ideas you had during the first part of today would need modification to fit in with the solution kit presented here.

(f) The example solution uses the non-generic version of ArrayList/List so that you can compile it with earlier versions of Java and C#. The code is insignificantly different from what a solution using generics would have been, as the list of strings is all constructed and accessed through the two simple helper methods PVM.addString and PVM.getString.

You will receive a copy of relevant parts of the attributed grammar and support files tomorrow, a copy in machine-readable form, and machine readable copies of the questions themselves.

A copy of the grammar document is available now, but you may not bring this copy to the exam!

I have a vivid imagination. Do you?

Have fun!


Home  © P.D. Terry