0% found this document useful (0 votes)
457 views14 pages

Compiler Design Previous Papers

The document outlines the examination structure for a B.Tech degree in Computer Science and Engineering, focusing on Compiler Design. It includes various questions related to compiler phases, parsing techniques, lexical analysis, and code generation, with specific tasks such as constructing DFAs, syntax trees, and discussing optimization techniques. The exam format requires answering a compulsory question and any four from the remaining, with all questions carrying equal marks.

Uploaded by

sree
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
457 views14 pages

Compiler Design Previous Papers

The document outlines the examination structure for a B.Tech degree in Computer Science and Engineering, focusing on Compiler Design. It includes various questions related to compiler phases, parsing techniques, lexical analysis, and code generation, with specific tasks such as constructing DFAs, syntax trees, and discussing optimization techniques. The exam format requires answering a compulsory question and any four from the remaining, with all questions carrying equal marks.

Uploaded by

sree
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

July2o22

[07 BENG 3209] suyrz22


IIIIV B.Tech. DEGREE EXAMINATION.
Second Semester

Computer Science and Engineering


COMPILER DESIGN

(Common with Information Technology)


(Effective from the admitted batch of 2015-2016)
Time: Three hours Maximum: 70 marks
First Question is compulsory.
Answer any FOUR from the remaining questions.

All questions carry equal marks.

Answer all parts of any question at one place.

1. (a) Define a compiler and list the phases of a


compiler.
(b) What is meant by atransition diagram? Give
an example.
(c) What are the problems with Top-down
parsing?
(d) Construct a syntax tree for the arithmetic
expression a * (b+c).
various strategies used in
7. (a)
Discuss
allocation and assignment. regse
(e) Define DAG and give an example.
about code generators.
() Which object code form makes the code (b) Explain
generation process easier and why? Describe various approaches to organize
(g) List out the contents of a symbol table. 8 (a) symbol table.:
2. (a) Explain about Cross compilers.
(b) Explain about Error Handling Routines
(b) Describe compiler construction tools.
3. (a) Construct DFA for the regular expression
(11+0)*(00+1)*
(b) Explain about Lexical analysis.
4 (a) Explain Shift-reduce parsing with an

example.
(b) Discuss about Recursive Descent Parsing.
5. (a) Translate the arithmetic expression
a:=b*-c+b*-c into
(i) Syntax tree i) Postfix notation
(ii) Three-address code.
(b) Discuss about Type Checking and Type
Conversions.

6. (a) Discuss basic blocks and flow graphs with an


example.
(b) Explain machine dependent code
optimization techniques.

2 [07 BENG - 3209]


BENG- 329
3 107
also construct [07 BENG -3209] (C-19)
8 (a) Optimize the following loop and July202
flow graph:
EXAMINATION.
Begin III/IV B.Tech. DEGREE
Prod =0 Second Semester
i=1 Computer Science Engineering
do COMPILER DESIGN
Begin
(Common with IT)
Prod =Prod + a{i]* bi]
2015-2016)
i=j+I (Effective from the admitted batch of
batch only
End For the academic year 2020-2021
While (i 20); Maximum: 70 marks
Time: Three hours
End
First Question iscompulsory
remaining.
Answer any FOUR questions from the
Write all parts of any question at one place.

regular expression Over alphabet


1. (a) Write
one 'a' and at least
{a, b, c} containing at least
one b'.

phase?
(b) What is meant by pass and

(c) What is left factoring?

(d) Define handle pruning.

(C-19)
4 [07BENG - 3209]
(e) What is abstract syntax tree? Give an 4. (a) Illustrate brute force parsing technique with
example. suitable example.
(t) Define constant folding. (b) Computer FIRST and FOLLOW of the flowing
grammar:

(g) What are the rules to identity leader basic S’ aBDh, B ’ cC, C- ’ bc &, D ’ EF
blocks? E+g|e,Ff] [.
2. (a) Show the output produced by different stages 5 Design CLR Parser for the following grammar.
in compiler for the expression a := b*c/36; S ’L= R|R
where a, b and c are real numbers. L’*RIa
R ’L
(b) Explain bootstrapping a compiler with
suitable diagrams. 6. (a) Write about syntax directed definition and
syntax directed translation.
3. (a) Construct DFA from the following NFA: (b) Describe about type expressions.
M= ((p, q, r, s}, {0, 1}, , p, s).
Present State Next State
7. (a) Generate three address code for the following
switch block:
1
Switch(ch)
p p, a} p}
Case 1: c=a + b;
{r}
break;
{s} Case 2: c=a - b;
{s} break;
Case 3: C=a * b;
(b) What is the structure of LEX program? Write break;
a LEX program that accepts the keywords:
"begin, if, else" and identifier: "abc'. (b) Translate the expression (a + b) / (c + d) *(at
b/ c) - d into quadruples, triples and indirect
triples.
2 [07 BENG -3209] (C-19)
3 [07 BENG- 32091 (C-19)
[07 BENG - 3212]

IIIIV B.Tech. DEGREE EXAMINATION,


Second Semester
Computer Science and Engineering
COMPILER DESIGN
(Effective from the admitted batch of 2019-2020)
Time:Three hours Maximum:70 marks
First Question No. l is Compulsory.
Answer any FOUR from remaining questions.
All questions carry equal marks.
Answer ALL parts of any question at one place
1. Answer the following in brief :
(a) What are the uses of cross compilers?
(b) Determine whether the following regular
expression define the same language.
(ab)* and a*b*
(c) ls macro processing a phase in compilation?
Justify your answer.
(d) What is left-factoring? Explain.
(e) Define e-closure.
() What language does the grammar
S’ aSa| bSb|c generate?
(g) What is ICAN? Explain.
2
Define comp1le and explain varous phasee of 5 Consider the grammar given below:
compiler in detail. Also write down the output for EE+ T
the following expreEEIOn after each phase ET
a:=b*d. TT*F
3. (a) Explain the roie of Lexcal analvsis and the TF

18sues with leXIcalanalvser F (E)


(b) Explain the general format of LEX program F id
with example Prepare LR Parsing table for the above grammar.
Give the moves of LR Parser on id * id + id.
4 (a) Construct the pred1ctive parser for the Also explain error recovery in LR parsing.
following grammar
6. (a) Explain different schemes f storing name
S L)|a attribute in symbol table.
(b) Describe the method of generating syntax
L-L. s/s. directed definition of control statements.
Construct the behaviour of the parser on the 7. (a) Explain the principle of
SOurces code
sentence (a, a) using the grammar specified optimization in detail.
above.
(b) Explain the DAG representation of the basic
(b) Analyse whether the following grammar is block with example.
LR1) or not. Explain your answer with
reasons. 8. (a) Efficient code generation the
requires
S-L, R remember f internal architectural of the
S’R target machine. Justify your answer with an
L’ *R example.
L+ id (b) How the instruction forms effect the
R’L computation time? Explain.
2 [07 BENG - 3212]
3 [07 BENG -3212]
(07-3216 | gy022 sES)
III/IV B.Tech. DEGREE EXAMINATION
Computer Science and Engineering
Second Semester
COMPILER DESIGN
(Common with BTech. Information Technology)
(Effective from the admitted batch of 2006-2007)
Time: Hours Max. Marks: 70

