Parsing questions — page 1 of 2

Q28

GATE CS 2026 CS-1ParsingMSQ1 mark
Which of the following statements is/are true?
More than one option can be correct.
Show answer without attempting

Answer: C

Q41

GATE CS 2026 CS-2ParsingMCQ2 marks−2/3 if wrong
Consider the canonical LR(0)LR(0) parsing of the grammar below using terminals {a,b,c}\{a, b, c\} and non-terminals {A,B,C,S}\{A, B, C, S\} with SS as the start symbol.

S→ACBS \rightarrow ACB

A→aA∣ϵA \rightarrow aA \mid \epsilon

C→cC∣ϵC \rightarrow cC \mid \epsilon

B→bB∣bB \rightarrow bB \mid b

Which one of the following options gives the number of shift-reduce conflicts that will occur in the LR(0)LR(0) ACTION table?
Show answer without attempting

Answer: D

Q46

GATE CS 2025 CS-1ParsingMSQ2 marks
Which of the following statement(s) is/are TRUE while computing First and Follow during top down parsing by a compiler?
More than one option can be correct.
Show answer without attempting

Answer: A, D

Q40

GATE CS 2025 CS-2ParsingMCQ2 marks−2/3 if wrong
Given a Context-Free Grammar GG as follows:

S→Aa∣bAc∣dc∣bdaS \rightarrow Aa \mid bAc \mid dc \mid bda
A→dA \rightarrow d

Which ONE of the following statements is TRUE?
Show answer without attempting

Answer: C

Q51

GATE CS 2025 CS-2ParsingMSQ2 marks
Consider two grammars G1G_1 and G2G_2 with the production rules given below:

G1:S→if E then S∣if E then S else S∣aG_1: S \rightarrow \text{if } E \text{ then } S \mid \text{if } E \text{ then } S \text{ else } S \mid a
E→bE \rightarrow b

G2:S→if E then S∣MG_2: S \rightarrow \text{if } E \text{ then } S \mid M
M→if E then M else S∣cM \rightarrow \text{if } E \text{ then } M \text{ else } S \mid c
E→bE \rightarrow b

where if,then,else,a,b,c\text{if}, \text{then}, \text{else}, a, b, c are the terminals.

Which of the following option(s) is/are CORRECT?
More than one option can be correct.
Show answer without attempting

Answer: C, D

Q26

GATE CS 2024 CS-1ParsingMSQ1 mark
Which of the following is/are Bottom-Up Parser(s)?
More than one option can be correct.
Show answer without attempting

Answer: A, D

Q40

GATE CS 2024 CS-2ParsingMCQ2 marks−2/3 if wrong
Consider the following context-free grammar where the start symbol is SS and the set of terminals is {a,b,c,d}\{a,b,c,d\}.

S→AaAb∣BbBaS \to AaAb \mid BbBa
A→cS∣ϵA \to cS \mid \epsilon
B→dS∣ϵB \to dS \mid \epsilon

The following is a partially-filled LL(1) parsing table.
aabbccdd$\$
SSS→AaAbS \to AaAbS→BbBaS \to BbBa(1)(2)
AAA→ϵA \to \epsilon(3)A→cSA \to cS
BB(4)B→ϵB \to \epsilonB→dSB \to dS
Which one of the following options represents the CORRECT combination for the numbered cells in the parsing table?

Note: In the options, "blank" denotes that the corresponding cell is empty.
Show answer without attempting

Answer: A

Q65

