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-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) {
|
|
|
|
return sprout::weed::parse(sprout::begin(range), sprout::end(range), parser);
|
|
|
|
}
|
2011-11-13 08:54:38 +00:00
|
|
|
} // namespace weed
|
|
|
|
} // namespace sprout
|
|
|
|
|
|
|
|
#endif // #ifndef SPROUT_WEED_PARSE_HPP
|