VTU Previous Year Question Papers BE CS 6th Semester Compiler Design December 2011
VTU Previous Year Question Papers BE CS 6th
Semester Compiler Design December 2011
Note: Answer any FIVE full questions, selecting at least TWO questions from each part.
1 a. With a neat diagram, explain the different phases of compilation.
b. Explain input buffering strategy, used in lexical analysis phase.
2 a. Write the transition diagram for an unsigned number.
b- Show that the following grammar is ambiguous: E £ + E |E*E|(E)id. Write an unambiguous grammar for the same.
c. Write a recursive descent parser for the grammar and for the input ‘cad’ trace the parser.
3 a. Construct the predictive parse table for the following grammar :
b. Explain the working of a shift reduce parser.
c. Explain handle pruning. Explain the same for the grammar E -» E+E JE * E| (CE) jid and the input string is idl + id2 * id3.
4 a. Consider the following grammar:
A Construct the SLR parse table for the grammar. Show the actions of Ibe parser, for the input string “abab”.
b. Construct the CLR parse table for the following grammar:
5 a. Define the following with examples : Synthesized attribute Inherited attribute S- attributed definitions L – attributed definitions.
b. Explain the parser stack implementation of post fix SDT, with an example.
c. For the SDD shown below:
|L —*-En||L.val = E.val|
|E —> Ei + T||E.val = El.val + T.val|
|E-»T||E.val = T.val|
|T -» T1 * F||T.val = Tl.val * F.val|
|T-»F||T.val = F.val|
|F -»(E)||F.val = E.val|
|F -> digit||F.val = digitJexval|
construct the annotated parse tree for 3 5 + 4n.
6 a. Explain the following, with an example :
iii) Indirect triples.
b. Write an algorithm for the unification of a pair of nodes in a type graph.
c. Explain syntax directed translation of switch statements.
7 a.What is an activation record? Explain its possible structure.
b. Explain the design goals for garbage collector.
c. Explain the desirable properties of memory manager.
8 a.What is next use information? Write an algorithm to determine the livens and next use Ma for each statement in a basic block. Apply the same for the following basic block:
3. T1 = Add (A) – 4
4. T2 = 4 * i
5. T3 =T1 [T2]
6. Sum = Sum + T3
7.1 = 1 + 1
8. If 20 go to 3
b. Generate the intermediate code for the statement: sum = A [i, j] + B [i, j]. Construct DAG and simplify the code.