Parsing: GATE CS Previous Year Questions

Parsing · Compiler Design

58 questions · asked in 25 of 27 years (2000–2026)

MCQ 46 · MSQ 5 · NAT 71-mark 39 · 2-mark 19

2000Questions per year2026

Questions 11–15 of 58

Q11GATE 2021 (Session 1)1 markMCQ−0.33 if wrong
Consider the following statements.

S1: Every SLR(1) grammar is unambiguous but there are certain unambiguous grammars that are not SLR(1).
S2: 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 n.

Which one of the following options is correct?

Q12GATE 2021 (Session 2)2 marksNAT
Consider the following augmented grammar with {#,@,<,>,a,b,c}\{ \#, @, <, >, a, b, c \} as the set of terminals.

S′→SS→S#cSS→SSS→S@S→<S>S→aS→bS→c\begin{array}{l} S' \rightarrow S \\ S \rightarrow S \# cS \\ S \rightarrow SS \\ S \rightarrow S @ \\ S \rightarrow < S > \\ S \rightarrow a \\ S \rightarrow b \\ S \rightarrow c \end{array}

Let I0=CLOSURE({S′→∙S})I_0 = \text{CLOSURE}(\{S' \rightarrow \bullet S\}). The number of items in the set GOTO(GOTO(I0<),<)\text{GOTO(GOTO}(I_0 \lt ), \lt ) is ___________

Q13GATE 20201 markNAT
Consider the following grammar.

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

The number of reduction steps taken by a bottom-up parser while accepting the string aaadbbbaaadbbb is___________.

Q14GATE 20191 markMCQ−0.33 if wrong
Which one of the following kinds of derivation is used by LR parsers?

Q15GATE 20191 markNAT
Consider the following given grammar:
 
S -> Aa
A -> BD
B -> b| ε
D -> d| ε 
Let a, b, d and $ be indexed as follows:
a b d $ 3 2 1 0
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).
Answer:_____

Keep practising

Topics in Compiler Design

All CS topics ›