The GATE Grind

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

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

42 questions worth 67 marks in all (17 1-mark, 25 2-mark). Asked between 2007 and 2026, so you can see how the topic has been tested over time.

  1. GATE 2007 CS Q18 (1 mark, Multiple choice) – Which is a top-down parser?
  2. GATE 2007 CS Q52 (2 marks, Multiple choice) – Grammar has N=S, C, S1, T=a, b, i, t, e, start S, rules S iCtSS 1 a, S 1 eS, C b. Why is it NOT LL(1)?
  3. GATE 2007 CS Q53 (2 marks, Multiple choice) – P: Every regular grammar is LL(1). Q: Every regular set has an LR(1) grammar. Which is TRUE?
  4. GATE 2008 CS Q11 (1 mark, Multiple choice) – Which best describes a handle in LR parsing?
  5. GATE 2008 CS Q55 (2 marks, Multiple choice) – An LALR(1) parser for grammar G can have shift-reduce conflicts if and only if
  6. GATE 2021 CS (CS2) Q61 (2 marks, Numerical answer) – The augmented grammar is S′→S; S→S#cS SS S@ <S> a b c, with #,@,<,>,a,b,c terminals. Let I0=CLOSURE(S′→·S). Find the number of LR(0) items in…
  7. GATE 2015 CS (CS3) Q15 (1 mark, Multiple choice) – Among SLR, canonical LR and LALR, select the method easiest to implement followed by the most powerful method.
  8. GATE 2015 CS (CS3) Q65 (2 marks, Multiple choice) – Grammar G has S→F H, F→p c, H→d c. S1: LL(1) can parse every string using grammar G. S2: LR(1) can parse every string using grammar G. Which are…
  9. GATE 2010 CS Q48 (2 marks, Multiple choice) – For the grammar S→aSa bSb c, which classification holds?
  10. GATE 2011 CS Q37 (2 marks, Multiple choice) – Binary operator ↓ has lower precedence than ↑. Operator ↑ is right-associative and ↓ left-associative. Which displayed parse tree represents…
  11. GATE 2013 CS Q19 (1 mark, Multiple choice) – A grammar has no ε-productions or unit productions (the source gives types A→ε and A→a). What is the maximum number of bottom-up reduce moves when…
  12. GATE 2013 CS Q50 (2 marks, Multiple choice) – Two LR(1) item sets share core X→c·X, X→·cX, X→·d. Their lookaheads are respectively c,d and end-marker. Which claims about their LALR merge are…
  13. GATE 2012 CS Q62 (2 marks, Multiple choice) – S→aAbB bAaB ε; A→S; B→S. The partial predictive table has S row (E1,E2,S→ε), A row (A→S,A→S,error), B row (B→S,B→S,E3), for lookaheads a,b,end-marker…
  14. GATE 2012 CS Q63 (2 marks, Multiple choice) – S→aAbB bAaB ε; A→S; B→S. The partial predictive table has S row (E1,E2,S→ε), A row (A→S,A→S,error), B row (B→S,B→S,E3), for lookaheads a,b,end-marker…
  15. GATE 2017 CS (CS2) Q16 (1 mark, Multiple choice) – Which parser statements are correct? I: Canonical LR is more powerful than SLR. II: SLR is more powerful than LALR. III: SLR is more powerful than…
  16. GATE 2017 CS (CS2) Q42 (2 marks, Multiple choice) – G has E→E−T T, T→T+F F, F→(E) id. Which equivalent grammar has no left recursion?
  17. GATE 2016 CS (CS2) Q55 (2 marks, Multiple choice) – Which grammar has no left recursion?
  18. GATE 2016 CS (CS2) Q56 (2 marks, Multiple choice) – Start symbol D and terminals int, ;, id, [, ], num generate one C-like array declaration with at least one dimension, such as int a[10][3];. G₁: D →…
  19. GATE 2014 CS (CS2) Q27 (1 mark, Multiple choice) – Grammar: S → T * P; T → U T * U; P → Q + P Q; Q → Id; U → Id. Which is TRUE?
  20. GATE 2014 CS (CS1) Q44 (2 marks, Multiple choice) – A canonical item set is S → L · > R and Q → R ·. On input symbol <, the set has .
  21. GATE 2017 CS (CS1) Q27 (1 mark, Multiple choice) – Consider the following grammar: P xQRS Q yz z R w S y What is FOLLOW(Q)?
  22. GATE 2016 CS (CS1) Q55 (2 marks, Numerical answer) – The attributes of three arithmetic operators in some programming language are given below. Operator Precedence Associativity Arity --- --- --- --- +…
  23. GATE 2015 CS (CS1) Q18 (1 mark, Multiple choice) – Which one of the following is TRUE at any valid state in shift-reduce parsing?
  24. GATE 2018 CS Q48 (2 marks, Multiple choice) – Consider the following parse tree for the expression a\#b36c36d\#e\#f, involving two binary operators 36 and `#`. Which one of the following is…
  25. GATE 2019 CS Q13 (1 mark, Multiple choice) – Which one of the following kinds of derivation is used by LR parsers?
  26. 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 36 be indexed as follows: a b d 36 --- --- --- --- 3 2 1 0 Compute…
  27. 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:…
  28. 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…
  29. GATE 2026 CS (CS1) Q28 (1 mark, Multiple select) – Which of the following statements is/are true?
  30. 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?
  31. 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…
  32. 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?
  33. 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,…
  34. 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…
  35. GATE 2024 CS (CS1) Q26 (1 mark, Multiple select) – Which of the following is/are Bottom-Up Parser(s)?
  36. 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),…
  37. 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,ε;…
  38. GATE 2022 CS Q13 (1 mark, Multiple choice) – Which one of the following statements is TRUE?
  39. 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'…
  40. GATE 2021 CS (CS1) 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…
  41. GATE 2021 CS (CS1) 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…
  42. 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 .