National Open University Exam Past Question – CIT445 JUNE/JULY EXAMINATION

NATIONAL OPEN UNIVERSITY OF NIGERIA CIT445 Principles & Techniques of Compilers

14/16 AHMADU BELLO WAY, VICTORIA ISLAND, LAGOS SCHOOL OF SCIENCE AND TECHNOLOGY JUNE/JULY EXAMINATION

COURSE CODE:    CIT445

COURSE TITLE:   Principles & Techniques of Compilers

TIME ALLOWED: 2½ hrs

INSTRUCTION:    Answer any five (5) questions. Each question carries 14 marks

1) With the aid of an illustrative diagram describe the phases of a compiler.                                   14 marks

2a) What are the benefits of LR parsing?                                                                                        4½ marks b)   List the common techniques for building tables for an “LR” parser stating the characteristics of each?

6½ marks

1. c) Consider the grammar,

G:         E → E + T | T T → T*F | F

F → (E) | i

What is the augmented grammar for this grammar.                                                           3 marks

3a)  Briefly describe the operations performed by the shift-reduce parser                                        6 marks b) Given the context-free grammar G below:

G:         E ® E + E

E ® E * E E ® (E)

E ® id

4) Consider the grammar,

G: S → a | aS | bS

1. a) Find the LR(0) items for this grammar                                                                                    10 marks b) Construct an NFA whose states are the LR(0) items from (a).                                                    4 marks

5a) Explain what is meant by the term Viable Prefix?                                                                        3 marks b) Given the grammar G with following production rules, S → a | aS | bS, determine whether the string aababbba can be generated by the grammar                                                                                    5 marks c) Enumerate any three of the errors which can be detected during lexical analysis                         6 marks

YOU MAY ALSO LIKE  National Open University Exam Past Question – AEM732 JUNE/JULY EXAMINATION

6) Consider the grammar G below: G: E ® E + T / T

T ® T * F / F F ® (E) / i

1. a) Generate the non-left recursive version of the grammar 5 marks b) Find FOLLOW of all the nonterminal symbols in the non-left recursive version of the grammar 9 marks

7a) Define formal language                                                                                                                 3 marks b) State three of the uses of formal languages                                                                                    3 marks

 c) What is a translator? 2 marks d) Why do we need a translator? 3 marks e) Enumerate the functions performed by the lexical analyser 4 marks

Close

Close