0% found this document useful (0 votes)
7 views16 pages

Compiler

The document outlines the structure and content of various Compiler Design examinations for B.Tech students across different semesters and years. It includes multiple sections with questions on topics such as compiler phases, parsing techniques, regular expressions, symbol tables, and optimization strategies. Each section contains a mix of brief questions, detailed explanations, and problem-solving tasks related to compiler design concepts.

Uploaded by

Sachin Patel
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)
7 views16 pages

Compiler

The document outlines the structure and content of various Compiler Design examinations for B.Tech students across different semesters and years. It includes multiple sections with questions on topics such as compiler phases, parsing techniques, regular expressions, symbol tables, and optimization strategies. Each section contains a mix of brief questions, detailed explanations, and problem-solving tasks related to compiler design concepts.

Uploaded by

Sachin Patel
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/ 16

Printed Pages:02 Sub Code:ECS603

Paper Id: 1 1 0 6 0 3 Roll No.

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

1. Attempt all questions in brief. 2 x 10 = 20


a) what is translator?
b) Differentiate between compiler and assembler.
c) Discuss conversion of NFA into a DFA . also give the algorithm used in this conversion.
d) Write down the short note on symbol table.
e) Describe Data structure for symbol table .
f) What is mean by Activation record
g) What is postfix notations ?
h) Define Three address Code

i) What are Quadruples.


j) what do you mean by regular expression?
SECTION B

2. Attempt any three of the following: 10 x 3 = 30


a). Write down the regular expression for
1. The set of all string over {a,b} such that fifth symbol from right is a.
2. The set of all string over {a,b} such that every block of four consecutive symbol contain
at least two zero.

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
SAB , ABS | b , BSA | 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
ETE’
E’+TE’|€
TFT’
T’*FT’|€
FF*|a|b
SECTION C
3. Attempt any one part of the following: 10 x 1 = 10
a). Give Operator –precedence parsing algorithm. Consider the following grammar and build up
operator precedence table. Also parse the input string (id+(id*id))
EE+T|T
TT*F|F
F(E)|id
b). For the grammar
SaAd |bBd |aBe |bAe Af , Bf
Construct LR(1) Parsing table .also draw the LALR table from the derived LR(1) parsing table.

4. Attempt any one part of the following: 10 x 1 = 10


a). What is postfix notations ? translate (C+D)*(E+Y) into postfix using syntax directed translation
scheme(STDS)
b). consider the following grammar EE+E | E*E|(E)|id . construct the SLR parsing table and
suggest your final parsing table.

5. Attempt any one part of the following: 10 x 1 = 10


a). Explain logical phase error and syntactic phase error . also suggest methods for recovery of error.
b). Generate three address code for C[A[I, j] ] = B[I ,j]+C[A[ I , j ] ]+D[ I + j ] (You can assume any data
for solving question , if needed) Assuming that all array elements are integer. Let A and B a 10 X 20
array with low1 =low2=1.

6. Attempt any one part of the following: 10 x 1 = 10


a). Give the algorithm for the elimination of local and global common Sub expression . discuss the
algorithm with the help of example also.
b). consider the following three address code segments
PROD := 0
I:= 1
T1:=4*I
T2:=addr(A)‐4
T3:=T2[T1]
T4:=addr(B)‐4
T5:=T4[T1]
T6:=T3*T5
PROD:=PROD +T6
I:=I+1
If i<=20 goto (3)
a. Find the basic blocks and flow graph of above sequence.
b. Optimize the code sequence by applying function preserving transformation and loop
optimization technique.
7. Attempt any one part of the following: 10 x 1 = 10
a). . Write short note on
i. Loop optimization
ii. Global data analysis

b). . Write short note on


i. Direct acyclic graph
ii. YACC parser generator
Printed Pages:2 Sub Code:RCS602

Paper Id: 110263 Roll No.

BTECH
(SEM VI) THEORY EXAMINATION 2018-19
COMPILER DESIGN
Time: 3 Hours Total Marks: 70
Note: 1. Attempt all Sections. If require any missing data; then choose suitably.

SECTION A

1. Attempt all questions in brief. 2 x 7 = 14


a. What are the two parts of a compilation? Explain briefly.
b. What is meant by viable prefixes?
c. What are the classifications of a compiler?
d. List the various error recovery strategies for a lexical analysis.
e. What is dangling else problem?

