parse_tree_utils.hpp 2.5 KB

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