| 1 | /*============================================================================= |
| 2 | Copyright (c) 2014 Thomas Bernard |
| 3 | |
| 4 | Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 5 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 6 | =============================================================================*/ |
| 7 | #if !defined(BOOST_SPIRIT_X3_NO_CASE_SEPT_16_2014_0912PM) |
| 8 | #define BOOST_SPIRIT_X3_NO_CASE_SEPT_16_2014_0912PM |
| 9 | |
| 10 | #include <boost/spirit/home/x3/support/context.hpp> |
| 11 | #include <boost/spirit/home/x3/support/unused.hpp> |
| 12 | #include <boost/spirit/home/x3/support/no_case.hpp> |
| 13 | #include <boost/spirit/home/x3/core/parser.hpp> |
| 14 | |
| 15 | namespace boost { namespace spirit { namespace x3 |
| 16 | { |
| 17 | // propagate no_case information through the context |
| 18 | template <typename Subject> |
| 19 | struct no_case_directive : unary_parser<Subject, no_case_directive<Subject>> |
| 20 | { |
| 21 | typedef unary_parser<Subject, no_case_directive<Subject> > base_type; |
| 22 | static bool const is_pass_through_unary = true; |
| 23 | static bool const handles_container = Subject::handles_container; |
| 24 | |
| 25 | constexpr no_case_directive(Subject const& subject) |
| 26 | : base_type(subject) {} |
| 27 | |
| 28 | template <typename Iterator, typename Context |
| 29 | , typename RContext, typename Attribute> |
| 30 | bool parse(Iterator& first, Iterator const& last |
| 31 | , Context const& context, RContext& rcontext, Attribute& attr) const |
| 32 | { |
| 33 | return this->subject.parse( |
| 34 | first, last |
| 35 | , make_context<no_case_tag>(no_case_compare_, context) |
| 36 | , rcontext |
| 37 | , attr); |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | struct no_case_gen |
| 42 | { |
| 43 | template <typename Subject> |
| 44 | constexpr no_case_directive<typename extension::as_parser<Subject>::value_type> |
| 45 | operator[](Subject const& subject) const |
| 46 | { |
| 47 | return { as_parser(subject) }; |
| 48 | } |
| 49 | }; |
| 50 | |
| 51 | constexpr auto no_case = no_case_gen{}; |
| 52 | }}} |
| 53 | |
| 54 | #endif |
| 55 | |