У меня есть следующая неоднозначная грамматика оператора
E -> E +E * E | E-E * E
E->E+E | E-E | E+E | E*E | E/E
E->(E) | x ````
I must convert it to an unambiguous one which is also SLR(1). The following rules regarding precedence and associativity must hold:
Operators * and / have the highest precedence (and precedence between them must be equal)
Operators - and + have the same precedence (lower than * and /)
All operators are left associative.
Reducing with the first 2 rules is preferred if it does not break the precedence and associativity rules.
My problem is the first line of the grammar ``` (E+E * E , E-E * E)
``` . I can't find i way to convert it and the new grammar will be SLR(1).