Compiler Design
Compiler Design
BTECH
(SEM V) THEORY EXAMINATION 2023-24
COMPILER DESIGN
TIME: 3 HRS M.MARKS: 100
Note: 1. Attempt all Sections. If require any missing data; then choose suitably.
SECTION A
1. Attempt all questions in brief. 2 x 10 = 20
Q no. Question Marks CO
a. Define bootstrapping in the context of compilers. 2 1
b. Which phase of compiler is optional and why? 2 1
c. Explain the concept of shift-reduce parsing. 2 2
d. Differentiate Parse tree and Syntax tree with an example. 2 2
e. Define syntax-directed translation schemes. 2 3
f. What are the two types of attributes that are associated with a grammar 2 3
symbol?
g. Discuss how scope information is represented in a symbol table. 2 4
h. What is mean by Activation record? 2 4
i. Discuss two design issues in code generation. 2 5
90
1
j. Explain the concept of global data-flow analysis. 2 5
13
_2
2.
SECTION B
P1
24
2. Attempt any three of the following: 10x3=30
a. Describe the relationship between finite state machines and regular 10 1
4D
5.
expressions. Discuss how regular expressions are used in lexical analysis
.5
P2
|1
support optimization.
:2
program execution. Explain how it is used for storing local variables and
4
SECTION C
|2
1|Page
QP24DP1_290 | 24-01-2024 13:27:35 | 117.55.242.131
Downloaded from: uptukhabar.net
Printed Page: 2 of 2
Subject Code: KCS502
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
BTECH
(SEM V) THEORY EXAMINATION 2023-24
COMPILER DESIGN
TIME: 3 HRS M.MARKS: 100
1
13
E→id
_2
2.
P1
arithmetic expressions.
24
4D
5.
6. Attempt any one part of the following: 10x1=10
.5
P2
a. Define Symbol table? Explain about the data structures used for symbol 10 4
17
table.
Q
1. x = a + b
2. y = x * c
4
02
3. z = y – d
Apply common sub expression elimination to optimize the basic block.
-2
basic block:
4-
1. x = a + b
|2
2. y = c - d
3. z = x * y
2|Page
QP24DP1_290 | 24-01-2024 13:27:35 | 117.55.242.131
Downloaded from: uptukhabar.net
Printed Pages:02 Sub Code:KCS-502
Paper Id: 231842 Roll No.
B. TECH.
(SEM V) THEORY EXAMINATION 2022-23
COMPILER DESIGN
SECTION A
2
90
13
(j) What is induction variable?
_2
2.
P1
24
SECTION B
5.
3D
.5
2. Attempt any three of the following: 10 x 3 = 30
P2
(a) Write SDD to produce three-address code for Boolean expressions and 17
Q
|1
obtain the three-address code for the statement given below:
7
while a < b do
:2
if c < d then
29
x=y*z
:
else
13
x=y+z
(b) Discuss the stack allocation and heap allocation strategies of the runtime
3
02
(d) Construct the NFA and DFA for the following regular expression.
8-
(0+1)*(00+11)(0+1)*
|1
(e) Explain the lexical analysis and syntax analysis phases of the compiler
with a suitable example. Explain the reporting errors in these two phases
as well.
SECTION C
Downloaded from|:18-01-2023
QP23DP1_290 uptukhabar.net
13:29:27 | 117.55.242.132
3. Attempt any one part of the following: 10 x 1 = 10
(a) Construct the CLR parse table for the following Grammar:
ABB
B cB
Bd
(b) Construct the SLR parsing table for the following Grammar.
S→ 0S0
S→ 1S1
S→ 10
2
90
(a) What is an activation record? Draw diagram of general activation
13
record and explain the purpose of different fields of an activation
_2
2.
record.
P1
24
and scope by location.
5.
3D
.5
P2
|1
symbol table.
(b) Explain the following:
7
(a) Explain in the DAG representation of the basic block with example.
-2
(b) Write quadruple, triples and indirect triples for following expression :
01
a = b * – c + b * – c.
8-
|1
B.TECH.
(SEM V ) THEORY EXAMINATION 2021-22
COMPILER DESIGN
SECTION A
1. Attempt all questions in brief. 2 x 10 = 20
a. What is the difference between parse tree and abstract syntax tree?
b. Explain the problems associated with top-down Parser.
c. What are the various errors that may appear in compilation process?
d. What are the two types of attributes that are associated with a grammar symbol?
e. Define the terms Language Translator and compiler.
f. What is hashing? Explain.
g. What is do you mean by left factoring the grammars? Explain.
h. Define left recursion. Is the following grammar left recursive?
E → E+E | E*E| a| b
1
90
i. What is an ambiguous grammar? Give example.
13
j. List down the conflicts during shift-reduce parsing.
_2
2.
1P
24
SECTION B
2O
5.
2. Attempt any three of the following: 10 x 3 = 30
.5
P2
|1
B→ aB / b
b. What is an activation record? Explain how it is related with runtime storage organization?
59
c. Write the quadruple, triple, indirect triple for the following expression
0:
(x + y)*(y + z) + (x + y + z)
:0
T →T *F/F
n
Ja
F →F /a/b
2-
SECTION C
|1
1
90
13
t2:=a[t1]
_2
if t2<10 goto B2
2.
1P
24
6. Attempt any one part of the following: 10 x 1 = 10
2O
5.
a. Test whether the grammar is LL(1) or not, and construct parsing table for it.
.5
P2
S1AB / ε
17
A1AC/0C
Q
|1
B0S
C1
59
b. Distinguish between static scope and dynamic scope. Briefly explain access to non local
0:
a. What are the various issues in design of code generator & code loop optimization?
2
02
b. Generate the three address code for the following code fragment.
-2
while(a>b)
n
{
Ja
if(c<d)
2-
x=y+z;
|1
else
x=y-z;
}
Downloaded
QP22O1P_290 from : uptukhabar.net
| 12-Jan-2022 09:00:59 | 117.55.242.131
Printed Page: 1 of 2
Subject Code: KCS502
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0
B TECH
(SEM-V) THEORY EXAMINATION 2020-21
COMPILER DESIGN
Time: 3 Hours Total Marks: 100
Note: 1. Attempt all Sections. If require any missing data; then choose suitably.
SECTION A
P
f. Discuss about non-linear type intermediate code. 2 CO 3
0Q
1
g. Write short note on “Activation Record” 2 CO 4
13
29
2.
i. Discus about constant folding. 2 CO 5
0E
24
j. Discuss about designing issues of code generator. 2 CO 5
P2
SECTION B
5.
_Q
.5
2. Attempt any three of the following: 17 3 x 10 = 30
TU
a=b+c*70.
4 8
S→AA, A→aA|b
:1
directed definition.
02
SECTION C
5-
P
case 1: x=x+1
0Q
1
case 2: y=y+2
13
29
case 3: z=z+3
2.
default: c=c-1
0E
24
P2
5.
_Q
symbol table.
4
fact(n)
Fe
{
int f=1;
5-
f=f*i;
return f;
}
b. Define a DAG. Construct a DAG for the expression: 10 CO 5
p+p*(q-r)+(q-r)*s
2|Page
AKTU_QP20E290QP | 25-Feb-2021 09:18:48 | 117.55.242.131
Printed Pages:02 Sub Code:ECS603
B. Tech.
(SEM VI) CARRY OVER THEORY EXAMINATION 2017-18
Compiler Design
Time: 3 Hours Total Marks: 100
Note: 1. Attempt all Sections. If require any missing data; then choose suitably.
2. Any special paper specific instruction.
SECTION A
b). Construct the NFA for the regular expression a/abb/a*b+ by using Thompson’s construction
methodology.
c). Eliminate left recursion from the following grammar
SAB , ABS | b , BSA | a
d). Discuss conversion of NFA into a DFA . also give the algorithm used in this conversion.
e). Explain non recursive predictive parsing. Consider the following grammar and construct the
predictive parsing table
ETE’
E’+TE’|€
TFT’
T’*FT’|€
FF*|a|b