예제 #1
0
inline bool 
token_equals(TokenT const &left, TokenT const &right)
{
    using namespace boost::wave;
    
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
    if (T_PARAMETERBASE == token_id(left) || 
        T_EXTPARAMETERBASE == token_id(left)) 
#else
    if (T_PARAMETERBASE == token_id(left))
#endif 
    {
    //  if the existing token is of type T_PARAMETERBASE, then the right token 
    //  must be of type T_IDENTIFIER or a keyword
    token_id id = token_id(right);
     
        return (T_IDENTIFIER == id || 
                IS_CATEGORY(id, KeywordTokenType) ||
                IS_EXTCATEGORY(id, OperatorTokenType|AltExtTokenType) ||
                IS_CATEGORY(id, BoolLiteralTokenType)) && 
            left.get_value() == right.get_value();
    }

    // if the left token has whitespace, the value is irrelevant
    return token_id(left) == token_id(right) && (
            IS_CATEGORY(left, WhiteSpaceTokenType) ||
            left.get_value() == right.get_value()
        );
}
예제 #2
0
    bool
    found_directive(ContextT const& ctx, TokenT const& directive)
#endif
    {
        // print the commented conditional directives
        using namespace boost::wave;
        token_id id = token_id(directive);
        switch (id) {
        case T_PP_IFDEF:
        case T_PP_IFNDEF:
        case T_PP_IF:
        case T_PP_ELIF:
            std::cout << "// " << directive.get_value() << " ";
            need_comment = false;
            break;
            
        case T_PP_ELSE:
        case T_PP_ENDIF:
            std::cout << "// " << directive.get_value() << std::endl;
            need_comment = true;
            break;

        default:
            break;
        }

#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS == 0
        return false;
#endif
    }
