Warning, file /include/boost/spirit/home/lex/meta_compiler.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007 #if !defined(BOOST_SPIRIT_LEX_META_COMPILER_APR_20_2009_0756PM)
0008 #define BOOST_SPIRIT_LEX_META_COMPILER_APR_20_2009_0756PM
0009
0010 #if defined(_MSC_VER)
0011 #pragma once
0012 #endif
0013
0014 #include <boost/spirit/home/support/meta_compiler.hpp>
0015 #include <boost/spirit/home/lex/domain.hpp>
0016 #include <boost/spirit/home/lex/lexer_type.hpp>
0017 #include <boost/proto/tags.hpp>
0018 #include <boost/type_traits/remove_reference.hpp>
0019 #include <boost/utility/enable_if.hpp>
0020
0021 namespace boost { namespace spirit
0022 {
0023 template <typename T>
0024 struct use_terminal<lex::domain, T
0025 , typename enable_if<traits::is_lexer<T> >::type>
0026 : mpl::true_ {};
0027
0028 namespace lex
0029 {
0030 template <typename T, typename Modifiers, typename Enable = void>
0031 struct make_primitive
0032 {
0033 typedef T result_type;
0034
0035 template <typename T_>
0036 T_& operator()(T_& val, unused_type) const
0037 {
0038 return val;
0039 }
0040
0041 template <typename T_>
0042 T_ const& operator()(T_ const& val, unused_type) const
0043 {
0044 return val;
0045 }
0046 };
0047
0048 template <typename Tag, typename Elements
0049 , typename Modifiers, typename Enable = void>
0050 struct make_composite;
0051 }
0052
0053
0054 template <>
0055 struct make_component<lex::domain, proto::tag::terminal>
0056 {
0057 template <typename Sig>
0058 struct result;
0059
0060 template <typename This, typename Elements, typename Modifiers>
0061 struct result<This(Elements, Modifiers)>
0062 {
0063 typedef typename lex::make_primitive<
0064 typename remove_const<typename Elements::car_type>::type,
0065 typename remove_reference<Modifiers>::type>::result_type
0066 type;
0067 };
0068
0069 template <typename Elements, typename Modifiers>
0070 typename result<make_component(Elements, Modifiers)>::type
0071 operator()(Elements const& elements, Modifiers const& modifiers) const
0072 {
0073 typedef typename remove_const<typename Elements::car_type>::type term;
0074 return lex::make_primitive<term, Modifiers>()(elements.car, modifiers);
0075 }
0076 };
0077
0078
0079 template <typename Tag>
0080 struct make_component<lex::domain, Tag>
0081 {
0082 template <typename Sig>
0083 struct result;
0084
0085 template <typename This, typename Elements, typename Modifiers>
0086 struct result<This(Elements, Modifiers)>
0087 {
0088 typedef typename
0089 lex::make_composite<Tag, Elements
0090 , typename remove_reference<Modifiers>::type>::result_type
0091 type;
0092 };
0093
0094 template <typename Elements, typename Modifiers>
0095 typename result<make_component(Elements, Modifiers)>::type
0096 operator()(Elements const& elements, Modifiers const& modifiers) const
0097 {
0098 return lex::make_composite<Tag, Elements, Modifiers>()(
0099 elements, modifiers);
0100 }
0101 };
0102
0103 }}
0104
0105 #endif