A
f. What are the various types of intermediate code representation?

PT
g. Define peephole optimization.
U
G

.2
SECTION B
AR

62
2. Attempt any three of the following: 7 x 3 = 21
M

5.
a. Write the quadruples ,triple and indirect triple for the following expression:
KU

11
(x+y)*(y+z)+(x+y+z)

5.
Y

|4
b. What are the problems with top down parsing? Write the algorithm for FIRST
JA

and FOLLOW.
46
VI

c. Perform Shift Reduce Parsing for the given input strings using the grammar
8:
R

S->(L)|a
:3
D

L->L,S|S
13

i) (a,(a,a))
ii) (a,a)
9
01

d. What is global data flow analysis? How does it use in code optimization?
-2
ay

e. Construct LR(0) parsing table for the following grammar


M

S-> cB | ccA
4-

A->cA | a
|1

B-> ccB | b

SECTION C
3. Attempt any one part of the following: 7x1=7
(a) Convert following NFA to equivalent DFA and hence minimize the number
of states in the DFA.

DR VIJAY KUMAR GUPTA | 14-May-2019 13:38:46 | 45.115.62.2


Printed Pages:2 Sub Code:RCS602

(b) Explain the various parameter passing mechanisms of a high level language.

4. Attempt any one part of the following: 7x1=7


(a) How would you represent the following equation using DAG?

a:=b*-c+b*-c
(b) Distinguish between static scope and dynamic scope. Briefly explain access to
non-local names in static scope.

A
PT
5. Attempt any one part of the following: 7x1=7
(a) U
Write short notes on the following with the help of example:
G
(i) Loop unrolling

.2
(ii) Loop Jamming
AR

62
(iii) Dominators
(iv) Viable Prefix
M

5.
KU

11
(b) Draw the format of Activation Record in stack allocation and explain each field
in it.
5.
Y

|4
JA

6. Attempt any one part of the following: 7x1=7


46
VI

(a) Write down the translation procedure for control statement and switch
8:
R

statement
:3
D

13

(b) Define Syntax Directed Translation. Construct an annotated parse tree for the
expression (4 * 7 + 1) * 2, using the simple desk calculator grammar.
9
01

7. Attempt any one part of the following: 7x1=7


-2

(a) Explain in detail the error recovery process in operator precedence parsing
ay

method.
M

(b) Explain what constitute a loop in flow graph and how will you do loop
4-

optimizations in code optimization of a compiler.


|1

DR VIJAY KUMAR GUPTA | 14-May-2019 13:38:46 | 45.115.62.2


Printed Pages : 1 Roll No. ECS603

B.TECH.
THEORY EXAMINATION (SEM–VI) 2016-17
COMPILER DESIGN

Time : 3 Hours Max. Marks : 100


Note : Be precise in your answer. In case of numerical problem assume data wherever not provided.

SECTION – A
1. Attempt the following: 10 x 2 = 20
(a) State any two reasons as to why phases of compiler should be grouped.
(b) Write regular expression to describe a language consist of strings made of even
numbers a & b.
(c) Write a CF grammar to represent palindrome.
(d) Why are quadruples preferred over triples in an optimizing compiler?
(e) Give syntax directed translation for case statement.
(f) What is a syntax tree? Draw the syntax tree for the following statement: c b c b a − ∗ +
−∗=
(g) How to perform register assignment for outer loops?
(h) List out the criteria for code improving transformations.
(i) Represent the following in flow graph i=1;sum=0;while (i<=10){sum+=i;i++}
(j) What is the use of algebraic identities in optimization of basic blocks?

SECTION – B
2. Attempt any five of the following questions: 5 x 10 = 50
(a) Explain in detail the process of compilation. Illustrate the output of each phase of
compilation of the input “a=(b+c)*(b+c)*2”..
(b) Construct the minimized DFA for the regular expression (0+1)*(0+1) 10.
(c) What is an ambiguous grammar? Is the following grammar ambiguous? Prove
EE+|E(E)|id.The grammar should be moved to the next line ,centered.
(d) Draw NFA for the regular expression ab*/ab.
(e) How names can be looked up in the symbol table? Discuss.
(f) Write an algorithm to partition a sequence of three address statements into basic blocks.
(g) Discuss in detail the process of optimization of basic blocks. Give an example
(h) How to subdivide a run-time memory into code and data areas. Explain

