👁️ 66 views
University of Barishal Logo

University of Barishal

Department of Computer Science and Engineering

Final Exam

Course Title: Compiler Design and Construction (CSE-4103)

Semester: 7th | Session: 19-20

Time: 180 minutes | Marks: 60.00

Course Teacher: Dr. Md Manjur Ahmed

Exam Date: June 29, 2025

Answer any Five Questions from the followings.

1.


a)

In Compiler, syntax-directed checker and translator do the static and dynamic type checking. Distinguish between static and dynamic checking with example(s).

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
5 Marks
b)

What will be the output of the lexical, syntax and sematic analyzers for the following expression: 
if(y%4=0) {printf("This may be a leap year")}

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
5 Marks
c)

What is the advantage of front end and back end model of compiler?

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
2 Marks
2.


a)

What is a dangling else?

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
2 Marks
b)

Compiler design is not only about compilers, and many people use the technology learned by studying compilers in school, yet have never, strictly speaking, written (even part of) a compiler for a major programming language. Compiler technology has other important uses as well. Additionally, compiler design impacts several other areas of computer science. Review the three most important interactions and applications of the technology. Give example for these applications.

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
4 Marks
c)

Let, a Context-free grammar for simple expressions: G1 = <{list,digit), (+,-,0,1,2,3,4,5,6,7,8,9), P, list with production

                                      P = list list + digit

                                            list → list - digit

                                            list → digit

                                            digit → 0 | 1 |... | 9

Suppose we use a single nonterminal string and consider the following context-free grammar: G2 = <{string), {+,-,0,1,2,3,4,5,6,7,8,9), P, string> with production P = string → string + string | string - string | 0 | 1 |...|9.

Which grammar (from G1 and G2) is ambiguous because more than one parse tree represents the string 10-6+3?
 

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
6 Marks
3.


a)

Differentiate the terms (i) Yacc compiler, (ii) Lex compiler, and (iii) C compiler

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
6 Marks
b)

When a production for nonterminal A starts with a self-reference then a predictive parser loops forever. For example, A → Aα | β | γ.

We can eliminate left recursive productions by systematically rewriting the grammar using right recursive productions. Analyse this procedure.

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
6 Marks
4.


a)

Analyze the terms: Recursive descent parsing and Predictive parsing

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
4 Marks
b)

The following grammar, which abstracts the dangling-else problem is considered as ambiguous grammar. The grammar is ambiguous and the ambiguity is manifested by a choice in what production to use when an e (else) is seen.

How to make unambiguous ?

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
8 Marks
5.


a)

Based on LL(1) predictive parsing table for the following grammar, describe how to do panic mode recovery and phrase level recovery.

        

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
6 Marks
b)

The following is a substring of grammar symbols:

a b b c d e

Prove that this substring shows the property of "Handle".

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
6 Marks
6.


a)

In LR(k) Parsers, Shift/Reduce decisions can be ambiguous. We can use a DFA for Shift/Reduce decisions in order to resolve the ambiguous issue. Describe it using Stack.

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
8 Marks
b)

Describe algorithm for LR Parser.

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
4 Marks
7.


a)

A good compiler should assist in identifying and locating errors. Describe about (a) Lexical errors, (b) Syntax errors, (c) Static semantic errors, (d) Dynamic semantic errors, (e) Logical errors.

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
6 Marks
b)

Describe typical tasks of the lexical analyzer.

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
3 Marks
c)

If the following expression is passed to the lexical analyzer, then what is the output?

y := 31 +28*x

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
3 Marks
8.


a)

Consider the following grammar and remove left recursion.

A → ABd / Aa / a

B→ Be / b
 

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
5 Marks
b)

Discuss the position of a Code Generator in the compiler model using figure.

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
3 Marks
c)

Let, you would like do parsing for syntax analyzer. Write down a table to show FOLLOW(A).

        E →TER

        ER → + TER | ε

        T → FTR

        TR → * FTR | ε

        F→(E) | id

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
4 Marks

-------------------------------------------------------------------***-------------------------------------------------------------------

Contributors of this Question:

Role Name Date
Prepared By (Teacher): Dr. Md Manjur Ahmed June 29, 2025
Uploaded By: Sumia Jahan Jyoti June 29, 2025, 2:09 p.m.
Converted By (Img/PDF to Text): Baishakhi Bir Feb. 8, 2026, 10:35 p.m.
Reviewed By: Obaydul Hasan Nayeem Feb. 9, 2026, 7:54 a.m.