mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
sprout/weed.hpp 追加
This commit is contained in:
parent
8103682fdb
commit
ecfc2b297a
96 changed files with 5127 additions and 0 deletions
115
sprout/weed/traits/parser/attribute_of.hpp
Normal file
115
sprout/weed/traits/parser/attribute_of.hpp
Normal file
|
@ -0,0 +1,115 @@
|
|||
#ifndef SPROUT_WEED_TRAITS_PARSER_ATTRIBUTE_OF_HPP
|
||||
#define SPROUT_WEED_TRAITS_PARSER_ATTRIBUTE_OF_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/weed/unused.hpp>
|
||||
#include <sprout/weed/expr/expr.hpp>
|
||||
#include <sprout/weed/expr/tag.hpp>
|
||||
#include <sprout/weed/traits/type/is_char_type.hpp>
|
||||
#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/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 {
|
||||
namespace traits {
|
||||
//
|
||||
// attribute_of
|
||||
//
|
||||
template<typename T, typename Iterator, typename Context, typename = void>
|
||||
struct attribute_of;
|
||||
template<typename T, typename Iterator, typename Context>
|
||||
struct attribute_of<T const, Iterator, Context>
|
||||
: public sprout::weed::traits::attribute_of<T, Iterator, Context>
|
||||
{};
|
||||
template<typename T, typename Iterator, typename Context>
|
||||
struct attribute_of<
|
||||
T,
|
||||
Iterator,
|
||||
Context,
|
||||
typename std::enable_if<
|
||||
sprout::weed::traits::is_parser<T>::value
|
||||
&& !sprout::weed::traits::is_expr<T>::value
|
||||
&& !sprout::weed::traits::is_char_type<T>::value
|
||||
&& !sprout::weed::traits::is_c_str<T>::value
|
||||
&& !sprout::weed::traits::is_string<T>::value
|
||||
>::type
|
||||
> {
|
||||
public:
|
||||
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_char_type<T>::value
|
||||
|| 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::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::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
|
||||
>
|
||||
{};
|
||||
} // namespace traits
|
||||
} // namespace weed
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_WEED_TRAITS_PARSER_ATTRIBUTE_OF_HPP
|
75
sprout/weed/traits/parser/is_parser.hpp
Normal file
75
sprout/weed/traits/parser/is_parser.hpp
Normal file
|
@ -0,0 +1,75 @@
|
|||
#ifndef SPROUT_WEED_TRAITS_PARSER_IS_PARSER_HPP
|
||||
#define SPROUT_WEED_TRAITS_PARSER_IS_PARSER_HPP
|
||||
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/weed/unused.hpp>
|
||||
#include <sprout/weed/parser/parser_base.hpp>
|
||||
#include <sprout/weed/traits/type/is_char_type.hpp>
|
||||
#include <sprout/weed/traits/type/is_c_str.hpp>
|
||||
#include <sprout/weed/traits/expr/is_expr.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace weed {
|
||||
namespace traits {
|
||||
//
|
||||
// is_parser
|
||||
//
|
||||
template<typename T, typename = void>
|
||||
struct is_parser;
|
||||
template<typename T>
|
||||
struct is_parser<
|
||||
T,
|
||||
typename std::enable_if<
|
||||
std::is_const<T>::value
|
||||
&& !std::is_array<T>::value
|
||||
>::type
|
||||
>
|
||||
: public sprout::weed::traits::is_parser<
|
||||
typename std::remove_const<T>::type
|
||||
>
|
||||
{};
|
||||
template<typename T>
|
||||
struct is_parser<
|
||||
T,
|
||||
typename std::enable_if<
|
||||
std::is_base_of<sprout::weed::parser_base, T>::value
|
||||
&& !std::is_const<T>::value
|
||||
>::type
|
||||
>
|
||||
: public std::true_type
|
||||
{};
|
||||
template<typename T>
|
||||
struct is_parser<
|
||||
T,
|
||||
typename std::enable_if<
|
||||
sprout::weed::traits::is_expr<T>::value
|
||||
&& !std::is_const<T>::value
|
||||
>::type
|
||||
>
|
||||
: public std::true_type
|
||||
{};
|
||||
template<typename T>
|
||||
struct is_parser<
|
||||
T,
|
||||
typename std::enable_if<
|
||||
sprout::weed::traits::is_char_type<T>::value
|
||||
&& !std::is_const<T>::value
|
||||
>::type
|
||||
>
|
||||
: public std::true_type
|
||||
{};
|
||||
template<typename T>
|
||||
struct is_parser<
|
||||
T,
|
||||
typename std::enable_if<
|
||||
sprout::weed::traits::is_c_str<T>::value
|
||||
>::type
|
||||
>
|
||||
: public std::true_type
|
||||
{};
|
||||
} // namespace traits
|
||||
} // namespace weed
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_WEED_TRAITS_PARSER_IS_PARSER_HPP
|
32
sprout/weed/traits/parser/limit_of.hpp
Normal file
32
sprout/weed/traits/parser/limit_of.hpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
#ifndef SPROUT_WEED_TRAITS_PARSER_LIMIT_OF_HPP
|
||||
#define SPROUT_WEED_TRAITS_PARSER_LIMIT_OF_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/weed/expr/expr.hpp>
|
||||
#include <sprout/weed/expr/tag.hpp>
|
||||
|
||||
namespace sprout {
|
||||
namespace weed {
|
||||
namespace traits {
|
||||
//
|
||||
// limit_of
|
||||
//
|
||||
template<typename T, typename Iterator, typename Context, typename = void>
|
||||
struct limit_of
|
||||
: public std::integral_constant<std::size_t, -1>
|
||||
{};
|
||||
template<typename T, typename Iterator, typename Context>
|
||||
struct limit_of<T const, Iterator, Context>
|
||||
: public sprout::weed::traits::limit_of<T, Iterator, Context>
|
||||
{};
|
||||
template<typename Arg, typename Iterator, typename Context>
|
||||
struct limit_of<sprout::weed::expr<sprout::weed::tag::terminal, Arg>, Iterator, Context>
|
||||
: public sprout::weed::traits::limit_of<Arg, Iterator, Context>
|
||||
{};
|
||||
} // namespace traits
|
||||
} // namespace weed
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_WEED_TRAITS_PARSER_LIMIT_OF_HPP
|
Loading…
Add table
Add a link
Reference in a new issue