SECTION – C
Attempt any two of the following questions: 2 x 15 = 30
3 Consider the following grammar
S-AS|b
A-SA|a.
Construct the SLR parse table for the grammar. Show the actions of the parser for the
input string “abab”.
4 How would you convert the following into intermediate code? Give a suitable example.
i) Assignment Statements. ii) Case Statements
5 Define a directed acyclic graph. Construct a DAG and write the sequence of
instructions for the expression a+a*(b-c)+(b-c)*d.
Printed Page: 1 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

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

and pattern matching.


17
b. For the grammar 10 2
Q

|1

SaAd |bBd |aBe |bAe , Af , Bf


Construct LR(1) Parsing table. Also draw the LALR table.
5

c. Explain the concepts of quadruples and triples in the context of syntax- 10 3


3

directed translation. Discuss how they represent intermediate code and


7:

support optimization.
:2

d. Describe a simple stack allocation scheme for managing memory during 10 4


13

program execution. Explain how it is used for storing local variables and
4

managing function calls.


02

e. Explain the role of a code generator in a compiler. Discuss its 10 5


-2

responsibilities and how it translates intermediate code into the target


code.
01
4-

SECTION C
|2

3. Attempt any one part of the following: 10x1=10


a. Given a regular expression a(b|c)*, construct the corresponding 10 1
Nondeterministic Finite Automaton (NFA) that recognizes the language
described by the regular expression.
b. Check whether given grammar is ambiguous or not. If ambiguous then convert 10 1
it into unambiguous grammar: E→E+E|E*E|id.

1|Page
QP24DP1_290 | 24-01-2024 13:27:35 | 117.55.242.131
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

4. Attempt any one part of the following: 10x1=10


a. Check whether the given grammar is LR(0) or not: S→PQy, P→Sy|x, Q→yS. 10 2
b. Consider the following grammar for a simple expression language: 10 2
E→E+T|T
T→T*F|F
F → ( E ) | id
Consider expression id * (id+id).Apply shift reduce parsing to construct parse
tree.

5. Attempt any one part of the following: 10x1=10


a. Write syntax directed definition for a given assignment statement: 10 3
S → id=E
E → E+E
E →E*E
E→-E
90
E → (E)

1
13
E→id
_2

b. Explain how syntax-directed translation handles array references within 10 3

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

b. Define semantic errors in a compiler. Discuss the challenges associated 10


|1

with detecting and handling semantic errors. Provide examples to


5

illustrate semantic issues.


3
7:

7. Attempt any one part of the following: 10x1=10


:2

a. Consider a basic block with the following three instructions: 10 5


13

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

b. Construct a Directed Acyclic Graph (DAG) to represent the following 10 5


01

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
Printed Pages:02 Sub Code: KIT-052
Paper Id: 231849 Roll No.

B. TECH.
(SEM V) THEORY EXAMINATION 2022-23
COMPILER DESIGN
Time: 3 Hours Total Marks: 100
Note: Attempt all Sections. If require any missing data; then choose suitably.

SECTION A

1. Attempt all questions in brief. 2 x 10 = 20


(a) What is a lexeme? Define a regular set.
(b) What is a predictive parser?
(c) List the properties of LR parser.
(d) Give the applications of DAG.
(e) Define backpatching.
(f) Draw the transition diagram for an identifier.
(g) Differentiate analysis and synthesis phase.
(h) What are the functions of error handler?
(i) Define a syntax-directed translation.
(j) Define loop jamming with an example.

2
90

13
_2

2.
SECTION B
P1

24
2. Attempt any three of the following: 10 x 3= 30

5.
3D

.5
(a) Construct a DFA that accepts a language L over input alphabets ∑ = {a, b} such that
P2

L is the set of all strings starting with ‘aa’ or ‘bb’. 17


Q

(b) Define the following terms and give suitable example for it.
|1
i) Handle
ii) Handle pruning
3
:3

iii) Left Factoring


29

(c) Construct CLR parsing table for the following grammar.


S→ CC
:
13

C→ cC | d
(d) Explain various data structures used in symbol table management.
3

