0% found this document useful (0 votes)
5 views

compiler design

The document contains examination papers for Compiler Design across various semesters, detailing the structure of the exams, including the number of questions and maximum marks. Each paper requires students to attempt five questions from a set of eight, covering topics such as compiler phases, parsing techniques, symbol tables, and code optimization. The questions are designed to assess understanding of both theoretical concepts and practical applications in compiler design.

Uploaded by

S.S Verma
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

compiler design

The document contains examination papers for Compiler Design across various semesters, detailing the structure of the exams, including the number of questions and maximum marks. Each paper requires students to attempt five questions from a set of eight, covering topics such as compiler phases, parsing techniques, symbol tables, and code optimization. The questions are designed to assess understanding of both theoretical concepts and practical applications in compiler design.

Uploaded by

S.S Verma
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Total No. of Questions : 8] [1] [Total No.

of Printed Pages : 3

Roll No ..................................
CS-603(C)-CBGS
B.Tech., VI Semester
Examination, December 2020
Choice Based Grading System (CBGS)
Compiler Design
Time : Three Hours
Maximum Marks : 70
Note: i) Attempt any five questions.
{H$Ýht nm±M àíZm| H$mo hb H$s{OE&
ii) All questions carry equal marks.
g^r àíZm| Ho$ g_mZ A§H$ h¢&
iii) In case of any doubt or dispute the English version
question should be treated as final.
{H$gr ^r àH$ma Ho$ g§Xoh AWdm {ddmX H$s pñW{V ‘| A§J«oOr ^mfm
Ho$ àíZ H$mo A§{V‘ ‘mZm Om¶oJm&
1. a) Describe the various data structures used in Compilers.
g§H$bH$ ‘| à¶w³V {d{^Þ S>oQ>m g§aMZmAm| H$m dU©Z H$a|&
b) What are Compiler construction tools? Write note on each
compiler construction tool.
g§H$bH$ {Z‘m©U CnH$aU ³¶m h¢? à˶oH$ g§H$bH$ {Z‘m©U CnH$aU
na ZmoQ> {bI|&
2. a) Explain in detail the various phases of compiler with an
example.
EH$ CXmhaU Ho$ gmW g§H$bH$ Ho$ {d{^Þ MaUm| Ho$ ~mao ‘| {dñVma
go ~VmBE&
CS-603(C)-CBGS PTO

https://www.rgpvonline.com
[2]

b) Define :
n[a^m{fV H$a| :
i) Tokens
ii) Input buffering
iii) LEX
3. a) Explain the various errors encountered in different phases
of Compiler.
g§H$bH$ Ho$ {d{^Þ MaUm§o ‘| AmB© {d{^Þ Ìw{Q>¶m| H$s ì¶m»¶m H$s{OE&
b) Differentiate :
A§Va H$amo :
i) Top down Vs Bottom up parsing
ii) Predictive Vs Operator precedence parsing
4. a) Construct a Syntax Directed Translation Scheme that
translates arithmetic expressions from infix into postfix
notation.
EH$ qgQ>o³g S>m¶ao³Q>oS> Q´>m§gboeZ ñH$s‘ H$m {Z‘m©U H$aZm Omo
BpÝ’$³g go A§H$J{UVr¶ A{^ì¶{³V¶m| H$mo nmoñQ>{’$³g ZmoQ>e
o Z ‘|
AZwdmX H$aVm h¡&
b) Explain the symbol table management system.
àVrH$ Vm{bH$m à~§YZ àUmbr H$s ì¶m»¶m H$a|&
5. a) Check whether the given grammar is LL(1) or not
Om±Mo {H$ {X¶m J¶m ì¶mH$aU Eb Eb (1) h¡ ¶m Zht
S → iEt SS' / a
S' → eS / E
E→b
b) Explain in detail different dynamic storage allocation
strategies.
{d{^Þ J{Verb ^§S>maU Amd§Q>Z aUZr{V¶m| Ho$ ~mao ‘| {dñVma go
~VmB¶o&
CS-603(C)-CBGS Contd...
PTO

https://www.rgpvonline.com
[3]

6. a) Construct DAG for the following expression :


{ZåZ{b{IV A{^ì¶{³V Ho$ {bE DAG H$m {Z‘m©U H$a| :
a + a * (b – c) + (b – c) * d
b) Discuss the issues in design of Code generator.
H$moS> OZaoQ>a Ho$ {S>μOmBZ ‘o§ ‘wÔm| na MMm© H$a|&
7. a) Explain the following with example.
CXmhaU Ho$ gmW {ZåZ{b{IV H$s ì¶m»¶m H$a|&
i) Strength reduction
ii) Variable propagation
iii) Common sub expression elimination
b) Describe Peephole optimization briefly. Also explain
Backpatching.
g§jon ‘| Peephole AZwHy$bZ H$m dU©Z H$a|? Backpatching ^r
g‘PmBE&
8. a) Explain the basic block and control flow graph.
Basic ãbm°H$ Am¡a {Z¶§ÌU àdmh J«m’$ H$s ì¶m»¶m H$a|&
b) Explain data flow analysis of structure flow graph.
g§aMZm àdmh J«m’$ Ho$ S>oQ>m àdmh {díbofU H$s ì¶m»¶m H$a|&
******

CS-603(C)-CBGS PTO

https://www.rgpvonline.com
https://www.rgpvonline.com

Total No. of Questions : 8] [1] [Total No. of Printed Pages :2

Roll No ..................................
CS-7002-CBGS
B.E. VII Semester
Examination, June 2020
Choice Based Grading System (CBGS)
Compiler Design
Time : Three Hours
Maximum Marks : 70
Note: i) Attempt any five questions (including all parts).
ii) All questions carry equal marks.
iii) Assume missing data, if any suitably.

1. a) Explain with neat diagram the various phases of compiler.


b) What is DFA? Construct the DFA machine for the given,
with ε-NDFA machine.
ε

a
2 3
start ε ε ε
ε a b b
0 1 ε 6 7 8 9 10
ε
4 5
b
ε

2. a) Describe the following in brief:


i) Ambiguity
ii) Left recursion
b) Consider the grammar:
E5 + T | 3 – T
T  V | V*V | V + V
Va|b
What is the use of left factoring? Find the first and follow
for above grammar and do the left factoring for it.
CS-7002-CBGS PTO

https://www.rgpvonline.com
https://www.rgpvonline.com

[2]

3. a) Construct the SLR parsing table for the following


grammar.
S → L=R
S → R
L →R
L → id
R → L
b) Explain with an example, recursive descent parser with
back tracking.
4. a) What are the features and capabilities of the symbol table?
b) What are shift-reduce and reduce-reduce conflicts?
Explain with suitable example.
5. a) Explain implicit type conversion and explicit type
conversion with example.
b) Explain different issues in the design of code generator.
6. a) Generate the three-address code for the following code
segment:
While (a < c and b < d) do
If a = 1 then c = c + 1;
Else
While ( a < = d) do
a = a + 3;
b) With an example, explain the various formats of
intermediate code.

7. Explain various code optimization techniques in detail.

8. Write short notes on following: (Any Three)


a) Input Buffering
b) Canonical items
c) L-attributes and S-attributes
d) Back Patching

******
CS-7002-CBGS PTO

https://www.rgpvonline.com
Total No. of Questions : 8] [1] [Total No. of Printed Pages : 2

Roll No ..................................
CS-701-GS
B.E. VII Semester
Examination, December 2020
Grading System (GS)
Compiler Design
Time : Three Hours
Maximum Marks : 70
Note: i) Attempt any five questions.
ii) All questions carry equal marks.

