You are on page 1of 25

Thakur College of Science & Commerce (Autonomous)

Department of Computer Science


Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Consider the following matrix:


10001010
00010010
10100010
00010000
10001010
10000101
00001000
10001001
a) Accept the matrix and store it in appropriate data structure and print.
b) Check whether it is a Boolean matrix.
c) Apply Warshall’s algorithm and find kleen’s closure of the same.

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II
Write a C/C++/JAVA/Python program to perform following: [40 marks]
Accept following grammar and perform following:
S->aB
S->bS
S->c
B->aS
B->bB
a) Store it in suitable data structure.
b) Print non terminals and terminals on screen.
Define grammar and mention its components on answer sheet.

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Consider the following matrix:


10001010
00010010
10100010
00010000
10001010
10000101
00001000
10001001
a) Accept the matrix and store it in appropriate data structure and print.
b) Check whether it is a Boolean matrix.
c) Apply Warshall’s algorithm and find kleen’s closure of the same.

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Consider the FA and perform following:


a) Identify whether it is NFA/DFA and justify. Write it in answer book. [05]
b) Accept the FA from user and store it in suitable data structure. [15]
c) Write a program to Display transition table and draw it on your paper. [10]
Count the number of “0” transitions. [10]
Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Write a C/C++/JAVA program to perform following: [40 marks]


Accept following grammar and perform following:
Z->bMb
M->(L
M->a
L->Ma)
a) Define the term grammar and explain four components of it.
b) Accept the grammar in appropriate data structure.
c) Construct First() matrix .
d) Compute Last() matrix. [10]
e) Write the matrix format on answer sheet. [05]
Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Write a C/C++/JAVA/Python program to construct DFA for following RE [40]

a(a+b)*b

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Consider the following matrix:


10001010
00010010
10100010
00010000
10001010
10000101
00001000
10001001
a) Accept the matrix and store it in appropriate data structure and print.
b) Check whether it is a Boolean matrix.
c) Apply Warshall’s algorithm and find kleen’s closure of the same.

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Consider the following matrix:


10001010
00010010
10100010
00010000
10001010
10000101
00001000
10001001
a) Accept the matrix and store it in appropriate data structure and print.
b) Check whether it is a Boolean matrix.
c) Apply Warshall’s algorithm and find kleen’s closure of the same.

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Write a C/C++/JAVA/Python program to perform following:

a) Define the term grammar and explain four components of it. [05]
b) Accept the grammar in appropriate data structure and print them on screen. [15]
Construct First() and Last() matrices and show on answer sheet . [20]
Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Write a C/C++/JAVA/Python program to perform following:

a) Accept three-address code and store it in suitable data structure. [15]


T1=-c
T2=b*T1
T3=-c
T4=b*T3
T5=T2+T4
b) Separate operators and operand. [05]
Display DAG on screen and write the same on answer sheet. [20]

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Write a C/C++/JAVA/Python program to perform following:

a) Accept the expression from user. [05]


C=A*B-C*(A*B-D)
b) Separate operands and operators. [05]
c) Generate three-address code and print them on screen. [15]
Generate DAG. [15]

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Consider the above Automata and perform following:


a) Define NFA. [05]
b) Accept it from user and store it in suitable data structure. [15]
c) Display transition table and print on screen. [05]
Convert into DFA. [15]

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Write a C/C++/JAVA/Python program to perform following:

a) Explain the working of loop unrolling with suitable example. [10]


b) Develop a suitable code to demonstrate the concept with proper comments [30]

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Write a C/C++/JAVA/Python program to perform following: [40]

Obtain the DAG for the following input arithmetic expression

a) Input the given expression and store it in suitable data structure of your choice
A = B + C , B = C + D, D = A
b) Print the operators and variables/constant on the screen.
c) Compute and generate the temporaries Ti required for generation of three address code.

Prepare a table with four fields: Label, Address, Identifiers, Left Child and Right Child for a
sequence of Three-Address Code and display the step- by-step output of the DAG.

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Write a C/C++/JAVA/Python program to perform following: [40]

