/*============================================================================= Copyright (c) 2011-2019 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_WEED_CONTEXT_PARSE_CONTEXT_TERMINAL_PARSER_HPP #define SPROUT_WEED_CONTEXT_PARSE_CONTEXT_TERMINAL_PARSER_HPP #include #include #include #include #include #include #include #include #include #include #include namespace sprout { namespace weed { // // parse_context::eval // template template struct parse_context::eval< Expr, typename std::enable_if< std::is_same< typename sprout::weed::traits::tag_of::type, sprout::weed::tag::terminal >::value && sprout::weed::traits::is_parser< typename sprout::tuples::tuple_element<0, typename Expr::args_type>::type >::value && !sprout::weed::traits::is_char_type< typename sprout::tuples::tuple_element<0, typename Expr::args_type>::type >::value && !sprout::weed::traits::is_string< typename sprout::tuples::tuple_element<0, typename Expr::args_type>::type >::value >::type > { private: typedef sprout::weed::parse_context context_type; typedef typename sprout::tuples::tuple_element<0, typename Expr::args_type>::type parser_type; public: typedef typename sprout::weed::traits::attribute_of< parser_type, Iterator, context_type >::type attribute_type; typedef sprout::weed::eval_result result_type; private: template SPROUT_CONSTEXPR result_type call( Result const& res, context_type const& ctx ) const { return result_type(res, context_type(ctx, res.current())); } public: SPROUT_CONSTEXPR result_type operator()( Expr const& expr, context_type const& ctx ) const { return call( sprout::tuples::get<0>(expr.args()) .template operator()(ctx.begin(), ctx.end(), ctx), ctx ); } }; } // namespace weed } // namespace sprout #endif // #ifndef SPROUT_WEED_CONTEXT_PARSE_CONTEXT_TERMINAL_PARSER_HPP