Show that an LR(1) grammar that is not LALR(1) must have only reduce/reduce conflicts

397 views Asked by At

Can someone please explain to me why an LR(1) grammar that is not LALR(1) must have only reduce/reduce conflicts

1

There are 1 answers

0
rici On BEST ANSWER

Because if there were a shift-reduce conflict, it would also exist in the LR(1) parser.

The proof is in pretty well every textbook which introduces LALR parsing. The LALR algorithm merges states with the same statesets, so the possible shift actions are the same in the merged state as in every one of the original states. Furthermore, every reduction action in the merged state is in at least one of the original states. So if a reduction action in the merged state conflicts with a shift action, it must also conflict with that shift action in the original state(s) in which the reduction action appears.