You are on page 1of 7

Student Declaration

I ___Muhammad Ahmad____________ Registration No._17-ARID-5611______, hereby

declare that by attempting the paper for the course ___Compiler Construction______, I will not

be involved in any kind of cheating/copying/plagiarizing in solving the short questions-based

paper of Final Term Examination Spring 2021. I take full responsibility of my conduct. If I

found involved in any kind of such activity of cheating/copying/plagiarizing, then Institute

reserves the right to take any disciplinary action against me.

Student Signature
Final Exam / Spring 2021 (Paper Duration 24 hours)
(Online Assignment Based Question Paper)

Course No.: CS-636 Course Title: Compiler Construction


Total Marks: 20 Date of Exams: 09/07/2021
Degree: BSCS Semester: 5th, 8th Section: A
Marks
Q.No. 1 2 3 4 5 6 7 8 9 10 Obtained/
Total Marks
Marks
Obtaine
/20
d
Total Marks in Words:
Name of the Teacher: Shafiq Babar
Who taught the course:Signature of Teacher / Examiner:

To be filled by Student

Registration No.: 17-ARID-5611 Name: Muhammad Ahmad

(PRACTICAL EXAMINATION)
Rules and regulations:

 Hand written documents will be accepted


 Paper submitted only in MS word format
 Plagiarism should be less than 15 %
 Formatting line spacing 1.5, Times and new Roman, paragraph justify
 Duplicate paper will not be accepted
 All diagrams should be drawn in draw.io/Visio/lucid Chart

Answer the following questions.


Q.No.1. Consider the following Context Free Grammar
S → Aa | BAb
A → BB | c | aa
B → Sd | e | ca
where {a, b, c, d, e} is the set of terminal symbols.

1. Give a right-most derivation of ecadeb. [1 mark]


2. Give a left-most derivation of ecadeb. [1 mark]
3. Compute FIRST and FOLLOW for this grammar. Show your work. [5 marks]
4. Is the grammar LL(1)? Justify your answer. [4 marks]
5. Is the grammar SLR(1)? Justify your answer. [6 marks]
6. Give two reasons why a compiler is typically broken down into passes (or phases) and
indicate a typical set of passes and the data structures passed between them. [3 marks]
Final Exam / Spring 2021 (Paper Duration 24 hours)
(Online Assignment Based Question Paper)

Course No.: CS-636 Course Title: Compiler Construction


Total Marks: 12 Date of Exams: 09/07/2021
Degree: BSCS Semester: 5th, 8th Section: A
Marks
Q.No. 1 2 3 4 5 6 7 8 9 10 Obtained/
Total Marks
Marks
Obtaine
/20
d
Total Marks in Words:
Name of the Teacher: Shafiq Babar
Who taught the course:Signature of Teacher / Examiner:

To be filled by Student

Registration No.: 17-ARID-5611 Name: Muhammad Ahmad

(PRACTICAL EXAMINATION)
Rules and regulations:

 Hand written documents will be accepted


 Paper submitted only in MS word format
 Formatting line spacing 1.5, Times and new Roman, paragraph justify
 Duplicate paper will not be accepted
 All diagrams should be drawn in draw.io/Visio/lucid Chart

Answer the following questions.


Q.No.1. Consider the following Context Free Grammar
S → Aa | BAb
A → BB | c | aa
B → Sd | e | ca
where {a, b, c, d, e} is the set of terminal symbols.

1. Give a right-most derivation of ecadeb. [1 mark]


2. Give a left-most derivation of ecadeb. [1 mark]
3. Compute FIRST and FOLLOW for this grammar. Show your work. [5 marks]
4. Is the grammar LL(1)? Justify your answer. [4 marks]
5. Is the grammar SLR(1)? Justify your answer. [6 marks]
6. Give two reasons why a compiler is typically broken down into passes (or phases) and
indicate a typical set of passes and the data structures passed between them. [3 marks]
1.

Answer:

Not possible.

The string ecadeb is not derived from the given grammer.

2.

Answer:

Not possible.

The string ecadeb is not derived from the given grammer.

3.

Grammer: First:

S→ aA | bBA F(S)→ {a, b}

A→ BB | c | aa F(A)→ {a, b, e, c, c, a}

B→ Sd | e | ca F(B)→ {a, b, e, c}

Follow:

Fo(S)→ {d}

Fo(A)→ {a, b}

Fo(B)→ {a, b, e, c, c, a}
4.

a b c d e &

S→ ①⑤ ⑧ ②
≠ θ
A→ ①⑤ ⑧ ② ④⑧ ⑦

B→ ①⑤ ⑧ ② ④⑧ ⑦
If value of
table is equal
to θ then grammar is LL①.

Therefore, grammar is not LL①.

5.
Table for checking:
a b c d e $
0 Accepted
1 S2 S2
2
3 S3 S3
4 R2 S4
5 R4
6 R5
7 S7

Here is point that the work going perfectly and the grammer SLR is SLR(1) because there is
no conflict.

6.

Reason 1:

To limit the number of passes, the compilers are divided down into steps. Check the
functionality of each phase at various levels in this way. For the correct tuning of a program
the compiler is needed and the phases are logical.

Reason 2:

We have broken down the compiler into phases to save time on the schedule. Phases are
grouped to limit the number of passes and hence save the program time during the
interpretation of the inputs.

You might also like