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

Compiler-7

The document is an examination paper for the CE401 Compiler Construction course at Charotar University of Science & Technology, dated November 21, 2018. It consists of two sections with various questions covering topics such as compiler phases, syntax trees, NFA construction, symbol tables, and parsing techniques. Students are instructed to attempt questions in separate answer sheets and make assumptions where necessary.

Uploaded by

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

Compiler-7

The document is an examination paper for the CE401 Compiler Construction course at Charotar University of Science & Technology, dated November 21, 2018. It consists of two sections with various questions covering topics such as compiler phases, syntax trees, NFA construction, symbol tables, and parsing techniques. Students are instructed to attempt questions in separate answer sheets and make assumptions where necessary.

Uploaded by

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

Candidate Seat no………….

CHAROTAR UNIVERSITY OF SCIENCE & TECHNOLOGY


Seventh Semester of B. Tech (CE) Examination
November 2018
CE401 Compiler Construction
Date: 21.11.2018, Wednesday Time: 1.30 p.m. To 4.30 p.m. Maximum Marks: 70
Instructions:
1. The question paper comprises two sections.
2. Section I and II must be attempted in separate answer sheets.
3. Make suitable assumptions and draw neat figures wherever required.
4. Use of scientific calculator is allowed.

SECTION – I
Q-1 Answer the question below.
a. Identify the phase of a compiler detecting following types of errors/warnings. Justify [03]
your answer.
a. Exceeding length of identifier
b. Unbalanced parenthesis
c. Not matching actual parameters with formal parameters
b. What is difference between parse tree and syntax tree? Draw the syntax tree for [04]
following expression:

𝐚 = 𝐚 + 𝐚 ∗ 𝐛 + 𝐚 ∗ 𝐛 ∗ 𝐜 − 𝐚/𝐛

Q – 2.a Construct NFA for (𝐚|𝐛)∗ 𝐜(𝐝|𝐞)∗ # using Thompson’s Construction. [04]
Q – 2.b Attempt any TWO questions. [10]
(i) Differentiate between s-attributed Syntax Directed Translation (S-SDT) and L-
attributed Syntax Directed Translation (L-SDT).
(ii) Find basic block and draw control graph for following code written in higher level
language.
fact(x)
{
int f = 1;
for (i = 2; i <= x; i++)
f = f * i;
return f;
}
(iii) Explain the technique that reduces the amount of overhead required to process an input
character during scanning process.
Q - 3 Attempt any TWO Questions. [14]
a. Symbol Table is an important data structure created and maintained by the compiler.
What information is stored in symbol table? Also explain which data structures are
used to implement symbol table with its pros and cons.

Page 1 of 3
Candidate Seat no………….

b. Justify that following grammar is not LL (1), not SLR (1) but it is CLR (1).
𝐒 → 𝐀𝐚 | 𝐛𝐀𝐜 |𝐁𝐜 | 𝐛𝐁𝐚
𝐀→𝐝
𝐁→𝐝
c. Check whether below grammar is LALR (1) or not.
𝐒 → 𝐂𝐂
𝐂 → 𝐜𝐂 | 𝐝

SECTION – II
Q-4 Answer the below questions.

a. Why there is a need to have intermediate code generation phase? Explain any two [03]
techniques to implement three address code.
b. Consider SLR (1) and LALR (1) table for a CFG, justify whether below statements are [04]
true or false.
1. Goto of both tables may be different.
2. Reduce entries in tables may be different.
3. Error entries in table may be different.
4. Shift entries in tables may be different.

Q–5 Attempt any FOUR questions. [16]

a. Justify what is the maximum number of reduce moves that can be taken by a bottom-up
parser for a grammar with no epsilon- and unit-production (i.e., of type 𝐴 −> є
and 𝐴 −> 𝑎) to parse a string with n tokens.
b. Consider the grammar
S → (S) | a

Let the number of states in SLR (1), LR (1) and LALR (1) parsers for the grammar be
n1, n2 and n3 respectively. Specify the relation between n1, n2 and n3.
c. Compute the operator precedence relation graph and precedence relation table for given
grammar.

𝐆→ 𝐄
𝐄→ 𝐄+𝐓
𝐓→ 𝐓∗𝐅
𝐅 → 𝐢𝐝
d. Why there is a need to have code optimization phase? Classify optimization types with
an example.

Page 2 of 3
Candidate Seat no………….

e. Find first ( ) and follow ( ) set for following grammar.


𝐒 → 𝐚𝐁𝐃𝐡
𝐁 → 𝐜𝐂
𝐂 → 𝐛𝐂 | 𝛜
𝐃 → 𝐄𝐅
𝐄→𝐠|𝛜
𝐅→𝐟|𝛜

Q – 6. Attempt any TWO questions. [12]

a. What is run time environment? Give brief idea of memory allocation done during
compilation with block structured language. What are the limitations of stack based
memory allocation?
b. Deign Syntax Direction Translation (SDT) to count number of 0’s and 1’s in a string.
Also draw the parse tree for the string 11001.
c. Code generation phase of the compiler takes an intermediate code as an input and
generates target machine code as an output. Discuss some common issues in design of
the code generator phase.
d. Write down the goals of an error handler in a parser. What are the different error
strategies used by a parser to recover from a syntactic error?
***

Page 3 of 3

You might also like