To overcome this problem we add additional constraints to the grammar to ensure that all parses the grammar generates belong to the same tree class.
one way to do this is to include the start state of a transition as an element of the terminal, e.g., we extend the terminals to include the left-hand side of the productions they are emitted from, e.g., and the sequence of terminals becomes: {P 4 } $.