Which one of the following is TRUE at any valid state in shift-reduce parsing?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2015 Set 1 · Q13
Time
Select one answerSingle correct
Solution
Official answer: C) The stack contains only a set of viable prefixes
Lexical Analysis, Parsing and SDTIn shift-reduce parsing (bottom-up parsing), a viable prefix is a prefix of a right-sentential form that can appear on the stack of a shift-reduce parser without extending past the right end of the handle [18].
At any valid configuration of a shift-reduce parser, the string of grammar symbols held in the parsing stack must form a viable prefix of some right-sentential form [18].
Hence, the parsing stack always contains only a viable prefix (or prefixes) of the grammar at every valid state [18].
Therefore, option C is the correct statement [18].
Try the question first, then check your work.
Examiner trap
Recall the definition of a viable prefix in bottom-up parsing: it is a prefix of a right-sentential form that does not continue past the right end of the rightmost handle.
This Lexical Analysis, Parsing and SDT previous year question is Q13 of the GATE CSE 2015 Set 1 paper. Find more GATE CSE PYQs on Lexical Analysis, Parsing and SDT in Compiler Design, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Lexical Analysis, Parsing and SDT PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Lexical Analysis, Parsing and SDT has 14 GATE CSE PYQs across 12 papers from 2011 to 2025. 9 of them are 1-mark MCQs like this one, and it is the only one in GATE CSE 2015 Set 1.
How GATE tests Lexical Analysis, Parsing and SDTIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.