# CD |Gate-2019| Previous Year Questions| Set-2

CD |Gate-2019| Compiler Design

1. Consider the grammar given below:

S → Aa
A → BD
B → b | ε
D → d | ε

Let a, b, d, and \$ be indexed as follows:

Compute the FOLLOW set of the non-terminal B and write the index values for the symbols in the FOLLOW set in the descending order. (For example, if the FOLLOW set is {a, b, d, \$}, then the answer should be 3210). [GATE – 2019]

a. 30
b. 31
c. 12
d. 33

CD |Gate-2019|

2. Which one of the following kinds of derivation is used by LR parsers? [GATE – 2019]

a. Leftmost in reverse
b. Leftmost
c. Rightmost in reverse
d. Rightmost

3. Consider the augmented grammar given below:

S’ → S
S → 〈L〉 | id
L → L,S | S

Let I0 = CLOSURE ({[S’ → ·S]}). The number of items in the set GOTO (I0 , 〈 ) is: _____. [GATE – 2019]

a. 4
b. 5
c. 6
d. 7

CD |Gate-2019|

4. Consider the following grammar and the semantic actions to support the inheriteatd type declaration attributes. Let X1, X2, X3, X4, X5 and X6 be the placeholders for the non-terminals D, T, L or L1 in the following table:

Which one of the following are the appropriate choices for X1, X2, X3 and X4? [GATE – 2019]

a. X1 = L, X2 = L, X3 = L1, X4 = T
b. X1 = L, X2 = T, X3 = L1, X4 = L
c. X1 = T, X2 = L, X3 = L1, X4 = T
d. X1 = T, X2 = L, X3 = T, X4 = L1