# How to solve the following left recursion?

A common left recursion:

A -> Aa | B


can be solve by transforming it into:

A  -> BA'
A' -> aA' | E


However, I face another similar yet different left recursion when I'm writing my compiler:

A -> (A|B) a


So, my question is, how to solve such left recursion?

Rewriting (A|B) a as Aa | Ba allows you to apply the solution you already have (with Ba instead of B).