1. What are your surname and student number? [2]
Pat Terry, 663T0184
2. What do you understand by the term "self-compiling compiler"? [2]
A compiler hosted in the language it is intended to compile, so that it can compile (regenerate) itself.
3. Suppose you have available a C compiler (BCC.EXE) for a Pentium computer. Complete the T diagrams below to show the steps you might follow in producing a self-compiling C# compiler for the same Pentium computer. [4]
.--------------------------. .--------------------------. | CSC1.C | | CSC1.EXE | | C# --------> M-code| | C# ---------> M-code| | | | | `-------. .--------------------------. .-------' | | BCC.EXE | | | C | C -------> M-code | M-Code | | | | | `------------------. .------------------' | | | | | | M-code | | | | | | | `----------' | Rewrite the | | Use this to compiler in | | compile it C# | | | .-----------------' v | .--------------------------. | .--------------------------. | CSC.C# | | | CSC.EXE | | C# --------> M-code | | | C# ---------> M-code| | | v | | `-------. .--------------------------. .-------' | | CSC1.EXE | | | C# | C# -------> M-code| M-Code | | | | | `------------------. .------------------' | | | M-Code | | | `----------'
4. Self-compiling compilers have to be able to pass a self consistency test. Depict this test by annotating the T diagram below. [2]
.--------------------------. .--------------------------. | CSC.C# | | CSC.EXE | | C# --------> M-code | | C# ---------> M-code | | | | | `-------. .--------------------------. .-------' | | CSC.EXE | | | C# | C# -------> M-code | M-code | | | | | `------------------. .------------------' | | ^ | M-code | | should be | |<-----------' identical `----------'
Home © P.D. Terry