(e) Define DAG. Explain DAG representation of basic block with example.
02
-2

SECTION C
01

3. Attempt any one part of the following: 10 x 1= 10


8-
|1

(a) Explain stack implementation of shift reduce parser.


(b) What is left recursion? Eliminate the left recursion from the following grammar.
E→E+T|T
T→ T * F | F
F → ( E ) | id

QP23DP1_290 | 18-01-2023 13:29:33 | 117.55.242.132


4. Attempt any one part of the following: 10 x 1= 10

(a) Discuss differences between inherited attributes and synthesized attributes.


(b) Explain various dynamic storage allocation techniques.

5. Attempt any one part of the following: 10 x 1= 10

(a) What is an activation record? Explain how they are used to access local and global
variables.
(b) Explain syntax directed translation scheme for Infix to Postfix conversation with
example.

6. Attempt any one part of the following: 10 x 1= 10

(a) Generate three address code for the following code segment
While (a<b) do
If (c<d) then x= y+z
(b) Explain different error recovery techniques with suitable example.

2
7. Attempt any one part of the following:
90 10 x 1= 10

13
_2

2.
(a) What is intermediate code? Explain different types of intermediate
P1

24
coderepresentations. Also discuss importance of intermediate code.
(b) Explain in detail about the data-flow schemas on basic block and the transfer

5.
3D

equations for reaching definitions with example.

.5
P2

17
Q

|1
3
:3
: 29
13
3
02
-2
01
8-
|1

QP23DP1_290 | 18-01-2023 13:29:33 | 117.55.242.132


Printed Pages:02 Sub Code:KCS-502
Paper Id: 231842 Roll No.

B. TECH.
(SEM V) THEORY EXAMINATION 2022-23
COMPILER DESIGN

Time: 3 Hours Total Marks: 100


Note: Attempt all Sections. If require any missing data; then choose suitably.

SECTION A

1. Attempt all questions in brief. 2 x 10 = 20


(a) How will you group the phases of compiler?
(b) Mention the role of semantic analysis.
(c) What are the various parts in LEX program?
(d) Differentiate Parse tree and Syntax tree with an example.
(e) Give the properties of intermediate representation.
(f) Differentiate between LR and LL parsers.
(g) What is phrase level error recovery?
(h) Discuss the capabilities of CFG.
(i) Define loop jamming.

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

environment with an example.


(c) What do you mean by attributed grammars? Discuss the translation
-2

scheme for converting an infix expression to its equivalent postfix form.


01

