LR-Parsing-Table: What determines next state in reduce-actions?

317 views Asked by At

as far as I know (read) about generating LR-Parsing tables is that the columns (= token), where the reduce-action is written into a cell for a certain state, depends on the Terminals, that are in the FOLLOW-set of the reduced symbol.

Is that correct?*

If so, then the next question that comes across my mind, is: what is it that determines the next state, into which to make a transition happen after reduction.

E.g., in state 5 a r6 means to reduce the symbol and then transition into state 6 (and there maybe consider the goto-table, into which state to transition further)

The states of the parse-table or the DFA - which an LR-Parser is - are paths in a graph representation. As bottom-up parser, an LR-Parser works by finding a path back to the start symbol / accepting state. The parse-table tries to find every such path.

And it seems complicated to me, to consequentially chose the right reduction-states.

Because it intimately depends on the states / ItemSets that preceded the current state as well as the states that totentially succeed the current state depending on the yet unread input tokens.

In comparison with reduce-actions, shift- and goto-actions seem easy as they are just the transitions that appear when moving the dot-position.

Thanks

PS: *If it is correct, then isn't it "double trouble" to generate LR1Items with the FOLLOW-Set as additional feature?

0

There are 0 answers