Question No. 1is compulsory


Answer any FOUR questions from the remaining.
All questions carry equal marks.
Answer all parts of any question ai one place.
1. Write in brief on the following:
(a) Define NFA with example.
(b) Differentiate between phase and pass.
(c) Why we separate the lexical and syntactic phases
of a Compiler?
(d) How are the shift reduce conflicts
resolved in
bottom -up parsing?
(e)' List out the different
intermediate code form. representationsof
(f) List out the principle sources of
(g) Give the basic
optimization.
optimization. characteristics of peephole

2. (a) Give NFA for (a+ b)" ablb convert this toDFA.
(b) Explain the applications of grammar in the
design of COMPILER.
(P.T.O)
[07-3216 |
3. Discuss about the different stages of a
aneat sketch.
Compiler with

4. Define Left recursion. Give an algorithm for the


elimination ofLeft recursion.
5. Discuss about LR parser and SLR
parser.
6. (a) Explain about syntax directed
translation.
(b) Discuss the following:
(i) Postfix notation
(ii) Quadruples
(iü)Triples.
7. (a) Explain loop
example.
optinmization techniques with an
(b) Generate a DAGfor the following block
a:=b*c: d:=b:e:=d*c:b:=e:f=b+c:g:=ftd.
8. (a)Briefly describe about runtime storage
the Compiler. used by
(b) Explain about data
structures for svmbol table.

2
Dee 2022

7. (a) Describe different methods that are used in [07 BENG 3122]
Peep hole optimization'
EXAMINATION.
(b) Write a procedure to construct flow graph in III/IV B.Tech DEGREE
loop optimization. First Semester

Generate target code from sequence of three


Computer Science Engineering
8. (a) code
address statements using simple COMPILER DESIGN
generator algorithm. admitted batch of 2020-2021)
(With effective fom the
(b) Generate. machine code for the following Maximum: 70 marks
.Time:Three hours
instruction:
First question compulsorily.
v=a+b*c)-d.
remaining questions.
Answer any FOUR from the
marks.
Allquestions carry equal
language
1. (a) What is the role of preprocessor in
processing?
two lexical and
(b) Give an example for any
semantic errors.
grammar
Consider the
(c)
G:P’xQRS, Q’yze, R’ue, S’y,
What is FOLLOW (Q)?
pruning?
(d) What is meant by handle
attribute?
(e What is inherited
[07BENG 3122]
principle of CLR parser and
Unreachable code and copy 4. Explain the working
parse table for the given grammar
() Define construct the
propagation.
L
S’L= R|R, L’*Ra, R ’
g) What is dynamic type checking? constructed above check
Using the CLR (1) table
string id = id/id.
2. (a) What do you mean by front end in the the acceptance of input
compiler design? Show the output produced (a). Translate the expression
5.
by it in different stages for a: = *c/36; where =-(a+b) *(c+d)+(a+b+c) into
a, b and c are real numbers.
() Quadruple
(b) Explain bootstrapping compiler with
suitable diagrams. (i1) Triple
(ii) Indirect triple.
3. (a) What are the basic operations in Shift reduce
parser? Find the shift reduce parser (b) Generate three address code for the following
algorithm for the input string (a, (a, a)) using switch block :
following grammar :
for (i =1; is 10; i+ +)
S’(L)|a, L’L, S|S a<i]=y*2;
6. (a) variables with
(b) Check the following grammar is LL(1) or Write a grrammar to declare
not: data type int or float or char. Also develop a
syntax directed definition for that.
table?
S’aA Bb, A’cle, B’dla (b) What are the entries of symbol symbol
Describe the various operations of
table.