l. a) What is front end and back end of compiler? What are the
advantages of breaking up the compiler functionality into
these two stages?
b) What are the various components of lexical specification
file? Illustrate with an example.

2. a) Illustrate the steps in the parsing of an input ‘x = y +z–5;’


by an LR parser using a predictive constructed LR passing
table.
b) Distinguish between top-down passing and bottom-up
parsing? What is the largest class of grammars that can
be parsed by each of them?

3. Explain various dynamic storage allocation techniques.

4. Discuss the role of lexical analyzer in detail.

5. What do you mean by Bootstrapping of compiler?

CS-701-GS PTO

https://www.rgpvonline.com
[2]

6. What do you mean by LEX? Explain in detail.

7. a) What are the fundamental differences between parse tree


and abstract syntax tree?
b) How does an Operator Precedence poner work? Use a
pre-constructed operator precedence table to guide the
parsing of an input ‘a+b–20’ using operator precedence
parser.

8. a) Describe the synthesis-analysis model of compiler?


b) Discuss input buffering and preliminary scanning in lexical
analysis.

******

CS-701-GS PTO

https://www.rgpvonline.com
https://www.rgpvonline.com

Total No. of Questions : 8] [Total No. of Printed Pages : 1

Roll No ..................................
CS-701 (GS)
B.E. VII Semester Examination, June 2020
Grading System (GS)
Compiler Design
Time : Three Hours
Maximum Marks : 70
Note: i) Attempt any five questions.
ii) All questions carry equal marks.

