Gujarat Technological UniversitySummer 2024 Examination

GTU 2170701 Compiler Design (CD) Summer 2024 Paper Solution & PDF

B.E. · Computer Engineering · Semester 7 · Subject Code: 2170701
Download Official GTU PDF
Share:
Total Marks70 MarksExternal theory exam
Passing Marks23 Marks33% minimum cutoff
Exam Duration2.5 Hours2:30 PM – 5:00 PM
Paper Structure5 QuestionsWith internal OR choices
Jump toQ1Q2Q3Q4Q5

Question 1

14 MarksMedium
(a)
Compare and contrast compilers and interpreters.
3 Marks
(b)
Explain in detail LEX Specification.
4 Marks
(c)
Explain Phases of Compilers with suitable example.
7 Marks

Question 2

14 MarksMedium
(a)
Describe language denoted by the following regular expression :
i)0 (0|1)*0
ii)((ε|0)1*)*
3 Marks
(b)
Draw transition diagram for following tokens.
i)Relop
ii)Identifier
iii)Unsigned number
iv)Whitespace
4 Marks
(c)
Write the two methods used in lexical analyzer for buffering the input.

Which technique is used for speeding up the lexical analyzer?

7 Marks
OR OPTION
(c)

Construct nondeterministic finite automata for following regular expression using Thomson‟s Construction. Show the sequence of moves made by each in Processing the input string ababbab. (a|b)*

7 Marks

Question 3

14 MarksMedium
(a)
Consider the grammar
S->aSbS|bSaS|ε
i)Show that this grammar is ambiguous by constructing two different leftmost derivations for the sentence abab.
ii)Construct the corresponding rightmost derivations for abab.
iii)Construct the corresponding parse trees for abab.
3 Marks
(b)
Define: Left Recursive Grammar. Check Following grammar is left
recursive or not, if yes, Remove left recursive from it.
S→aBDh
B→Bb|c
D→EF
E→g| ε
F→f| ε
4 Marks
(c)
Construct CLR Parsing table for the following grammar.
S→CC
C→cC|d
7 Marks
OR OPTION
(a)
Explain following terms:
i)Ambiguous grammar
ii)Left-Factoring grammar
3 Marks
(b)
Write a difference(s) between CLR, SLR and LALR methods.
4 Marks
(c)
Explain operator precedence parsing method with example.
7 Marks

Question 4

14 MarksMedium
(a)
Construct the dag for following arithmetic expression: a+a+(a+a+a)
3 Marks
(b)
Discuss synthesized and inherited attributes using a suitable grammar.
4 Marks
(c)
For the input expression (4*7+1)*2, construct on annotated Parse tree
according to the syntax directed definition of figure given below.
Production Semantic Rules
L->En Print(E.val)
E->E1+T E.val:=E.val+T.val
E->T E.val:=T.val
T->T1 *F T.val:= T1.val * F.val
T->(E) T.val:=E.val
F->digit F.val:=digit.lexval
T->F T.val:=F.val
7 Marks
OR OPTION
(a)
Explain dynamic memory allocation strategy.
3 Marks
(b)
Explain performance for bottom up evaluation of an inherited attributes.
4 Marks
(c)
Explain various parameter passing methods.
7 Marks

Question 5

14 MarksMedium
(a)

Explain activation record. How is task divided between calling & called program for stack updating?

3 Marks
(b)
Explain any two code optimization methods with examples.
4 Marks
(c)

What is Intermediate form of the code? What are the advantages of it? What are generally used intermediate forms? Write three address code for following expression. (a+b)*(c+d)

7 Marks
OR OPTION
(a)
How symbol table differs from other data structures?
3 Marks
(b)
Compare: Static v/s Dynamic Memory Allocation.
4 Marks
(c)
Explain various issues in design of code generator.
7 Marks
College Exam Groups

Studying for Compiler Design?

Circulate this solved paper with KaTeX formulas and 1-click AI step solvers to your batchmates on WhatsApp or Telegram.

About this Examination Paper & Attribution

Official Gujarat Technological University (GTU) examination paper and step-by-step solutions for Compiler Design (CD) (Summer 2024, B.E. · Computer Engineering, Sem 7). Features complete 70-mark regular & remedial examination pattern, official marking distribution across all 5 questions, and direct 1-click official PDF download.

Transcribed for student exam preparation from Gujarat Technological University official examination archives. Questions, syllabus guidelines, and curriculum marking schemes remain the intellectual property of Gujarat Technological University.

Download PDF