👁️ 185 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: 17-18

Time: 180 minutes | Marks: 60.00

Answer any FIVE questions out of the followings. All parts of each question must be answered consecutively. Right side of the question shows the maximum marks.

1.


a)

What is compiler? Design the analysis and synthesis model of computer.

Please SUBSCRIBE to view full question

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

Write the three-address code sequence for the statement x=y*z + y*-z. Also give its triple representation.

Please SUBSCRIBE to view full question

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

What is code optimization? Explain machine dependent and independent code optimization.

Please SUBSCRIBE to view full question

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

Differentiate tokens, patterns, and lexeme.

Please SUBSCRIBE to view full question

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


a)

State the role of the lexical analyzer. Identify the lexemes and their corresponding tokens in the following statement: printf ("Simple Interest=%f\n", si);

Please SUBSCRIBE to view full question

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

Discuss the various phases of compiler and trace the program segment a = b + c * 50 for all phases.

Please SUBSCRIBE to view full question

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

Using operator precedence relations, parse the string id + (id * id).

Please SUBSCRIBE to view full question

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


a)

Differentiate leftmost derivation and rightmost derivation. Show an example for each.

Please SUBSCRIBE to view full question

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

Draw the DFA for the regular expression (a | b)* (abb | a+b).

Please SUBSCRIBE to view full question

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

Draw the transition diagram for the regular definition, relop◊ < | <= | = | <> | >= | >.

Please SUBSCRIBE to view full question

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


a)

Write down the NFA of all binary strings in which second last bit is 1. Convert the NFA into DFA.

Please SUBSCRIBE to view full question

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

Write down the sequence of top-down parse trees for the input id+id*id according to the given grammar.

E → T E' 
E' → +T E' | ε 
T → F T' 
T' → * F T' | ε 
F → (E) |
id

Please SUBSCRIBE to view full question

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


a)

Define a Parser. What is the role of grammars in Parser construction? Construct the Predictive parsing table for the following grammar G:

E → E+T | T,
T→ T*F | F,
F → (E) | id.

Please SUBSCRIBE to view full question

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

What is an LALR(1) grammar? Construct LALR parsing table for the following grammar:

S → CC

C → cC

 C → c | d

Please SUBSCRIBE to view full question

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


a)

Define an LL(1) grammar. Is the following grammar LL (1)?


S → iEtS | iEtSes | a,
E → b.

Please SUBSCRIBE to view full question

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

Check whether the grammar is LALR (1) but not SLR(1)

S-->Aa/bAc/dc/bda
A-->d

Please SUBSCRIBE to view full question

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

Explain syntax directed definition with simple examples?

Please SUBSCRIBE to view full question

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


a)

Show the following grammar:

S->Aa | bAc | Bc | bBa
A->d
B->d
is LR (l) but not LALR (l).

Please SUBSCRIBE to view full question

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

Write short note on:

i) Synthesized attributes

ii) Inherited attributes

iii) Dependency graph

iv) Evaluation order

v) Directed Acyclic Graph (DAG)

Please SUBSCRIBE to view full question

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


a)

Design a recursive descent parser for the grammar:

E->E+T | T

T->T*F | F

F->(E) | id

Please SUBSCRIBE to view full question

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

Find the FIRST and FOLLOW of the non-terminals in the grammar:

S->aABe
A->Abc | b
B->d

Please SUBSCRIBE to view full question

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

What is Recursive Descent parsing? List the problems faced in designing such a parser.

Please SUBSCRIBE to view full question

Topics: N/A Solution is Coming!
4 Marks

Contributors of this Question:

Role Name Date
Uploaded By: Onebyzero Edu Aug. 9, 2024, 11:12 p.m.
Converted By (Img/PDF to Text): Baishakhi Bir Feb. 9, 2026, 11:30 p.m.
Reviewed By: Obaydul Hasan Nayeem Feb. 10, 2026, 8:10 p.m.