The GATE Grind

GATE Compiler Design: Parsing and Syntax Analysis – Previous Year Questions

22 GATE previous year questions on Parsing and Syntax Analysis (Compiler Design, Computer Science) with answers and explanations, from every paper.

  1. GATE 2017 CS Q27 (1 mark, Multiple choice) – Consider the following grammar: P xQRS Q yz z R w S y What is FOLLOW(Q)?
  2. GATE 2016 CS Q55 (2 marks, Numerical answer) – The attributes of three arithmetic operators in some programming language are given below. Operator Precedence Associativity Arity --- --- --- --- +…
  3. GATE 2015 CS Q18 (1 mark, Multiple choice) – Which one of the following is TRUE at any valid state in shift-reduce parsing?
  4. GATE 2018 CS Q48 (2 marks, Multiple choice) – Consider the following parse tree for the expression `a#b\c\d#e#f`, involving two binary operators `\` and `#`. Which one of the following is correct…
  5. GATE 2019 CS Q13 (1 mark, Multiple choice) – Which one of the following kinds of derivation is used by LR parsers?
  6. GATE 2019 CS Q29 (1 mark, Numerical answer) – Consider the grammar given below: 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…
  7. GATE 2019 CS Q53 (2 marks, Numerical answer) – Consider the augmented grammar given below: S' → S S → ⟨L⟩ id L → L,S S Let I 0=CLOSURE(\[S' S]\). The number of items in the set GOTO(I 0,) is:…
  8. GATE 2026 CS (CS2) Q41 (2 marks, Multiple choice) – Consider canonical LR(0) parsing of the grammar below using terminals \a,b,c\ and non-terminals \A,B,C,S\, with S as the start symbol. S ACB A aA C cC…
  9. GATE 2026 CS (CS1) Q28 (1 mark, Multiple select) – Which of the following statements is/are true?
  10. GATE 2025 CS (CS2) Q40 (2 marks, Multiple choice) – Given a Context-Free Grammar G as follows: S Aa bAc dc bda A d Which ONE of the following statements is TRUE?
  11. GATE 2025 CS (CS2) Q51 (2 marks, Multiple select) – Consider two grammars G 1 and G 2 with the production rules given below: G 1: S if\ E\ then\ S if\ E\ then\ S\ else\ S a E b G 2: S if\ E\ then\ S M M…
  12. GATE 2025 CS (CS1) Q46 (2 marks, Multiple select) – Which of the following statement(s) is/are TRUE while computing First and Follow during top down parsing by a compiler?
  13. GATE 2024 CS (CS2) Q40 (2 marks, Multiple choice) – Consider the CFG with start symbol S and terminals a,b,c,d: S AaAb BbBa, A cS, B dS. In the partially-filled LL(1) table, S row has S→AaAb at a,…
  14. GATE 2024 CS (CS2) Q65 (2 marks, Numerical answer) – Consider the augmented grammar parsed with an SLR parser, terminals \a,b,c,d,\#,@\: S' S; S SS Aa bAc Bc bBa; A d\#; B @. Let I 0=CLOSURE(\S' S\). The…
  15. GATE 2024 CS (CS1) Q26 (1 mark, Multiple select) – Which of the following is/are Bottom-Up Parser(s)?
  16. GATE 2024 CS (CS1) Q33 (1 mark, Numerical answer) – Consider the operator precedence and associativity rules for the integer arithmetic operators given in the table: + (Highest, Left), - (High, Right),…
  17. GATE 2024 CS (CS1) Q38 (2 marks, Multiple choice) – Consider grammar G with start symbol S: S→daT (1); T→aS bT (2); R→(3) ε. Terminals are a,b,c,d,f. FIRST(S)=c,d,f, FIRST(T)=a,b,ε, FIRST(R)=c,ε;…
  18. GATE 2022 CS Q13 (1 mark, Multiple choice) – Which one of the following statements is TRUE?
  19. GATE 2022 CS Q29 (1 mark, Numerical answer) – Consider the augmented grammar with \+, *, (, ), id\ as the set of terminals. S' S S S+R R R R*P P P (S) id If I 0 is the set of two LR(0) items \[S'…
  20. GATE 2021 CS Q15 (1 mark, Multiple choice) – Consider the following statements. S 1: Every SLR(1) grammar is unambiguous but there are certain unambiguous grammars that are not SLR(1). S 2: For…
  21. GATE 2021 CS Q41 (2 marks, Multiple choice) – Consider the following context-free grammar where the set of terminals is a, b, c, d, f. S -> d a T R f T -> a S b a T epsilon R -> c a T R epsilon…
  22. GATE 2020 CS Q34 (1 mark, Numerical answer) – Consider the following grammar. S aSB d B b The number of reduction steps taken by a bottom-up parser while accepting the string aaadbbb is .