GATE || Compiler design || Syntax Analysis || Pyq ( 2010 to 2025 )

Last Updated :
Discuss
Comments

Question 1

Consider the following grammar G.

S -> F | H

F -> p | c

H ->d | c

Where S, F and H are non-terminal symbols, p, d and c are terminal symbols. Which of the following statement(s) is/are correct?

S1: LL(1) can parse all strings that are generated using grammar G.

S2: LR(1) can parse all strings that are generated using grammar.

[GATE 2015||SET-3 MCQ || 2-mark]


  • Only S1

  • Only S2

  • Both S1 and S2

  • Neither S1 nor S2

Question 2

Consider the following grammar G, with S as the start symbol. The grammar G has three incomplete productions denoted by (1), (2), and (3):
𝑆 → 𝑑𝑎𝑇 | (1)
𝑇 → 𝑎𝑆 | 𝑏𝑇 | (2)
𝑅 → (3) | 𝜖

The set of terminals is {𝑎, 𝑏, 𝑐, 𝑑, 𝑓}. The FIRST and FOLLOW sets of the different non-terminals are as follows:

FIRST(𝑆) = {𝑐, 𝑑, 𝑓}, FIRST(𝑇) = {𝑎, 𝑏, 𝜖}, FIRST(𝑅) = {𝑐, 𝜖}

FOLLOW(𝑆) = FOLLOW(𝑇) = {𝑐, 𝑓, $}, FOLLOW(𝑅) = {𝑓}

[GATE 2024|| SET-1 MCQ|| 1-mark]

  • (1) S→Rf  (2) T→ϵ  (3) R→cTR

  • (1) S→fR  (2) T→ϵ  (3) R→cTR

  • (1)  SfR  (2) TcT (3)  RcR

  • (1)  SRf  (2)  TcT (3)  RcR

Question 3

Which of the following is/are Bottom-Up Parser(s) [GATE 2024|| SET-1 MSQ|| 1-mark]

  • Shift-reduce Parser

  • Predictive Parser

  • LL(1) Parser

  • LR Parser

Question 4

Consider the augmented grammar with { +, *, (, ), id } as the set of terminals.

Screenshot-2025-10-14-125620
.

If I0 is the set of two LR(0) items {[S′→S.],[S→S.+R]} then goto(closure (I0 ),+) contains exactly _____ items. [GATE 2022|| NAT || 2-mark]

  • 5

Question 5

Consider the following grammar along with translation rules.

Screenshot-2025-10-14-122925
.

Here # and % are operators and id is a token that represents an integer and id.val represents the corresponding integer value.
The set of non-terminals is {S, T, R, P} and a subscripted non-terminal indicates an instance of the non-terminal.

Using this translation scheme, the computed value of S.val for root of the parse tree for the expression
20#10%5#8%2%2 is ______. [GATE 2022|| NAT || 2-mark]


  • 80

Question 6

Consider two grammars G₁ and G₂ with the production rules given below: [GATE 2025|| SET-2 MSQ|| 2-mark]

Screenshot-2025-10-13-123158
.

Which of the following option(s) is/are CORRECT?


  • G1​ is not LL(1) and G2​ is LL(1).

  • G1​ is LL(1) and G2​ is not LL(1).

  • G1​ and G2​ are not LL(1).

  • G1​ and G2 are ambiguous.

Question 7

Which of the following statement(s) is/are TRUE while computing First and Follow during top-down parsing by a compiler?

[GATE 2025|| SET-1 MSQ|| 2-mark]


  • For a production A→ϵ, ϵ epsilon will be added to First(A)

  • If there is any input right end marker, it will be added to First(S), where S is the start symbol.

  • For a production A→ϵ, ϵ epsilon will be added to Follow(A).

  • If there is any input right end marker, it will be added to Follow(S), where S is the start symbol.

Question 8

Which one of the following statements is TRUE? [GATE 2022|| MCQ || 1-mark]

  • The LALR(1) parser for a grammar G cannot have reduce – reduce conflict if the LR(1) parser for G does not have reduce – reduce conflict.

  • Symbol table is accessed only during the lexical analysis phase.

  • Data flow analysis is necessary for run-time memory management.

  • LR(1) parsing is sufficient for deterministic context – free languages.

Question 9

The grammar : S → aSa|bS|c is:-

[GATE 2010 || MCQ|| 2-mark]


  • LL(1) but not LR(1)

  • LR(1) but not LL(1)

  • Both LL(1) and LR(1)

  • Neither LL(1) nor LR(1)


Question 10

Consider two binary operators ‘↑’ and ‘↓’ with the precedence of operator ↓ being lower than that of the operator ↑. Operator ↑ is right associative while operator ↓ is left associative. Which one of the following represents the parse tree for expression (7↓3↑4↑3↓2) ?

[GATE 2011 || MCQ|| 2-mark]  

  • Screenshot-2025-10-14-172327
    .


  • Screenshot-2025-10-14-172336
    .


  • Screenshot-2025-10-14-171404
    .


  • Screenshot-2025-10-14-171427
    .


There are 31 questions to complete.

Take a part in the ongoing discussion