Chris@102: /*============================================================================= Chris@102: Copyright (c) 2014 Joel de Guzman Chris@102: Chris@102: Distributed under the Boost Software License, Version 1.0. (See accompanying Chris@102: file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@102: =============================================================================*/ Chris@102: #if !defined(SPIRIT_X3_RAW_APRIL_9_2007_0912AM) Chris@102: #define SPIRIT_X3_RAW_APRIL_9_2007_0912AM Chris@102: Chris@102: #include Chris@102: #include Chris@102: #include Chris@102: #include Chris@102: Chris@102: namespace boost { namespace spirit { namespace x3 Chris@102: { Chris@102: // this is a pseudo attribute type indicating that the parser wants the Chris@102: // iterator range pointing to the [first, last) matching characters from Chris@102: // the input iterators. Chris@102: struct raw_attribute_type {}; Chris@102: Chris@102: template Chris@102: struct raw_directive : unary_parser> Chris@102: { Chris@102: typedef unary_parser > base_type; Chris@102: typedef raw_attribute_type attribute_type; Chris@102: static bool const handles_container = Subject::handles_container; Chris@102: typedef Subject subject_type; Chris@102: Chris@102: raw_directive(Subject const& subject) Chris@102: : base_type(subject) {} Chris@102: Chris@102: template Chris@102: bool parse(Iterator& first, Iterator const& last Chris@102: , Context const& context, RContext& rcontext, Attribute& attr) const Chris@102: { Chris@102: x3::skip_over(first, last, context); Chris@102: Iterator i = first; Chris@102: if (this->subject.parse(i, last, context, rcontext, unused)) Chris@102: { Chris@102: traits::move_to(first, i, attr); Chris@102: first = i; Chris@102: return true; Chris@102: } Chris@102: return false; Chris@102: } Chris@102: Chris@102: template Chris@102: bool parse(Iterator& first, Iterator const& last Chris@102: , Context const& context, RContext& rcontext, unused_type) const Chris@102: { Chris@102: return this->subject.parse(first, last, context, rcontext, unused); Chris@102: } Chris@102: }; Chris@102: Chris@102: struct raw_gen Chris@102: { Chris@102: template Chris@102: raw_directive::value_type> Chris@102: operator[](Subject const& subject) const Chris@102: { Chris@102: return {as_parser(subject)}; Chris@102: } Chris@102: }; Chris@102: Chris@102: raw_gen const raw = raw_gen(); Chris@102: }}} Chris@102: Chris@102: #endif