14-02-2013, 12:46 PM
2010/2011 Second Semester Examination for CSC 204 Compiler Construction
Second Semester.docx (Size: 19.25 KB / Downloads: 17)
Instruction: Answer question 1 and any other
1. a) Explain what you understand by the term “compiler construction”, and state why it is important. [5 marks]
b) Explain the various parts that make up a translation process. [4 marks]
C) Explain 4 differences between a multi-pass compiler and a single-pass compiler. [4 marks]
d) Define “language” in the context of this course, by explaining its constituent parts. [5 marks]
2. a) Explain the concept of splitting a compiler into front-end and back-end. Is it of any advantages? [4 marks]
c) Draw the possible structural/syntax trees for each of the following sentences i.) a/d-c ii.) a-b/c iii.) (a-d)/(c-b) [5 marks]
b) What is the language defined by each of the following set of syntactic rules
i) S = AB.
A = “a” | “b”.
B = “c” | “d”.
ii) S = A.
A = “a” A | Ø.
iii) S = A.
A = “a” A “b” | “b”.
[3 marks]
3. a) Given the following syntax:
E = T | E "+" T. expression
T = F | T "*" F. term
F = id | "(" E ")". factor
and let the sentence to be recognized be x * (y + z). Show the process of recognizing the sentence using bottom- up approach.
(Hint: In order to display the process, the remaining source text is shown to the right, whereas to the left the - initially empty - sequence of recognized constructs is listed. At the far left, the letters S and R indicate the kind of step taken) [6 marks]
b) Show the process of recognizing the sentence in question (3a) above using the top-down principle
(Hint: The two kinds of steps are denoted by M (match) and P (produce, expand). The start symbol is E.).