void UdpWriteModule::pingRemote(TokenT udpToken)
{
	dbglog << "UdpWriteModule #" << mPeerId
	       << " pinging remote " << *mRemoteEndpoint
	       << " aka #" << mPeerId
	       << " with token: " << udpToken;
	
	CharArray512T ca512;
	std::copy(udpToken.begin(), udpToken.end(), ca512.begin());
	DataPayload payload(ID::NE_PING_UDP, 0, 0, udpToken.size(), ca512);
	onSend(payload);
}
    void
    detected_pragma_once(ContextT const& ctx, TokenT const& pragma_token,
        std::string filename) 
    {
        using boost::wave::util::impl::escape_lit;

#if defined(BOOST_WINDOWS)
        filename = replace_slashes(filename);
#endif

        BOOST_WAVETEST_OSSTREAM strm;
        strm << "20: " << repr(pragma_token.get_position()) << ": " 
             << pragma_token.get_value() << ": " 
             << escape_lit(filename) << std::endl;
        hooks_trace += BOOST_WAVETEST_GETSTRING(strm);
    }
    void expanding_object_like_macro(TokenT const &macrodef, 
        ContainerT const &definition, TokenT const &macrocall)
    {
        if (enabled_macro_counting())
            count_invocation(macrodef.get_value().c_str());

        if (!enabled_macro_tracing()) 
            return;
BOOST_WAVE_INTLITGRAMMAR_GEN_INLINE
uint_literal_type
intlit_grammar_gen<TokenT>::evaluate(TokenT const &token,
    bool &is_unsigned)
{
    using namespace boost::spirit::classic;

intlit_grammar g(is_unsigned);
uint_literal_type result = 0;
typename TokenT::string_type const &token_val = token.get_value();
parse_info<typename TokenT::string_type::const_iterator> hit =
    parse(token_val.begin(), token_val.end(), g[spirit_assign_actor(result)]);

    if (!hit.hit) {
        BOOST_WAVE_THROW(preprocess_exception, ill_formed_integer_literal,
            token_val.c_str(), token.get_position());
    }
    return result;
}
    void expanding_function_like_macro(
        TokenT const &macrodef, std::vector<TokenT> const &formal_args, 
        ContainerT const &definition,
        TokenT const &macrocall, std::vector<ContainerT> const &arguments) 
    {
        if (enabled_macro_counting())
            count_invocation(macrodef.get_value().c_str());

        if (!enabled_macro_tracing()) 
            return;
예제 #8
0
BOOST_WAVE_CHLITGRAMMAR_GEN_INLINE 
unsigned int
chlit_grammar_gen<TokenT>::evaluate(TokenT const &token)
{
    using namespace boost::spirit;
    
chlit_grammar g;
boost::uint32_t result = 0;
typename TokenT::string_type const &token_val = token.get_value();
parse_info<typename TokenT::string_type::const_iterator> hit =
    parse(token_val.begin(), token_val.end(), g[spirit_assign_actor(result)]);

    if (!hit.hit) {
        BOOST_WAVE_THROW(preprocess_exception, ill_formed_character_literal, 
            token_val.c_str(), token.get_position());
    }
    else {
    // range check
        if ('L' == token_val[0]) {
        // recognised wide character
            if (g.overflow || 
                result > (unsigned long)(std::numeric_limits<wchar_t>::max)()) 
            {
            // out of range
                BOOST_WAVE_THROW(preprocess_exception, 
                    character_literal_out_of_range, 
                    token_val.c_str(), token.get_position());
            }
        }
        else {
        // recognised narrow ('normal') character
            if (g.overflow || 
                result > (unsigned long)(std::numeric_limits<unsigned char>::max)()) 
            {
            // out of range
                BOOST_WAVE_THROW(preprocess_exception, 
                    character_literal_out_of_range, 
                    token_val.c_str(), token.get_position());
            }
        }
    }
    return result;
}
inline bool 
token_equals(TokenT const &left, TokenT const &right)
{
    using namespace boost::wave;

    if (IS_CATEGORY(left, ParameterTokenType)) {
    //  if the existing token is of type T_PARAMETERBASE, then the right token 
    //  must be of type T_IDENTIFIER or a keyword
    token_id id = token_id(right);

        return (T_IDENTIFIER == id || 
                IS_CATEGORY(id, KeywordTokenType) ||
                IS_EXTCATEGORY(id, OperatorTokenType|AltExtTokenType) ||
                IS_CATEGORY(id, BoolLiteralTokenType)) && 
            left.get_value() == right.get_value();
    }

    // if the left token has whitespace, the value is irrelevant
    return token_id(left) == token_id(right) && (
            IS_CATEGORY(left, WhiteSpaceTokenType) ||
            left.get_value() == right.get_value()
        );
}
예제 #10
0
    void
    skipped_token(ContextT const& ctx, TokenT const& token)
#endif
    {
        // prepend a comment at the beginning of all skipped lines
        using namespace boost::wave;
        if (need_comment) {
            std::cout << "// ";
            need_comment = false;
        }
        std::cout << token.get_value();
        if (token_id(token) == T_NEWLINE || token_id(token) == T_CPPCOMMENT) 
            need_comment = true;
    }
    bool 
    expanding_object_like_macro(ContextT const& ctx,
        TokenT const &macrodef, ContainerT const &definition, 
        TokenT const &macrocall)
    {
        if (enabled_macro_counting())
            count_invocation(macrodef.get_value().c_str());

        if (!enabled_macro_tracing()) 
            return false;
#endif
        if (0 == get_level()) {
        // output header line
        BOOST_WAVE_OSSTREAM stream;

            stream 
                << macrocall.get_position() << ": "
                << macrocall.get_value() << std::endl;
            output(BOOST_WAVE_GETSTRING(stream));
            increment_level();
        }

    // output definition reference
        {
        BOOST_WAVE_OSSTREAM stream;

            stream 
                << macrodef.get_position() << ": see macro definition: "
                << macrodef.get_value() << std::endl;
            output(BOOST_WAVE_GETSTRING(stream));
        }
        open_trace_body();

#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS == 0
        return false;
#endif
    }
    bool 
    expanding_function_like_macro(ContextT const& ctx,
        TokenT const &macrodef, std::vector<TokenT> const &formal_args, 
        ContainerT const &definition,
        TokenT const &macrocall, std::vector<ContainerT> const &arguments,
        IteratorT const& seqstart, IteratorT const& seqend) 
    {
        if (enabled_macro_counting())
            count_invocation(macrodef.get_value().c_str());

        if (!enabled_macro_tracing()) 
            return false;
#endif
        if (0 == get_level()) {
        // output header line
        BOOST_WAVE_OSSTREAM stream;

            stream 
                << macrocall.get_position() << ": "
                << macrocall.get_value() << "(";

        // argument list
            for (typename ContainerT::size_type i = 0; i < arguments.size(); ++i) {
                stream << boost::wave::util::impl::as_string(arguments[i]);
                if (i < arguments.size()-1)
                    stream << ", ";
            }
            stream << ")" << std::endl; 
            output(BOOST_WAVE_GETSTRING(stream));
            increment_level();
        }

    // output definition reference
        {
        BOOST_WAVE_OSSTREAM stream;

            stream 
                << macrodef.get_position() << ": see macro definition: "
                << macrodef.get_value() << "(";

        // formal argument list
            for (typename std::vector<TokenT>::size_type i = 0; 
                i < formal_args.size(); ++i) 
            {
                stream << formal_args[i].get_value();
                if (i < formal_args.size()-1)
                    stream << ", ";
            }
            stream << ")" << std::endl; 
            output(BOOST_WAVE_GETSTRING(stream));
        }

        if (formal_args.size() > 0) {
        // map formal and real arguments
            open_trace_body("invoked with\n");
            for (typename std::vector<TokenT>::size_type j = 0; 
                j < formal_args.size(); ++j) 
            {
                using namespace boost::wave;

                BOOST_WAVE_OSSTREAM stream;
                stream << formal_args[j].get_value() << " = ";
#if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
                if (T_ELLIPSIS == token_id(formal_args[j])) {
                // ellipsis
                    for (typename ContainerT::size_type k = j; 
                        k < arguments.size(); ++k) 
                    {
                        stream << boost::wave::util::impl::as_string(arguments[k]);
                        if (k < arguments.size()-1)
                            stream << ", ";
                    }
                } 
                else 
#endif
                {
                    stream << boost::wave::util::impl::as_string(arguments[j]);
                }
                stream << std::endl;
                output(BOOST_WAVE_GETSTRING(stream));
            }
            close_trace_body();
        }
        open_trace_body();

#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS == 0
        return false;
#endif
    }