argument_expression.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*=============================================================================
  2. Copyright (c) 2011 Thomas Heller
  3. Copyright (c) 2001-2011 Hartmut Kaiser
  4. Copyright (c) 2011 Thomas Heller
  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_ARGUMENT_MARCH_22_2011_0939PM)
  9. #define BOOST_SPIRIT_ARGUMENT_MARCH_22_2011_0939PM
  10. #include <boost/phoenix/core/terminal.hpp>
  11. #include <boost/phoenix/core/v2_eval.hpp>
  12. #include <boost/proto/proto_fwd.hpp> // for transform placeholders
  13. namespace boost { namespace spirit
  14. {
  15. template <int N>
  16. struct argument;
  17. template <typename Dummy>
  18. struct attribute_context;
  19. namespace expression
  20. {
  21. template <int N>
  22. struct argument
  23. : phoenix::expression::terminal<spirit::argument<N> >
  24. {
  25. typedef typename phoenix::expression::terminal<
  26. spirit::argument<N>
  27. >::type type;
  28. static type make()
  29. {
  30. type const e = {{{}}};
  31. return e;
  32. }
  33. };
  34. template <typename Dummy>
  35. struct attribute_context
  36. : phoenix::expression::terminal<spirit::attribute_context<Dummy> >
  37. {
  38. typedef typename phoenix::expression::terminal<
  39. spirit::attribute_context<Dummy>
  40. >::type type;
  41. static type make()
  42. {
  43. type const e = {{{}}};
  44. return e;
  45. }
  46. };
  47. }
  48. }}
  49. namespace boost { namespace phoenix
  50. {
  51. namespace result_of
  52. {
  53. template <typename Dummy>
  54. struct is_nullary<custom_terminal<spirit::attribute_context<Dummy> > >
  55. : mpl::false_
  56. {};
  57. template <int N>
  58. struct is_nullary<custom_terminal<spirit::argument<N> > >
  59. : mpl::false_
  60. {};
  61. }
  62. template <typename Dummy>
  63. struct is_custom_terminal<spirit::attribute_context<Dummy> >
  64. : mpl::true_
  65. {};
  66. template <int N>
  67. struct is_custom_terminal<spirit::argument<N> >
  68. : mpl::true_
  69. {};
  70. template <typename Dummy>
  71. struct custom_terminal<spirit::attribute_context<Dummy> >
  72. : proto::call<
  73. v2_eval(
  74. proto::make<spirit::attribute_context<Dummy>()>
  75. , proto::call<
  76. functional::env(proto::_state)
  77. >
  78. )
  79. >
  80. {};
  81. template <int N>
  82. struct custom_terminal<spirit::argument<N> >
  83. : proto::call<
  84. v2_eval(
  85. proto::make<spirit::argument<N>()>
  86. , proto::call<
  87. functional::env(proto::_state)
  88. >
  89. )
  90. >
  91. {};
  92. }}
  93. #endif