123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562 |
- #if !defined(BOOST_CPP_ITERATOR_HPP_175CA88F_7273_43FA_9039_BCF7459E1F29_INCLUDED)
- #define BOOST_CPP_ITERATOR_HPP_175CA88F_7273_43FA_9039_BCF7459E1F29_INCLUDED
- #include <string>
- #include <vector>
- #include <list>
- #include <cstdlib>
- #include <cctype>
- #include <boost/assert.hpp>
- #include <boost/shared_ptr.hpp>
- #include <boost/filesystem/path.hpp>
- #include <boost/filesystem/operations.hpp>
- #include <boost/lexical_cast.hpp>
- #include <boost/spirit/include/classic_multi_pass.hpp>
- #include <boost/spirit/include/classic_parse_tree_utils.hpp>
- #include <boost/wave/wave_config.hpp>
- #include <boost/pool/pool_alloc.hpp>
- #include <boost/wave/util/insert_whitespace_detection.hpp>
- #include <boost/wave/util/macro_helpers.hpp>
- #include <boost/wave/util/cpp_macromap_utils.hpp>
- #include <boost/wave/util/interpret_pragma.hpp>
- #include <boost/wave/util/transform_iterator.hpp>
- #include <boost/wave/util/functor_input.hpp>
- #include <boost/wave/util/filesystem_compatibility.hpp>
- #include <boost/wave/grammars/cpp_grammar_gen.hpp>
- #include <boost/wave/grammars/cpp_expression_grammar_gen.hpp>
- #if BOOST_WAVE_ENABLE_COMMANDLINE_MACROS != 0
- #include <boost/wave/grammars/cpp_predef_macros_gen.hpp>
- #endif
- #include <boost/wave/whitespace_handling.hpp>
- #include <boost/wave/cpp_iteration_context.hpp>
- #include <boost/wave/cpp_exceptions.hpp>
- #include <boost/wave/language_support.hpp>
- #ifdef BOOST_HAS_ABI_HEADERS
- #include BOOST_ABI_PREFIX
- #endif
- namespace boost {
- namespace wave {
- namespace util {
- template <
- typename ContextT, typename ParseNodeT, typename TokenT,
- typename PositionT
- >
- inline bool
- retrieve_macroname(ContextT& ctx, ParseNodeT const &node,
- boost::spirit::classic::parser_id id, TokenT ¯oname, PositionT& act_pos,
- bool update_position)
- {
- ParseNodeT const* name_node = 0;
- using boost::spirit::classic::find_node;
- if (!find_node(node, id, &name_node))
- {
-
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_define_statement,
- "bad parse tree (unexpected)", act_pos);
- return false;
- }
- typename ParseNodeT::children_t const& children = name_node->children;
- if (0 == children.size() ||
- children.front().value.begin() == children.front().value.end())
- {
-
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_define_statement,
- "bad parse tree (unexpected)", act_pos);
- return false;
- }
-
- macroname = *children.front().value.begin();
- if (update_position) {
- macroname.set_position(act_pos);
- act_pos.set_column(act_pos.get_column() + macroname.get_value().size());
- }
- return true;
- }
- template <typename ParseNodeT, typename ContainerT, typename PositionT>
- inline bool
- retrieve_macrodefinition(
- ParseNodeT const &node, boost::spirit::classic::parser_id id,
- ContainerT ¯odefinition, PositionT& act_pos, bool update_position)
- {
- using namespace boost::wave;
- typedef typename ParseNodeT::const_tree_iterator const_tree_iterator;
-
- std::pair<const_tree_iterator, const_tree_iterator> nodes;
- using boost::spirit::classic::get_node_range;
- if (get_node_range(node, id, nodes)) {
-
- typename ContainerT::iterator last_nonwhite = macrodefinition.end();
- const_tree_iterator end = nodes.second;
- for (const_tree_iterator cit = nodes.first; cit != end; ++cit) {
- if ((*cit).value.begin() != (*cit).value.end()) {
- typename ContainerT::iterator inserted = macrodefinition.insert(
- macrodefinition.end(), *(*cit).value.begin());
- if (!IS_CATEGORY(macrodefinition.back(), WhiteSpaceTokenType) &&
- T_NEWLINE != token_id(macrodefinition.back()) &&
- T_EOF != token_id(macrodefinition.back()))
- {
- last_nonwhite = inserted;
- }
- if (update_position) {
- (*inserted).set_position(act_pos);
- act_pos.set_column(
- act_pos.get_column() + (*inserted).get_value().size());
- }
- }
- }
-
- if (last_nonwhite != macrodefinition.end()) {
- if (update_position) {
- act_pos.set_column((*last_nonwhite).get_position().get_column() +
- (*last_nonwhite).get_value().size());
- }
- macrodefinition.erase(++last_nonwhite, macrodefinition.end());
- }
- return true;
- }
- return false;
- }
- #if BOOST_WAVE_ENABLE_COMMANDLINE_MACROS != 0
- template <typename ContextT>
- bool add_macro_definition(ContextT &ctx, std::string macrostring,
- bool is_predefined, boost::wave::language_support language)
- {
- typedef typename ContextT::token_type token_type;
- typedef typename ContextT::lexer_type lexer_type;
- typedef typename token_type::position_type position_type;
- typedef boost::wave::grammars::predefined_macros_grammar_gen<lexer_type>
- predef_macros_type;
- using namespace boost::wave;
- using namespace std;
-
- std::string::iterator begin = macrostring.begin();
- std::string::iterator end = macrostring.end();
- while(begin != end && isspace(*begin))
- ++begin;
-
- position_type act_pos("<command line>");
- boost::spirit::classic::tree_parse_info<lexer_type> hit =
- predef_macros_type::parse_predefined_macro(
- lexer_type(begin, end, position_type(), language), lexer_type());
- if (!hit.match || (!hit.full && T_EOF != token_id(*hit.stop))) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_macro_definition,
- macrostring.c_str(), act_pos);
- return false;
- }
-
- token_type macroname;
- std::vector<token_type> macroparameters;
- typename ContextT::token_sequence_type macrodefinition;
- bool has_parameters = false;
- if (!boost::wave::util::retrieve_macroname(ctx, *hit.trees.begin(),
- BOOST_WAVE_PLAIN_DEFINE_ID, macroname, act_pos, true))
- return false;
- has_parameters = boost::wave::util::retrieve_macrodefinition(*hit.trees.begin(),
- BOOST_WAVE_MACRO_PARAMETERS_ID, macroparameters, act_pos, true);
- boost::wave::util::retrieve_macrodefinition(*hit.trees.begin(),
- BOOST_WAVE_MACRO_DEFINITION_ID, macrodefinition, act_pos, true);
-
- if (!macrodefinition.empty() && token_id(macrodefinition.back()) == T_EOF)
- macrodefinition.pop_back();
-
-
- if (macrodefinition.empty() && '=' != macrostring[macrostring.size()-1])
- macrodefinition.push_back(token_type(T_INTLIT, "1", act_pos));
-
- return ctx.add_macro_definition(macroname, has_parameters, macroparameters,
- macrodefinition, is_predefined);
- }
- #endif
- }
- template <typename ContextT> class pp_iterator;
- namespace impl {
- template <typename ContextT>
- class pp_iterator_functor {
- public:
-
- typedef typename ContextT::token_type result_type;
-
- static result_type const eof;
- private:
-
- typedef typename ContextT::token_sequence_type token_sequence_type;
- typedef typename ContextT::lexer_type lexer_type;
- typedef typename result_type::string_type string_type;
- typedef typename result_type::position_type position_type;
- typedef boost::wave::grammars::cpp_grammar_gen<lexer_type, token_sequence_type>
- cpp_grammar_type;
-
-
- typedef base_iteration_context<ContextT, lexer_type>
- base_iteration_context_type;
- typedef iteration_context<ContextT, lexer_type> iteration_context_type;
-
- typedef typename cpp_grammar_type::node_factory_type node_factory_type;
- typedef boost::spirit::classic::tree_parse_info<lexer_type, node_factory_type>
- tree_parse_info_type;
- typedef boost::spirit::classic::tree_match<lexer_type, node_factory_type>
- parse_tree_match_type;
- typedef typename parse_tree_match_type::node_t parse_node_type;
- typedef typename parse_tree_match_type::parse_node_t parse_node_value_type;
- typedef typename parse_tree_match_type::container_t parse_tree_type;
- public:
- template <typename IteratorT>
- pp_iterator_functor(ContextT &ctx_, IteratorT const &first_,
- IteratorT const &last_, typename ContextT::position_type const &pos_)
- : ctx(ctx_),
- iter_ctx(new base_iteration_context_type(ctx,
- lexer_type(first_, last_, pos_,
- boost::wave::enable_prefer_pp_numbers(ctx.get_language())),
- lexer_type(),
- pos_.get_file().c_str()
- )),
- seen_newline(true), skipped_newline(false),
- must_emit_line_directive(false), act_pos(ctx_.get_main_pos()),
- whitespace(boost::wave::need_insert_whitespace(ctx.get_language()))
- {
- act_pos.set_file(pos_.get_file());
- #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
- ctx_.set_current_filename(pos_.get_file().c_str());
- #endif
- iter_ctx->emitted_lines = (unsigned int)(-1);
- }
-
- result_type const &operator()();
-
- result_type const ¤t_token() const { return act_token; }
- protected:
- friend class pp_iterator<ContextT>;
- bool on_include_helper(char const *t, char const *s, bool is_system,
- bool include_next);
- protected:
- result_type const &get_next_token();
- result_type const &pp_token();
- template <typename IteratorT>
- bool extract_identifier(IteratorT &it);
- template <typename IteratorT>
- bool ensure_is_last_on_line(IteratorT& it, bool call_hook = true);
- template <typename IteratorT>
- bool skip_to_eol_with_check(IteratorT &it, bool call_hook = true);
- bool pp_directive();
- template <typename IteratorT>
- bool handle_pp_directive(IteratorT &it);
- bool dispatch_directive(tree_parse_info_type const &hit,
- result_type const& found_directive,
- token_sequence_type const& found_eoltokens);
- void replace_undefined_identifiers(token_sequence_type &expanded);
- void on_include(string_type const &s, bool is_system, bool include_next);
- void on_include(typename parse_tree_type::const_iterator const &begin,
- typename parse_tree_type::const_iterator const &end, bool include_next);
- void on_define(parse_node_type const &node);
- void on_undefine(lexer_type const &it);
- 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);
- void on_line(typename parse_tree_type::const_iterator const &begin,
- typename parse_tree_type::const_iterator const &end);
- void on_if(result_type const& found_directive,
- typename parse_tree_type::const_iterator const &begin,
- typename parse_tree_type::const_iterator const &end);
- void on_elif(result_type const& found_directive,
- typename parse_tree_type::const_iterator const &begin,
- typename parse_tree_type::const_iterator const &end);
- void on_error(typename parse_tree_type::const_iterator const &begin,
- typename parse_tree_type::const_iterator const &end);
- #if BOOST_WAVE_SUPPORT_WARNING_DIRECTIVE != 0
- void on_warning(typename parse_tree_type::const_iterator const &begin,
- typename parse_tree_type::const_iterator const &end);
- #endif
- bool on_pragma(typename parse_tree_type::const_iterator const &begin,
- typename parse_tree_type::const_iterator const &end);
- bool emit_line_directive();
- bool returned_from_include();
- bool interpret_pragma(token_sequence_type const &pragma_body,
- token_sequence_type &result);
- private:
- ContextT &ctx;
- boost::shared_ptr<base_iteration_context_type> iter_ctx;
- bool seen_newline;
- bool skipped_newline;
- bool must_emit_line_directive;
- result_type act_token;
- typename result_type::position_type &act_pos;
- token_sequence_type unput_queue;
- token_sequence_type pending_queue;
-
-
-
- boost::wave::util::insert_whitespace_detection whitespace;
- };
- template <typename ContextT>
- typename pp_iterator_functor<ContextT>::result_type const
- pp_iterator_functor<ContextT>::eof;
- template <typename ContextT>
- inline bool
- pp_iterator_functor<ContextT>::returned_from_include()
- {
- if (iter_ctx->first == iter_ctx->last && ctx.get_iteration_depth() > 0) {
-
- ctx.get_hooks().returning_from_include_file(ctx.derived());
-
-
- BOOST_WAVE_STRINGTYPE oldfile = iter_ctx->real_filename;
- position_type old_pos (act_pos);
-
- #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
- if (need_include_guard_detection(ctx.get_language())) {
- std::string guard_name;
- if (iter_ctx->first.has_include_guards(guard_name))
- ctx.add_pragma_once_header(ctx.get_current_filename(), guard_name);
- }
- #endif
- iter_ctx = ctx.pop_iteration_context();
- must_emit_line_directive = true;
- iter_ctx->emitted_lines = (unsigned int)(-1);
- seen_newline = true;
-
- act_pos.set_file(iter_ctx->filename);
- act_pos.set_line(iter_ctx->line);
- act_pos.set_column(0);
-
- #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
- namespace fs = boost::filesystem;
- fs::path rfp(wave::util::create_path(iter_ctx->real_filename.c_str()));
- std::string real_filename(rfp.string());
- ctx.set_current_filename(real_filename.c_str());
- #endif
- ctx.set_current_directory(iter_ctx->real_filename.c_str());
- ctx.set_current_relative_filename(iter_ctx->real_relative_filename.c_str());
-
-
- if (iter_ctx->if_block_depth != ctx.get_if_block_depth()) {
- using boost::wave::util::impl::escape_lit;
- BOOST_WAVE_STRINGTYPE msg(escape_lit(oldfile));
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, unbalanced_if_endif,
- msg.c_str(), old_pos);
- }
- return true;
- }
- return false;
- }
- namespace impl {
-
-
-
-
-
- template <typename ContextT>
- bool consider_emitting_line_directive(ContextT const& ctx, token_id id)
- {
- if (need_preserve_comments(ctx.get_language()))
- {
- if (!IS_CATEGORY(id, EOLTokenType) && !IS_CATEGORY(id, EOFTokenType))
- {
- return true;
- }
- }
- if (!IS_CATEGORY(id, WhiteSpaceTokenType) &&
- !IS_CATEGORY(id, EOLTokenType) && !IS_CATEGORY(id, EOFTokenType))
- {
- return true;
- }
- return false;
- }
- }
- template <typename ContextT>
- inline typename pp_iterator_functor<ContextT>::result_type const &
- pp_iterator_functor<ContextT>::operator()()
- {
- using namespace boost::wave;
-
- ctx.init_context();
-
- bool was_seen_newline = seen_newline;
- bool was_skipped_newline = skipped_newline;
- token_id id = T_UNKNOWN;
- try {
- do {
- if (skipped_newline) {
- was_skipped_newline = true;
- skipped_newline = false;
- }
-
- get_next_token();
-
- id = token_id(act_token);
- if (!need_preserve_comments(ctx.get_language()) &&
- (T_CPPCOMMENT == id || context_policies::util::ccomment_has_newline(act_token)))
- {
- act_token.set_token_id(id = T_NEWLINE);
- act_token.set_value("\n");
- }
- if (IS_CATEGORY(id, EOLTokenType))
- seen_newline = true;
- } while (ctx.get_hooks().may_skip_whitespace(ctx.derived(), act_token, skipped_newline));
- }
- catch (boost::wave::cpplexer::lexing_exception const& e) {
-
- ctx.get_hooks().throw_exception(ctx.derived(), e);
- return act_token;
- }
-
- if (was_skipped_newline)
- skipped_newline = true;
-
- if ((must_emit_line_directive || (was_seen_newline && skipped_newline)) &&
- impl::consider_emitting_line_directive(ctx, id))
- {
-
- if (need_emit_line_directives(ctx.get_language()) && emit_line_directive())
- {
- skipped_newline = false;
- ctx.get_hooks().may_skip_whitespace(ctx.derived(), act_token, skipped_newline);
- id = token_id(act_token);
- }
- }
-
- seen_newline = false;
- switch (id) {
- case T_NONREPLACABLE_IDENTIFIER:
- act_token.set_token_id(id = T_IDENTIFIER);
- break;
- case T_GENERATEDNEWLINE:
- act_token.set_token_id(id = T_NEWLINE);
- ++iter_ctx->emitted_lines;
- seen_newline = true;
- break;
- case T_NEWLINE:
- case T_CPPCOMMENT:
- seen_newline = true;
- ++iter_ctx->emitted_lines;
- break;
- #if BOOST_WAVE_SUPPORT_CPP0X != 0
- case T_RAWSTRINGLIT:
- iter_ctx->emitted_lines +=
- context_policies::util::rawstring_count_newlines(act_token);
- break;
- #endif
- case T_CCOMMENT:
- iter_ctx->emitted_lines +=
- context_policies::util::ccomment_count_newlines(act_token);
- break;
- case T_PP_NUMBER:
- {
- token_sequence_type rescanned;
- std::string pp_number(
- util::to_string<std::string>(act_token.get_value()));
- lexer_type it = lexer_type(pp_number.begin(),
- pp_number.end(), act_token.get_position(),
- ctx.get_language());
- lexer_type end = lexer_type();
- for (; it != end && T_EOF != token_id(*it); ++it)
- rescanned.push_back(*it);
- pending_queue.splice(pending_queue.begin(), rescanned);
- act_token = pending_queue.front();
- id = token_id(act_token);
- pending_queue.pop_front();
- }
- break;
- case T_EOF:
- seen_newline = true;
- break;
- default:
- if (IS_CATEGORY(id, WhiteSpaceTokenType))
- seen_newline = was_seen_newline;
- break;
- }
- if (token_is_valid(act_token) && whitespace.must_insert(id, act_token.get_value())) {
-
-
- whitespace.shift_tokens(T_SPACE);
- pending_queue.push_front(act_token);
- return act_token = result_type(T_SPACE,
- typename result_type::string_type(" "),
- act_token.get_position());
- }
- whitespace.shift_tokens(id);
- return ctx.get_hooks().generated_token(ctx.derived(), act_token);
- }
- template <typename ContextT>
- inline typename pp_iterator_functor<ContextT>::result_type const &
- pp_iterator_functor<ContextT>::get_next_token()
- {
- using namespace boost::wave;
-
-
- if (!pending_queue.empty() || !unput_queue.empty())
- return pp_token();
-
-
- bool returned_from_include_file = returned_from_include();
-
- if (iter_ctx->first != iter_ctx->last) {
- do {
-
-
-
- if (!pending_queue.empty()) {
- util::on_exit::pop_front<token_sequence_type>
- pop_front_token(pending_queue);
- return act_token = pending_queue.front();
- }
-
- bool was_seen_newline = seen_newline || returned_from_include_file;
-
- act_token = *iter_ctx->first;
- act_pos = act_token.get_position();
-
- token_id id = token_id(act_token);
- if (T_EOF == id) {
-
- whitespace.shift_tokens(T_EOF);
- ++iter_ctx->first;
-
- if ((!seen_newline || act_pos.get_column() > 1) &&
- !need_single_line(ctx.get_language()))
- {
- if (need_no_newline_at_end_of_file(ctx.get_language()))
- {
- seen_newline = true;
- pending_queue.push_back(
- result_type(T_NEWLINE, "\n", act_pos)
- );
- }
- else
- {
-
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- last_line_not_terminated, "", act_pos);
- }
- }
- continue;
- }
- else if (T_NEWLINE == id || T_CPPCOMMENT == id) {
-
-
- seen_newline = true;
- ++iter_ctx->first;
- if (!ctx.get_if_block_status()) {
-
- whitespace.shift_tokens(id);
- util::impl::call_skipped_token_hook(ctx, act_token);
- continue;
- }
- return act_token;
- }
- seen_newline = false;
- if (was_seen_newline && pp_directive()) {
-
- if (iter_ctx->first == iter_ctx->last)
- {
- seen_newline = true;
- act_token = result_type(T_NEWLINE, "\n", act_pos);
- }
-
-
-
- }
- else if (ctx.get_if_block_status()) {
-
-
- return pp_token();
- }
- else {
-
-
-
- if (T_NEWLINE == token_id(act_token)) {
- seen_newline = true;
- must_emit_line_directive = true;
- }
-
- util::impl::call_skipped_token_hook(ctx, act_token);
- ++iter_ctx->first;
- }
- } while ((iter_ctx->first != iter_ctx->last) ||
- (returned_from_include_file = returned_from_include()));
-
- if (ctx.get_if_block_depth() > 0 && !need_single_line(ctx.get_language()))
- {
-
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- missing_matching_endif, "", act_pos);
- }
- }
- else {
- act_token = eof;
- }
- return act_token;
- }
- template <typename ContextT>
- inline bool
- pp_iterator_functor<ContextT>::emit_line_directive()
- {
- using namespace boost::wave;
- typename ContextT::position_type pos = act_token.get_position();
- if (must_emit_line_directive ||
- iter_ctx->emitted_lines+1 != act_pos.get_line())
- {
-
- pending_queue.push_front(act_token);
- pos.set_line(act_pos.get_line());
- if (iter_ctx->emitted_lines+2 == act_pos.get_line() && act_pos.get_line() != 1) {
-
- act_token = result_type(T_NEWLINE, "\n", pos);
- }
- else {
-
- act_pos.set_line(act_pos.get_line()-1);
- iter_ctx->emitted_lines = act_pos.get_line()-1;
- token_sequence_type pending;
- if (!ctx.get_hooks().emit_line_directive(ctx, pending, act_token))
- {
- unsigned int column = 6;
-
- pos.set_column(1);
- pending.push_back(result_type(T_PP_LINE, "#line", pos));
- pos.set_column(column);
- pending.push_back(result_type(T_SPACE, " ", pos));
-
-
- std::string buffer = lexical_cast<std::string>(pos.get_line());
- pos.set_column(++column);
- pending.push_back(result_type(T_INTLIT, buffer.c_str(), pos));
- pos.set_column(column += (unsigned int)buffer.size());
- pending.push_back(result_type(T_SPACE, " ", pos));
- pos.set_column(++column);
- std::string file("\"");
- boost::filesystem::path filename(
- wave::util::create_path(act_pos.get_file().c_str()));
- using wave::util::impl::escape_lit;
- file += escape_lit(wave::util::native_file_string(filename)) + "\"";
- pending.push_back(result_type(T_STRINGLIT, file.c_str(), pos));
- pos.set_column(column += (unsigned int)file.size());
- pending.push_back(result_type(T_GENERATEDNEWLINE, "\n", pos));
- }
-
- if (!pending.empty()) {
- pending_queue.splice(pending_queue.begin(), pending);
- act_token = pending_queue.front();
- pending_queue.pop_front();
- }
- }
- must_emit_line_directive = false;
- return true;
- }
- must_emit_line_directive = false;
- return false;
- }
- template <typename ContextT>
- inline typename pp_iterator_functor<ContextT>::result_type const &
- pp_iterator_functor<ContextT>::pp_token()
- {
- using namespace boost::wave;
- token_id id = token_id(*iter_ctx->first);
-
-
- do {
- if (!pending_queue.empty()) {
-
- act_token = pending_queue.front();
- pending_queue.pop_front();
- act_pos = act_token.get_position();
- }
- else if (!unput_queue.empty()
- || T_IDENTIFIER == id
- || IS_CATEGORY(id, KeywordTokenType)
- || IS_EXTCATEGORY(id, OperatorTokenType|AltExtTokenType)
- || IS_CATEGORY(id, BoolLiteralTokenType))
- {
-
-
- act_token = ctx.expand_tokensequence(iter_ctx->first,
- iter_ctx->last, pending_queue, unput_queue, skipped_newline);
- }
- else {
-
- act_token = *iter_ctx->first;
- ++iter_ctx->first;
- }
- id = token_id(act_token);
- } while (T_PLACEHOLDER == id);
- return act_token;
- }
- namespace impl {
-
- template <typename ContextT>
- bool call_found_directive_hook(ContextT& ctx,
- typename ContextT::token_type const& found_directive)
- {
- if (ctx.get_hooks().found_directive(ctx.derived(), found_directive))
- return true;
- return false;
- }
- template <typename ContextT, typename IteratorT>
- bool next_token_is_pp_directive(ContextT &ctx, IteratorT &it, IteratorT const &end)
- {
- using namespace boost::wave;
- token_id id = T_UNKNOWN;
- for (; it != end; ++it) {
- id = token_id(*it);
- if (!IS_CATEGORY(id, WhiteSpaceTokenType))
- break;
- if (IS_CATEGORY(id, EOLTokenType) || IS_CATEGORY(id, EOFTokenType))
- break;
- if (T_CPPCOMMENT == id ||
- context_policies::util::ccomment_has_newline(*it))
- {
- break;
- }
-
- util::impl::call_skipped_token_hook(ctx, *it);
- }
- BOOST_ASSERT(it == end || id != T_UNKNOWN);
- return it != end && IS_CATEGORY(id, PPTokenType);
- }
-
- template <typename ContextT, typename IteratorT>
- bool pp_is_last_on_line(ContextT &ctx, IteratorT &it, IteratorT const &end,
- bool call_hook = true)
- {
- using namespace boost::wave;
-
- if (call_hook)
- util::impl::call_skipped_token_hook(ctx, *it);
- for (++it; it != end; ++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);
- ++it;
- return true;
- }
- if (!IS_CATEGORY(id, WhiteSpaceTokenType))
- break;
-
- if (call_hook)
- util::impl::call_skipped_token_hook(ctx, *it);
- }
- return need_no_newline_at_end_of_file(ctx.get_language()) &&
- ((it == end) || (T_EOF == token_id(*it)));
- }
-
- template <typename ContextT, typename IteratorT>
- bool skip_to_eol(ContextT &ctx, IteratorT &it, IteratorT const &end,
- bool call_hook = true)
- {
- using namespace boost::wave;
- for (; it != end; ++it) {
- token_id id = token_id(*it);
- if (T_CPPCOMMENT == id || T_NEWLINE == id ||
- context_policies::util::ccomment_has_newline(*it))
- {
-
- util::impl::call_skipped_token_hook(ctx, *it);
- ++it;
- return true;
- }
- if (call_hook)
- util::impl::call_skipped_token_hook(ctx, *it);
- }
- return false;
- }
-
- template <typename ContextT, typename ContainerT>
- inline void
- remove_leading_whitespace(ContextT &ctx, ContainerT& c, bool call_hook = true)
- {
- typename ContainerT::iterator it = c.begin();
- while (IS_CATEGORY(*it, WhiteSpaceTokenType)) {
- typename ContainerT::iterator save = it++;
- if (call_hook)
- util::impl::call_skipped_token_hook(ctx, *save);
- c.erase(save);
- }
- }
- }
- template <typename ContextT>
- template <typename IteratorT>
- inline bool
- pp_iterator_functor<ContextT>::extract_identifier(IteratorT &it)
- {
- token_id id = util::impl::skip_whitespace(it, iter_ctx->last);
- if (T_IDENTIFIER == id || IS_CATEGORY(id, KeywordTokenType) ||
- IS_EXTCATEGORY(id, OperatorTokenType|AltExtTokenType) ||
- IS_CATEGORY(id, BoolLiteralTokenType))
- {
- IteratorT save = it;
- if (impl::pp_is_last_on_line(ctx, save, iter_ctx->last, false))
- return true;
- }
-
- impl::skip_to_eol(ctx, it, iter_ctx->last);
- string_type str(util::impl::as_string<string_type>(iter_ctx->first, it));
- seen_newline = true;
- iter_ctx->first = it;
- on_illformed(str);
- return false;
- }
- template <typename ContextT>
- template <typename IteratorT>
- inline bool
- pp_iterator_functor<ContextT>::ensure_is_last_on_line(IteratorT& it, bool call_hook)
- {
- if (!impl::pp_is_last_on_line(ctx, it, iter_ctx->last, call_hook))
- {
-
- impl::skip_to_eol(ctx, it, iter_ctx->last);
- string_type str(util::impl::as_string<string_type>(iter_ctx->first, it));
- seen_newline = true;
- iter_ctx->first = it;
-
- on_illformed(str);
- return false;
- }
- if (it == iter_ctx->last && !need_single_line(ctx.get_language()))
- {
-
- seen_newline = true;
- iter_ctx->first = it;
- if (!need_no_newline_at_end_of_file(ctx.get_language()))
- {
-
-
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- last_line_not_terminated, "", act_pos);
- }
- return false;
- }
- return true;
- }
- template <typename ContextT>
- template <typename IteratorT>
- inline bool
- pp_iterator_functor<ContextT>::skip_to_eol_with_check(IteratorT &it, bool call_hook)
- {
- typename ContextT::string_type value ((*it).get_value());
- if (!impl::skip_to_eol(ctx, it, iter_ctx->last, call_hook) &&
- !need_single_line(ctx.get_language()))
- {
-
- seen_newline = true;
- iter_ctx->first = it;
- if (!need_no_newline_at_end_of_file(ctx.get_language()))
- {
-
-
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- last_line_not_terminated, "", act_pos);
- }
- return false;
- }
-
- seen_newline = true;
- iter_ctx->first = it;
- return true;
- }
- template <typename ContextT>
- template <typename IteratorT>
- inline bool
- pp_iterator_functor<ContextT>::handle_pp_directive(IteratorT &it)
- {
- token_id id = token_id(*it);
- bool can_exit = true;
- bool call_hook_in_skip = true;
- if (!ctx.get_if_block_status()) {
- if (IS_EXTCATEGORY(*it, PPConditionalTokenType)) {
-
- switch (id) {
- case T_PP_IFDEF:
- case T_PP_IFNDEF:
- case T_PP_IF:
- ctx.enter_if_block(false);
- break;
- case T_PP_ELIF:
- if (!ctx.get_enclosing_if_block_status()) {
- if (!ctx.enter_elif_block(false)) {
-
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- missing_matching_if, "#elif", act_pos);
- return true;
- }
- }
- else {
- can_exit = false;
- }
- break;
- case T_PP_ELSE:
- case T_PP_ENDIF:
- {
-
- if (T_PP_ELSE == token_id(*it))
- on_else();
- else
- on_endif();
-
-
- ensure_is_last_on_line(it);
-
- seen_newline = true;
- iter_ctx->first = it;
- }
- if (T_PP_ENDIF == id)
- must_emit_line_directive = true;
- return true;
- default:
- on_illformed((*it).get_value());
- break;
- }
- }
- else {
- util::impl::call_skipped_token_hook(ctx, *it);
- ++it;
- }
- }
- else {
-
- result_type directive = *it;
- bool include_next = false;
- switch (id) {
- case T_PP_QHEADER:
- #if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
- case T_PP_QHEADER_NEXT:
- #endif
- include_next = (T_PP_QHEADER_NEXT == id) ? true : false;
- if (!impl::call_found_directive_hook(ctx, *it))
- {
- string_type dir((*it).get_value());
-
-
- if (ensure_is_last_on_line(it))
- {
- seen_newline = true;
- iter_ctx->first = it;
- on_include (dir, false, include_next);
- }
- return true;
- }
- break;
- case T_PP_HHEADER:
- #if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
- case T_PP_HHEADER_NEXT:
- #endif
- include_next = (T_PP_HHEADER_NEXT == id) ? true : false;
- if (!impl::call_found_directive_hook(ctx, *it))
- {
- string_type dir((*it).get_value());
-
-
- if (ensure_is_last_on_line(it))
- {
- seen_newline = true;
- iter_ctx->first = it;
- on_include (dir, true, include_next);
- }
- return true;
- }
- break;
- case T_PP_ELSE:
- case T_PP_ENDIF:
- if (!impl::call_found_directive_hook(ctx, *it))
- {
-
- if (T_PP_ELSE == token_id(*it))
- on_else();
- else
- on_endif();
-
-
- ensure_is_last_on_line(it);
-
- seen_newline = true;
- iter_ctx->first = it;
- if (T_PP_ENDIF == id)
- must_emit_line_directive = true;
- return true;
- }
- break;
-
-
- case T_PP_UNDEF:
- if (!impl::call_found_directive_hook(ctx, *it) &&
- extract_identifier(it))
- {
- on_undefine(it);
- }
- call_hook_in_skip = false;
- break;
- #if BOOST_WAVE_SUPPORT_MS_EXTENSIONS != 0
- #endif
- default:
- can_exit = false;
- break;
- }
- }
-
- if (can_exit) {
- skip_to_eol_with_check(it, call_hook_in_skip);
- return true;
- }
- return false;
- }
- template <typename ContextT>
- inline bool
- pp_iterator_functor<ContextT>::pp_directive()
- {
- using namespace cpplexer;
-
- lexer_type it = iter_ctx->first;
- if (!impl::next_token_is_pp_directive(ctx, it, iter_ctx->last)) {
-
- if (it != iter_ctx->last && T_POUND == BASE_TOKEN(token_id(*it))) {
- if (impl::pp_is_last_on_line(ctx, it, iter_ctx->last)) {
-
- seen_newline = true;
- iter_ctx->first = it;
- return true;
- }
- else if (ctx.get_if_block_status()) {
-
- impl::skip_to_eol(ctx, it, iter_ctx->last);
- seen_newline = true;
- string_type str(boost::wave::util::impl::as_string<string_type>(
- iter_ctx->first, it));
- token_sequence_type faulty_line;
- for (; iter_ctx->first != it; ++iter_ctx->first)
- faulty_line.push_back(*iter_ctx->first);
- token_sequence_type pending;
- if (ctx.get_hooks().found_unknown_directive(ctx, faulty_line, pending))
- {
-
- if (!pending.empty())
- pending_queue.splice(pending_queue.begin(), pending);
- return true;
- }
-
- on_illformed(str);
- }
- }
-
- return false;
- }
-
- if (it == iter_ctx->last)
- return false;
-
-
- if (handle_pp_directive(it)) {
-
-
- return true;
- }
-
- bool found_eof = false;
- result_type found_directive;
- token_sequence_type found_eoltokens;
- tree_parse_info_type hit = cpp_grammar_type::parse_cpp_grammar(
- it, iter_ctx->last, act_pos, found_eof, found_directive, found_eoltokens);
- if (hit.match) {
-
-
- iter_ctx->first = hit.stop;
- seen_newline = true;
- must_emit_line_directive = true;
-
-
- bool result = dispatch_directive(hit, found_directive, found_eoltokens);
- if (found_eof && !need_single_line(ctx.get_language()) &&
- !need_no_newline_at_end_of_file(ctx.get_language()))
- {
-
-
-
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- last_line_not_terminated, "", act_pos);
- }
- return result;
- }
- else if (token_id(found_directive) != T_EOF) {
-
- impl::skip_to_eol(ctx, it, iter_ctx->last);
- seen_newline = true;
- string_type str(boost::wave::util::impl::as_string<string_type>(
- iter_ctx->first, it));
- iter_ctx->first = it;
-
- on_illformed(str);
- }
- return false;
- }
- template <typename ContextT>
- inline bool
- pp_iterator_functor<ContextT>::dispatch_directive(
- tree_parse_info_type const &hit, result_type const& found_directive,
- token_sequence_type const& found_eoltokens)
- {
- using namespace cpplexer;
- typedef typename parse_tree_type::const_iterator const_child_iterator_t;
-
- const_child_iterator_t begin = hit.trees.begin();
-
- parse_tree_type const& root = (*begin).children;
- parse_node_value_type const& nodeval = get_first_leaf(*root.begin()).value;
-
- 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 = token_id(found_directive);
-
- if (impl::call_found_directive_hook(ctx, found_directive))
- return true;
- switch (id) {
- case T_PP_INCLUDE:
- #if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
- case T_PP_INCLUDE_NEXT:
- #endif
- on_include (begin_child_it, end_child_it, T_PP_INCLUDE_NEXT == id);
- break;
- case T_PP_DEFINE:
- on_define (*begin);
- break;
- case T_PP_IFDEF:
- on_ifdef(found_directive, begin_child_it, end_child_it);
- break;
- case T_PP_IFNDEF:
- on_ifndef(found_directive, begin_child_it, end_child_it);
- break;
- case T_PP_IF:
- on_if(found_directive, begin_child_it, end_child_it);
- break;
- case T_PP_ELIF:
- on_elif(found_directive, begin_child_it, end_child_it);
- break;
- case T_PP_LINE:
- on_line(begin_child_it, end_child_it);
- break;
- case T_PP_ERROR:
- on_error(begin_child_it, end_child_it);
- break;
- #if BOOST_WAVE_SUPPORT_WARNING_DIRECTIVE != 0
- case T_PP_WARNING:
- on_warning(begin_child_it, end_child_it);
- break;
- #endif
- case T_PP_PRAGMA:
- return on_pragma(begin_child_it, end_child_it);
- #if BOOST_WAVE_SUPPORT_MS_EXTENSIONS != 0
- case T_MSEXT_PP_REGION:
- case T_MSEXT_PP_ENDREGION:
- break;
- #endif
- default:
- on_illformed((*nodeval.begin()).get_value());
-
-
- {
- token_sequence_type expanded;
- get_token_value<result_type, parse_node_type> get_value;
- std::copy(make_ref_transform_iterator(begin_child_it, get_value),
- make_ref_transform_iterator(end_child_it, get_value),
- std::inserter(expanded, expanded.end()));
- pending_queue.splice(pending_queue.begin(), expanded);
- }
- break;
- }
-
- typename token_sequence_type::const_iterator eol = found_eoltokens.begin();
- impl::skip_to_eol(ctx, eol, found_eoltokens.end());
- return true;
- }
- template <typename ContextT>
- inline void
- pp_iterator_functor<ContextT>::on_include (string_type const &s,
- bool is_system, bool include_next)
- {
- BOOST_ASSERT(ctx.get_if_block_status());
- typename string_type::size_type pos_end = s.find_last_of(is_system ? '>' : '\"');
- if (string_type::npos == pos_end) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_statement,
- s.c_str(), act_pos);
- return;
- }
- typename string_type::size_type pos_begin =
- s.find_last_of(is_system ? '<' : '\"', pos_end-1);
- if (string_type::npos == pos_begin) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_statement,
- s.c_str(), act_pos);
- return;
- }
- std::string file_token(s.substr(pos_begin, pos_end - pos_begin + 1).c_str());
- std::string file_path(s.substr(pos_begin + 1, pos_end - pos_begin - 1).c_str());
-
- on_include_helper(file_token.c_str(), file_path.c_str(), is_system,
- include_next);
- }
- template <typename ContextT>
- inline bool
- pp_iterator_functor<ContextT>::on_include_helper(char const* f, char const* s,
- bool is_system, bool include_next)
- {
- namespace fs = boost::filesystem;
-
- std::string file_path(s);
- std::string dir_path;
- #if BOOST_WAVE_SUPPORT_INCLUDE_NEXT != 0
- char const* current_name = include_next ? iter_ctx->real_filename.c_str() : 0;
- #else
- char const* current_name = 0;
- #endif
- if (ctx.get_hooks().found_include_directive(ctx.derived(), f, include_next))
- return true;
- file_path = util::impl::unescape_lit(file_path);
- std::string native_path_str;
- if (!ctx.get_hooks().locate_include_file(ctx, file_path, is_system,
- current_name, dir_path, native_path_str))
- {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_file,
- file_path.c_str(), act_pos);
- return false;
- }
- #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
- if (!ctx.has_pragma_once(native_path_str))
- #endif
- {
-
- ctx.set_current_directory(native_path_str.c_str());
-
- boost::shared_ptr<base_iteration_context_type> new_iter_ctx(
- new iteration_context_type(ctx, native_path_str.c_str(), act_pos,
- boost::wave::enable_prefer_pp_numbers(ctx.get_language()),
- is_system ? base_iteration_context_type::system_header :
- base_iteration_context_type::user_header));
-
- ctx.get_hooks().opened_include_file(ctx.derived(), dir_path, file_path,
- is_system);
-
- iter_ctx->real_relative_filename = ctx.get_current_relative_filename().c_str();
- iter_ctx->filename = act_pos.get_file();
- iter_ctx->line = act_pos.get_line();
- iter_ctx->if_block_depth = ctx.get_if_block_depth();
- iter_ctx->emitted_lines = (unsigned int)(-1);
-
- ctx.push_iteration_context(act_pos, iter_ctx);
- iter_ctx = new_iter_ctx;
- seen_newline = true;
- must_emit_line_directive = true;
- act_pos.set_file(iter_ctx->filename);
- #if BOOST_WAVE_SUPPORT_PRAGMA_ONCE != 0
- fs::path rfp(wave::util::create_path(iter_ctx->real_filename.c_str()));
- std::string real_filename(rfp.string());
- ctx.set_current_filename(real_filename.c_str());
- #endif
- ctx.set_current_relative_filename(dir_path.c_str());
- iter_ctx->real_relative_filename = dir_path.c_str();
- act_pos.set_line(iter_ctx->line);
- act_pos.set_column(0);
- }
- return true;
- }
- template <typename ContextT>
- inline void
- pp_iterator_functor<ContextT>::on_include(
- typename parse_tree_type::const_iterator const &begin,
- typename parse_tree_type::const_iterator const &end, bool include_next)
- {
- BOOST_ASSERT(ctx.get_if_block_status());
-
- get_token_value<result_type, parse_node_type> get_value;
- token_sequence_type expanded;
- token_sequence_type toexpand;
- std::copy(make_ref_transform_iterator(begin, get_value),
- make_ref_transform_iterator(end, get_value),
- std::inserter(toexpand, toexpand.end()));
- typename token_sequence_type::iterator begin2 = toexpand.begin();
-
- ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded,
- false, false);
-
- using namespace boost::wave::util::impl;
- string_type s (trim_whitespace(as_string(expanded)));
- bool is_system = '<' == s[0] && '>' == s[s.size()-1];
- if (!is_system && !('\"' == s[0] && '\"' == s[s.size()-1])) {
-
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, bad_include_statement,
- s.c_str(), act_pos);
- return;
- }
- on_include(s, is_system, include_next);
- }
- template <typename ContextT>
- inline void
- pp_iterator_functor<ContextT>::on_define (parse_node_type const &node)
- {
- BOOST_ASSERT(ctx.get_if_block_status());
-
- result_type macroname;
- std::vector<result_type> macroparameters;
- token_sequence_type macrodefinition;
- bool has_parameters = false;
- position_type pos(act_token.get_position());
- if (!boost::wave::util::retrieve_macroname(ctx, node,
- BOOST_WAVE_PLAIN_DEFINE_ID, macroname, pos, false))
- return;
- has_parameters = boost::wave::util::retrieve_macrodefinition(node,
- BOOST_WAVE_MACRO_PARAMETERS_ID, macroparameters, pos, false);
- boost::wave::util::retrieve_macrodefinition(node,
- BOOST_WAVE_MACRO_DEFINITION_ID, macrodefinition, pos, false);
- if (has_parameters) {
- #if BOOST_WAVE_SUPPORT_VARIADICS_PLACEMARKERS != 0
- if (boost::wave::need_variadics(ctx.get_language())) {
-
-
- using namespace cpplexer;
- typedef typename std::vector<result_type>::iterator
- parameter_iterator_t;
- bool seen_ellipses = false;
- parameter_iterator_t end = macroparameters.end();
- for (parameter_iterator_t pit = macroparameters.begin();
- pit != end; ++pit)
- {
- if (seen_ellipses) {
-
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- bad_define_statement, macroname.get_value().c_str(),
- (*pit).get_position());
- return;
- }
- if (T_ELLIPSIS == token_id(*pit))
- seen_ellipses = true;
-
- if ("__VA_ARGS__" == (*pit).get_value()) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- bad_define_statement_va_args,
- macroname.get_value().c_str(), (*pit).get_position());
- return;
- }
- #if BOOST_WAVE_SUPPORT_VA_OPT != 0
-
- if (boost::wave::need_va_opt(ctx.get_language()) &&
- ("__VA_OPT__" == (*pit).get_value())) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- bad_define_statement_va_opt,
- macroname.get_value().c_str(), (*pit).get_position());
- return;
- }
- #endif
- }
-
-
- if (!seen_ellipses) {
- typedef typename token_sequence_type::iterator definition_iterator_t;
- bool seen_va_args = false;
- #if BOOST_WAVE_SUPPORT_VA_OPT != 0
- bool seen_va_opt = false;
- #endif
- definition_iterator_t pend = macrodefinition.end();
- for (definition_iterator_t dit = macrodefinition.begin();
- dit != pend; ++dit)
- {
- if (T_IDENTIFIER == token_id(*dit) &&
- "__VA_ARGS__" == (*dit).get_value())
- {
- seen_va_args = true;
- }
- #if BOOST_WAVE_SUPPORT_VA_OPT != 0
- if (T_IDENTIFIER == token_id(*dit) &&
- "__VA_OPT__" == (*dit).get_value())
- {
- seen_va_opt = true;
- }
- #endif
- }
- if (seen_va_args) {
-
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- bad_define_statement_va_args,
- macroname.get_value().c_str(), act_token.get_position());
- return;
- }
- #if BOOST_WAVE_SUPPORT_VA_OPT != 0
- if (seen_va_opt) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- bad_define_statement_va_opt,
- macroname.get_value().c_str(), act_token.get_position());
- return;
- }
- #endif
- }
- }
- else
- #endif
- {
-
- using namespace cpplexer;
- typedef typename std::vector<result_type>::iterator
- parameter_iterator_t;
- parameter_iterator_t end = macroparameters.end();
- for (parameter_iterator_t pit = macroparameters.begin();
- pit != end; ++pit)
- {
- if (T_ELLIPSIS == token_id(*pit)) {
-
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- bad_define_statement, macroname.get_value().c_str(),
- (*pit).get_position());
- return;
- }
- }
- }
- }
-
- ctx.add_macro_definition(macroname, has_parameters, macroparameters,
- macrodefinition);
- }
- template <typename ContextT>
- inline void
- pp_iterator_functor<ContextT>::on_undefine (lexer_type const &it)
- {
- BOOST_ASSERT(ctx.get_if_block_status());
-
- ctx.remove_macro_definition((*it).get_value());
- }
- template <typename ContextT>
- inline void
- pp_iterator_functor<ContextT>::on_ifdef(
- 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()));
- bool is_defined = false;
- do {
- is_defined = ctx.is_defined_macro(toexpand.begin(), toexpand.end());
- } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(),
- 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,
- 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()));
- bool is_defined = false;
- do {
- is_defined = ctx.is_defined_macro(toexpand.begin(), toexpand.end());
- } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(),
- found_directive, toexpand, is_defined));
- ctx.enter_if_block(!is_defined);
- }
- template <typename ContextT>
- inline void
- pp_iterator_functor<ContextT>::on_else()
- {
- if (!ctx.enter_else_block()) {
-
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, missing_matching_if,
- "#else", act_pos);
- }
- }
- template <typename ContextT>
- inline void
- pp_iterator_functor<ContextT>::on_endif()
- {
- if (!ctx.exit_if_block()) {
-
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, missing_matching_if,
- "#endif", act_pos);
- }
- }
- template <typename ContextT>
- inline void
- pp_iterator_functor<ContextT>::replace_undefined_identifiers(
- token_sequence_type &expanded)
- {
- typename token_sequence_type::iterator exp_end = expanded.end();
- for (typename token_sequence_type::iterator exp_it = expanded.begin();
- exp_it != exp_end; ++exp_it)
- {
- using namespace boost::wave;
- token_id id = token_id(*exp_it);
- if (IS_CATEGORY(id, IdentifierTokenType) ||
- IS_CATEGORY(id, KeywordTokenType))
- {
- (*exp_it).set_token_id(T_INTLIT);
- (*exp_it).set_value("0");
- }
- }
- }
- template <typename ContextT>
- inline void
- pp_iterator_functor<ContextT>::on_if(
- 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, get_value),
- make_ref_transform_iterator(end, get_value),
- std::inserter(toexpand, toexpand.end()));
- impl::remove_leading_whitespace(ctx, toexpand);
- bool if_status = false;
- grammars::value_error status = grammars::error_noerror;
- token_sequence_type expanded;
- do {
- expanded.clear();
- typename token_sequence_type::iterator begin2 = toexpand.begin();
- ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded);
-
- replace_undefined_identifiers(expanded);
- #if BOOST_WAVE_DUMP_CONDITIONAL_EXPRESSIONS != 0
- {
- string_type outstr(boost::wave::util::impl::as_string(toexpand));
- outstr += "(" + boost::wave::util::impl::as_string(expanded) + ")";
- BOOST_WAVE_DUMP_CONDITIONAL_EXPRESSIONS_OUT << "#if " << outstr
- << std::endl;
- }
- #endif
- try {
-
- if_status = grammars::expression_grammar_gen<result_type>::
- evaluate(expanded.begin(), expanded.end(), act_pos,
- ctx.get_if_block_status(), status);
- }
- catch (boost::wave::preprocess_exception const& e) {
-
- ctx.get_hooks().throw_exception(ctx.derived(), e);
- break;
- }
- } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(),
- found_directive, toexpand, if_status)
- && status == grammars::error_noerror);
- ctx.enter_if_block(if_status);
- if (grammars::error_noerror != status) {
-
- string_type expression = util::impl::as_string(expanded);
- if (0 == expression.size())
- expression = "<empty expression>";
- if (grammars::error_division_by_zero & status) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, division_by_zero,
- expression.c_str(), act_pos);
- }
- else if (grammars::error_integer_overflow & status) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, integer_overflow,
- expression.c_str(), act_pos);
- }
- else if (grammars::error_character_overflow & status) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- character_literal_out_of_range, expression.c_str(), act_pos);
- }
- }
- }
- template <typename ContextT>
- inline void
- pp_iterator_functor<ContextT>::on_elif(
- 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, get_value),
- make_ref_transform_iterator(end, get_value),
- std::inserter(toexpand, toexpand.end()));
- impl::remove_leading_whitespace(ctx, toexpand);
-
- if (ctx.get_if_block_some_part_status()) {
- if (!ctx.enter_elif_block(false)) {
-
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- missing_matching_if, "#elif", act_pos);
-
- }
-
- typename token_sequence_type::iterator begin2 = toexpand.begin();
- impl::skip_to_eol(ctx, begin2, toexpand.end());
- return;
- }
-
- bool if_status = false;
- grammars::value_error status = grammars::error_noerror;
- token_sequence_type expanded;
- do {
- expanded.clear();
- typename token_sequence_type::iterator begin2 = toexpand.begin();
- ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded);
-
- replace_undefined_identifiers(expanded);
- #if BOOST_WAVE_DUMP_CONDITIONAL_EXPRESSIONS != 0
- {
- string_type outstr(boost::wave::util::impl::as_string(toexpand));
- outstr += "(" + boost::wave::util::impl::as_string(expanded) + ")";
- BOOST_WAVE_DUMP_CONDITIONAL_EXPRESSIONS_OUT << "#elif " << outstr << std::endl;
- }
- #endif
- try {
-
- if_status = grammars::expression_grammar_gen<result_type>::
- evaluate(expanded.begin(), expanded.end(), act_pos,
- ctx.get_if_block_status(), status);
- }
- catch (boost::wave::preprocess_exception const& e) {
-
- ctx.get_hooks().throw_exception(ctx.derived(), e);
- }
- } while (ctx.get_hooks().evaluated_conditional_expression(ctx.derived(),
- found_directive, toexpand, if_status)
- && status == grammars::error_noerror);
- if (!ctx.enter_elif_block(if_status)) {
-
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, missing_matching_if,
- "#elif", act_pos);
- return;
- }
- if (grammars::error_noerror != status) {
-
- string_type expression = util::impl::as_string(expanded);
- if (0 == expression.size())
- expression = "<empty expression>";
- if (grammars::error_division_by_zero & status) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, division_by_zero,
- expression.c_str(), act_pos);
- }
- else if (grammars::error_integer_overflow & status) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- integer_overflow, expression.c_str(), act_pos);
- }
- else if (grammars::error_character_overflow & status) {
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception,
- character_literal_out_of_range, expression.c_str(), act_pos);
- }
- }
- }
- template <typename ContextT>
- inline void
- pp_iterator_functor<ContextT>::on_illformed(
- typename result_type::string_type s)
- {
- BOOST_ASSERT(ctx.get_if_block_status());
-
- typename string_type::size_type p = s.find_last_not_of('\n');
- if (string_type::npos != p)
- s = s.substr(0, p+1);
-
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, ill_formed_directive,
- s.c_str(), act_pos);
- }
- namespace impl {
- template <typename IteratorT, typename StringT>
- bool retrieve_line_info (IteratorT first, IteratorT const &last,
- unsigned int &line, StringT &file,
- boost::wave::preprocess_exception::error_code& error)
- {
- using namespace boost::wave;
- token_id id = token_id(*first);
- if (T_PP_NUMBER == id || T_INTLIT == id) {
-
- using namespace std;
- line = (unsigned int)atoi((*first).get_value().c_str());
- if (0 == line)
- error = preprocess_exception::bad_line_number;
-
- using namespace boost::spirit::classic;
- if (!parse((*first).get_value().c_str(), int_p).full)
- error = preprocess_exception::bad_line_number;
-
- while (++first != last && IS_CATEGORY(*first, WhiteSpaceTokenType))
- ;
- if (first != last) {
- if (T_STRINGLIT != token_id(*first)) {
- error = preprocess_exception::bad_line_filename;
- return false;
- }
- StringT const& file_lit = (*first).get_value();
- if ('L' == file_lit[0]) {
- error = preprocess_exception::bad_line_filename;
- return false;
- }
- file = file_lit.substr(1, file_lit.size()-2);
-
- while (++first != last && IS_CATEGORY(*first, WhiteSpaceTokenType))
- ;
- }
- return first == last;
- }
- error = preprocess_exception::bad_line_statement;
- return false;
- }
- }
- template <typename ContextT>
- inline void
- pp_iterator_functor<ContextT>::on_line(
- typename parse_tree_type::const_iterator const &begin,
- typename parse_tree_type::const_iterator const &end)
- {
- BOOST_ASSERT(ctx.get_if_block_status());
-
-
-
- token_sequence_type expanded;
- get_token_value<result_type, parse_node_type> get_value;
- typedef typename ref_transform_iterator_generator<
- get_token_value<result_type, parse_node_type>,
- typename parse_tree_type::const_iterator
- >::type const_tree_iterator_t;
- const_tree_iterator_t first = make_ref_transform_iterator(begin, get_value);
- const_tree_iterator_t last = make_ref_transform_iterator(end, get_value);
-
-
- unsigned int line = 0;
- preprocess_exception::error_code error = preprocess_exception::no_error;
- string_type file_name;
- token_sequence_type toexpand;
- std::copy(first, last, std::inserter(toexpand, toexpand.end()));
- if (!impl::retrieve_line_info(first, last, line, file_name, error)) {
-
- typename token_sequence_type::iterator begin2 = toexpand.begin();
- ctx.expand_whole_tokensequence(begin2, toexpand.end(),
- expanded, false, false);
- error = preprocess_exception::no_error;
- if (!impl::retrieve_line_info(expanded.begin(), expanded.end(),
- line, file_name, error))
- {
- typename ContextT::string_type msg(
- boost::wave::util::impl::as_string(expanded));
- BOOST_WAVE_THROW_VAR_CTX(ctx, preprocess_exception, error,
- msg.c_str(), act_pos);
- return;
- }
-
- ctx.get_hooks().found_line_directive(ctx.derived(), expanded, line,
- file_name.c_str());
- }
- else {
-
- ctx.get_hooks().found_line_directive(ctx.derived(), toexpand, line,
- file_name.c_str());
- }
-
- BOOST_ASSERT(unput_queue.empty());
- BOOST_ASSERT(pending_queue.empty());
-
- must_emit_line_directive = true;
-
- if (error != preprocess_exception::no_error) {
- typename ContextT::string_type msg(
- boost::wave::util::impl::as_string(expanded));
- BOOST_WAVE_THROW_VAR_CTX(ctx, preprocess_exception, error,
- msg.c_str(), act_pos);
- return;
- }
-
- if (!file_name.empty()) {
- using boost::wave::util::impl::unescape_lit;
- act_pos.set_file(unescape_lit(file_name).c_str());
- }
- act_pos.set_line(line);
- if (iter_ctx->first != iter_ctx->last)
- {
- iter_ctx->first.set_position(act_pos);
- }
- }
- template <typename ContextT>
- inline void
- pp_iterator_functor<ContextT>::on_error(
- typename parse_tree_type::const_iterator const &begin,
- typename parse_tree_type::const_iterator const &end)
- {
- BOOST_ASSERT(ctx.get_if_block_status());
-
- token_sequence_type expanded;
- get_token_value<result_type, parse_node_type> get_value;
- typename ref_transform_iterator_generator<
- get_token_value<result_type, parse_node_type>,
- typename parse_tree_type::const_iterator
- >::type first = make_ref_transform_iterator(begin, get_value);
- #if BOOST_WAVE_PREPROCESS_ERROR_MESSAGE_BODY != 0
-
- token_sequence_type toexpand;
- std::copy(first, make_ref_transform_iterator(end, get_value),
- std::inserter(toexpand, toexpand.end()));
- typename token_sequence_type::iterator begin2 = toexpand.begin();
- ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded,
- false, false);
- if (!ctx.get_hooks().found_error_directive(ctx.derived(), toexpand))
- #else
-
-
- std::copy(first, make_ref_transform_iterator(end, get_value),
- std::inserter(expanded, expanded.end()));
- if (!ctx.get_hooks().found_error_directive(ctx.derived(), expanded))
- #endif
- {
-
- BOOST_WAVE_STRINGTYPE msg(boost::wave::util::impl::as_string(expanded));
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, error_directive,
- msg.c_str(), act_pos);
- }
- }
- #if BOOST_WAVE_SUPPORT_WARNING_DIRECTIVE != 0
- template <typename ContextT>
- inline void
- pp_iterator_functor<ContextT>::on_warning(
- typename parse_tree_type::const_iterator const &begin,
- typename parse_tree_type::const_iterator const &end)
- {
- BOOST_ASSERT(ctx.get_if_block_status());
-
- token_sequence_type expanded;
- get_token_value<result_type, parse_node_type> get_value;
- typename ref_transform_iterator_generator<
- get_token_value<result_type, parse_node_type>,
- typename parse_tree_type::const_iterator
- >::type first = make_ref_transform_iterator(begin, get_value);
- #if BOOST_WAVE_PREPROCESS_ERROR_MESSAGE_BODY != 0
-
- token_sequence_type toexpand;
- std::copy(first, make_ref_transform_iterator(end, get_value),
- std::inserter(toexpand, toexpand.end()));
- typename token_sequence_type::iterator begin2 = toexpand.begin();
- ctx.expand_whole_tokensequence(begin2, toexpand.end(), expanded,
- false, false);
- if (!ctx.get_hooks().found_warning_directive(ctx.derived(), toexpand))
- #else
-
-
- std::copy(first, make_ref_transform_iterator(end, get_value),
- std::inserter(expanded, expanded.end()));
- if (!ctx.get_hooks().found_warning_directive(ctx.derived(), expanded))
- #endif
- {
-
- BOOST_WAVE_STRINGTYPE msg(boost::wave::util::impl::as_string(expanded));
- BOOST_WAVE_THROW_CTX(ctx, preprocess_exception, warning_directive,
- msg.c_str(), act_pos);
- }
- }
- #endif
- template <typename ContextT>
- inline bool
- pp_iterator_functor<ContextT>::on_pragma(
- typename parse_tree_type::const_iterator const &begin,
- typename parse_tree_type::const_iterator const &end)
- {
- using namespace boost::wave;
- BOOST_ASSERT(ctx.get_if_block_status());
-
-
-
- token_sequence_type expanded;
- get_token_value<result_type, parse_node_type> get_value;
- typedef typename ref_transform_iterator_generator<
- get_token_value<result_type, parse_node_type>,
- typename parse_tree_type::const_iterator
- >::type const_tree_iterator_t;
- const_tree_iterator_t first = make_ref_transform_iterator(begin, get_value);
- const_tree_iterator_t last = make_ref_transform_iterator(end, get_value);
- expanded.push_back(result_type(T_PP_PRAGMA, "#pragma", act_token.get_position()));
- while (first != last && IS_CATEGORY(*first, WhiteSpaceTokenType))
- expanded.push_back(*first++);
- if (first != last) {
- if (T_IDENTIFIER == token_id(*first) &&
- boost::wave::need_c99(ctx.get_language()) &&
- (*first).get_value() == "STDC")
- {
-
- std::copy(first, last, std::inserter(expanded, expanded.end()));
- }
- else {
- #if BOOST_WAVE_PREPROCESS_PRAGMA_BODY != 0
-
- token_sequence_type toexpand;
- std::copy(first, last, std::inserter(toexpand, toexpand.end()));
- typename token_sequence_type::iterator begin2 = toexpand.begin();
- ctx.expand_whole_tokensequence(begin2, toexpand.end(),
- expanded, false, false);
- #else
-
- std::copy(first, last, std::inserter(expanded, expanded.end()));
- #endif
- }
- }
-
- BOOST_ASSERT(unput_queue.empty());
- BOOST_ASSERT(pending_queue.empty());
-
- token_sequence_type pending;
- if (interpret_pragma(expanded, pending)) {
-
- if (!pending.empty())
- pending_queue.splice(pending_queue.begin(), pending);
- return true;
- }
- #if BOOST_WAVE_EMIT_PRAGMA_DIRECTIVES != 0
-
-
- if (boost::wave::need_emit_pragma_directives(ctx.get_language())) {
- pending_queue.splice(pending_queue.begin(), expanded);
- return false;
- }
- #endif
- return true;
- }
- template <typename ContextT>
- inline bool
- pp_iterator_functor<ContextT>::interpret_pragma(
- token_sequence_type const &pragma_body, token_sequence_type &result)
- {
- using namespace cpplexer;
- typename token_sequence_type::const_iterator end = pragma_body.end();
- typename token_sequence_type::const_iterator it = pragma_body.begin();
- for (++it; it != end && IS_CATEGORY(*it, WhiteSpaceTokenType); ++it)
- ;
- if (it == end)
- return false;
- return boost::wave::util::interpret_pragma(
- ctx.derived(), act_token, it, end, result);
- }
- }
- template <typename ContextT>
- class pp_iterator
- : public boost::spirit::classic::multi_pass<
- boost::wave::impl::pp_iterator_functor<ContextT>,
- boost::wave::util::functor_input
- >
- {
- public:
- typedef boost::wave::impl::pp_iterator_functor<ContextT> input_policy_type;
- private:
- typedef
- boost::spirit::classic::multi_pass<input_policy_type, boost::wave::util::functor_input>
- base_type;
- typedef pp_iterator<ContextT> self_type;
- typedef boost::wave::util::functor_input functor_input_type;
- public:
- pp_iterator()
- {}
- template <typename IteratorT>
- pp_iterator(ContextT &ctx, IteratorT const &first, IteratorT const &last,
- typename ContextT::position_type const &pos)
- : base_type(input_policy_type(ctx, first, last, pos))
- {}
- bool force_include(char const *path_, bool is_last)
- {
- bool result = this->get_functor().on_include_helper(path_, path_,
- false, false);
- if (is_last) {
- this->functor_input_type::
- template inner<input_policy_type>::advance_input();
- }
- return result;
- }
- };
- }
- }
- #ifdef BOOST_HAS_ABI_HEADERS
- #include BOOST_ABI_SUFFIX
- #endif
- #endif
|