Convert ambiguous grammar to unambiguous and SLR(1) I have the following ambiguous operator grammar:

E-&gt;E+E*E | E-E*E
E-&gt;E+E | E-E | E+E | E*E | E/E
E-&gt;(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).

Edit:
The closest i came is this grammar, but it has 2 SLR conflicts:

E-&gt;E+F | E-F | T
T-&gt;T+F | T-F | F
F-&gt; F*C | F/C | C
C-&gt; (E) | x
Let's start where you probably started, with the classic expression grammar:

$$\begin{align}E&amp;\to T\mid E + T\mid E - T\\
T&amp;\to F\mid T * F\mid T / F\\
F&amp;\to ( E )\mid x\\
\end{align}$$

and then we add the "fused" productions:

$$\begin{align}E&amp;\to E + T * F\mid E - T * F\\
\end{align}$$

That grammar has a conflict because of the ambiguity:

$$\begin{align}E&amp;\to E+T*F\\E&amp;\to E+T \to E+T*F\end{align}$$
(and similarly for the $-$ operator).

So how to get rid of the ambiguity? Clearly, we don't want $E\to E+T$ to match $E+T*F$. So we need to define $$T' = T \setminus T * F$$ in order to be able to restrict the $E$ production to $E\to E + T'$.

Since the set difference operator is not valid in a CFG, we need to write the definition out the long way:

$$\begin{align}E\to&amp;\;T\mid E + T'\mid E - T'\;\mid\\
&amp;\;E + T * F\mid E - T * F\\
T'\to&amp;\;F\mid T / F\\
T\to&amp;\;T'\mid T * F\\
F\to&amp;\;( E )\mid x\\
\end{align}$$