/*============================================================================= Copyright (c) 2011-2017 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_AUXILIARY_EOL_HPP #define SPROUT_WEED_PARSER_AUXILIARY_EOL_HPP #include #include #include #include #include #include #include #include namespace sprout { namespace weed { // // eol_p // struct eol_p : public sprout::weed::parser_base { public: template struct attribute : public sprout::identity {}; 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; typedef typename std::iterator_traits::value_type elem_type; return first != last ? *first == SPROUT_CHAR_LITERAL('\r', elem_type) ? sprout::next(first) != last ? *sprout::next(first) == SPROUT_CHAR_LITERAL('\n', elem_type) ? result_type(true, sprout::next(sprout::next(first)), attribute_type()) : result_type(true, sprout::next(first), attribute_type()) : result_type(true, sprout::next(first), attribute_type()) : *first == SPROUT_CHAR_LITERAL('\n', elem_type) ? result_type(true, sprout::next(first), attribute_type()) : result_type(false, first, attribute_type()) : result_type(false, first, attribute_type()) ; } }; // // eol // SPROUT_STATIC_CONSTEXPR sprout::weed::eol_p eol = sprout::weed::eol_p(); } // namespace weed } // namespace sprout #endif // #ifndef SPROUT_WEED_PARSER_AUXILIARY_EOL_HPP