This has been alluded to before.
What would /A*B*/ produce?
Because if you were just processing the rex, I think you'd have to finish generating all possibilities of A* before you began iterating over B*...
The "proper" way would be to first produce all possibilities of length n before giving any possibility of length n+1.
'' 'A' 'B' 'AA' 'AB' 'BB' 'AAA' 'AAB' ...
I haven't spent a milisecond of working out whether that's feasible to implement, but from a theoretical POV it seems like the solution.
-- Matthijs van Duin -- May the Forth be with you!