Multiple choice

Consider the following two sets of LR (1) items of an LR (1) grammar X $\rightarrow$ c. X c / d X $\rightarrow$ c.X, $ X $\rightarrow$ .Cx, c / d X $\rightarrow$.Cx, $ X $\rightarrow$ .d, c / d X $\rightarrow$.d, $ Which of the following statements related to merging of the two sets in the corresponding LALR parser is/are FALSE?

  1. Cannot be merged since look aheads are different
  2. Can be merged but will result in S–R conflict
  3. Can be merged but will result in R–R conflict
  4. Cannot be merged since goto on c will lead to two different sets

  1. 1 only

  2. 2 only

  3. 1 and 4 only

  4. 1, 2, 3 and 4

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

  1. Merging of two sets depends on core part (production rule with dot operator), not on look aheads.
  2. The two states are not containing Reduce item. So after merging, the merged state cannot contain any S-R conflict.
  3. As there is no reduce item in any of the state, so the scenario can’t have R-R conflict.
  4. Merging of sets does not depend on further goto on any terminal. So, all statements are false.