FACULTY OF SCIENCE AND SCIENCE EDUCATION
DEPARTMENT OF COMPUTER SCIENCE & INFORMATION TECHNOLOGY
B.Sc. DEGREE SECOND SEMESTER EXAMINATION 2007/2008 SESSION
COURSE CODE: CIT 220
COURSE CREDIT: 3
COURSE TITLE: PRINCIPLES OF COMPILERS
DATE: 13-05-08
TIME: 2 HOURS
Section A (Attempt all questions in this section)
1. _________________ and _______________ are inputs to the compiler
2. _________________ and _______________ are outputs from the compiler
3. A compiler is composed of ___________ segments
4. Give three reasons why compilers optimise codes.
5. How many components has a language?
6. Name the components of a language.
7. The expression (0|1)*.(0|1)* is the regular expression for _______________________
8. Give the FA for the regular expression in 7 above.
9. What are the differences between an NFA and a DFA?
10. Given the CFG
Start → S
S→(L)
S→a
L→L,S
L→S
Show that the string (a, (a, a)) would parse.
11. What does LL(k) mean?
12. What is left recursion problem?
13. How do you solve the left recursion problem
14. How do you resolve the common prefix problem
15. Explain the ε-transition problem
16. What is a PDA?
17. What is a multi pass compiler?
18. What is backtracking?
19. What is bottom up parsing?
20. What is a grammar?
Section B (Attempt any two questions from this section)
Question 1.
a.) Draw a DFA that accepts all strings in (a + b)* that do not contain bababb as a substring
b.) Present a context-free grammar that generates the language accepted by your DFA from (a) above.
c.) Convert the following NFA to a DFA. For each DFA state, indicate the set of NFA states to which it corresponds. ε ε
start
ε
1 x z
5
ε
2
ε
3 y 6
ε
7
4
Question 2
The Java Virtual Machine Specification describes the format of descriptors, which are used in .class files to describe the signature of a Java class’s methods and fields. The following grammar describes