subrule_context.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*=============================================================================
  2. Copyright (c) 2009 Francois Barel
  3. Copyright (c) 2001-2010 Joel de Guzman
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #if !defined(BOOST_SPIRIT_REPOSITORY_SUPPORT_SUBRULE_CONTEXT_AUGUST_12_2009_0539PM)
  8. #define BOOST_SPIRIT_REPOSITORY_SUPPORT_SUBRULE_CONTEXT_AUGUST_12_2009_0539PM
  9. #if defined(_MSC_VER)
  10. #pragma once
  11. #endif
  12. #include <boost/spirit/home/support/context.hpp>
  13. ///////////////////////////////////////////////////////////////////////////////
  14. namespace boost { namespace spirit { namespace repository
  15. {
  16. ///////////////////////////////////////////////////////////////////////////
  17. // subrule_context: special context used with subrules, to pass around
  18. // the current set of subrule definitions (subrule_group)
  19. ///////////////////////////////////////////////////////////////////////////
  20. template <typename Group, typename Attributes, typename Locals>
  21. struct subrule_context
  22. : context<Attributes, Locals>
  23. {
  24. typedef context<Attributes, Locals> base_type;
  25. typedef Group group_type;
  26. subrule_context(
  27. Group const& group
  28. , typename Attributes::car_type attribute
  29. ) : base_type(attribute), group(group)
  30. {
  31. }
  32. template <typename Args, typename Context>
  33. subrule_context(
  34. Group const& group
  35. , typename Attributes::car_type attribute
  36. , Args const& args
  37. , Context& caller_context
  38. ) : base_type(attribute, args, caller_context), group(group)
  39. {
  40. }
  41. subrule_context(Group const& group, Attributes const& attributes)
  42. : base_type(attributes), group(group)
  43. {
  44. }
  45. Group const& group;
  46. };
  47. }}}
  48. #endif