Compiler Design
CSE · Midterm · Fall 23
Batch 58
Read the questions as text
Read off the PDF by AI, so it may have mistakes. The PDF is the original.
Daffodil International University
Faculty of Science & Information Technology
Mid-Term Exam Examination, Fall 2023
Course Code: CSE331, Course Title: Compiler Design
Level: L3 Term: T2 Batch: 58
Time: 1.5 Hrs
Marks: 25
Answer ALL Questions
[The figures in the right margin indicate the full marks and corresponding course outcomes. All portions of each question must be answered sequentially.]
1 a) #include <iostream>
using namespace std;
int main() {
int first, second, sum;
cin >> first >> second;
sum = first + second;
cout << first << " + " << second << " = " << sum;
return 0;
}
Explain which translator should be used between compiler and interpreter for the given source code
[5] CO1
1 b) Identify the typical order in which the phases of a compiler are executed, and why is this order important for the overall compilation process. Use the given expression to construct the front end phases of the compiler.
Total = 25/100*Quiz+25/100*Mid+50/100*Final
[5]
2 a) Consider the following CFG and answer the following question.
S -> a | aAb | abSb
A -> aAaB | bS
Explain if the above mentioned CFG is ambiguous or not, and give proper justification. You may use "aababb" as input string to test the ambiguousness.
[5] CO1
3 a) Consider the given regular expression [ ab + (b + aa)b* a ] and convert it to E-NFA and write the 5 tuples for the E-NFA.
[5]
3 b) [Figure: FSM diagram with states, transitions for a, b, 0, 1]
Fig 1: FSM
Identify if the given FSM is deterministic. If not then convert it into a deterministic FSM.
[5]