weed::traits::attribute_of をコンテキストに依存するよう変更

This commit is contained in:
bolero-MURAKAMI 2011-11-14 20:48:17 +09:00
parent a7698fa6e9
commit 1c898f8b93
13 changed files with 64 additions and 79 deletions

View file

@ -4,6 +4,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/tuple/tuple.hpp>
#include <sprout/weed/unused.hpp>
#include <sprout/weed/eval_result.hpp>
#include <sprout/weed/expr/tag.hpp>
#include <sprout/weed/expr/eval.hpp>
@ -30,7 +31,7 @@ namespace sprout {
private:
typedef sprout::weed::parse_context<Iterator> context_type;
public:
typedef typename sprout::weed::traits::attribute_of<Expr, Iterator, context_type>::type attribute_type;
typedef sprout::weed::unused attribute_type;
typedef sprout::weed::eval_result<context_type, Iterator, attribute_type> result_type;
public:
SPROUT_CONSTEXPR result_type operator()(

View file

@ -7,6 +7,7 @@
#include <sprout/weed/eval_result.hpp>
#include <sprout/weed/expr/tag.hpp>
#include <sprout/weed/expr/eval.hpp>
#include <sprout/weed/attr_cnv/result_of/bitwise_or.hpp>
#include <sprout/weed/attr_cnv/bitwise_or.hpp>
#include <sprout/weed/traits/expr/tag_of.hpp>
#include <sprout/weed/traits/parser/attribute_of.hpp>
@ -35,7 +36,10 @@ namespace sprout {
typedef typename sprout::weed::traits::attribute_of<expr1_type, Iterator, context_type>::type attr1_type;
typedef typename sprout::weed::traits::attribute_of<expr2_type, Iterator, context_type>::type attr2_type;
public:
typedef typename sprout::weed::traits::attribute_of<Expr, Iterator, context_type>::type attribute_type;
typedef typename sprout::weed::attr_cnv::result_of::bitwise_or<
typename sprout::weed::traits::attribute_of<expr1_type, Iterator, context_type>::type,
typename sprout::weed::traits::attribute_of<expr2_type, Iterator, context_type>::type
>::type attribute_type;
typedef sprout::weed::eval_result<context_type, Iterator, attribute_type> result_type;
private:
template<typename Result2>

View file

@ -8,6 +8,7 @@
#include <sprout/weed/limited.hpp>
#include <sprout/weed/expr/tag.hpp>
#include <sprout/weed/expr/eval.hpp>
#include <sprout/weed/attr_cnv/result_of/times.hpp>
#include <sprout/weed/attr_cnv/times.hpp>
#include <sprout/weed/traits/expr/tag_of.hpp>
#include <sprout/weed/traits/parser/attribute_of.hpp>
@ -36,7 +37,10 @@ namespace sprout {
typedef typename sprout::weed::traits::limit_of<expr_type, Iterator, context_type>::type limit;
typedef typename sprout::weed::traits::attribute_of<expr_type, Iterator, context_type>::type attr_type;
public:
typedef typename sprout::weed::traits::attribute_of<Expr, Iterator, context_type>::type attribute_type;
typedef typename sprout::weed::attr_cnv::result_of::times<
limit::value,
typename sprout::weed::traits::attribute_of<expr_type, Iterator, context_type>::type
>::type attribute_type;
typedef sprout::weed::eval_result<context_type, Iterator, attribute_type> result_type;
private:
template<typename Result, typename Head, typename... Attrs>

View file

@ -4,6 +4,7 @@
#include <type_traits>
#include <sprout/config.hpp>
#include <sprout/tuple/tuple.hpp>
#include <sprout/weed/unused.hpp>
#include <sprout/weed/eval_result.hpp>
#include <sprout/weed/expr/tag.hpp>
#include <sprout/weed/expr/eval.hpp>
@ -30,7 +31,7 @@ namespace sprout {
private:
typedef sprout::weed::parse_context<Iterator> context_type;
public:
typedef typename sprout::weed::traits::attribute_of<Expr, Iterator, context_type>::type attribute_type;
typedef sprout::weed::unused attribute_type;
typedef sprout::weed::eval_result<context_type, Iterator, attribute_type> result_type;
public:
SPROUT_CONSTEXPR result_type operator()(

View file

@ -29,8 +29,10 @@ namespace sprout {
> {
private:
typedef sprout::weed::parse_context<Iterator> context_type;
typedef typename sprout::tuples::tuple_element<0, typename Expr::args_type>::type expr1_type;
typedef typename sprout::tuples::tuple_element<1, typename Expr::args_type>::type expr2_type;
public:
typedef typename sprout::weed::traits::attribute_of<Expr, Iterator, context_type>::type attribute_type;
typedef typename sprout::weed::traits::attribute_of<expr1_type, Iterator, context_type>::type attribute_type;
typedef sprout::weed::eval_result<context_type, Iterator, attribute_type> result_type;
private:
template<typename Result1>

View file

@ -8,6 +8,7 @@
#include <sprout/weed/limited.hpp>
#include <sprout/weed/expr/tag.hpp>
#include <sprout/weed/expr/eval.hpp>
#include <sprout/weed/attr_cnv/result_of/modulus.hpp>
#include <sprout/weed/attr_cnv/modulus.hpp>
#include <sprout/weed/traits/expr/tag_of.hpp>
#include <sprout/weed/traits/parser/attribute_of.hpp>
@ -37,7 +38,10 @@ namespace sprout {
typedef typename sprout::weed::traits::limit_of<expr1_type, Iterator, context_type>::type limit;
typedef typename sprout::weed::traits::attribute_of<expr1_type, Iterator, context_type>::type attr_type;
public:
typedef typename sprout::weed::traits::attribute_of<Expr, Iterator, context_type>::type attribute_type;
typedef typename sprout::weed::attr_cnv::result_of::modulus<
limit::value,
typename sprout::weed::traits::attribute_of<expr1_type, Iterator, context_type>::type
>::type attribute_type;
typedef sprout::weed::eval_result<context_type, Iterator, attribute_type> result_type;
private:
template<typename Result, typename... Attrs>

View file

@ -7,6 +7,7 @@
#include <sprout/weed/eval_result.hpp>
#include <sprout/weed/expr/tag.hpp>
#include <sprout/weed/expr/eval.hpp>
#include <sprout/weed/attr_cnv/result_of/negate.hpp>
#include <sprout/weed/attr_cnv/negate.hpp>
#include <sprout/weed/traits/expr/tag_of.hpp>
#include <sprout/weed/traits/parser/attribute_of.hpp>
@ -30,8 +31,11 @@ namespace sprout {
> {
private:
typedef sprout::weed::parse_context<Iterator> context_type;
typedef typename sprout::tuples::tuple_element<0, typename Expr::args_type>::type expr_type;
public:
typedef typename sprout::weed::traits::attribute_of<Expr, Iterator, context_type>::type attribute_type;
typedef typename sprout::weed::attr_cnv::result_of::negate<
typename sprout::weed::traits::attribute_of<expr_type, Iterator, context_type>::type
>::type attribute_type;
typedef sprout::weed::eval_result<context_type, Iterator, attribute_type> result_type;
private:
template<typename Result>

View file

@ -7,6 +7,7 @@
#include <sprout/weed/eval_result.hpp>
#include <sprout/weed/expr/tag.hpp>
#include <sprout/weed/expr/eval.hpp>
#include <sprout/weed/attr_cnv/result_of/shift_left.hpp>
#include <sprout/weed/attr_cnv/shift_left.hpp>
#include <sprout/weed/traits/expr/tag_of.hpp>
#include <sprout/weed/traits/parser/attribute_of.hpp>
@ -30,8 +31,13 @@ namespace sprout {
> {
private:
typedef sprout::weed::parse_context<Iterator> context_type;
typedef typename sprout::tuples::tuple_element<0, typename Expr::args_type>::type expr1_type;
typedef typename sprout::tuples::tuple_element<1, typename Expr::args_type>::type expr2_type;
public:
typedef typename sprout::weed::traits::attribute_of<Expr, Iterator, context_type>::type attribute_type;
typedef typename sprout::weed::attr_cnv::result_of::shift_left<
typename sprout::weed::traits::attribute_of<expr1_type, Iterator, context_type>::type,
typename sprout::weed::traits::attribute_of<expr2_type, Iterator, context_type>::type
>::type attribute_type;
typedef sprout::weed::eval_result<context_type, Iterator, attribute_type> result_type;
private:
template<typename Attr1, typename Result2>

View file

@ -8,6 +8,7 @@
#include <sprout/weed/limited.hpp>
#include <sprout/weed/expr/tag.hpp>
#include <sprout/weed/expr/eval.hpp>
#include <sprout/weed/attr_cnv/result_of/times.hpp>
#include <sprout/weed/attr_cnv/times.hpp>
#include <sprout/weed/traits/expr/tag_of.hpp>
#include <sprout/weed/traits/parser/attribute_of.hpp>
@ -36,7 +37,10 @@ namespace sprout {
typedef typename sprout::weed::traits::limit_of<expr_type, Iterator, context_type>::type limit;
typedef typename sprout::weed::traits::attribute_of<expr_type, Iterator, context_type>::type attr_type;
public:
typedef typename sprout::weed::traits::attribute_of<Expr, Iterator, context_type>::type attribute_type;
typedef typename sprout::weed::attr_cnv::result_of::times<
limit::value,
typename sprout::weed::traits::attribute_of<expr_type, Iterator, context_type>::type
>::type attribute_type;
typedef sprout::weed::eval_result<context_type, Iterator, attribute_type> result_type;
private:
template<typename Result, typename Head, typename... Attrs>

View file

@ -35,7 +35,7 @@ namespace sprout {
private:
typedef sprout::weed::parse_context<Iterator> context_type;
public:
typedef typename sprout::weed::traits::attribute_of<Expr, Iterator, context_type>::type attribute_type;
typedef sprout::weed::unused attribute_type;
typedef sprout::weed::eval_result<context_type, Iterator, attribute_type> result_type;
public:
SPROUT_CONSTEXPR result_type operator()(

View file

@ -38,7 +38,11 @@ namespace sprout {
typedef sprout::weed::parse_context<Iterator> context_type;
typedef typename sprout::tuples::tuple_element<0, typename Expr::args_type>::type parser_type;
public:
typedef typename sprout::weed::traits::attribute_of<Expr, Iterator, context_type>::type attribute_type;
typedef typename sprout::weed::traits::attribute_of<
parser_type,
Iterator,
context_type
>::type attribute_type;
typedef sprout::weed::eval_result<context_type, Iterator, attribute_type> result_type;
private:
template<typename Result>

View file

@ -39,7 +39,7 @@ namespace sprout {
private:
typedef sprout::weed::parse_context<Iterator> context_type;
public:
typedef typename sprout::weed::traits::attribute_of<Expr, Iterator, context_type>::type attribute_type;
typedef sprout::weed::unused attribute_type;
typedef sprout::weed::eval_result<context_type, Iterator, attribute_type> result_type;
private:
template<typename Arg>

View file

@ -10,12 +10,8 @@
#include <sprout/weed/traits/type/is_c_str.hpp>
#include <sprout/weed/traits/type/is_string.hpp>
#include <sprout/weed/traits/expr/is_expr.hpp>
#include <sprout/weed/traits/expr/terminal_of.hpp>
#include <sprout/weed/traits/parser/is_parser.hpp>
#include <sprout/weed/traits/parser/limit_of.hpp>
#include <sprout/weed/attr_cnv/result_of/times.hpp>
#include <sprout/weed/attr_cnv/result_of/shift_left.hpp>
#include <sprout/weed/attr_cnv/result_of/modulus.hpp>
#include <sprout/weed/attr_cnv/result_of/bitwise_or.hpp>
namespace sprout {
namespace weed {
@ -46,6 +42,18 @@ namespace sprout {
typedef typename T::template attribute<Context, Iterator>::type type;
};
template<typename T, typename Iterator, typename Context>
struct attribute_of<
T,
Iterator,
Context,
typename std::enable_if<
sprout::weed::traits::is_expr<T>::value
>::type
> {
public:
typedef typename Context::template eval<T>::attribute_type type;
};
template<typename T, typename Iterator, typename Context>
struct attribute_of<
T,
Iterator,
@ -55,68 +63,11 @@ namespace sprout {
|| sprout::weed::traits::is_c_str<T>::value
|| sprout::weed::traits::is_string<T>::value
>::type
> {
public:
typedef sprout::weed::unused type;
};
template<typename Arg, typename Iterator, typename Context>
struct attribute_of<sprout::weed::expr<sprout::weed::tag::terminal, Arg>, Iterator, Context>
: public sprout::weed::traits::attribute_of<Arg, Iterator, Context>
{};
template<typename Arg, typename Iterator, typename Context>
struct attribute_of<sprout::weed::expr<sprout::weed::tag::unary_plus, Arg>, Iterator, Context>
: public sprout::weed::attr_cnv::result_of::times<
sprout::weed::traits::limit_of<Arg, Iterator, Context>::value,
typename sprout::weed::traits::attribute_of<Arg, Iterator, Context>::type
>
{};
template<typename Arg, typename Iterator, typename Context>
struct attribute_of<sprout::weed::expr<sprout::weed::tag::negate, Arg>, Iterator, Context>
: public sprout::weed::attr_cnv::result_of::negate<
typename sprout::weed::traits::attribute_of<Arg, Iterator, Context>::type
>
{};
template<typename Arg, typename Iterator, typename Context>
struct attribute_of<sprout::weed::expr<sprout::weed::tag::dereference, Arg>, Iterator, Context>
: public sprout::weed::attr_cnv::result_of::times<
sprout::weed::traits::limit_of<Arg, Iterator, Context>::value,
typename sprout::weed::traits::attribute_of<Arg, Iterator, Context>::type
>
{};
template<typename Arg, typename Iterator, typename Context>
struct attribute_of<sprout::weed::expr<sprout::weed::tag::address_of, Arg>, Iterator, Context> {
public:
typedef sprout::weed::unused type;
};
template<typename Arg, typename Iterator, typename Context>
struct attribute_of<sprout::weed::expr<sprout::weed::tag::logical_not, Arg>, Iterator, Context> {
public:
typedef sprout::weed::unused type;
};
template<typename Arg1, typename Arg2, typename Iterator, typename Context>
struct attribute_of<sprout::weed::expr<sprout::weed::tag::shift_left, Arg1, Arg2>, Iterator, Context>
: public sprout::weed::attr_cnv::result_of::shift_left<
typename sprout::weed::traits::attribute_of<Arg1, Iterator, Context>::type,
typename sprout::weed::traits::attribute_of<Arg2, Iterator, Context>::type
>
{};
template<typename Arg1, typename Arg2, typename Iterator, typename Context>
struct attribute_of<sprout::weed::expr<sprout::weed::tag::modulus, Arg1, Arg2>, Iterator, Context>
: public sprout::weed::attr_cnv::result_of::modulus<
sprout::weed::traits::limit_of<Arg1, Iterator, Context>::value,
typename sprout::weed::traits::attribute_of<Arg1, Iterator, Context>::type
>
{};
template<typename Arg1, typename Arg2, typename Iterator, typename Context>
struct attribute_of<sprout::weed::expr<sprout::weed::tag::minus, Arg1, Arg2>, Iterator, Context> {
public:
typedef typename sprout::weed::traits::attribute_of<Arg1, Iterator, Context>::type type;
};
template<typename Arg1, typename Arg2, typename Iterator, typename Context>
struct attribute_of<sprout::weed::expr<sprout::weed::tag::bitwise_or, Arg1, Arg2>, Iterator, Context>
: public sprout::weed::attr_cnv::result_of::bitwise_or<
typename sprout::weed::traits::attribute_of<Arg1, Iterator, Context>::type,
typename sprout::weed::traits::attribute_of<Arg2, Iterator, Context>::type
>
: public sprout::weed::traits::attribute_of<
typename sprout::weed::traits::terminal_of<T>::type,
Iterator,
Context
>
{};
} // namespace traits