l. Construct a DAG for the basic block whose code is given below:
D: = B * C
E: = A + B
B: = B * C
A=E–D

2. Prove that Grammar is CLR but not LALR


S → Aa / bAc / Bc / bBa
A→d
B→d
3. Distinguish between top-down passing and bottom-up parsing? What is the largest class of grammars
that can be parsed by each of them?
4. What are the typical entries in a symbol table, what are the various data structures used to implement
the table.
5. How does an Operator Precedence poner work? Use a pre-constructed operator precedence table
to guide the parsing of an input ‘a+b–20’ using operator precedence parser.

6. Define a Quadruple. How is it different from triples? Convert the following expression into three
address code and quadruple.
S = (a + b) / (c – d) * (e + f)
7. Construct the DAG for the following basic block:
a:=b+c
b:=b–d
c:=c+d
e:=b+c
OR
What do you mean by LEX? Explain in detail.
8. Write short notes:(Any two)
a) Local and Loop optimization
b) Peephole optimization
c) Dead code elimination

******
CS-701 (GS)

https://www.rgpvonline.com
Total No. of Questions : 8] [1] [Total No. of Printed Pages : 3

Roll No ..................................

IT-6004-CBGS
B.E. VI Semester
Examination, December 2020
Choice Based Grading System (CBGS)
Compiler Design
Time : Three Hours
Maximum Marks : 70
Note: i) Attempt any five questions.
ii) All questions carry equal marks.
iii) Assume missing data if any, suitably.

1. a) Compare the features of a single pass compiler with


multi-pass compiler. 7
b) Briefly explain the compiler construction tools. 7

2. a) Consider the grammar: 7

E →5 + T 3 − T ,
T → V V *V V + V ,
V → a b.

What is the use of left factoring? Find the first and follow
for above grammar and do the left factoring for it.
b) Describe the following in brief. 7
i) Ambiguity
ii) Left recursion
iii) Parse Tree

IT-6004-CBGS PTO

https://www.rgpvonline.com
[2]

3. a) Consider the following grammar 7


E → E+T
T’ → TF/F
F → F*/a/b
Construct the SLR Parsing table for this grammar.
b) Construct the predictive parser for the following
grammar: 7
S – > (L)/a
L– > L,S/S

4. a) Write the grammar and syntax directed definitions for a


simple desk calculator and show annotated parse tree for
the expression: (3+4) * (5+6). 7
b) With an example, explain the various formats of
intermediate code. 7

5. a) What are the features and capabilities of the symbol table?


7
b) What is an activation record? Explain the purpose of
different fields in an activation record. 7

6. a) Write an algorithm to construct a DAG from a basic block.


7
b) Generate the three-address code for the following code
segment:
While (a < c and b < d) do
If a = l then c = c + 1;
Else
While (a < = d) do
a = a + 3; 7

IT-6004-CBGS Contd...
PTO

https://www.rgpvonline.com
[3]

7. a) Explain the common sub expression elimination, copy


propagation and transformation for moving loop invariant
computations in details. 7
b) Explain the peephole optimization. 7

8. Write short notes on following.(any three) 14


a) Lexical analysis
b) Canonical items
c) Back patching
d) L-attributes and S-attributes

******

IT-6004-CBGS PTO

https://www.rgpvonline.com

You might also like