#ifndef CHILON_PARSER_NODE_PARSER_HPP
#define CHILON_PARSER_NODE_PARSER_HPP
#include <chilon/parser/parse.hpp>
#include <chilon/meta/return.hpp>
#include <type_traits>
namespace chilon { namespace parser {
struct is_simple_node;
namespace detail {
template <class T, bool is_node>
struct node_parser_helper {
typedef T parser_type;
typedef typename stored<parser_type>::type store_type;
template <class U>
static inline auto get(U&& u) CHILON_RETURN(std::forward<U>(u))
};
template <class T>
struct node_parser_helper<T, true> {
typedef typename T::node_parser_type parser_type;
typedef T store_type;
typedef typename stored<parser_type>::type node_store_type;
template <class U>
static inline node_store_type& get(U& u) {
return u.value_;
}
};
}
template <class T>
struct node_parser
: detail::node_parser_helper<T, std::is_base_of<is_simple_node, T>::value> {};
template <class T>
struct node_parser< sequence<T> > : node_parser<T> {};
template <class T>
struct node_parser< parse<T> > : node_parser<T> {};
} }
#endif