1 /*============================================================================= 2 Copyright (c) 2001-2014 Joel de Guzman 3 Copyright (c) 2001-2011 Hartmut Kaiser 4 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_X3_KLEENE_JANUARY_07_2007_0818AM) 9 #define BOOST_SPIRIT_X3_KLEENE_JANUARY_07_2007_0818AM 10 11 #include <boost/spirit/home/x3/core/parser.hpp> 12 #include <boost/spirit/home/x3/support/traits/container_traits.hpp> 13 #include <boost/spirit/home/x3/support/traits/attribute_of.hpp> 14 #include <boost/spirit/home/x3/core/detail/parse_into_container.hpp> 15 16 namespace boost { namespace spirit { namespace x3 17 { 18 template <typename Subject> 19 struct kleene : unary_parser<Subject, kleene<Subject>> 20 { 21 typedef unary_parser<Subject, kleene<Subject>> base_type; 22 static bool const handles_container = true; 23 kleeneboost::spirit::x3::kleene24 constexpr kleene(Subject const& subject) 25 : base_type(subject) {} 26 27 template <typename Iterator, typename Context 28 , typename RContext, typename Attribute> parseboost::spirit::x3::kleene29 bool parse(Iterator& first, Iterator const& last 30 , Context const& context, RContext& rcontext, Attribute& attr) const 31 { 32 while (detail::parse_into_container( 33 this->subject, first, last, context, rcontext, attr)) 34 ; 35 return true; 36 } 37 }; 38 39 template <typename Subject> 40 constexpr kleene<typename extension::as_parser<Subject>::value_type> operator *(Subject const & subject)41 operator*(Subject const& subject) 42 { 43 return { as_parser(subject) }; 44 } 45 }}} 46 47 namespace boost { namespace spirit { namespace x3 { namespace traits 48 { 49 template <typename Subject, typename Context> 50 struct attribute_of<x3::kleene<Subject>, Context> 51 : build_container< 52 typename attribute_of<Subject, Context>::type> {}; 53 }}}} 54 55 #endif 56