[857] | 1 | /*=============================================================================
|
---|
| 2 | Copyright (c) 2001-2003 Daniel Nuffer
|
---|
| 3 | Copyright (c) 2001-2003 Hartmut Kaiser
|
---|
| 4 | http://spirit.sourceforge.net/
|
---|
| 5 |
|
---|
| 6 | Use, modification and distribution is subject to the Boost Software
|
---|
| 7 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
---|
| 8 | http://www.boost.org/LICENSE_1_0.txt)
|
---|
| 9 | =============================================================================*/
|
---|
| 10 |
|
---|
| 11 | #if !defined(PARSE_TREE_UTILS_HPP)
|
---|
| 12 | #define PARSE_TREE_UTILS_HPP
|
---|
| 13 |
|
---|
| 14 | #include <utility> // for std::pair
|
---|
| 15 |
|
---|
| 16 | #include <boost/spirit/tree/parse_tree.hpp> // needed for parse tree generation
|
---|
| 17 |
|
---|
| 18 | ///////////////////////////////////////////////////////////////////////////////
|
---|
| 19 | namespace boost {
|
---|
| 20 | namespace spirit {
|
---|
| 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 containes 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 | } // namespace spirit
|
---|
| 59 | } // namespace boost
|
---|
| 60 |
|
---|
| 61 | #include "boost/spirit/tree/impl/parse_tree_utils.ipp"
|
---|
| 62 |
|
---|
| 63 | #endif // !defined(PARSE_TREE_UTILS_HPP)
|
---|