/*============================================================================= Copyright (c) 2011-2015 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_PARSER_LIM_HPP #define SPROUT_WEED_PARSER_LIM_HPP #include #include #include #include #include #include #include #include #include #include #include #include namespace sprout { namespace weed { // // limit_p // template struct limit_p : public sprout::weed::parser_base { public: SPROUT_STATIC_CONSTEXPR std::size_t limit = Limit; public: template struct attribute : public sprout::weed::traits::attribute_of {}; template struct result : public sprout::identity::type> > {}; private: typedef typename sprout::weed::traits::terminal_or_expr_of::type expr_type; private: expr_type expr_; sprout::weed::limited::category limited_category_; public: SPROUT_CONSTEXPR limit_p() SPROUT_DEFAULTED_DEFAULT_CONSTRUCTOR_DECL explicit SPROUT_CONSTEXPR limit_p( Parser const& p, sprout::weed::limited::category limited_category = sprout::weed::limited::discard ) : expr_(sprout::weed::make_terminal_or_expr(p)) , limited_category_(limited_category) {} SPROUT_CONSTEXPR sprout::weed::limited::category limited_category() const { return limited_category_; } template SPROUT_CONSTEXPR typename result::type operator()( Iterator, Iterator, Context const& ctx ) const { return sprout::weed::eval(expr_, ctx).presult(); } }; template SPROUT_CONSTEXPR_OR_CONST std::size_t limit_p::limit; // // lim // template SPROUT_CONSTEXPR sprout::weed::limit_p lim(Parser const& p) { return sprout::weed::limit_p(p); } template SPROUT_CONSTEXPR sprout::weed::limit_p lim( Parser const& p, sprout::weed::limited::category limited_category ) { return sprout::weed::limit_p(p, limited_category); } namespace traits { // // limit_of // template struct limit_of, Iterator, Context> : public sprout::integral_constant {}; } // namespace traits } // namespace weed } // namespace sprout #endif // #ifndef SPROUT_WEED_PARSER_LIM_HPP