Boost-Graph
view release on metacpan or search on metacpan
include/boost/wave/util/cpp_iterator.hpp view on Meta::CPAN
for (/**/; it != end; ++it) {
token_id id = token_id(*it);
if (T_CPPCOMMENT == id || T_NEWLINE == id) {
++it; // skip eol/C++ comment
return true; // found pp_null
}
}
return false;
}
}
template <typename ContextT>
inline bool
pp_iterator_functor<ContextT>::pp_directive()
{
using namespace cpplexer;
// test, if the next non-whitespace token is a pp directive
lexer_type it = iter_ctx->first;
if (!next_token_is_pp_directive(it, iter_ctx->last)) {
// eventually skip null pp directive (no need to do it via the parser)
if (it != iter_ctx->last && T_POUND == BASE_TOKEN(token_id(*it))) {
if (is_pp_null(it, iter_ctx->last)) {
seen_newline = true;
iter_ctx->first = it; // start over with the next line
return true;
}
else {
on_illformed((*it).get_value());
}
}
// this line does not contain a pp directive, so simply return
return false;
}
if (it == iter_ctx->last)
return false;
// ignore all pp directives not related to conditional compilation while
// if block status is false
if (!ctx.get_if_block_status() &&
!IS_EXTCATEGORY(*it, PPConditionalTokenType))
{
seen_newline = true;
skip_to_eol(it, iter_ctx->last);
iter_ctx->first = it; // start over with the next line
return true;
}
// found a pp directive, so try to identify it, start with the pp_token
bool found_eof = false;
boost::spirit::tree_parse_info<lexer_type> hit =
cpp_grammar_type::parse_cpp_grammar(it, iter_ctx->last, found_eof, act_pos);
if (hit.match) {
// position the iterator past the matched sequence to allow
// resynchronisation, if an error occurs
iter_ctx->first = hit.stop;
// found a valid pp directive, dispatch to the correct function to handle
// the found pp directive
bool result = dispatch_directive (hit);
if (found_eof) {
// The line was terminated with an end of file token.
// So trigger a warning, that the last line was not terminated with a
// newline.
BOOST_WAVE_THROW(preprocess_exception, last_line_not_terminated, "",
act_pos);
}
return result;
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
//
// dispatch_directive(): dispatch a recognized preprocessor directive
//
///////////////////////////////////////////////////////////////////////////////
template <typename ContextT>
inline bool
pp_iterator_functor<ContextT>::dispatch_directive(
boost::spirit::tree_parse_info<lexer_type> const &hit)
{
using namespace cpplexer;
using namespace boost::spirit;
typedef typename parse_tree_type::const_iterator const_child_iterator_t;
// this iterator points to the root node of the parse tree
const_child_iterator_t begin = hit.trees.begin();
// decide, which preprocessor directive was found
parse_tree_type const &root = (*begin).children;
parse_node_value_type const &nodeval = get_first_leaf(*root.begin()).value;
//long node_id = nodeval.id().to_long();
const_child_iterator_t begin_child_it = (*root.begin()).children.begin();
const_child_iterator_t end_child_it = (*root.begin()).children.end();
token_id id = cpp_grammar_type::found_directive;
switch (id) {
case T_PP_QHEADER: // #include "..."
#if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
case T_PP_QHEADER_NEXT: // #include_next "..."
#endif
on_include ((*nodeval.begin()).get_value(), false,
T_PP_QHEADER_NEXT == id);
break;
case T_PP_HHEADER: // #include <...>
#if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
case T_PP_HHEADER_NEXT: // #include_next <...>
#endif
on_include ((*nodeval.begin()).get_value(), true,
( run in 0.471 second using v1.01-cache-2.11-cpan-39bf76dae61 )