Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

REDEEMER’S UNIVERSITY (RUN)

Department of Mathematical Sciences


CMP 479 1ST SEMESTER EXAMINATION 2008/2009 SESSION Time: 2 ½ Hours
Instruction: Answer question 1 and any other 3 questions

1. a. What is a compiler?

b. What qualities are important in a compiler?

c. Describe with a diagram the Phases involved in Compiler construction

d. The entire compilation process can be broken down into two phases.
Explain

2. a. Describe a Lexical analyzer


b. Enumerate the functions of a lexical analyzer
c. Lexical analyzer can be implemented in different ways. Explain

d. Write a regular definitions for

(i) identifiers in C (ii) numbers in Pascal

3. a. Describe transition diagrams briefly


b. Construct transition diagrams for the following
(i) relational operators
(ii) identifiers and keywords
(iii) white space
c. (i) Design an NFA to accept {a|b)*abb
(ii) Convert the NFA in (i) to a DFA
4. a. What is a parser?
b. There are various strategies that a parser can employ to recover from a
syntactic error. Discuss
c. (i) What is Lex?
(ii) Describe briefly the structure of Lex

5. a. Stat → if cond then stat


| if cond then stat else stat
| other-stat
Is the grammar above ambiguous? If yes, disambiguate the grammar.
b. The sentence id1 + id2 * id3 has two distinct leftmost derivations. Prove
this.
c. Highlight the advantages and disadvantages of operator precedence parsers

6. Consider the grammar G below:


E → E + T|T
T → T * F|F
F → (E)| id
(a) Eliminate the left recursion from the grammar
(b) Construct a parsing table for the grammar
(c) Which type of grammar is G?

You might also like