annotate DEPENDENCIES/generic/include/boost/spirit/home/x3/directive/raw.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 f46d142149f5
children
rev   line source
Chris@102 1 /*=============================================================================
Chris@102 2 Copyright (c) 2014 Joel de Guzman
Chris@102 3
Chris@102 4 Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@102 5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@102 6 =============================================================================*/
Chris@102 7 #if !defined(SPIRIT_X3_RAW_APRIL_9_2007_0912AM)
Chris@102 8 #define SPIRIT_X3_RAW_APRIL_9_2007_0912AM
Chris@102 9
Chris@102 10 #include <boost/spirit/home/x3/core/skip_over.hpp>
Chris@102 11 #include <boost/spirit/home/x3/core/parser.hpp>
Chris@102 12 #include <boost/spirit/home/x3/support/traits/move_to.hpp>
Chris@102 13 #include <boost/range/iterator_range.hpp>
Chris@102 14
Chris@102 15 namespace boost { namespace spirit { namespace x3
Chris@102 16 {
Chris@102 17 // this is a pseudo attribute type indicating that the parser wants the
Chris@102 18 // iterator range pointing to the [first, last) matching characters from
Chris@102 19 // the input iterators.
Chris@102 20 struct raw_attribute_type {};
Chris@102 21
Chris@102 22 template <typename Subject>
Chris@102 23 struct raw_directive : unary_parser<Subject, raw_directive<Subject>>
Chris@102 24 {
Chris@102 25 typedef unary_parser<Subject, raw_directive<Subject> > base_type;
Chris@102 26 typedef raw_attribute_type attribute_type;
Chris@102 27 static bool const handles_container = Subject::handles_container;
Chris@102 28 typedef Subject subject_type;
Chris@102 29
Chris@102 30 raw_directive(Subject const& subject)
Chris@102 31 : base_type(subject) {}
Chris@102 32
Chris@102 33 template <typename Iterator, typename Context
Chris@102 34 , typename RContext, typename Attribute>
Chris@102 35 bool parse(Iterator& first, Iterator const& last
Chris@102 36 , Context const& context, RContext& rcontext, Attribute& attr) const
Chris@102 37 {
Chris@102 38 x3::skip_over(first, last, context);
Chris@102 39 Iterator i = first;
Chris@102 40 if (this->subject.parse(i, last, context, rcontext, unused))
Chris@102 41 {
Chris@102 42 traits::move_to(first, i, attr);
Chris@102 43 first = i;
Chris@102 44 return true;
Chris@102 45 }
Chris@102 46 return false;
Chris@102 47 }
Chris@102 48
Chris@102 49 template <typename Iterator, typename Context, typename RContext>
Chris@102 50 bool parse(Iterator& first, Iterator const& last
Chris@102 51 , Context const& context, RContext& rcontext, unused_type) const
Chris@102 52 {
Chris@102 53 return this->subject.parse(first, last, context, rcontext, unused);
Chris@102 54 }
Chris@102 55 };
Chris@102 56
Chris@102 57 struct raw_gen
Chris@102 58 {
Chris@102 59 template <typename Subject>
Chris@102 60 raw_directive<typename extension::as_parser<Subject>::value_type>
Chris@102 61 operator[](Subject const& subject) const
Chris@102 62 {
Chris@102 63 return {as_parser(subject)};
Chris@102 64 }
Chris@102 65 };
Chris@102 66
Chris@102 67 raw_gen const raw = raw_gen();
Chris@102 68 }}}
Chris@102 69
Chris@102 70 #endif