#ifndef SPROUT_WEED_PARSER_CHAR_CHAR_HPP #define SPROUT_WEED_PARSER_CHAR_CHAR_HPP #include #include #include #include #include #include #include #include #include #include namespace sprout { namespace weed { // // lit_char_p // template struct lit_char_p : public sprout::weed::parser_base { public: template struct attribute : public sprout::identity {}; template struct result : public sprout::identity::type> > {}; private: T t_; public: lit_char_p() = default; explicit SPROUT_CONSTEXPR lit_char_p(T const& t) : t_(t) {} template SPROUT_CONSTEXPR typename result::type operator()( Iterator first, Iterator last, Context const& ) const { typedef typename result::type result_type; typedef typename attribute::type attribute_type; typedef typename std::iterator_traits::value_type elem_type; return first != last && *first == elem_type(t_) ? result_type(true, sprout::next(first), attribute_type()) : result_type(false, first, typename attribute::type()) ; } }; // // lit_g // template struct lit_g::eval< T, typename std::enable_if< sprout::weed::traits::is_char_type::value >::type > { public: typedef sprout::weed::lit_char_p result_type; public: SPROUT_CONSTEXPR result_type operator()(T const& t) const { return result_type(t); } }; // // char_p // template struct char_p : public sprout::weed::parser_base { public: template struct attribute : public sprout::identity::value_type> {}; template struct result : public sprout::identity::type> > {}; private: T t_; public: char_p() = default; explicit SPROUT_CONSTEXPR char_p(T const& t) : t_(t) {} template SPROUT_CONSTEXPR typename result::type operator()( Iterator first, Iterator last, Context const& ) const { typedef typename result::type result_type; typedef typename attribute::type attribute_type; typedef typename std::iterator_traits::value_type elem_type; return first != last && *first == elem_type(t_) ? result_type(true, sprout::next(first), *first) : result_type(false, first, attribute_type()) ; } }; // // any_char_p // struct any_char_p : public sprout::weed::parser_base { public: template struct attribute : public sprout::identity::value_type> {}; template struct result : public sprout::identity::type> > {}; public: template SPROUT_CONSTEXPR typename result::type operator()( Iterator first, Iterator last, Context const& ) const { typedef typename result::type result_type; typedef typename attribute::type attribute_type; return first != last ? result_type(true, sprout::next(first), *first) : result_type(false, first, attribute_type()) ; } template SPROUT_CONSTEXPR sprout::weed::char_p operator()(T const& t) const { return sprout::weed::char_p(t); } }; // // char_ // SPROUT_STATIC_CONSTEXPR sprout::weed::any_char_p char_ = sprout::weed::any_char_p(); } // namespace weed } // namespace sprout #endif // #ifndef SPROUT_WEED_PARSER_CHAR_CHAR_HPP