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

Set-15 GATE-2006 CD

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:

abd$
3210

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

Answer : b)
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

Answer : c)


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

Answer:  b)
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:

Production RuleSemantic action
D → T LX1. type = X2 .type
T → intT.type = int
T → floatT.type = float
L → L1  , idX3. type = X4. type addType (id.entry, X5. type)
L → idaddType(id.entry, X6. type)

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

Answer : b)


Back to GATE-HOME


Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *