| 1 | /*============================================================================= |
| 2 | Copyright (c) 2001-2003 Daniel Nuffer |
| 3 | Copyright (c) 2001-2007 Hartmut Kaiser |
| 4 | http://spirit.sourceforge.net/ |
| 5 | |
| 6 | Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 7 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 8 | =============================================================================*/ |
| 9 | |
| 10 | #ifndef BOOST_SPIRIT_CLASSIC_TREE_PARSE_TREE_UTILS_HPP |
| 11 | #define BOOST_SPIRIT_CLASSIC_TREE_PARSE_TREE_UTILS_HPP |
| 12 | |
| 13 | #include <utility> // for std::pair |
| 14 | |
| 15 | #include <boost/spirit/home/classic/tree/parse_tree.hpp> // needed for parse tree generation |
| 16 | |
| 17 | /////////////////////////////////////////////////////////////////////////////// |
| 18 | namespace boost { |
| 19 | namespace spirit { |
| 20 | BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN |
| 21 | |
| 22 | /////////////////////////////////////////////////////////////////////////////// |
| 23 | // |
| 24 | // The function 'get_first_leaf' returnes a reference to the first leaf node |
| 25 | // of the given parsetree. |
| 26 | // |
| 27 | /////////////////////////////////////////////////////////////////////////////// |
| 28 | template <typename T> |
| 29 | tree_node<T> const & |
| 30 | get_first_leaf (tree_node<T> const &node); |
| 31 | |
| 32 | /////////////////////////////////////////////////////////////////////////////// |
| 33 | // |
| 34 | // The function 'find_node' finds a specified node through recursive search. |
| 35 | // If the return value is true, the variable to which points the parameter |
| 36 | // 'found_node' will contain the address of the node with the given rule_id. |
| 37 | // |
| 38 | /////////////////////////////////////////////////////////////////////////////// |
| 39 | template <typename T> |
| 40 | bool |
| 41 | find_node (tree_node<T> const &node, parser_id node_to_search, |
| 42 | tree_node<T> const **found_node); |
| 43 | |
| 44 | /////////////////////////////////////////////////////////////////////////////// |
| 45 | // |
| 46 | // The function 'get_node_range' return a pair of iterators pointing at the |
| 47 | // range, which contains the elements of a specified node. It's very useful |
| 48 | // for locating all information related with a specified node. |
| 49 | // |
| 50 | /////////////////////////////////////////////////////////////////////////////// |
| 51 | template <typename T> |
| 52 | bool |
| 53 | get_node_range (tree_node<T> const &node, parser_id node_to_search, |
| 54 | std::pair<typename tree_node<T>::const_tree_iterator, |
| 55 | typename tree_node<T>::const_tree_iterator> &nodes); |
| 56 | |
| 57 | /////////////////////////////////////////////////////////////////////////////// |
| 58 | BOOST_SPIRIT_CLASSIC_NAMESPACE_END |
| 59 | } // namespace spirit |
| 60 | } // namespace boost |
| 61 | |
| 62 | #include <boost/spirit/home/classic/tree/impl/parse_tree_utils.ipp> |
| 63 | |
| 64 | #endif |
| 65 | |