CFG - Left factoring in recursive nested productions
You can solve this with regular expressions:

S -&gt; a b S | T


is equivalent to

S -&gt; (a b)* T


and

T -&gt; a c T | d T | ϵ


is equivalent to

T -&gt; (a c | d)*


Subtitute T into the rule for S:

S -&gt; (a b)* (a c | d)*


Now, you can use a standard method to derive a right regular grammar.