You are on page 1of 2

Compiler Construction

Assignment No. 01
Due Date 18-03-2020 (Before Examination)

Note : Write handwritten solution on A4 size paper. Do not use any file cover for assignment
submission. Just write question No. and write your answer.
Question No. 01
Differentiate Panic Mode and Phrase Level Recovery with example.
Select a suitable example (other than the examples discussed in lectures) and show all the phases
of compiler construction.
Question No. 02
Consider the Following Grammar
S  SS+ | SS* | a
i. Show how the string aa+a* can be generated by this grammar
ii. Construct a parse tree for this string
iii. What language does this grammar generates
Question No. 03
Construct unambiguous Context Free Grammar for each of the following language
i. Left associative lists of identifiers separated by commas
ii. Right associative lists of identifiers separated by commas
Question No. 04
Consider the following code
float getval(int x){
return (x>10.0? 10.0 : x/2);
}
Divide the above program code into appropriate lexemes, using discussion of lexeme and tokens
in the lecture as hint. Which lexeme should get associated lexical value? What should those values
be?
Question No. 05
In a string of length N, how many of the following are there?
Prefixes
Suffixes
Question No. 06
Write regular definition for the following language
All strings of lowercase letters that contains five vowels in order
Question No 07
Suppose we have two tokens (1) the keyword while and (2) identifier, which are strings of letters
and digits beginning with a letter other than while. Show DFA for these tokens
Question No. 08
Consider the following grammar
S  0S1 | 01
Devise predictive parser and show the parsing table. You may left factor and of eliminate left
recursion from your grammar first
Question No. 09
Compute the First and Follow of the following grammar
S  0S1 | 01
S  S+S | SS | (S) | S* | a
Question N0. 10
Consider the following grammar
E  TX
T  ( E ) | int Y
X  +E | 
Y  *T | 
Construct LL(1) Parse table and verify the following string
int * int$

You might also like