Warning, file /include/boost/spirit/home/lex/qi/plain_raw_token.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 #if !defined(BOOST_SPIRIT_LEX_PLAIN_RAW_TOKEN_JUN_03_2011_0853PM)
0007 #define BOOST_SPIRIT_LEX_PLAIN_RAW_TOKEN_JUN_03_2011_0853PM
0008
0009 #if defined(_MSC_VER)
0010 #pragma once
0011 #endif
0012
0013 #include <boost/spirit/home/support/info.hpp>
0014 #include <boost/spirit/home/qi/detail/attributes.hpp>
0015 #include <boost/spirit/home/support/common_terminals.hpp>
0016 #include <boost/spirit/home/support/handles_container.hpp>
0017 #include <boost/spirit/home/qi/skip_over.hpp>
0018 #include <boost/spirit/home/qi/domain.hpp>
0019 #include <boost/spirit/home/qi/parser.hpp>
0020 #include <boost/spirit/home/qi/meta_compiler.hpp>
0021 #include <boost/spirit/home/qi/detail/assign_to.hpp>
0022 #include <boost/fusion/include/vector.hpp>
0023 #include <boost/fusion/include/at.hpp>
0024 #include <boost/mpl/or.hpp>
0025 #include <boost/type_traits/is_integral.hpp>
0026 #include <boost/type_traits/is_enum.hpp>
0027 #include <iterator> // for std::iterator_traits
0028 #include <sstream>
0029
0030 namespace boost { namespace spirit
0031 {
0032
0033
0034
0035
0036
0037 template <>
0038 struct use_terminal<qi::domain, tag::raw_token>
0039 : mpl::true_ {};
0040
0041
0042 template <typename A0>
0043 struct use_terminal<qi::domain
0044 , terminal_ex<tag::raw_token, fusion::vector1<A0> >
0045 > : mpl::or_<is_integral<A0>, is_enum<A0> > {};
0046
0047
0048 template <>
0049 struct use_lazy_terminal<
0050 qi::domain, tag::raw_token, 1
0051 > : mpl::true_ {};
0052 }}
0053
0054 namespace boost { namespace spirit { namespace qi
0055 {
0056 #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
0057 using spirit::raw_token;
0058 #endif
0059 using spirit::raw_token_type;
0060
0061
0062 template <typename TokenId>
0063 struct plain_raw_token
0064 : primitive_parser<plain_raw_token<TokenId> >
0065 {
0066 template <typename Context, typename Iterator>
0067 struct attribute
0068 {
0069 typedef unused_type type;
0070 };
0071
0072 plain_raw_token(TokenId const& id)
0073 : id(id) {}
0074
0075 template <typename Iterator, typename Context
0076 , typename Skipper, typename Attribute>
0077 bool parse(Iterator& first, Iterator const& last
0078 , Context& , Skipper const& skipper
0079 , Attribute& attr) const
0080 {
0081 qi::skip_over(first, last, skipper);
0082
0083 if (first != last) {
0084
0085
0086
0087 typedef typename
0088 std::iterator_traits<Iterator>::value_type
0089 token_type;
0090 typedef typename token_type::id_type id_type;
0091
0092 token_type const& t = *first;
0093 if (id_type(~0) == id_type(id) || id_type(id) == t.id()) {
0094 spirit::traits::assign_to(t, attr);
0095 ++first;
0096 return true;
0097 }
0098 }
0099 return false;
0100 }
0101
0102 template <typename Context>
0103 info what(Context& ) const
0104 {
0105 std::stringstream ss;
0106 ss << "raw_token(" << id << ")";
0107 return info("raw_token", ss.str());
0108 }
0109
0110 TokenId id;
0111 };
0112
0113
0114
0115
0116 template <typename Modifiers>
0117 struct make_primitive<tag::raw_token, Modifiers>
0118 {
0119 typedef plain_raw_token<std::size_t> result_type;
0120
0121 result_type operator()(unused_type, unused_type) const
0122 {
0123 return result_type(std::size_t(~0));
0124 }
0125 };
0126
0127 template <typename Modifiers, typename TokenId>
0128 struct make_primitive<terminal_ex<tag::raw_token, fusion::vector1<TokenId> >
0129 , Modifiers>
0130 {
0131 typedef plain_raw_token<TokenId> result_type;
0132
0133 template <typename Terminal>
0134 result_type operator()(Terminal const& term, unused_type) const
0135 {
0136 return result_type(fusion::at_c<0>(term.args));
0137 }
0138 };
0139 }}}
0140
0141 namespace boost { namespace spirit { namespace traits
0142 {
0143
0144 template<typename Idtype, typename Attr, typename Context, typename Iterator>
0145 struct handles_container<qi::plain_raw_token<Idtype>, Attr, Context, Iterator>
0146 : mpl::true_
0147 {};
0148 }}}
0149
0150 #endif