'Unrestricted grammar for L = WW common solution question

I found this solution on a forum, it seems right to me and I can understand most of it, however I think it is incomplete since C -> CP can generate infinite P's. There's the possibility that there will be no more a or b's remaining to shift, making a sentence such as abCP#ab impossible to finish, given that C# -> ε will never happen.

I believe there should also have the P# -> # rule, making C# -> ε possible.

I'm missing something or is it right?

Solution



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source