0% found this document useful (0 votes)
34 views

Compiler Design

compiler design d batu pyq

Uploaded by

Mahesh Mahesh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Compiler Design

compiler design d batu pyq

Uploaded by

Mahesh Mahesh
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

DR.

BABASAHEB AMBEDKAR TECHNOLOGICAL UNIVERSITY, LONERE


Summer Examination – 2023
Course: B. Tech.Branch : Computer Science & Engineering Semester : VI
Subject Code & Name: BTCOC601 - Compiler Design
Max Marks: 60 Date:12/07/2023 Duration: 3 Hr.
Instructions to the Students:
1. All the questions are compulsory.
2. The level of question/expected answer as per OBE or the Course Outcome (CO) on
which the question is based is mentioned in ( ) in front of the question.
3. Use of non-programmable scientific calculators is allowed.
4. Assume suitable data wherever necessary and mention it clearly.
(Level/CO) Marks
Q. 1 Solve Any Two of the following. 12
A) Draw a neat diagram and explain different phases of compiler. Remembering 6
Differentiate between Interpreter, Compiler and Hybrid compiler.

B) Define token, pattern, and lexeme with suitable examples. Find tokens, Remembering 6
pattern and lexemes forthe following C- program. Give reasonable at-
tribute values for the tokens.

int main()
{
int a = 10, b = 20;
printf (“Sum is : %d”, a+b);
return (0)
}
C) i) Explain regular expression and regular definition with example. Analyzing 6
ii) Write regular definitions for the following languages:
1. All strings of lowercase letters that contain the five vowels in
order.
2. All strings of lowercase letters in which the letters are in
ascending lexicographic order.

Q.2 Solve Any Two of the following. 12


A) Explain the two buffer input scheme for scanning the source program in Remembering 6
lexical analyzer? How the use of sentinels can improve its performance?
B) i) Explain the role of finite automata in lexical analyzer and differentiate Applying 6
between NFA and DFA.
ii) Convert the following regular expression to NFA using Thompson
Construction algorithm.

(a|b*ab)*

C) Convert the following NFA to DFA using subset construction algorithm. Remembering 6
Analyzing
((01| 0) 1*)*
Q.3 Solve Any Two of the following. 12
A) i) What is left recursion and left factoring? Remembering 6
ii) Consider the CFG SSS+| SS* | a
a) Left factor this grammar.
b) Eliminate the left recursion from the original grammar.
c) Is the resulting grammar suitable for top-down parsing?

B) What is the difference between recursive–descent parsing and predictive Remembering 6


parsing?Draw and explain the model of non recursive predictive parser. Applying

C) What is LL(1) grammar? Construct a LL(1) parsing table for the Applying 6
following grammar. Test whether following grammar isLL(1).
S → aAB|bA|є
A → aAb |є
B → bB |c
Q.4 Solve Any Two of the following. 12
A) Explain stack implementation of shift reduce parsing with their four Understanding, 6
Applying
possible actions.
Consider the following grammar

S → TL
T → int | float
L → L,id | id
Parse the input string int id, id using shift – reduce parser.

B) i) Differentiate between LR(0) and LR(1) grammar with suitable Applying 6


Analyzing
example.

ii)What is handle? Consider the following grammar and show the handle

of each right sentential form for the string ( a ,( a , a )).

S→ (L)|a

L → L ,S |S

C) Show that following grammar is LL(1) but not SLR(1). Applying 6

S→ AaAb | BbBa

A →є

B→є

Q.5 Solve Any Two of the following.


A) For the SDD given below, give annotated parse tree for the expression Applying 6
3*5+4
B) List the issues in designing code generator. Generate code for the Applying 6
following three-address statements assuming all variables are stored in
memory locations.
x=b*c
y=a+x
C) Define basic block and flow graph. Give basic blocks and flow graph for Remembering 6
Understanding
the following sequence of three address code statements:

*** End ***


The grid and the borders of the table will be hidden before final printing.

You might also like