GTU Computer Engineering (Semester 7)
Compiler Design
June 2015
Total marks: --
Total time: --
INSTRUCTIONS
(1) Assume appropriate data and state your reasons
(2) Marks are given to the right of every question
(3) Draw neat diagrams wherever necessary


1 (a) What are regular expressions? Find the regular expression described by DFA {{A,B},{0,1},δ,A,{B}},where &delta:is detailed in following table .
  0 1
A A B
B ϕ A

Please note B is accepting state. Describe the language defined by the regular expression.
7 M
1 (b) Construct the NFA using Thompson's notation for following regular expression and then convert it to DFA.
a + (c |d) b * f #
7 M

2 (a) List the errors generated by the syntax analysis phase. Discuss error handling methods in the syntax analysis phase.
7 M
2 (b) For the following grammar
D→ T L ;
L→ L , id | id
T→int | float
1)Remove left recursion (if required)
2)Find first and follow for each non terminal for Resultant grammar
3)Construct LL(1) parsing table
4)Parse the following string (show stack actions clearly) and draw parse tree for the input:
int id, id;
7 M
2 (c) How top down and bottom up parser will parse the string "bbd" using grammar A → bA | d. Show all steps clearly.
7 M

3 (a) Explain the phases of compiler with an example.
7 M
3 (b) Construct the collection of sets of LR(0) items for the following grammar.
S-> Aa | bAc | dc | bda
A->d
7 M
3 (c) Construct DFA by syntax tree construction method.
a + b * (c |d) f #
Optimize the resultant DFA.
7 M
3 (d) Develop a predictive parser for the following grammar.
S?->S
S->aA|b|cB|d
A->aA|b
B->cB|d.
7 M

4 (a) Explain the following:
1) The Handle
2) Left Factoring
3) Directed Acyclic Graph
4) Conflicts in LR Parsing
5) Parser Generator
6) Dependency Graph
7) Locality of reference.
7 M
4 (b) Construct an SLR Parsing table for the following grammar.
E->E-T|T
T->F↑T|F
F->(E) | id.
7 M
4 (c) Elaborate the term 'Activation Record' in detail.
7 M
4 (d) Discuss various code optimization techniques.
7 M

5 (a) Write a context free grammar for arithmetic expressions. Develop a syntax directed definition for the grammar. Draw an annotated parse tree for the input expression: (3*2+2)*4.
7 M
5 (b) Convert the following statement into triple, indirect triple and quadruple forms.
A= (B+C) $ E + (B+C) *F
7 M
5 (c) Discuss synthesized and inherited attributes using a suitable grammar.
7 M
5 (d) What is intermediate code? What is its importance? Discuss various representations of three address code.
7 M



More question papers from Compiler Design
SPONSORED ADVERTISEMENTS