60 2 B. E. (Computer Engg.) VIIth Semester Examination, December-2002 PRINCIPLES OF COMPILER DESIGN Paper-CSE-403-C TIme allowed: 3 hours
Maximum Marks: 100
Note: Attempt any five questions. 1. (a) What is meant by a translator ? What are the characteristics of a good translator?
10
(b) What is meant by book-keeping? Which phases of a compiler perform this job? Justify your answer. 10 2.(a) Explain the role of lexical analyzer in compiler.
10
(b) What is meant by input buffering? How it is useful in design of lexical analyzer?
10
3. (a) What do you mean by a handle? Explain the stack implementation of shift-reduce parser with the help of an example. 10 (b) What do you understand by ambiguous grammar ? How ambiguity can be removed? Give an example. 10 4.
Following is an LL (1) grammar for regular expressions over alphabet {a, b}, with + standing for union operator (I) and E for symbol E. E~TE' E' ~ + E/
E
T~FT'
6 0 2 1 A O O P 2 ( Q 8 )
i
(2) 'T'
--* TIE
F--*PF'
F' --* *F' I E P --* (E) I a I b I
E
(a) Compute First and Follow for each nonterminal of above grammar. (b) Show that grammar is LL (1). (c) Construct the predictive parsing table for grammar. (d) Construct a recursive-descent parser for grammar.
20 5.
Explain the syntax directed translation scheme for the desk calculator which performs +,
* operations of simple data
types. Also evaluate the expression 23 * 5 + 4 $. 20 6.
What information a good symbol table should contain? Explain how the information about data is stored and fetched from symbol table when needed. 20
7.
What are the various sources of error? Explain some of the possible action a good compiler should take after finding some errors. 20
8. Write short notes on : (b) Code Motion (c) Induction variables.
602-1,400
20