/*============================================================================= Copyright (c) 2011-2016 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_DIRECTIVE_OMIT_HPP #define SPROUT_WEED_PARSER_DIRECTIVE_OMIT_HPP #include #include #include #include #include #include #include #include #include #include namespace sprout { namespace weed { // // omit_p // template struct omit_p : public sprout::weed::parser_base { public: template struct attribute : public sprout::identity {}; template struct result : public sprout::identity::type> > {}; private: typedef typename sprout::weed::traits::terminal_or_expr_of::type expr_type; private: expr_type expr_; private: template SPROUT_CONSTEXPR typename result::type call( Iterator first, Result const& res ) const { typedef typename result::type result_type; typedef typename attribute::type attribute_type; return res.success() ? result_type(true, res.current(), attribute_type()) : result_type(false, first, attribute_type()) ; } public: SPROUT_CONSTEXPR omit_p() SPROUT_DEFAULTED_DEFAULT_CONSTRUCTOR_DECL explicit SPROUT_CONSTEXPR omit_p( Parser const& p ) : expr_(sprout::weed::make_terminal_or_expr(p)) {} template SPROUT_CONSTEXPR typename result::type operator()( Iterator first, Iterator, Context const& ctx ) const { return call(first, sprout::weed::eval(expr_, ctx)); } }; // // omit_d // struct omit_d { public: template SPROUT_CONSTEXPR sprout::weed::omit_p operator[](Parser const& p) const { return sprout::weed::omit_p(p); } }; // // omit // SPROUT_CONSTEXPR sprout::weed::omit_d omit = sprout::weed::omit_d(); } // namespace weed } // namespace sprout #endif // #ifndef SPROUT_WEED_PARSER_DIRECTIVE_OMIT_HPP