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

46 lines
1.4 KiB
C++
Raw Normal View History

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