Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 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-A
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&A
S.No. Course Outcome PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PO13 PO14 PO15

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

2 H H H H M L L L M M L H H H H
CO2
3 CO3 H H H H M L L L M M L H H H H
4 H H H H M L L L M M L H H H H
CO4

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

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

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) Push down automata i) Regular expression
b) Finite State Machines ii) Context free grammar
c) Syntax analysis iii) Lexeme
d) Forward pointer iv) Parse tree
a) A-ii; b-i;c-iv; d-iii
b) A-i; b-ii;c-iv; d-iii
c) A-ii; b-i;c-iii; d-iv
d) A-ii; b-iii;c-iv; d-i

Ans: a
2 _______ is the maximum number of states that an ε-NFA can have on ε 1 2 1 3 3.6.1
moves.
a) n
b) 0
c) Infinite
d) 1

Ans: c
3 What is the length of the improper substring of “equivalent”? 1 2 1 3 3.6.1
a) 10
b) 9
c) 8
d) 11

Ans: a

4 The _________ is realized by ________ operation. 1 1 1 6 6.3.1


a) sequential execution, union
b) iteration, closure
c) branching, concatenation
d) conditional branch, concatenation

Ans: b

5 I: DFA’s can be constructed for all the languages 1 1 1 1 1.6.1


II: The strings accepted by DFA will be accepted by NFA
What can be said about these two statements?
a) Only II is false
b) Only I is false
c) I is false and II is true
d) II is true and I is false

Ans: c,or d
Part –B
Answer any two (2x 4=8 marks)
Q. Question Mark B C P PI
N s L O O Cod
o e
6 Distinguish the operational difference between compiler and interpreter. Also, 4 1 1 1 1.6.1
list the tasks done by preprocessor.

Answer

 A compiler takes in the entire program and requires a lot of


time to analyze the source code. Whereas the interpreter
takes a single line of code and very little time to analyze it.
 Compiled code runs faster, while interpreted code runs
slower.
 A compiler displays all errors after compilation. If your
code has mistakes, it will not compile. But the interpreter
displays errors of each line one by one.
 Interpretation does not replace compilation completely.
 Compilers can contain interpreters for optimization reasons
like faster performance and smaller memory footprint.
Tasks done by Preprocessor:
 Source file inclusion

 Macro expansion

 Conditional compilation

7 Construct a DFA which can accept the strings starting and ending with same 4 3 1 6 6.3.1
letter over the input Σ={a, b}. Also, give its formal definition.

Answer
8 Explain the role of two pointers in input buffering scheme with a neat 4 2 1 6 6.3.1
diagram.

Answer

The forward ptr moves ahead to search for end of lexeme. As soon as
the blank space is encountered, it indicates end of lexeme. The fp will
be moved ahead at white space, when fp encounters white space, it
ignore and moves ahead. then both the lexeme pointer and forward
ptr(fp) are set at next token.

Part –C
Answer all ( 1x 12=12 marks)
Q. Question Mark B C P PI
N s L O O Code
o
9 a) Convert the following RE=a(a|b)*abb to DFA using subset 12 4 1 6 6.3.1
construction method and minimize it.

Answer
(OR)
b) Describe the various phases of compiler and trace it with the
program segment
(a: = b + real * 60).

Answer

 Lexical analyzer reads the stream of characters making up the


source program and groups the characters into meaningful
sequences called lexeme
 For each lexeme, the lexical analyzer produces a token of the form
that it passes on to the subsequent phase, syntax analysis
(token-name, attribute-value)
 Token-name: an abstract symbol is used during syntax analysis, an
 attribute-value: points to an entry in the symbol table for this
token.
.”a” is a lexeme mapped into a token (id, 1), where id is an abstract
symbol standing for identifier and 1 points to the symbol table entry
for position. The symbol-table entry for an identifier holds
information about the identifier, such as its name and type.
2. = is a lexeme that is mapped into the token (=). Since this token
needs no attribute-value, we have omitted the second component. For
notational convenience, the lexeme itself is used as the name of the
abstract symbol.
3. “b” is a lexeme that is mapped into the token (id, 2), where 2
points to the symbol-table entry for initial.
4. + is a lexeme that is mapped into the token (+).
5. “rate” is a lexeme mapped into the token (id, 3), where 3 points to
the symbol-table entry for rate.
6. * is a lexeme that is mapped into the token (*) .
7. 60 is a lexeme that is mapped into the token (60)
Blanks separating the lexemes would be discarded by the lexical
analyzer
*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