Skip to content
Official PYQ · 2015

GATE CS 2015 Set 1 Q1 — Parsing (LL, LR)

Explain with AI

Which one of the following is TRUE at any valid state in shift-reduce parsing?

Choose one option
View worked solution

Answer: C

In shift-reduce parsing, the contents of the parser stack always represent a prefix of a right-sentential form that does not extend past the right end of the rightmost handle. This is the definition of a viable prefix.

Specifically:

  • A viable prefix is a prefix of a right-sentential form that can appear on the stack of a shift-reduce parser before a reduction takes place.
  • If the stack contains a sequence of symbols α\alpha, then α\alpha is a viable prefix.
  • Furthermore, any prefix of a viable prefix is also a viable prefix. Since the stack grows from the bottom, any partial content of the stack from the bottom up to any position is also a viable prefix.

Thus, at any valid state during shift-reduce parsing, the stack contains only viable prefixes.

Therefore, Option C is the correct statement.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Parsing (LL, LR) questions