annotate DEPENDENCIES/generic/include/boost/spirit/home/qi/operator/plus.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /*=============================================================================
Chris@16 2 Copyright (c) 2001-2011 Joel de Guzman
Chris@16 3 Copyright (c) 2001-2011 Hartmut Kaiser
Chris@16 4
Chris@16 5 Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 7 =============================================================================*/
Chris@16 8 #if !defined(SPIRIT_PLUS_MARCH_13_2007_0127PM)
Chris@16 9 #define SPIRIT_PLUS_MARCH_13_2007_0127PM
Chris@16 10
Chris@16 11 #if defined(_MSC_VER)
Chris@16 12 #pragma once
Chris@16 13 #endif
Chris@16 14
Chris@16 15 #include <boost/spirit/home/qi/meta_compiler.hpp>
Chris@16 16 #include <boost/spirit/home/qi/parser.hpp>
Chris@16 17 #include <boost/spirit/home/support/container.hpp>
Chris@16 18 #include <boost/spirit/home/qi/detail/attributes.hpp>
Chris@16 19 #include <boost/spirit/home/qi/detail/fail_function.hpp>
Chris@16 20 #include <boost/spirit/home/qi/detail/pass_container.hpp>
Chris@16 21 #include <boost/spirit/home/support/has_semantic_action.hpp>
Chris@16 22 #include <boost/spirit/home/support/handles_container.hpp>
Chris@16 23 #include <boost/spirit/home/support/info.hpp>
Chris@16 24
Chris@16 25 namespace boost { namespace spirit
Chris@16 26 {
Chris@16 27 ///////////////////////////////////////////////////////////////////////////
Chris@16 28 // Enablers
Chris@16 29 ///////////////////////////////////////////////////////////////////////////
Chris@16 30 template <>
Chris@16 31 struct use_operator<qi::domain, proto::tag::unary_plus> // enables +p
Chris@16 32 : mpl::true_ {};
Chris@16 33 }}
Chris@16 34
Chris@16 35 namespace boost { namespace spirit { namespace qi
Chris@16 36 {
Chris@16 37 template <typename Subject>
Chris@16 38 struct plus : unary_parser<plus<Subject> >
Chris@16 39 {
Chris@16 40 typedef Subject subject_type;
Chris@16 41
Chris@16 42 template <typename Context, typename Iterator>
Chris@16 43 struct attribute
Chris@16 44 {
Chris@16 45 // Build a std::vector from the subject's attribute. Note
Chris@16 46 // that build_std_vector may return unused_type if the
Chris@16 47 // subject's attribute is an unused_type.
Chris@16 48 typedef typename
Chris@16 49 traits::build_std_vector<
Chris@16 50 typename traits::attribute_of<
Chris@16 51 Subject, Context, Iterator>::type
Chris@16 52 >::type
Chris@16 53 type;
Chris@16 54 };
Chris@16 55
Chris@16 56 plus(Subject const& subject_)
Chris@16 57 : subject(subject_) {}
Chris@16 58
Chris@16 59 template <typename F>
Chris@16 60 bool parse_container(F f) const
Chris@16 61 {
Chris@16 62 // in order to succeed we need to match at least one element
Chris@16 63 if (f (subject))
Chris@16 64 return false;
Chris@16 65
Chris@16 66 while (!f (subject))
Chris@16 67 ;
Chris@16 68 return true;
Chris@16 69 }
Chris@16 70
Chris@16 71 template <typename Iterator, typename Context
Chris@16 72 , typename Skipper, typename Attribute>
Chris@16 73 bool parse(Iterator& first, Iterator const& last
Chris@16 74 , Context& context, Skipper const& skipper
Chris@16 75 , Attribute& attr_) const
Chris@16 76 {
Chris@16 77 typedef detail::fail_function<Iterator, Context, Skipper>
Chris@16 78 fail_function;
Chris@16 79
Chris@16 80 // ensure the attribute is actually a container type
Chris@16 81 traits::make_container(attr_);
Chris@16 82
Chris@16 83 Iterator iter = first;
Chris@16 84 fail_function f(iter, last, context, skipper);
Chris@16 85 if (!parse_container(detail::make_pass_container(f, attr_)))
Chris@16 86 return false;
Chris@16 87
Chris@16 88 first = f.first;
Chris@16 89 return true;
Chris@16 90 }
Chris@16 91
Chris@16 92 template <typename Context>
Chris@16 93 info what(Context& context) const
Chris@16 94 {
Chris@16 95 return info("plus", subject.what(context));
Chris@16 96 }
Chris@16 97
Chris@16 98 Subject subject;
Chris@16 99 };
Chris@16 100
Chris@16 101 ///////////////////////////////////////////////////////////////////////////
Chris@16 102 // Parser generators: make_xxx function (objects)
Chris@16 103 ///////////////////////////////////////////////////////////////////////////
Chris@16 104 template <typename Elements, typename Modifiers>
Chris@16 105 struct make_composite<proto::tag::unary_plus, Elements, Modifiers>
Chris@16 106 : make_unary_composite<Elements, plus>
Chris@16 107 {};
Chris@16 108 }}}
Chris@16 109
Chris@16 110 namespace boost { namespace spirit { namespace traits
Chris@16 111 {
Chris@16 112 ///////////////////////////////////////////////////////////////////////////
Chris@16 113 template <typename Subject>
Chris@16 114 struct has_semantic_action<qi::plus<Subject> >
Chris@16 115 : unary_has_semantic_action<Subject> {};
Chris@16 116
Chris@16 117 ///////////////////////////////////////////////////////////////////////////
Chris@16 118 template <typename Subject, typename Attribute, typename Context
Chris@16 119 , typename Iterator>
Chris@16 120 struct handles_container<qi::plus<Subject>, Attribute, Context
Chris@16 121 , Iterator>
Chris@16 122 : mpl::true_ {};
Chris@16 123 }}}
Chris@16 124
Chris@16 125 #endif