0% found this document useful (0 votes)
31 views6 pages

CT 1 - B Answer Key

This document contains a test for a Compiler Design course taken by students in their third year of study. It consists of three parts - Part A with 5 multiple choice questions worth 1 mark each, Part B with 2 questions worth 4 marks each, and Part C with 1 question worth 12 marks. The questions cover topics related to compilers including scanners, parsers, regular expressions, symbol tables, and error handling strategies. Performance indicators and course outcomes are mapped to each question.

Uploaded by

lalith jetty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views6 pages

CT 1 - B Answer Key

This document contains a test for a Compiler Design course taken by students in their third year of study. It consists of three parts - Part A with 5 multiple choice questions worth 1 mark each, Part B with 2 questions worth 4 marks each, and Part C with 1 question worth 12 marks. The questions cover topics related to compilers including scanners, parsers, regular expressions, symbol tables, and error handling strategies. Performance indicators and course outcomes are mapped to each question.

Uploaded by

lalith jetty
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

SRM Institute of Science and Technology

College of Engineering and Technology


School of Computing
SRM Nagar, Kattankulathur – 603203, Chengalpattu District, Tamilnadu
Academic Year: 2024 (EVEN)
School of Computing SET-B
Test: CLA-T1 Date: 13/2/2024
Course Code & Title: 18CSC304J & Compiler design Duration: 50 minutes periods
Year & Sem: III Year /VI Sem Max. Marks: 25
Batch & Set: I&B
S.No. Course Outcome PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PO13 PO14 PO15

1 CO1 H H H H M L L L M M L H H H H

2 CO2 H H H H M L L L M M L H H H H

3 CO3 H H H H M L L L M M L H H H H

4 CO4 H H H H M L L L M M L H H H H

5 CO5 H H H H M L L L M M L H H H H

6 CO6 H H H H M L L L M M L H H H H

Part – A
Answer all (5 x 1=5 marks)
Q. Question Mark B C P PI
N s L O O Cod
o e
1 Match the following: 1 2 1 3 3.6.1
a) Scanners i) Context free grammars
b) Parsers ii) Language extensions
c) Preprocessor iii) Machine code
d) Interpreter iv) Lexemes
a) A-iii; b-i;c-iv; d-ii
b) A-iv; b-i; c-ii; d-iii
c) A-iii; b-i;c-ii; d-iv
d) A-iv; b-iii;c-ii; d-i

Ans b
2 What is the minimum number of states for NFA that accepts the language 1 2 1 3 3.6.1
{0101n | n >=0}?
a) 5 b) 4 c) 6 d) 16

Ans a

3 Which of the following is not done by lexical analyser? 1 2 1 3 3.6.1


a) Inserting line numbers
b) Removing tabs
c) Evaluating macros
d) Removing comments

Ans c
4 ________ occurs before _________. 1 1 1 6 6.3.1
a) Syntax checking, type checking
b) Type checking, syntax checking
c) Syntax checking, spell checking
d) Type checking, spell checking
Ans a
5 Which is not true about symbol table? 1 1 1 1 1.6.1
a) Can be implemented as Doubly linked list
b) Declarations are managed by symbol table
c) Symbol table is updated by compiler
d) Semantic details cannot be sought from symbol table

Ans d

Part –B
Answer any two (2x 4=8 marks)
Q. Question Mark BL C PO PI
N s O Code
o
6 What is the role of syntax directed translation engine in compiler 4 1 1 1 1.6.1
construction process? What is the significance of the process done by it?

Answer
It generates intermediate code with three address format
from the input that consists of a parse tree. These engines
have routines to traverse the parse tree and then produces
the intermediate code. In this, each node of the parse tree
is associated with one or more translations.

7 Give the regular expression for binary language which generates strings 4 3 1 6 6.3.1
that start and end with same digit.

Answer

R1=0 (0+1)* 0 + 1 (0+1)*1

8 Write about error recovery strategies adopted by the compiler. 4 2 1 6 6.3.1

Answer
1. Panic Mode Recovery

In this method, successive characters from the input are


removed one at a time until a designated set of
synchronizing tokens is found. The advantage is that it’s
easy to implement and guarantees not to go into an infinite
loop. The disadvantage is that a considerable amount of
input is skipped without checking it for additional errors
2. Statement Mode recovery
In this method, when a parser encounters an error, it
performs the necessary correction on the remaining input
so that the rest of the input statement allows the parser to
parse ahead. The correction can be deletion of extra
semicolons, replacing the comma with semicolons, or
inserting a missing semicolon.
While performing correction, utmost care should be taken
for not going in an infinite loop. A disadvantage is that it
finds it difficult to handle situations where the actual error
occurred before pointing of detection.
3. Error production
If a user has knowledge of common errors that can be
encountered then, these errors can be incorporated by
augmenting the grammar with error productions that
generate erroneous constructs.
If this is used then, during parsing appropriate error
messages can be generated and parsing can be
continued.The disadvantage is that it’s difficult to
maintain.
4. Global Correction

The parser examines the whole program and tries to find


out the closest match for it which is error-free.The closest
match program has less number of insertions, deletions,
and changes of tokens to recover from erroneous input.
Due to high time and space complexity, this method is not
implemented practically.

Part –C
Answer all ( 1x 12=12 marks)
Q Question Mar B C P PI
. ks L O O Co
N de
o
9 a) A strong password generator comprises of diverse types of tokens. A 12 4 1 6 6.3.
leading IT firm decides to automate the process of password generation 1
by constructing a Regular expression for it. The permissible token are
{ %, a, b, @}. The following are the rules to be followed:
i) The password cannot start with @ or %.
ii) There is no restriction on its maximum length but it should have
at least two characters.
iii) The password cannot end with a or b
Create a Regular expression for the password generator and also give its
equivalent ε-NFA for the same. Also, give its equivalent deterministic machine.

Answer

i) The password cannot start with @ or %.


ii) There is no restriction on its maximum length but it should have at
least two characters.
iii) The password cannot end with a or b
Create a Regular expression for the password generator and also give its
equivalent ε-NFA for the same. Also, give its equivalent deterministic
machine.
RE-6 marks E-NFA-6 marks
R1=(a+b)(a+b+@+%)*(@+%)+

(OR)

b) Convert the Regular Expression(a/b)*abb to DFA using Direct method


and minimize it

Answer
*Performance Indicators are available separately for Computer Science and Engineering in AICTE examination
reforms policy.

Course Outcome (CO) and Bloom’s level (BL) Coverage in Questions

Approved by the Audit Professor/Course Coordinator

You might also like