2 [07 BENG 3122] [07 BENG 3122|


CSE - SEP 202|

[07 BENG - 3209] (C-19)


IIIV B.Tech. DEGREE EXAMINATION.
Second Semester

Computer Science and Engineering


COMPILER DESIGN

(Common with Information Technology)


(Effective from the admitted batch of 2015-2016)
(For the AcademicYear 2020-2021 batch only)
Time:Three hours Maximum: 70 marks

First Question iscompulsory


Answer any FOUR questions from the remaining.

Write all parts of any question at one place.

1. (a) Define bootstrapping of a compiler.


(b) How does lexical analyzer help in the process
of compilation?
(c) Give the structure of LEX program.

(d) Define left recursion. How to eliminate left


recursion from CFG?
(e) Show that the grammar G:S ’ SS| aSb | 6. (a) What are the basic operations in Shift reduce
bsa | &is ambiguous. parser? Find the shift reduce parser
algorithm for the input string (a, (a, a)) using
() Define syntax directed translation. following grammar:
(g) Define loop invariant. Give an example. S’(L) | a, L-’L, S |S
2. (a) (b) Write a procedure to construct parsing table
What are different analysis phases of in SLR parser.
compiler? Explain the reasons for separation
of lexical analysis from syntax analysis. 7. (a) Explain about s-attributes and 1 attributes
(b) Describe compiler construction tools with with suitable example.
example. (b) Translate the expression: x = - (a +t b) *
(c + d) + (a + b + c) into (i) Quadruple
3. (a) Construct DFA for the regular expression: (ii) Triple (iii)Indirect triple.
(0 + 1)* 011.
8. (a) What is Peephole optimization? Explain
(b) Construct finite automata that accepts different Peep - hole optimization methods.
tokens: identifiers, decimal constants and
(b) What is a leader of basic block? Write an
integer constants.
algorithm tofind leaders.
4. (a) What is input buffering? Describe different
input buffering schemes.
(b) Write a procedure to compute FIRST and
FOLLOW of the grammar.

5. Construct predictive parsing table for the


following grammar and verify the string (a + a) is
accepting or not
E E+T|T T’T*F|F F’ (E) La

2 [07 BENG - 3209] (C-19)


3 [07 BENG - 3209](C-19
J07 BENG - 3209]
III/IV B.Tech. DEGREE EXAMINATION.
Second Semester

Computer Science Engineering


COMPLIER DESIGN

(Common with Information Technology)


(Effective from the admitted batch of 2015-2016)

Time : Three hours Maximum: 70 marks

First question is compulsory.


Answer any FOUR from the remaining questions.
All questions carries equal marks.
Answer allparts of any question at one place.

1. Answer the following in brief:


Finite automata.
(a)
(b) LR (K) parsing.
(c) Type conversion and type checking.
(d) Local optimization.
(e) Loop inversion.
() Lexical phase errors.
(g) Code generator.
2 (a) Explain different phases of compiler, 6. (a) What are the various attributes of symbol
showing the output of each phase, using the
example of the following statement. table? Discuss about ordered and unordered
symbol tables.
Position:= initial +rate * 60
(b) What is the function of symbol table in
(b) What is ambiguious grammar? Eliminate the
ambiguities for the grammar compilation process? Explain.
E’E+ E|E*E|(E) |id 7. (a) Explain about dataflow analysis of
3.
structured programs.
(a) Construct SLR parsing table for the
following grammar (b) Describe about Peep-Hole optimization and
machine dependent optimization techniques.
S’ AS|b
A ’SAla 8. Write short notes on the following :
(b) What is recursive descent parser? Constant (a) Brute force parsing
recursive descent parser for the following (b) 3-Address code
grammar.
(c) Code generation from DAG.
E’E+ TIT
T’ TF|F
F’F|a|b
4. (a) Write the quadruple, triple, indirect triple
for the statement a:=b' -c+b -c.
(b) Explain the role of intermediate code
generator in compilation process.
5. (a) Describe various register allocation
techniques.
(b) What is code optimization? What are its
advantáges? Discuss the problems in
optimizing the code.
2 [07 BENG - 3209] [07 BENG 3209]

You might also like