2013-08-08 09:54:33 +00:00
|
|
|
/*=============================================================================
|
2016-02-25 09:48:28 +00:00
|
|
|
Copyright (c) 2011-2016 Bolero MURAKAMI
|
2013-08-08 09:54:33 +00:00
|
|
|
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)
|
|
|
|
=============================================================================*/
|
2011-11-13 08:54:38 +00:00
|
|
|
#ifndef SPROUT_WEED_PARSER_AUXILIARY_EOL_HPP
|
|
|
|
#define SPROUT_WEED_PARSER_AUXILIARY_EOL_HPP
|
|
|
|
|
|
|
|
#include <sprout/config.hpp>
|
2014-04-30 07:30:26 +00:00
|
|
|
#include <sprout/workaround/std/cstddef.hpp>
|
2011-11-13 08:54:38 +00:00
|
|
|
#include <sprout/iterator/next.hpp>
|
2013-03-25 03:43:47 +00:00
|
|
|
#include <sprout/type_traits/identity.hpp>
|
2011-11-13 08:54:38 +00:00
|
|
|
#include <sprout/weed/unused.hpp>
|
|
|
|
#include <sprout/weed/parser_result.hpp>
|
|
|
|
#include <sprout/weed/parser/parser_base.hpp>
|
2014-10-27 01:16:49 +00:00
|
|
|
#include <sprout/detail/char_literal.hpp>
|
2011-11-13 08:54:38 +00:00
|
|
|
|
|
|
|
namespace sprout {
|
|
|
|
namespace weed {
|
|
|
|
//
|
|
|
|
// eol_p
|
|
|
|
//
|
|
|
|
struct eol_p
|
|
|
|
: public sprout::weed::parser_base
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
template<typename Context, typename Iterator>
|
2013-03-25 03:43:47 +00:00
|
|
|
struct attribute
|
|
|
|
: public sprout::identity<sprout::weed::unused>
|
|
|
|
{};
|
2011-11-13 08:54:38 +00:00
|
|
|
template<typename Context, typename Iterator>
|
2013-03-25 03:43:47 +00:00
|
|
|
struct result
|
|
|
|
: public sprout::identity<sprout::weed::parser_result<Iterator, typename attribute<Context, Iterator>::type> >
|
|
|
|
{};
|
2011-11-13 08:54:38 +00:00
|
|
|
public:
|
|
|
|
template<typename Context, typename Iterator>
|
|
|
|
SPROUT_CONSTEXPR typename result<Context, Iterator>::type operator()(
|
2016-04-01 14:37:48 +00:00
|
|
|
Iterator first, Iterator last,
|
2011-11-13 08:54:38 +00:00
|
|
|
Context const&
|
|
|
|
) const
|
|
|
|
{
|
|
|
|
typedef typename result<Context, Iterator>::type result_type;
|
|
|
|
typedef typename attribute<Context, Iterator>::type attribute_type;
|
|
|
|
typedef typename std::iterator_traits<Iterator>::value_type elem_type;
|
|
|
|
return first != last
|
2014-10-27 01:16:49 +00:00
|
|
|
? *first == SPROUT_CHAR_LITERAL('\r', elem_type)
|
2011-11-13 08:54:38 +00:00
|
|
|
? sprout::next(first) != last
|
2014-10-27 01:16:49 +00:00
|
|
|
? *sprout::next(first) == SPROUT_CHAR_LITERAL('\n', elem_type)
|
2011-11-13 08:54:38 +00:00
|
|
|
? 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())
|
2014-10-27 01:16:49 +00:00
|
|
|
: *first == SPROUT_CHAR_LITERAL('\n', elem_type)
|
2011-11-13 08:54:38 +00:00
|
|
|
? 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
|