GATE / CS ARCHIVE

GATE CSE 2022 / QUESTION 13

GATE CSE 2022 Q13

Compiler Design · Parsing & Syntax Analysis · Full GATE CSE 2022 paper

GATE 2022, Q13 1 mark · MCQ
Report issue

Parsing & Syntax Analysis

Question 13, GATE 2022: Choose the true statement: A LALR(1) cannot introduce reduce/reduce conflicts absent from LR(1); B symbol tables are accessed only during lexical analysis; C data-flow analysis is necessary for run-time memory management; D LR(1) parsing suffices for deterministic context-free languages.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Every deterministic context-free language has an LR(1) grammar, so LR(1) parsing is sufficient for these languages, D. LALR merging can introduce reduce-reduce conflicts even when canonical LR has none. Symbol-table information is used beyond lexical analysis, and data-flow analysis is not a necessary runtime step in program execution. The claim is about existence of a suitable LR(1) grammar, not that every grammar of the language is LR(1).

LALR merges canonical states with identical LR(0) cores but potentially different lookahead sets; combining these lookaheads can create a reduce/reduce choice. Symbol tables also serve declaration/type checking, code generation, and optimization. LR(1) sufficiency concerns a grammar for the language, not every arbitrary presentation of it.

Original paper, page 12 · Answer key