Compiler Design questions

Q3

GATE CS 2019 CSParsingMCQ1 mark−1/3 if wrong
Which one of the following kinds of derivation is used by LR parsers?
Show answer without attempting

Answer: D

Q19

GATE CS 2019 CSParsingNAT1 mark
Consider the grammar given below:
S→AaS \to Aa
A→BDA \to BD
B→b∣ϵB \to b \mid \epsilon
D→d∣ϵD \to d \mid \epsilon

Let a,b,d,a, b, d, and $\$ be indexed as follows:
abd$\$
3210
Compute the FOLLOW set of the non-terminal BB 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,$}\{a, b, d, \$\}, then the answer should be 3210)
Answer: __________.
Show answer without attempting

Answer: 31

Q36

GATE CS 2019 CSSyntax Directed TranslationMCQ2 marks−2/3 if wrong
Consider the following grammar and the semantic actions to support the inherited type declaration attributes. Let X1,X2,X3,X4,X5,X_1, X_2, X_3, X_4, X_5, and X6X_6 be the placeholders for the non-terminals D,T,LD, T, L or L1L_1 in the following table:
Production ruleSemantic action
D→T  LD \to T \; LX1.type=X2.typeX_1.\text{type} = X_2.\text{type}
T→intT \to \text{int}T.type=intT.\text{type} = \text{int}
T→floatT \to \text{float}T.type=floatT.\text{type} = \text{float}
L→L1,idL \to L_1, \text{id}X3.type=X4.typeX_3.\text{type} = X_4.\text{type}; addType(id.entry,X5.type)\text{addType}(\text{id.entry}, X_5.\text{type})
L→idL \to \text{id}addType(id.entry,X6.type)\text{addType}(\text{id.entry}, X_6.\text{type})
Which one of the following are the appropriate choices for X1,X2,X3X_1, X_2, X_3 and X4X_4?
Show answer without attempting

Answer: A

Q43

GATE CS 2019 CSParsingNAT2 marks
Consider the augmented grammar given below:
S′→SS' \to S
S→(L)∣idS \to (L) \mid \text{id}
L→L,S∣SL \to L, S \mid S

Let I0=CLOSURE({[S′→∙S]})I_0 = \text{CLOSURE}(\{[S' \to \bullet S]\}). The number of items in the set GOTO(I0,()\text{GOTO}(I_0, \text{(}) is: __________.
Show answer without attempting

Answer: 5

0/40 correct0 marks

Related topics in GATE CS