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 26–30 of 58

Q26GATE 20131 markMCQ−0.33 if wrong
What is the maximum number of reduce moves that can be taken by a bottom-up parser for a grammar with no epsilon- and unit-production (i.e., of type A→ϵA\rightarrow \epsilon and A→aA \rightarrow a) to parse a string with n tokens?

Q27GATE 20122 marksMCQ−0.67 if wrong
For the grammar below, a partial LL(1) parsing table is also presented along with the grammar. Entries that need to be filled are indicated as E1, E2, and E3. ε\varepsilon is the empty string, $ indicates end of input, and, | separates alternate right hand sides of productions.
S→aAbB∣bAaB∣εS\rightarrow aAbB|bAaB|\varepsilon
A→SA\rightarrow S
B→SB\rightarrow S
a b $ S E1 E2 S → ε A A → S A → S error B B → S B → S E3
The appropriate entries for E1, E2, and E3 are

Q28GATE 20122 marksMCQ−0.67 if wrong
For the grammar below, a partial LL(1) parsing table is also presented along with the grammar. Entries that need to be filled are indicated as E1, E2, and E3. ε\varepsilon is the empty string, $ indicates end of input, and, | separates alternate right hand sides of productions.
S→aAbB∣bAaB∣εS\rightarrow aAbB|bAaB|\varepsilon
A→SA\rightarrow S
B→SB\rightarrow S
a b $ S E1 E2 S → ε A A → S A → S error B B → S B → S E3
The FIRST and FOLLOW sets for the non-terminals A and B are

Q29GATE 20112 marksMCQ−0.67 if wrong
Consider two binary operators '↑\uparrow 'and '↓\downarrow' with the precedence of operator ↓\downarrow being lower than that of the operator ↑\uparrow . Operator ↑\uparrow is right associative while operator ↓\downarrow is left associative. Which one of the following represents the parse tree for expression (7 ↓\downarrow 3 ↑\uparrow4 ↑\uparrow 3 ↓\downarrow2)?
(A) (C) (B) (D) ↓ ↑ ↑ ↓ 7 3 4 3 2 ↓ ↓ ↑ ↑ 2 7 3 4 3 ↓ ↓ ↑ ↑ 7 2 3 3 4 ↓ ↑ ↑ ↓ 2 3 4 7 3

Q30GATE 20102 marksMCQ−0.67 if wrong
The grammar S→\rightarrowaSa|bS|c is

Keep practising

Topics in Compiler Design

All CS topics ›