Let's say I'm reading a line from a file:
{Parent{{ChildA}{ChildB}}}
More complex example:
{Parent{{ChildA{ChildC}{ChildD}}{ChildB{ChildE}{ChildF}}}}
Which is the grammar used to construct a tree.
Any name inside {}
brackets is a node, and if within that bracket there are other nodes (brackets), those nodes are children.
I'm able to parse the first specific example using a counter, but only to find the text names of the nodes. How can I parse this so that I can determine what nodes are children of one another? I can't seem to wrap my mind around the code I would use. I have a feeling I would use recursion.
Any help or advice would be appreciated.
C++ is preferred.
Thank you very much.