argument_expression.hpp 2.7 KB

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