void on_define(parse_node_type const &node);
void on_undefine(lexer_type const &it);
- void on_ifdef(result_type const& found_directive, lexer_type const &it);
-// typename parse_tree_type::const_iterator const &end);
- void on_ifndef(result_type const& found_directive, lexer_type const& it);
-// typename parse_tree_type::const_iterator const &end);
+ void on_ifdef(result_type const& found_directive,
+ typename parse_tree_type::const_iterator const &begin,
+ typename parse_tree_type::const_iterator const &end);
+ void on_ifndef(result_type const& found_directive,
+ typename parse_tree_type::const_iterator const &begin,
+ typename parse_tree_type::const_iterator const &end);
void on_else();
void on_endif();
void on_illformed(typename result_type::string_type s);
{
if (iter_ctx->first == iter_ctx->last && ctx.get_iteration_depth() > 0) {
// call the include policy trace function
-#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0
- ctx.get_hooks().returning_from_include_file();
-#else
ctx.get_hooks().returning_from_include_file(ctx.derived());
-#endif
// restore the previous iteration context after finishing the preprocessing
// of the included file
bool call_found_directive_hook(ContextT& ctx,
typename ContextT::token_type const& found_directive)
{
-#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0
- ctx.get_hooks().found_directive(found_directive);
-#else
if (ctx.get_hooks().found_directive(ctx.derived(), found_directive))
return true; // skip this directive and return newline only
-#endif
return false;
}
// void call_skipped_token_hook(ContextT& ctx,
// typename ContextT::token_type const& skipped)
// {
-// #if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0
-// ctx.get_hooks().skipped_token(skipped);
-// #else
// ctx.get_hooks().skipped_token(ctx.derived(), skipped);
-// #endif
// }
template <typename ContextT, typename IteratorT>
util::impl::call_skipped_token_hook(ctx, *it);
for (++it; it != end; ++it) {
- token_id id = token_id(*it);
+ token_id id = token_id(*it);
if (T_CPPCOMMENT == id || T_NEWLINE == id ||
context_policies::util::ccomment_has_newline(*it))
if (call_hook)
util::impl::call_skipped_token_hook(ctx, *it);
}
- return need_no_newline_at_end_of_file(ctx.get_language());
+ return need_no_newline_at_end_of_file(ctx.get_language()) &&
+ ((it == end) || (T_EOF == token_id(*it)));
}
///////////////////////////////////////////////////////////////////////////
// enable error recovery (start over with the next line)
impl::skip_to_eol(ctx, it, iter_ctx->last);
- string_type str(util::impl::as_string<string_type>(
- iter_ctx->first, it));
+ string_type str(util::impl::as_string<string_type>(iter_ctx->first, it));
seen_newline = true;
iter_ctx->first = it;
call_hook_in_skip = false;
break;
- case T_PP_IFDEF: // #ifdef
- if (!impl::call_found_directive_hook(ctx, *it) &&
- extract_identifier(it))
- {
- on_ifdef(directive, it);
- }
- call_hook_in_skip = false;
- break;
-
- case T_PP_IFNDEF: // #ifndef
- if (!impl::call_found_directive_hook(ctx, *it) &&
- extract_identifier(it))
- {
- on_ifndef(directive, it);
- }
- call_hook_in_skip = false;
- break;
-
#if BOOST_WAVE_SUPPORT_MS_EXTENSIONS != 0
// case T_MSEXT_PP_REGION: // #region ...
// break;
// on_undefine(*nodeval.begin());
// break;
//
-// case T_PP_IFDEF: // #ifdef
-// on_ifdef(found_directive, begin_child_it, end_child_it);
-// break;
-//
-// case T_PP_IFNDEF: // #ifndef
-// on_ifndef(found_directive, begin_child_it, end_child_it);
-// break;
+ case T_PP_IFDEF: // #ifdef
+ on_ifdef(found_directive, begin_child_it, end_child_it);
+ break;
+
+ case T_PP_IFNDEF: // #ifndef
+ on_ifndef(found_directive, begin_child_it, end_child_it);
+ break;
case T_PP_IF: // #if
on_if(found_directive, begin_child_it, end_child_it);
#endif
// call the 'found_include_directive' hook function
-#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0
- ctx.get_hooks().found_include_directive(f, include_next);
-#else
if (ctx.get_hooks().found_include_directive(ctx.derived(), f, include_next))
return true; // client returned false: skip file to include
-#endif
file_path = util::impl::unescape_lit(file_path);
std::string native_path_str;
base_iteration_context_type::user_header));
// call the include policy trace function
-#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0
- ctx.get_hooks().opened_include_file(dir_path, file_path,
- ctx.get_iteration_depth(), is_system);
-#else
ctx.get_hooks().opened_include_file(ctx.derived(), dir_path, file_path,
is_system);
-#endif
// store current file position
iter_ctx->real_relative_filename = ctx.get_current_relative_filename().c_str();
template <typename ContextT>
inline void
pp_iterator_functor<ContextT>::on_ifdef(
- result_type const& found_directive, lexer_type const &it)
-// typename parse_tree_type::const_iterator const &it)
-// typename parse_tree_type::const_iterator const &end)
+ result_type const& found_directive,
+ typename parse_tree_type::const_iterator const &begin,
+ typename parse_tree_type::const_iterator const &end)
{
- // get_token_value<result_type, parse_node_type> get_value;
- // token_sequence_type toexpand;
- //
- // std::copy(make_ref_transform_iterator((*begin).children.begin(), get_value),
- // make_ref_transform_iterator((*begin).children.end(), get_value),
- // std::inserter(toexpand, toexpand.end()));
+ get_token_value<result_type, parse_node_type> get_value;
+ token_sequence_type toexpand;
- bool is_defined = false;
- token_sequence_type directive;
+ std::copy(make_ref_transform_iterator((*begin).children.begin(), get_value),
+ make_ref_transform_iterator((*begin).children.end(), get_value),
+ std::inserter(toexpand, toexpand.end()));
- directive.insert(directive.end(), *it);
+ bool is_defined = false;
-#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0
- is_defined = ctx.is_defined_macro((*it).get_value()); // toexpand.begin(), toexpand.end());
- ctx.get_hooks().evaluated_conditional_expression(directive, is_defined);
-#else
do {
- is_defined = ctx.is_defined_macro((*it).get_value()); // toexpand.begin(), toexpand.end());
+ is_defined = ctx.is_defined_macro(toexpand.begin(), toexpand.end());
} while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(),
- found_directive, directive, is_defined));
-#endif
+ found_directive, toexpand, is_defined));
ctx.enter_if_block(is_defined);
}
template <typename ContextT>
inline void
pp_iterator_functor<ContextT>::on_ifndef(
- result_type const& found_directive, lexer_type const &it)
-// typename parse_tree_type::const_iterator const &it)
-// typename parse_tree_type::const_iterator const &end)
+ result_type const& found_directive,
+ typename parse_tree_type::const_iterator const &begin,
+ typename parse_tree_type::const_iterator const &end)
{
- // get_token_value<result_type, parse_node_type> get_value;
- // token_sequence_type toexpand;
- //
- // std::copy(make_ref_transform_iterator((*begin).children.begin(), get_value),
- // make_ref_transform_iterator((*begin).children.end(), get_value),
- // std::inserter(toexpand, toexpand.end()));
+ get_token_value<result_type, parse_node_type> get_value;
+ token_sequence_type toexpand;
- bool is_defined = false;
- token_sequence_type directive;
+ std::copy(make_ref_transform_iterator((*begin).children.begin(), get_value),
+ make_ref_transform_iterator((*begin).children.end(), get_value),
+ std::inserter(toexpand, toexpand.end()));
- directive.insert(directive.end(), *it);
+ bool is_defined = false;
-#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0
- is_defined = ctx.is_defined_macro((*it).get_value()); // toexpand.begin(), toexpand.end());
- ctx.get_hooks().evaluated_conditional_expression(directive, is_defined);
-#else
do {
- is_defined = ctx.is_defined_macro((*it).get_value()); // toexpand.begin(), toexpand.end());
+ is_defined = ctx.is_defined_macro(toexpand.begin(), toexpand.end());
} while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(),
- found_directive, directive, is_defined));
-#endif
+ found_directive, toexpand, is_defined));
ctx.enter_if_block(!is_defined);
}
break;
}
-#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0
- ctx.get_hooks().evaluated_conditional_expression(toexpand, if_status);
- } while (false);
-#else
} while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(),
found_directive, toexpand, if_status)
&& status == grammars::error_noerror);
-#endif
ctx.enter_if_block(if_status);
if (grammars::error_noerror != status) {
ctx.get_hooks().throw_exception(ctx.derived(), e);
}
-#if BOOST_WAVE_USE_DEPRECIATED_PREPROCESSING_HOOKS != 0
- ctx.get_hooks().evaluated_conditional_expression(toexpand, if_status);
- } while (false);
-#else
} while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(),
found_directive, toexpand, if_status)
&& status == grammars::error_noerror);
-#endif
if (!ctx.enter_elif_block(if_status)) {
// #elif without matching #if