(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

QP23DP1_290 | 18-01-2023 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:
ABB
B cB
Bd
(b) Construct the SLR parsing table for the following Grammar.
S→ 0S0
S→ 1S1
S→ 10

4. Attempt any one part of the following: 10 x 1 = 10


(a) What is back patching. Generate three address code for the following
Boolean expression using back patching:
a < b or c > d and e < f
(b) What is top down parsing? What are the problems in top down parsing?
Explain each with suitable example.

5. Attempt any one part of the following: 10 x 1 = 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

(b) How do we represent the scope information? Explain scope by number

24
and scope by location.

5.
3D

.5
P2

6. Attempt any one part of the following: 10 x 1 = 10


(a) Define Symbol table? Explain about the data structures used for 17
Q

|1
symbol table.
(b) Explain the following:
7

(i) Copy Propagation


:2

(ii) Dead-Code Elimination


29

(iii) Code Motion


:

(iv) Reduction in Strength.


13
3

7. Attempt any one part of the following: 10 x 1 = 10


02

(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

QP23DP1_290 | 18-01-2023 13:29:27 | 117.55.242.132


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 2021-22
COMPILER DESIGN

Time: 3 Hours Total 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
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

a. Construct the LALR parsing table for the given grammar


17
S →BB
Q

|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

d. Discuss the following terms:


i. Basic block
09

ii. Next use information


2

iii. Flow graph


02

e. Construct predictive parse table for the following grammar.


E → E + T/T
-2

T →T *F/F
n
Ja

F →F /a/b
2-

SECTION C
|1

3. Attempt any one part of the following: 10 x 1 = 10


a. Construct the SLR parse table for the following Grammar
E→E+E
E→E*E
E→id
b. Differentiate between stack allocation and heap allocation.

QP22O1P_290 | 12-Jan-2022 09:00:59 | 117.55.242.131


Printed Page: 2 of 2
Subject Code: KCS502
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0

4. Attempt any one part of the following: 10 x 1 = 10


a. Write syntax directed definition for a given assignment statement:
S → id=E
E → E+E
E →E*E
E→-E
E → (E)
E→id
b. What are the advantages of DAG? Explain the peephole optimization.

5. Attempt any one part of the following: 10 x 1 = 10


a. What do you understand by lexical phase error and syntactic error? Also suggest methods
for recovery of errors.
b. Discuss how induction variables can be detected and eliminated from the given
intermediate code
B2: i:= i+1
t1:=4*j

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

S1AB / ε
17
A1AC/0C
Q

|1

B0S
C1
59

b. Distinguish between static scope and dynamic scope. Briefly explain access to non local
0:

names in static scope.


:0

7. Attempt any one part of the following: 10 x 1 = 10


09

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;
}

QP22O1P_290 | 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

1. Attempt all questions in brief. 2 x 10 = 20


Qno. Question Marks CO
a. What is YACC? Discuss about it. 2 CO 1
b. Design a DFA for the following regular expression: 2 CO 1
(x+y)*xyy
c. Consider the following grammar: 2 CO 2
S→B|SabS, B→bB| ε
Compute FOLLOW(B)
d. Discuss about shift-reduce parsing. 2 CO 2
e. Find the postfix notation for the following expression: 2 CO 3
(a+b+c)*(c+q)

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

h. Discuss about hash table. 2 CO 4

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

Qno. Question Marks CO


|1

a. Explain in detail the process of compilation for the statement 10 CO 1


AK

a=b+c*70.
4 8

b. Construct the CLR(1) parsing table for the following grammar: 10 CO 2


8:

S→AA, A→aA|b
:1

c. Consider the following grammar and give the syntax directed 10 CO 3


09

definition to construct parse tree for the input expression 4*7+3*9.


Also construct an annotated parse tree according to your syntax
1

directed definition.
02

E→E+T|T, T→T*F|F, F→num.


2

d. Explain lexical, syntax, semantic phase errors in detail. 10 CO 4


b-

e. Explain in detail about loop optimization. 10 CO 5


Fe

SECTION C
5-

3. Attempt any one part of the following:


|2

Qno. Question Marks CO


a. (i). Write a regular expression to represent a language consisting of 10 CO 1
strings made up of odd number of a & odd number of b.
(ii). Write a CFG to represent the language L={an+mbn|m,n≥1}.
b. (i). Check whether given grammar is ambiguous or not. If ambiguous 10 CO 1
then convert it into unambiguous grammar:
E→E+E|E*E|id
(ii). Discuss about cross compiler.
1|Page
AKTU_QP20E290QP | 25-Feb-2021 09:18:48 | 117.55.242.131
Printed Page: 2 of 2
Subject Code: KCS502
0Roll No: 0 0 0 0 0 0 0 0 0 0 0 0 0

4. Attempt any one part of the following:


Qno. Question Marks CO
a. Check whether the given grammar is LR(0) or not: 10 CO 2
S→PQy, P→Sy|x, Q→yS
b. Find the precedence and function table of the following grammar by 10 CO 2
using operator precedence technique.
P→SR|S, R→bSR|bS, S→WbS|W, W→L*W|L, L→id

5. Attempt any one part of the following:


Qno. Question Marks CO
a. Translate the following arithmetic expression into quadruples and 10 CO 3
triples:
(i). x=y*z+y*-z
(ii). a=-b*(c+d)+b
b. Generate three address code for the following code: 10 CO 3
Switch p+q
{

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

6. Attempt any one part of the following:


.5
17
TU

Qno. Question Marks CO


|1
AK

a. What is symbol table? Explain various data structures used for 10 CO 4


8

symbol table.
4

b. (i). Explain the function of error handling phase of a compiler. 10 CO 4


8:

(ii). Write short note on scoping.


:1
09

7. Attempt any one part of the following:


1
02

Qno. Question Marks CO


a. Construct the flow graph for the following code segment: 10 CO 5
2
b-

fact(n)
Fe

{
int f=1;
5-

for(i=2; i≤n; i++)


|2

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

You might also like