(a) Consider the following general form of T diagram. Although it uses the letters A through I in the various arms of the T's, one could draw the diagram with fewer letters. How?
---------------------------- ---------------------------- | | | | | A ----------> B | | C -----------> D | | | | | --------- ---------------------------- --------- | | | | | E | F --------> G | H | | | | | -------------------- -------------------- | | | I | | | ------------
(b) A pretty printer is a program that will take the source code of a program written in some language and essentially simply reproduce it, but making it look "pretty", for example adjusting all the indentation to be consistent, placing each statement on a new line, adding blank lines between functions and so on.
Suppose you have available a C++ compiler CC.EXE for the PC, and that you have just been introduced to the language PGTC (Pat's Gift to Civilization). Use T diagrams to show in broad detail how you would (a) develop a pretty printer PRETTY.EXE for PGTC that would run (walk) on a Windows NT system in the Braae Laboratory, and (b) use this pretty printer on that NT system to beautify a messy program MESSY.PGTC written in PGTC.
(c) Suppose that you were required to develop a C compiler for the newly invented Betta Mousetrap computer. Assume that you have available both the C source code and the corresponding executable version of a C compiler that will run on the Sadleigh Outdeight machine that you have somewhere in the spare room. Using T-diagrams, outline how you would develop the new compiler so that when you get a Betta Mousetrap for Christmas you will be able to plug your compiler in and have it working immediately.
(d) In the practical sessions you should have used the Extacy Modula-2 to C translator. This was developed in Russia by a team who used the JPI Modula-2 compiler available for the PC. But the demonstration system we downloaded from the Internet came with the file XC.EXE and a few other modules written in Modula-2 (but not the source of the XC executable itself). Draw T-diagrams showing the process the Russians must have used to produce this system, and go on to draw T-diagrams showing how you managed to take the program SIEVE.MOD and run it on the PC using the MicroSoft C++ system as your time-waster of choice.