annotate DEPENDENCIES/generic/include/boost/spirit/home/x3/directive/expect.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) 2001-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_EXPECT_MARCH_16_2012_1024PM)
Chris@102 8 #define SPIRIT_EXPECT_MARCH_16_2012_1024PM
Chris@102 9
Chris@102 10 #if defined(_MSC_VER)
Chris@102 11 #pragma once
Chris@102 12 #endif
Chris@102 13
Chris@102 14 #include <boost/spirit/home/x3/support/context.hpp>
Chris@102 15 #include <boost/spirit/home/x3/core/parser.hpp>
Chris@102 16 #include <boost/throw_exception.hpp>
Chris@102 17 #include <stdexcept>
Chris@102 18
Chris@102 19 namespace boost { namespace spirit { namespace x3
Chris@102 20 {
Chris@102 21 template <typename Iterator>
Chris@102 22 struct expectation_failure : std::runtime_error
Chris@102 23 {
Chris@102 24 public:
Chris@102 25
Chris@102 26 expectation_failure(Iterator where, std::string const& which)
Chris@102 27 : std::runtime_error("boost::spirit::x3::expectation_failure")
Chris@102 28 , where_(where), which_(which)
Chris@102 29 {}
Chris@102 30 ~expectation_failure() throw() {}
Chris@102 31
Chris@102 32 std::string which() const { return which_; }
Chris@102 33 Iterator const& where() const { return where_; }
Chris@102 34
Chris@102 35 private:
Chris@102 36
Chris@102 37 Iterator where_;
Chris@102 38 std::string which_;
Chris@102 39 };
Chris@102 40
Chris@102 41 template <typename Subject>
Chris@102 42 struct expect_directive : unary_parser<Subject, expect_directive<Subject>>
Chris@102 43 {
Chris@102 44 typedef unary_parser<Subject, expect_directive<Subject> > base_type;
Chris@102 45 static bool const is_pass_through_unary = true;
Chris@102 46
Chris@102 47 expect_directive(Subject const& subject)
Chris@102 48 : base_type(subject) {}
Chris@102 49
Chris@102 50 template <typename Iterator, typename Context
Chris@102 51 , typename RContext, typename Attribute>
Chris@102 52 bool parse(Iterator& first, Iterator const& last
Chris@102 53 , Context const& context, RContext& rcontext, Attribute& attr) const
Chris@102 54 {
Chris@102 55 bool r = this->subject.parse(first, last, context, rcontext, attr);
Chris@102 56
Chris@102 57 if (!r)
Chris@102 58 {
Chris@102 59 boost::throw_exception(
Chris@102 60 expectation_failure<Iterator>(
Chris@102 61 first, what(this->subject)));
Chris@102 62 }
Chris@102 63 return r;
Chris@102 64 }
Chris@102 65 };
Chris@102 66
Chris@102 67 struct expect_gen
Chris@102 68 {
Chris@102 69 template <typename Subject>
Chris@102 70 expect_directive<typename extension::as_parser<Subject>::value_type>
Chris@102 71 operator[](Subject const& subject) const
Chris@102 72 {
Chris@102 73 return {as_parser(subject)};
Chris@102 74 }
Chris@102 75 };
Chris@102 76
Chris@102 77 expect_gen const expect = expect_gen();
Chris@102 78 }}}
Chris@102 79
Chris@102 80 #endif