| 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_PLUS_MARCH_13_2007_0127PM) |
| 9 | #define BOOST_SPIRIT_X3_PLUS_MARCH_13_2007_0127PM |
| 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 plus : unary_parser<Subject, plus<Subject>> |
| 20 | { |
| 21 | typedef unary_parser<Subject, plus<Subject>> base_type; |
| 22 | static bool const handles_container = true; |
| 23 | |
| 24 | constexpr plus(Subject const& subject) |
| 25 | : base_type(subject) {} |
| 26 | |
| 27 | template <typename Iterator, typename Context |
| 28 | , typename RContext, typename Attribute> |
| 29 | bool parse(Iterator& first, Iterator const& last |
| 30 | , Context const& context, RContext& rcontext, Attribute& attr) const |
| 31 | { |
| 32 | if (!detail::parse_into_container( |
| 33 | this->subject, first, last, context, rcontext, attr)) |
| 34 | return false; |
| 35 | |
| 36 | while (detail::parse_into_container( |
| 37 | this->subject, first, last, context, rcontext, attr)) |
| 38 | ; |
| 39 | return true; |
| 40 | } |
| 41 | }; |
| 42 | |
| 43 | template <typename Subject> |
| 44 | constexpr plus<typename extension::as_parser<Subject>::value_type> |
| 45 | operator+(Subject const& subject) |
| 46 | { |
| 47 | return { as_parser(subject) }; |
| 48 | } |
| 49 | }}} |
| 50 | |
| 51 | namespace boost { namespace spirit { namespace x3 { namespace traits |
| 52 | { |
| 53 | template <typename Subject, typename Context> |
| 54 | struct attribute_of<x3::plus<Subject>, Context> |
| 55 | : build_container< |
| 56 | typename attribute_of<Subject, Context>::type> {}; |
| 57 | }}}} |
| 58 | |
| 59 | #endif |
| 60 | |