closure_context.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*=============================================================================
  2. Copyright (c) 2002-2003 Joel de Guzman
  3. Copyright (c) 2002-2003 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(BOOST_SPIRIT_CLOSURE_CONTEXT_HPP)
  9. #define BOOST_SPIRIT_CLOSURE_CONTEXT_HPP
  10. #include <boost/spirit/home/classic/namespace.hpp>
  11. ///////////////////////////////////////////////////////////////////////////////
  12. namespace boost { namespace spirit {
  13. BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
  14. #if !defined(BOOST_SPIRIT_CLOSURE_CONTEXT_LINKER_DEFINED)
  15. #define BOOST_SPIRIT_CLOSURE_CONTEXT_LINKER_DEFINED
  16. ///////////////////////////////////////////////////////////////////////////////
  17. //
  18. // closure_context_linker
  19. // { helper template for the closure extendability }
  20. //
  21. // This classes can be 'overloaded' (defined elsewhere), to plug
  22. // in additional functionality into the closure parsing process.
  23. //
  24. ///////////////////////////////////////////////////////////////////////////////
  25. template<typename ContextT>
  26. struct closure_context_linker : public ContextT
  27. {
  28. template <typename ParserT>
  29. closure_context_linker(ParserT const& p)
  30. : ContextT(p) {}
  31. template <typename ParserT, typename ScannerT>
  32. void pre_parse(ParserT const& p, ScannerT const& scan)
  33. { ContextT::pre_parse(p, scan); }
  34. template <typename ResultT, typename ParserT, typename ScannerT>
  35. ResultT&
  36. post_parse(ResultT& hit, ParserT const& p, ScannerT const& scan)
  37. { return ContextT::post_parse(hit, p, scan); }
  38. };
  39. #endif // !defined(BOOST_SPIRIT_CLOSURE_CONTEXT_LINKER_DEFINED)
  40. ///////////////////////////////////////////////////////////////////////////////
  41. BOOST_SPIRIT_CLASSIC_NAMESPACE_END
  42. }} // namespace BOOST_SPIRIT_CLASSIC_NS
  43. #endif // BOOST_SPIRIT_CLOSURE_CONTEXT_HPP