GATE CS 2024 CS-2ParsingNAT2 marks
Consider the following augmented grammar, which is to be parsed with a SLR parser. The set of terminals is {a,b,c,d,#,@}\{a,b,c,d,\#,@\}

S′→SS' \to S
S→SS∣Aa∣bAc∣Bc∣bBaS \to SS \mid Aa \mid bAc \mid Bc \mid bBa
A→d#A \to d\#
B→@B \to @

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

Answer: 9

Q13

GATE CS 2022 CSParsingMCQ1 mark−1/3 if wrong
Which one of the following statements is TRUE?
Show answer without attempting

Answer: D

Q29

GATE CS 2022 CSParsingNAT1 mark
Consider the augmented grammar with {+,∗,(,),id}\{+, *, (, ), \text{id}\} as the set of terminals.

S′→SS' \to S
S→S+R∣RS \to S + R \mid R
R→R∗P∣PR \to R * P \mid P
P→(S)∣idP \to (S) \mid \text{id}

If I0I_0 is the set of two LR(0)LR(0) items {[S′→S∙],[S→S∙+R]}\bigl\{[S' \to S\bullet], [S \to S\bullet + R]\bigr\}, then goto(closure(I0),+)\text{goto}(\text{closure}(I_0), +) contains exactly __________ items.
Show answer without attempting

Answer: 5

Q5

GATE CS 2021 CS-1ParsingMCQ1 mark−1/3 if wrong
Consider the following statements.
S1S_1: Every SLR(1) grammar is unambiguous but there are certain unambiguous grammars that are not SLR(1).
S2S_2: For any context-free grammar, there is a parser that takes at most O(n3)O(n^3) time to parse a string of length nn.
Which one of the following options is correct?
Show answer without attempting

Answer: C

Q31

GATE CS 2021 CS-1ParsingMCQ2 marks−2/3 if wrong
Consider the following context-free grammar where the set of terminals is {a,b,c,d,f}\{a, b, c, d, f\}.
S→daT∣RfS \to daT \mid Rf
T→aS∣baT∣ϵT \to aS \mid baT \mid \epsilon
R→caTR∣ϵR \to caTR \mid \epsilon
The following is a partially-filled LL(1) parsing table.
aabbccddff$\$
S(1)S→daTS \to daT(2)
TT→aST \to aST→baTT \to baT(3)T→ϵT \to \epsilon(4)
RR→caTRR \to caTRR→ϵR \to \epsilon
Which one of the following choices represents the correct combination for the numbered cells in the parsing table ("blank" denotes that the corresponding cell is empty)?
Show answer without attempting

Answer: A

Q51

GATE CS 2021 CS-2ParsingNAT2 marks
Consider the following augmented grammar with {#,@,<,>,a,b,c}\{\#, @, <, >, a, b, c\} as the set of terminals.

<br>S′→S<br>S→S#cS<br>S→SS<br>S→S@<br>S→<S><br>S→a<br>S→b<br>S→c<br>\begin{aligned}<br>S' & \to S \\<br>S & \to S \# c S \\<br>S & \to S S \\<br>S & \to S @ \\<br>S & \to < S > \\<br>S & \to a \\<br>S & \to b \\<br>S & \to c<br>\end{aligned}

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

Answer: 8

Q24

GATE CS 2020 CSParsingNAT1 mark
Consider the following grammar.

S→aSB∣dS \rightarrow aSB \mid d
B→bB \rightarrow b

The number of reduction steps taken by a bottom-up parser while accepting the string aaadbbbaaadbbb is __________.
Show answer without attempting

Answer: 7

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

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

Q8

GATE CS 2018 CSParsingMCQ1 mark−1/3 if wrong
Which one of the following statements is FALSE?
Show answer without attempting

Answer: B

Q38

GATE CS 2018 CSParsingMCQ2 marks−2/3 if wrong
Consider the following parse tree for the expression a#b$c$d#e#fa \# b \$ c \$ d \# e \# f, involving two binary operators $\$ and #\#.

Which one of the following is correct for the given parse tree?
Question figure
Show answer without attempting

Answer: A

Q43

GATE CS 2017 CS-1ParsingNAT2 marks
Consider the following grammar:
stmt -> if expr then expr else expr; stmt | ε
expr -> term relop term | term
term -> id | number
id -> a | b | c
number -> [0-9]
where relop is a relational operator (e.g., <,>,…<, >, \dots), ε\varepsilon refers to the empty statement, and if, then, else are terminals.

Consider a program PP following the above grammar containing ten if terminals. The number of control flow paths in PP is ____________. For example, the program
if e1 then e2 else e3
has 2 control flow paths, e1→e2e_1 \to e_2 and e1→e3e_1 \to e_3.
Show answer without attempting

Answer: 1024.0

0/200 correct0 marks

Related topics in Compiler Design