Semester : SEMESTER 6
Subject : Compiler Design
Year : 2021
Term : JULY
Branch : COMPUTER SCIENCE AND ENGINEERING
Scheme : 2015 Full Time
Course Code : CS 304
Page:2
10
12
13
14
a)
b)
a)
b)
a)
b)
03000CS304052002
the output of each phase for the input x = 2 * a + b, where a and 7 are float
variables.
Check if following grammar is LL(1) by constructing a parse table:
57೫ (1,) | a
L~> SL’
igo”, SL’|e
Note that ‘,’ is a terminal and € is the empty string.
Explain bootstrapping.
PART ட
Answer all questions, each carries 3 marks.
Determine the FIRST and FOLLOW sets for the non-terminals in the following
grammar:
ऽ -> 44
4 -> ५4 | ¢
Define an operator grammar. Give an example
Distinguish between S-attributed definitions and L-attributed definitions.
What is type checking? What are its two types?
PART D
Answer any two full questions, each carries 9 marks.
Construct the SLR(1) parsing table for the following grammar:
E>T+E|T
+ =+
Write a syntax directed translation scheme for a simple desk calculator.
What sequence of moves are made by a bottom up parser on the input 23*5+4
using the translations in part (a)?
Consider the following grammar:
$ -+ 4 | (7)
7 -¬ 7, 518
For the string (a, (a, a)), indicate how a parse tree is constructed by a shift
reduce parser using a rightmost derivation.
Explain the bottom- up evaluation of S- attributed definitions.
Page 2 of 3
(5)
(4)
(3)
(3)
(3)
(3)
(9)
(3)
(6)
(6)
(3)