Skip to content

Compiler Design

CSE · Final · Fall 24

Batch 60

This browser can’t show the PDF here

Open it, and your phone’s PDF viewer takes it, or download it.

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 Department of Computer Science & Engineering Final Examination, Fall 2024 Course Code: CSE331, Course Title: Compiler Design Level: 4 Term: 1 Batch: 60 Time: 01:30 Hrs Marks: 40 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) Considering the following expression show the task for each phase (up to Semantic Analysis) of compiler: increment = gross * rate + 40 [5] 1. b) Identify the specific error from the following code: #include<stdio.h> int main{ innt a[2]={2,4,6}, b=1; sum = a[b]+b printf("Rasalt is: %f, sum); return b; } [3] 1. c) Explain how the panic mode recovery would handle the syntax error 1(b). [2] 2. a) Consider the following CFG-1 and answer the following question. P -> ABCD A -> aA | cC | oD | iC B -> ov | ovC C -> id | id-D | Ε D -> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 CFG-1 [5] [CO1] i. Show the left most and right most derivation for the string "covid-19". ii. Explain how an ambiguous grammar can be determined? Show if the above mentioned grammar is ambiguous or not. 2. b) Consider the following grammar. If there is Left Recursion then eliminate it. A -> Ba | c B -> Cb | Ad C -> Ae | f [3] 3. a) Convert the following NFA in Fig. 1 into a DFA using subset construction method. [Figure: NFA with states 1, 2, 3, 4, 5, transitions with a, b, epsilon] [5] 3. b) Write down the formal definition of Finite Automata? Justify the statement briefly - "Every DFA is a NFA, but not the vice versa". [2]