Demonstrate loop unrolling for the given code sequence containing loop.
a) Accept the code sequence from the user and store them in suitable data structure of
your choice int i;

for ( i=0;i<100;i++)
{
j=5;
i= i+ j;
}

b) Determine the unroll statements from the body.


c) Determine the unrolling factor, unroll the code and store in suitable data structure.

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Write a C/C++/JAVA/Python program to perform following: [40]

a. Explain the working of loop unrolling with suitable example.


b. Accept the following code and store it in suitable data structure.
for i=1 to 100
do
if i<50 then goto b1

if i>=50 and i<60 then goto b2


else goto b3
c. Develop a code to unroll following code.

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Write a C/C++/JAVA/Python program to perform following: [40]

Obtain the DAG for the following input arithmetic expression


a) Input the given expression and store it in suitable data structure of your choice.
A=Z+X , D=M-9, R=D
b) Print the operators and variables/constant on the screen.
c) Compute and generate the temporaries Ti required for generation of three address code.
d) Prepare a table with four fields: Label, Address, Identifiers, Left Child and Right Child
for a sequence of Three-Address Code and display the step- by-step output of the DAG.

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Write a C/C++/JAVA/Python program to perform following: [40]

Consider the above Automata and perform following:


a) Define NFA.
b) Accept it from user and store it in suitable data structure.
c) Display transition table and print on screen.
Convert into DFA

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Consider the following matrix:


10001010
00010010
10100010
00010000
10001010
10000101
00001000
10001001
a) Accept the matrix and store it in appropriate data structure and print.
b) Check whether it is a Boolean matrix.
c) Apply Warshall’s algorithm and find kleen’s closure of the same.

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Write a C/C++/JAVA/Python program to perform following: [40]

a) Explain the definition of operator grammar and precedency relations.


b) Accept the following grammar and store it in suitable data structure.
G=(NT,T,P,S)
NT={E,T,F}
T={+,*,(,),id}

P={
E->E+T / T
T->T*F / F
F->(E) / id
}
S={E}

c) Display First matrix and last matrix.

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Write a C/C++/JAVA/Python program to construct NFA for following RE [40]

aab(a+b)*

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Write a C/C++/JAVA/Python program to perform following: [40]

a) Explain the definition of operator grammar and precedency relations.


b) Accept the following grammar and store it in suitable data structure.
G=(NT,T,P,S)
NT={E,T,F}
T={+,*,(,),id}

P={
E->E+T / T
T->T*F / F
F->(E) / id
}
S={E}

c) Display First matrix and last matrix.

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Write a C/C++/JAVA/Python program to check syntax of ‘for’ loop in C Program. [40]

Examples:
Input : for (i = 10; i < 20 i++)
Output : Semicolon Error

Input : for(i = 10; i < 20; i++


Output : Closing parenthesis absent at end

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Write a C/C++/JAVA/Python program to construct DFA for following RE [40]

a(a+b)*b

Journal [5]
Viva [5]
Thakur College of Science & Commerce (Autonomous)
Department of Computer Science
Practical Examination, M.Sc. CS, Sem II (Regular) (2022-2023)
Subject: Design and implementation of Modern Compilers
Date: April 2023Roll No: _______ Lab: 301 PC No: ____
General Instructions to candidates:
• Create a folder with name as your Roll No in the folder “M.Sc.Sem-II ” in D:.
• Answer to the questions, if any, should be written in the answer book. Use the last page for
rough work.
• Candidates are allowed to use the help or the documentation of the software/language that
they use.
• Once finished with the experiment, candidates are requested to show the results to the
examiner for testing. No printout will be given. Create a Word Document with your Seat No.
and save your experiment code. Experiment work will be copied in Hard Disk and
will be kept for record and verification.
• Strict action will be taken against students carrying mobile/pen drive/Hard disk drive/CDs/Rough sheet
with them.
Paper II

Write a C/C++/JAVA/Python program to construct NFA for following RE [40]

aab(a+b)*

Journal [5]
Viva [5]

You might also like