Chris@102
|
1 /*=============================================================================
|
Chris@102
|
2 Copyright (c) 2001-2014 Joel de Guzman
|
Chris@102
|
3 Copyright (c) 2001-2011 Hartmut Kaiser
|
Chris@102
|
4
|
Chris@102
|
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@102
|
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@102
|
7 =============================================================================*/
|
Chris@102
|
8 #if !defined(SPIRIT_PLUS_MARCH_13_2007_0127PM)
|
Chris@102
|
9 #define SPIRIT_PLUS_MARCH_13_2007_0127PM
|
Chris@102
|
10
|
Chris@102
|
11 #if defined(_MSC_VER)
|
Chris@102
|
12 #pragma once
|
Chris@102
|
13 #endif
|
Chris@102
|
14
|
Chris@102
|
15 #include <boost/spirit/home/x3/core/parser.hpp>
|
Chris@102
|
16 #include <boost/spirit/home/x3/support/traits/container_traits.hpp>
|
Chris@102
|
17 #include <boost/spirit/home/x3/support/traits/attribute_of.hpp>
|
Chris@102
|
18 #include <boost/spirit/home/x3/core/detail/parse_into_container.hpp>
|
Chris@102
|
19
|
Chris@102
|
20 namespace boost { namespace spirit { namespace x3
|
Chris@102
|
21 {
|
Chris@102
|
22 template <typename Subject>
|
Chris@102
|
23 struct plus : unary_parser<Subject, plus<Subject>>
|
Chris@102
|
24 {
|
Chris@102
|
25 typedef unary_parser<Subject, plus<Subject>> base_type;
|
Chris@102
|
26 static bool const handles_container = true;
|
Chris@102
|
27
|
Chris@102
|
28 plus(Subject const& subject)
|
Chris@102
|
29 : base_type(subject) {}
|
Chris@102
|
30
|
Chris@102
|
31 template <typename Iterator, typename Context
|
Chris@102
|
32 , typename RContext, typename Attribute>
|
Chris@102
|
33 bool parse(Iterator& first, Iterator const& last
|
Chris@102
|
34 , Context const& context, RContext& rcontext, Attribute& attr) const
|
Chris@102
|
35 {
|
Chris@102
|
36 if (!detail::parse_into_container(
|
Chris@102
|
37 this->subject, first, last, context, rcontext, attr))
|
Chris@102
|
38 return false;
|
Chris@102
|
39
|
Chris@102
|
40 while (detail::parse_into_container(
|
Chris@102
|
41 this->subject, first, last, context, rcontext, attr))
|
Chris@102
|
42 ;
|
Chris@102
|
43 return true;
|
Chris@102
|
44 }
|
Chris@102
|
45 };
|
Chris@102
|
46
|
Chris@102
|
47 template <typename Subject>
|
Chris@102
|
48 inline plus<typename extension::as_parser<Subject>::value_type>
|
Chris@102
|
49 operator+(Subject const& subject)
|
Chris@102
|
50 {
|
Chris@102
|
51 return {as_parser(subject)};
|
Chris@102
|
52 }
|
Chris@102
|
53 }}}
|
Chris@102
|
54
|
Chris@102
|
55 namespace boost { namespace spirit { namespace x3 { namespace traits
|
Chris@102
|
56 {
|
Chris@102
|
57 template <typename Subject, typename Context>
|
Chris@102
|
58 struct attribute_of<x3::plus<Subject>, Context>
|
Chris@102
|
59 : build_container<
|
Chris@102
|
60 typename attribute_of<Subject, Context>::type> {};
|
Chris@102
|
61 }}}}
|
Chris@102
|
62
|
Chris@102
|
63 #endif
|