1

I've an exercise in which I have LR(2) grammar and I want to transform in LR(1) grammar. But I don't see how I can do that. I've this grammar (4 rules) :

  • e -> true | false | id | e ^ e | e v e | (e)
  • i -> if e then i | if e then i else i | id = e | (i) | ma
  • ma -> a | a ^ ma
  • a -> id = e

The problem with this grammar that she produces a reduce/reduce conflict (nobody likes that). So I need to change this grammar in LR(1) but I really don't see the algorithm for to do that. Help please :)

Bart Kiers
  • 166,582
  • 36
  • 299
  • 288
afk
  • 563
  • 2
  • 5
  • 12
  • There is a related discussion about [LR(k) to LR(1) grammar conversion](https://stackoverflow.com/questions/20683692/lrk-to-lr1-grammar-conversion). – Anderson Green Jul 30 '17 at 17:42

0 Answers0