diff options
Diffstat (limited to 'boost/spirit/home/x3/directive/expect.hpp')
-rw-r--r-- | boost/spirit/home/x3/directive/expect.hpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/boost/spirit/home/x3/directive/expect.hpp b/boost/spirit/home/x3/directive/expect.hpp index 879d92c2df..fe4491a22e 100644 --- a/boost/spirit/home/x3/directive/expect.hpp +++ b/boost/spirit/home/x3/directive/expect.hpp @@ -9,6 +9,8 @@ #include <boost/spirit/home/x3/support/context.hpp> #include <boost/spirit/home/x3/core/parser.hpp> +#include <boost/spirit/home/x3/core/detail/parse_into_container.hpp> + #include <boost/throw_exception.hpp> #include <stdexcept> @@ -24,10 +26,10 @@ namespace boost { namespace spirit { namespace x3 , where_(where), which_(which) {} ~expectation_failure() throw() {} - + std::string which() const { return which_; } Iterator const& where() const { return where_; } - + private: Iterator where_; @@ -73,4 +75,30 @@ namespace boost { namespace spirit { namespace x3 auto const expect = expect_gen{}; }}} +namespace boost { namespace spirit { namespace x3 { namespace detail +{ + // Special case handling for expect expressions. + template <typename Subject, typename Context, typename RContext> + struct parse_into_container_impl<expect_directive<Subject>, Context, RContext> + { + template <typename Iterator, typename Attribute> + static bool call( + expect_directive<Subject> const& parser + , Iterator& first, Iterator const& last + , Context const& context, RContext& rcontext, Attribute& attr) + { + bool r = parse_into_container( + parser.subject, first, last, context, rcontext, attr); + + if (!r) + { + boost::throw_exception( + expectation_failure<Iterator>( + first, what(parser.subject))); + } + return r; + } + }; +}}}} + #endif |