1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-12-03 21:15:42 +00:00
Sprout/sprout/weed/parse.hpp

62 lines
2.2 KiB
C++
Raw Normal View History

2013-08-08 09:54:33 +00:00
/*=============================================================================
Copyright (c) 2011-2017 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_PARSE_HPP
#define SPROUT_WEED_PARSE_HPP
#include <sprout/config.hpp>
2012-07-23 11:39:03 +00:00
#include <sprout/container/functions.hpp>
#include <sprout/container/traits.hpp>
2011-11-13 08:54:38 +00:00
#include <sprout/weed/expr/make_terminal_or_expr.hpp>
#include <sprout/weed/context/parse_context.hpp>
#include <sprout/weed/traits/expr/terminal_or_expr_of.hpp>
namespace sprout {
namespace weed {
//
// parse
//
template<typename Iterator, typename Parser>
2012-07-23 11:39:03 +00:00
inline SPROUT_CONSTEXPR typename sprout::weed::parse_context<
Iterator
>::template eval<
2011-11-13 08:54:38 +00:00
typename sprout::weed::traits::terminal_or_expr_of<Parser>::type
2012-07-23 11:39:03 +00:00
>::result_type::presult_type
parse(Iterator first, Iterator last, Parser const& parser) {
2011-11-13 08:54:38 +00:00
return sprout::weed::eval(
sprout::weed::make_terminal_or_expr(parser),
sprout::weed::parse_context<Iterator>(first, last)
).presult()
;
}
2012-07-27 04:49:47 +00:00
template<typename Range, typename Parser>
inline SPROUT_CONSTEXPR typename sprout::weed::parse_context<
typename sprout::container_traits<Range>::const_iterator
>::template eval<
typename sprout::weed::traits::terminal_or_expr_of<Parser>::type
>::result_type::presult_type
parse(Range const& range, Parser const& parser) {
return sprout::weed::parse(sprout::begin(range), sprout::end(range), parser);
}
2012-07-23 11:39:03 +00:00
//
// parse_range
//
template<typename Range, typename Parser>
inline SPROUT_CONSTEXPR typename sprout::weed::parse_context<
typename sprout::container_traits<Range>::const_iterator
>::template eval<
typename sprout::weed::traits::terminal_or_expr_of<Parser>::type
>::result_type::presult_type
parse_range(Range const& range, Parser const& parser) {
2012-07-27 04:49:47 +00:00
return sprout::weed::parse(range, parser);
2012-07-23 11:39:03 +00:00
}
2011-11-13 08:54:38 +00:00
} // namespace weed
} // namespace sprout
#endif // #ifndef SPROUT_WEED_PARSE_HPP