Professional Documents
Culture Documents
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
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
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
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
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
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
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
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
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
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
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
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;
}
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
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
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
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
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
P={
E->E+T / T
T->T*F / F
F->(E) / id
}
S={E}
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
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
P={
E->E+T / T
T->T*F / F
F->(E) / id
}
S={E}
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
Examples:
Input : for (i = 10; i < 20 i++)
Output : Semicolon Error
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
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
aab(a+b)*
Journal [5]
Viva [5]