Hi Nat Goodspeed,

thank for your reply. Yes, I want to traverse the tree after a correct parsing. It seems that these are 2 independent tasks.

Regards
Olivier



2013/9/30 Nat Goodspeed <nat@lindenlab.com>
On Sun, Sep 29, 2013 at 2:12 PM, Olivier Austina <olivier.austina@gmail.com> wrote:

I would like to traverse a parsed tree. The parsing is fine. I am using this tutorial :
http://en.highscore.de/cpp/boost/parser.html

I would like to traverse the parsed tree like classical tree (Pre-order, In-order, Post-order) to have data in a given order. Any suggestion will be appreciated. Thank you.

So if I understand correctly, this is no longer a question about parsing, it's a question about tree traversal.

Are you saying you want to flatten the tree to process its elements by iteration, in a particular order?

Consider the same_fringe.cpp example in the coroutine library in the Subversion trunk:
http://svn.boost.org/svn/boost/trunk/libs/coroutine/example/cpp03/same_fringe.cpp

Look at the traverse() function. This is bound to a particular tree of nodes and launched as a coroutine. You can then use boost::begin() and boost::end() on the coroutine object. This permits use with BOOST_FOREACH, standard algorithms, ...

You can alter processing order simply by writing a traversal function whose body processes the node's value in different places relative to the subtrees.

Apologies if I've completely misunderstood your question.

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users