5.8.4 Unreachable States

If there exists no sequence of transitions from the parser’s start state to
some state s, then Bison considers s to be an unreachable
state. A state can become unreachable during conflict resolution if Bison
disables a shift action leading to it from a predecessor state.

By default, Bison removes unreachable states from the parser after conflict
resolution because they are useless in the generated parser. However,
keeping unreachable states is sometimes useful when trying to understand the
relationship between the parser and the grammar.

Directive: %define lr.keep-unreachable-statevalue

Request that Bison allow unreachable states to remain in the parser tables.
value must be a Boolean. The default is false.

There are a few caveats to consider:

Missing or extraneous warnings.

Unreachable states may contain conflicts and may use rules not used in any
other state. Thus, keeping unreachable states may induce warnings that are
irrelevant to your parser’s behavior, and it may eliminate warnings that are
relevant. Of course, the change in warnings may actually be relevant to a
parser table analysis that wants to keep unreachable states, so this
behavior will likely remain in future Bison releases.

Other useless states.

While Bison is able to remove unreachable states, it is not guaranteed to
remove other kinds of useless states. Specifically, when Bison disables
reduce actions during conflict resolution, some goto actions may become
useless, and thus some additional states may become useless. If Bison were
to compute which goto actions were useless and then disable those actions,
it could identify such states as unreachable and then remove those states.
However, Bison does not compute which goto actions are useless.