1
M
S
M S RAMAIAH INSTITUTE OF TECHNOLOGY
(AUTONOMOUS INSTITUTE, AFFILIATED TO VTU)
BANGALORE - 560 054
SEMESTER END EXAMINATIONS - MAY / JUNE 2012
Course & Branch
.
Subject
B E - Com ut Science E
S
F. er
& n gineering
t
VI
e rne s e r
Compiler Design Max. Marks : 100
Subject Code
: CS612
Duration : 3 Hrs
Instructions to the Candidates: '
. Answer one full question from each unit
UNIT - I
1. a) What is the front end and back end of a compiler? What are the (08) advantages of breaking up the compiler functionality into two distinct stages? b) Show that translation made by each of the compiler phases for the (06) statement a:=b+c*10 where a,b,c, are float
c) What are the common programming errors? How should the passer recover (06) once an error is detected?
2. a) Explain the role of lexical analyzer in a compiler. Why Lexical Analysis and (08) parsing are separated into two phases?
b) Write regular expression for the following character sets (04)
i) All strings of lowercase letters that begin and end with a ii) All string of digits that does not contain he substring 110 iii) All strings of a's and b's such that the 3rd letter from right is 'a' and minimum length of string is three iv) All strings of digits that contain no leading zeros
c) Explain left recursion and show how it is eliminated from the following (08) grammar. Also describe the algorithm for eliminating left recursion
A -^BalAaIc
B -^Bb ^Abd
3.
a)
b)
UNIT - II
(02)
Define an LL(1) grammar with example.
Write the rules to compute FIRST(X) and FOLLOW(A). Applying the rules (08) compute the FIRST and FOLLOW sets for the following grammar.
S --^aSeIB
B-^bBeIC
C--^cCeId
c) Check whether the following grammar is suitable for predictive passing . If (10) not do necessary transformations to make it suitable for LL(1) parsing.
Construct a predictive parsing table and show the moves made by the parser on input