C++ Generate and BFS a Derivation Tree of a User Defined Grammar and Final State