00001 #ifndef XYZ_ATTRIBUTE_LIST_MAP
00002 #define XYZ_ATTRIBUTE_LIST_MAP
00003
00004 #define DEBUG_WAVE_ROSE_CONNECTION 1
00005 #define DEBUG_USE_ROSE_BOOST_WAVE_SUPPORT 1
00006
00007
00008
00009
00010
00012
00013 #ifndef _MSC_VER
00014 #include <boost/wave.hpp>
00015 #endif
00016
00018
00019 #include <boost/wave/cpplexer/cpp_lex_token.hpp>
00020 #include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
00021
00022
00023
00024
00026
00027
00029 NodeQuerySynthesizedAttributeType
00030 queryFloatDoubleValExp (SgNode * astNode);
00031
00032
00033
00034
00035
00036 class AttributeListMap {
00037
00038 private:
00039
00040
00041
00042 int rescan_macro_status;
00043 std::string macro_expand_filename;
00044
00045
00046 PreprocessingInfo::rose_macro_call* macro_call_to_expand;
00047 token_container currentTokSeq;
00048
00049
00050
00051
00052
00053 public:
00054
00055 typedef std::map<std::string,ROSEAttributesList*> attribute_map_type;
00056 attribute_map_type currentMapOfAttributes;
00057
00058 token_container* skippedTokenStream;
00059
00060
00061 std::map<std::pair<std::string,int>, PreprocessingInfo*> defMap;
00062
00063
00064
00065
00066
00067
00068 AttributeListMap(SgFile* sageFilePtr);
00069
00070 template <typename TokenT> bool found_include_directive(TokenT directive, std::string relname, std::string absname );
00071
00072
00073
00075
00076
00077
00078
00080 template <typename TokenT, typename ContainerT>
00081 bool
00082 found_directive(TokenT const& directive, ContainerT const& expression, bool expression_value)
00083 {
00084
00085 PreprocessingInfo::DirectiveType rose_typeid;
00086 using namespace boost::wave;
00087 token_id wave_typeid = token_id(directive);
00088
00089
00090
00091 switch(wave_typeid){
00092 case T_PP_DEFINE:
00093 rose_typeid = PreprocessingInfo::CpreprocessorDefineDeclaration;
00094 break;
00095 case T_PP_IFDEF:
00096 rose_typeid = PreprocessingInfo::CpreprocessorIfdefDeclaration;
00097 break;
00098 case T_PP_IFNDEF:
00099 rose_typeid = PreprocessingInfo::CpreprocessorIfndefDeclaration;
00100 break;
00101 case T_PP_IF:
00102 rose_typeid = PreprocessingInfo::CpreprocessorIfDeclaration;
00103 break;
00104 case T_PP_ELIF:
00105
00106
00107 rose_typeid = PreprocessingInfo::CpreprocessorElifDeclaration;
00108 break;
00109 case T_PP_ELSE:
00110 rose_typeid = PreprocessingInfo::CpreprocessorElseDeclaration;
00111 break;
00112 case T_PP_ENDIF:
00113 rose_typeid = PreprocessingInfo::CpreprocessorEndifDeclaration;
00114 break;
00115 case T_CPPCOMMENT:
00116 rose_typeid = PreprocessingInfo::CplusplusStyleComment;
00117 break;
00118 case T_CCOMMENT:
00119 rose_typeid = PreprocessingInfo::C_StyleComment;
00120 break;
00121 case T_PP_ERROR:
00122 rose_typeid = PreprocessingInfo::CpreprocessorErrorDeclaration;
00123 break;
00124 case T_PP_LINE:
00125 rose_typeid = PreprocessingInfo::CpreprocessorLineDeclaration;
00126 break;
00127 case T_PP_UNDEF:
00128 rose_typeid = PreprocessingInfo::CpreprocessorUndefDeclaration;
00129 break;
00130 case T_PP_WARNING:
00131 rose_typeid = PreprocessingInfo::CpreprocessorWarningDeclaration;
00132 break;
00133 case T_PP_QHEADER:
00134 case T_PP_HHEADER:
00135 case T_PP_INCLUDE:
00136 if(SgProject::get_verbose() >= 1)
00137 std::cout << "Token to include directive: " << directive.get_value() << std::endl;
00138 rose_typeid = PreprocessingInfo::CpreprocessorIncludeDeclaration;
00139 break;
00140 case T_PP_PRAGMA:
00141
00142 return false;
00143
00144
00145
00146 default:
00147
00148 ROSE_ASSERT(false==true);
00149 rose_typeid = PreprocessingInfo::CpreprocessorUnknownDeclaration;
00150 break;
00151
00152 }
00153 if(SgProject::get_verbose() >= 1){
00154
00155 std::cout << "THE FOUND DIRECTIVE IS: " << directive.get_value().c_str() << std::endl;
00156 std::cout << "THE FOUND DEF IS: " << boost::wave::util::impl::as_string(expression) << std::endl;
00157 }
00158
00159 std::string filename(directive.get_position().get_file().c_str());
00160 token_list_container tokListCont;
00161
00162 copy (expression.begin(), expression.end(),
00163 inserter(tokListCont, tokListCont.end()));
00164
00165
00166
00167 if(currentMapOfAttributes.find(filename)==currentMapOfAttributes.end())
00168 currentMapOfAttributes[filename] = new ROSEAttributesList();
00169 currentMapOfAttributes.find(filename)->second->addElement(*(new PreprocessingInfo(directive,tokListCont,expression_value,rose_typeid,PreprocessingInfo::before)));
00170
00171 return false;
00172 }
00173
00174
00175 template <typename TokenT, typename ContainerT>
00176 void
00177 update_token(TokenT const& token, ContainerT const& stream, bool expression_value)
00178 {
00179
00180 std::string filename(token.get_position().get_file().c_str());
00181
00182 ROSE_ASSERT(currentMapOfAttributes.find(filename) != currentMapOfAttributes.end());
00183
00184 std::vector<PreprocessingInfo*>& infos = currentMapOfAttributes.find(filename)->second->getList();
00185 for(std::vector<PreprocessingInfo*>::reverse_iterator i = infos.rbegin(); i != infos.rend(); ++i)
00186 {
00187
00188 if ((*(*i)->get_token_stream())[0] == token && (*(*i)->get_token_stream())[0].get_position() == token.get_position())
00189 {
00190
00191 for (typename ContainerT::const_iterator item = stream.begin(); item != stream.end(); ++item)
00192 {
00193 (*i)->push_back_token_stream(*item);
00194 }
00195 return;
00196 }
00197 }
00198 ROSE_ASSERT(!"Token to update not found!");
00199 }
00200
00201
00203
00204
00205
00206
00208
00209 template <typename TokenT>
00210 void
00211 found_directive(TokenT const& directive)
00212 {
00213
00214 PreprocessingInfo::DirectiveType rose_typeid;
00215 using namespace boost::wave;
00216 token_id wave_typeid = token_id(directive);
00217
00218
00219
00220 switch(wave_typeid){
00221 case T_PP_IFDEF:
00222 rose_typeid = PreprocessingInfo::CpreprocessorIfdefDeclaration;
00223 break;
00224 case T_PP_IFNDEF:
00225 rose_typeid = PreprocessingInfo::CpreprocessorIfndefDeclaration;
00226 break;
00227 case T_PP_IF:
00228 rose_typeid = PreprocessingInfo::CpreprocessorIfDeclaration;
00229 break;
00230
00231
00232 ROSE_ASSERT(false);
00233 break;
00234 case T_PP_DEFINE:
00235 rose_typeid = PreprocessingInfo::CpreprocessorDefineDeclaration;
00236 break;
00237 case T_PP_ELIF:
00238 rose_typeid = PreprocessingInfo::CpreprocessorElifDeclaration;
00239 break;
00240 case T_PP_ELSE:
00241 rose_typeid = PreprocessingInfo::CpreprocessorElseDeclaration;
00242 break;
00243 case T_PP_ENDIF:
00244 rose_typeid = PreprocessingInfo::CpreprocessorEndifDeclaration;
00245 break;
00246 case T_CPPCOMMENT:
00247 rose_typeid = PreprocessingInfo::CplusplusStyleComment;
00248 break;
00249 case T_CCOMMENT:
00250 rose_typeid = PreprocessingInfo::C_StyleComment;
00251 break;
00252 case T_PP_ERROR:
00253 rose_typeid = PreprocessingInfo::CpreprocessorErrorDeclaration;
00254 break;
00255 case T_PP_LINE:
00256 rose_typeid = PreprocessingInfo::CpreprocessorLineDeclaration;
00257 break;
00258 case T_PP_UNDEF:
00259 rose_typeid = PreprocessingInfo::CpreprocessorUndefDeclaration;
00260 break;
00261 case T_PP_WARNING:
00262 rose_typeid = PreprocessingInfo::CpreprocessorWarningDeclaration;
00263 break;
00264 case T_PP_QHEADER:
00265 case T_PP_HHEADER:
00266 case T_PP_INCLUDE:
00267 if(SgProject::get_verbose() >= 1)
00268 std::cout << "Token to include directive: " << directive.get_value() << std::endl;
00269 rose_typeid = PreprocessingInfo::CpreprocessorIncludeDeclaration;
00270 break;
00271 case boost::wave::T_PP_HHEADER_NEXT:
00272 if(SgProject::get_verbose() >= 1)
00273 std::cout << "Token to include next directive: " << directive.get_value() << std::endl;
00274 rose_typeid = PreprocessingInfo::CpreprocessorIncludeNextDeclaration;
00275
00276 break;
00277 case T_PP_PRAGMA:
00278
00279 return;
00280
00281
00282
00283
00284 default:
00285 {
00286
00287
00288
00289 if (SgProject::get_verbose() >= 1)
00290 {
00291 std::cout << "Error: Unknown preprocessor declaration found : " << directive.get_value().c_str() << std::endl;
00292 std::cout << boost::wave::get_token_name(wave_typeid) << " " << directive.get_position().get_file().c_str() << " " << directive.get_position().get_line()
00293 << " " << directive.get_position().get_column() << std::endl;
00294 ROSE_ASSERT(false);
00295 }
00296
00297 rose_typeid = PreprocessingInfo::CpreprocessorUnknownDeclaration;
00298 break;
00299 }
00300
00301 }
00302
00303
00304
00305 token_container currentTokSeq2;
00306 currentTokSeq2.push_back(directive);
00307 std::string filename(directive.get_position().get_file().c_str());
00308 if(currentMapOfAttributes.find(filename)==currentMapOfAttributes.end())
00309 currentMapOfAttributes[filename] = new ROSEAttributesList();
00310 currentMapOfAttributes.find(filename)->second->addElement(*(new PreprocessingInfo(currentTokSeq2,rose_typeid,PreprocessingInfo::before)));
00311
00312
00313 }
00314
00315
00316
00318
00319
00320
00321
00322
00323
00324
00326
00327 template<typename TokenT, typename ParametersT, typename DefinitionT>
00328 PreprocessingInfo* build_preprocessingInfo_macro_def(TokenT& macro_name, bool is_functionlike,
00329 ParametersT& parameters, DefinitionT &definition, bool is_predefined){
00330
00331 PreprocessingInfo::rose_macro_definition* macro_def = new PreprocessingInfo::rose_macro_definition();
00332
00333
00334 macro_def->is_functionlike = is_functionlike;
00335 macro_def->is_predefined = is_predefined;
00336
00337 macro_def->macro_name = macro_name;
00338 macro_def->paramaters = parameters;
00339
00340 copy (definition.begin(), definition.end(),
00341 inserter(macro_def->definition, macro_def->definition.end()));
00342 PreprocessingInfo* preprocMacroDef = new PreprocessingInfo(macro_def,PreprocessingInfo::before);
00343
00344 return preprocMacroDef;
00345 }
00346
00348
00349
00350
00352 template<typename TokenT, typename ParametersT, typename DefinitionT>
00353 void defined_macro(TokenT& macro_name, bool is_functionlike,
00354 ParametersT& parameters, DefinitionT &definition, bool is_predefined){
00355 if(skippedTokenStream != NULL){
00356
00357 if(macro_name.get_position().get_file().size()!=0){
00358 if(macro_name.get_position().get_file()!="<built-in>")
00359 skipped_token(macro_name,true);
00360 }else if(SgProject::get_verbose() >= 1)
00361 std::cout << "SKIPPED BECAUSE FILE IS NULL: " << macro_name.get_value().c_str() << std::endl;
00362
00363 }
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373 PreprocessingInfo* preprocMacroDef = build_preprocessingInfo_macro_def(macro_name, is_functionlike, parameters, definition, is_predefined);
00374 ROSE_ASSERT(preprocMacroDef != NULL);
00375
00376 Sg_File_Info* file_info = preprocMacroDef->get_file_info();
00377 ROSE_ASSERT(file_info != NULL);
00378
00379 std::string filename = file_info->get_filenameString();
00380
00381
00382
00383 ROSE_ASSERT(filename != "");
00384
00385 if(currentMapOfAttributes.find(filename)==currentMapOfAttributes.end())
00386 currentMapOfAttributes[filename] = new ROSEAttributesList();
00387 if(SgProject::get_verbose() >= 1)
00388 std::cout << "DONE adding to map" << std::endl;
00389 currentMapOfAttributes.find(filename)->second->addElement(*preprocMacroDef);
00390 if(SgProject::get_verbose() >= 1)
00391 std::cout << "Before mapKey" << std::endl;
00392
00393 std::pair<std::string,int> mapKey(filename,macro_name.get_position().get_line());
00394 if(SgProject::get_verbose() >= 1){
00395 std::cout << "After mapKey" << std::endl;
00396
00397 std::cout << "ASXXX Defining macro: " << macro_name.get_value().c_str() << std::endl;
00398 std::cout << "at " << filename << " l" << mapKey.second << std::endl;
00399 }
00400
00401
00402
00403
00404
00405
00406
00407 if( defMap.find(mapKey) == defMap.end() )
00408 defMap[mapKey]=preprocMacroDef;
00409
00410 }
00411
00413
00414
00415
00417 template<typename TokenT, typename ContainerT>
00418 bool expanding_function_like_macro(TokenT const ¯odef, std::vector<TokenT> const &formal_args,
00419 ContainerT const &definition, TokenT const ¯ocall, std::vector<ContainerT> const &arguments){
00420 if(skippedTokenStream != NULL)
00421 skipped_token(macrodef,true);
00422
00424
00425
00426
00427
00428
00429
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440 if(rescan_macro_status==0){
00441
00442 if(SgProject::get_verbose() >= 1){
00443
00444 std::cout << "DEFINITION: " << boost::wave::util::impl::as_string(definition);
00445
00446 std::cout << "\n MACRO CALL: " << macrocall.get_value() << std::endl;
00447 }
00448
00449 ROSE_ASSERT(macro_call_to_expand == NULL);
00450 macro_call_to_expand = new PreprocessingInfo::rose_macro_call();
00451 macro_call_to_expand->is_functionlike = true;
00452 macro_call_to_expand->macro_call = macrocall;
00453
00454
00455
00456
00457 std::pair<std::string,int> mapKey;
00458
00459 if(macrodef.get_position().get_file()!="<built-in>"){
00460 mapKey.first = string(macrodef.get_position().get_file().c_str());
00461 mapKey.second = macrodef.get_position().get_line();
00462 ROSE_ASSERT( defMap.find(mapKey) != defMap.end() );
00463 macro_call_to_expand->macro_def = defMap[mapKey];
00464
00465
00466 }else{
00467 bool is_function_like = true;
00468 bool is_predefined = false;
00469 macro_call_to_expand->macro_def = build_preprocessingInfo_macro_def(macrodef, is_function_like, formal_args, definition, is_predefined);
00470 }
00471
00472 if( (defMap.find(mapKey) == defMap.end())&&(SgProject::get_verbose() >= 1) ){
00473 std::cout << "Did not find: " << macrodef.get_value().c_str() << " " << boost::wave::util::impl::as_string(definition) << std::endl;
00474 std::cout << "in " << mapKey.first << " l " << mapKey.second << std::endl;
00475 };
00476
00477
00478
00479 typedef typename std::vector<ContainerT>::const_iterator vec_call_iterator_t;
00480
00481
00482
00483 vec_call_iterator_t it = arguments.begin();
00484 vec_call_iterator_t it_end = arguments.end();
00485
00486
00487
00488
00489 if(SgProject::get_verbose() >= 1)
00490 std::cout << "ARGUMENTS:\n";
00491
00492 while (it != it_end ){
00493 if(SgProject::get_verbose() >= 1){
00494 std::cout << boost::wave::util::impl::as_string(*it);
00495 }
00496 std::list<token_type> tk;
00497
00498 copy (it->begin(), it->end(),
00499 inserter(tk, tk.end()));
00500
00501 macro_call_to_expand->arguments.push_back(tk);
00502 ++it;
00503 }
00504
00505
00506 }
00507
00508 ++rescan_macro_status;
00509
00510
00511 #if 0
00512 typename testType::iterator it2 = test.begin();
00513 typename testType::iterator it_end2 = test.end();
00514
00515 while (it2 != it_end2 ){
00516 std::cout<< boost::wave::util::impl::as_string(*it2);
00517 ++it2;
00518 }
00519 #endif
00520 return false;
00521
00522 }
00523
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00536 template<typename TokenT, typename ContainerT>
00537 bool expanding_object_like_macro(TokenT const ¯o, ContainerT const &definition, TokenT const ¯ocall){
00538 if(skippedTokenStream != NULL)
00539 skipped_token(macro,true);
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554 if(rescan_macro_status==0){
00555 ROSE_ASSERT(macro_call_to_expand == NULL);
00556 if(SgProject::get_verbose() >= 1)
00557 std::cout << "DEFINITION: " << boost::wave::util::impl::as_string(definition);
00558
00559 macro_call_to_expand = new PreprocessingInfo::rose_macro_call();
00560
00561 macro_call_to_expand->is_functionlike = false;
00562 macro_call_to_expand->macro_call = macrocall;
00563
00564 std::pair<std::string,int> mapKey;
00565
00566 if( (macro.get_position().get_file().size() != 0 ) && (macro.get_position().get_file()!="<built-in>")
00567 && (macro.get_position().get_file()!="<command line>") ){
00568 mapKey.first = string(macro.get_position().get_file().c_str());
00569 mapKey.second = macro.get_position().get_line();
00570
00571 if( defMap.find(mapKey) == defMap.end() ){
00572 std::cout << "Did not find: " << macro.get_value().c_str() << " " <<
00573 macrocall.get_value().c_str() << " " << boost::wave::util::impl::as_string(definition) << std::endl;
00574 std::cout << "in " << mapKey.first << " l " << mapKey.second << std::endl;
00575 };
00576
00577 ROSE_ASSERT( defMap.find(mapKey) != defMap.end() );
00578 macro_call_to_expand->macro_def = defMap[mapKey];
00579
00580
00581 }else{
00582
00583 bool is_function_like = false;
00584 bool is_predefined = false;
00585
00586 token_container parameters;
00587 macro_call_to_expand->macro_def = build_preprocessingInfo_macro_def(macro, is_function_like, parameters, definition, is_predefined);
00588 }
00589
00590
00591 if(SgProject::get_verbose() >= 1)
00592 std::cout << "\n MACRO CALL: " << macrocall.get_value() << std::endl;
00593 }
00594
00595 ++rescan_macro_status;
00596 return false;
00597 }
00598
00600
00601
00602
00603
00604
00605
00606
00608 template <typename ContainerT>
00609 void expanded_macro(ContainerT const &result)
00610 {
00611
00612 }
00613
00614
00616
00617
00618
00619
00620
00621
00622
00623
00625 template <typename ContainerT>
00626 void rescanned_macro(ContainerT const &result)
00627 {
00628
00629
00630 --rescan_macro_status;
00631 ROSE_ASSERT( rescan_macro_status >= 0 );
00632 #if 0
00633 std::cout << "Rescanned macro: " << boost::wave::util::impl::as_string(result) << std::endl;
00634 #endif
00635 if(rescan_macro_status==0){
00636 ROSE_ASSERT(macro_call_to_expand != NULL);
00637
00638 copy (result.begin(), result.end(),
00639 inserter(macro_call_to_expand->expanded_macro, macro_call_to_expand->expanded_macro.end()));
00640
00641
00642
00643 std::string filename(macro_call_to_expand->macro_call.get_position().get_file().c_str());
00644 if(currentMapOfAttributes.find(filename)==currentMapOfAttributes.end())
00645 currentMapOfAttributes[filename] = new ROSEAttributesList();
00646 currentMapOfAttributes.find(filename)->second->addElement(*(new PreprocessingInfo(macro_call_to_expand,PreprocessingInfo::before)));
00647 macro_call_to_expand = NULL;
00648
00649 }
00650 }
00651
00653
00654
00655
00657
00658 template<typename TokenIterator, typename DirectiveType>
00659 struct findDirective: public std::binary_function<TokenIterator,DirectiveType,bool>
00660 {
00661 bool operator()(TokenIterator node, DirectiveType directive) const{
00662 bool returnValue = false;
00663
00664 using namespace boost::wave;
00665
00666 token_id wave_typeid = token_id(node);
00667
00668 if(wave_typeid == directive)
00669 returnValue = true;
00670
00671 return returnValue;
00672 };
00673
00674 };
00675
00677
00678
00679
00680
00682 template<typename TokenIterator, typename DirectiveType>
00683 struct findDirectiveInList: public std::binary_function<TokenIterator,std::list<DirectiveType>,bool>
00684 {
00685 bool operator()(TokenIterator node, std::list<DirectiveType> directiveList) const{
00686 bool returnValue = false;
00687
00688 using namespace boost::wave;
00689
00690 token_id wave_typeid = token_id(node);
00691 #if 0
00692
00693 if( T_PP_ELIF == wave_typeid)
00694 std::cout << "Found an #elif\n";
00695 #endif
00696
00697 if(std::find(directiveList.begin(),directiveList.end(), wave_typeid) != directiveList.end())
00698 returnValue = true;
00699
00700 return returnValue;
00701 };
00702
00703 };
00704
00705 template <typename TokenT>
00706 void
00707 skipped_token(TokenT const& token, bool last_skipped = false)
00708 {
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718 if(skippedTokenStream == NULL)
00719 skippedTokenStream = new token_container();
00720
00721 if(last_skipped == false)
00722 {
00723 if(SgProject::get_verbose() >= 1)
00724 std::cout << "Pushed Skipped Token: " << token.get_value().c_str() << std::endl;
00725 skippedTokenStream->push_back(token);
00726 }
00727 else
00728 {
00729 skippedTokenStream->push_back(token);
00730
00731 if(SgProject::get_verbose() >= 1)
00732 {
00733 std::cout << "Pushed Skipped Token: " << token.get_value().c_str() << std::endl;
00734 std::cout << "Popping Skipped Tokens: " << boost::wave::util::impl::as_string(*skippedTokenStream).c_str() << std::endl;
00735 }
00736 std::string filename(skippedTokenStream->begin()->get_position().get_file().c_str());
00737 if (currentMapOfAttributes.find(filename) == currentMapOfAttributes.end())
00738 currentMapOfAttributes[filename] = new ROSEAttributesList();
00739 currentMapOfAttributes.find(filename)->second->addElement(*(new PreprocessingInfo(*skippedTokenStream, PreprocessingInfo::CSkippedToken, PreprocessingInfo::before)));
00740
00741 ROSE_ASSERT(skippedTokenStream != NULL);
00742 delete skippedTokenStream;
00743 skippedTokenStream = NULL;
00744 }
00745 if (SgProject::get_verbose() >= 1)
00746 std::cout << "SKIPPED TOKEN: " << token.get_value().c_str() << std::endl;
00747 }
00748
00749 inline void flush_token_stream()
00750 {
00751 if (skippedTokenStream == NULL || skippedTokenStream->begin() == skippedTokenStream->end())
00752 return;
00753
00754 std::string filename(skippedTokenStream->begin()->get_position().get_file().c_str());
00755 if (currentMapOfAttributes.find(filename) == currentMapOfAttributes.end())
00756 currentMapOfAttributes[filename] = new ROSEAttributesList();
00757 currentMapOfAttributes.find(filename)->second->addElement(*(new PreprocessingInfo(*skippedTokenStream, PreprocessingInfo::CSkippedToken, PreprocessingInfo::before)));
00758 delete skippedTokenStream;
00759 skippedTokenStream = NULL;
00760 }
00761
00762 template <typename ContextT, typename TokenT>
00763 bool
00764 may_skip_whitespace(ContextT const& ctx, TokenT& token, bool& skipped_newline)
00765 {
00766 using namespace boost::wave;
00767
00768
00769 token_id id = token_id(token);
00770 bool skip = id == T_PP_ELSE || id == T_PP_ELIF || id == T_PP_ENDIF;
00771 using namespace boost::wave;
00772 if(SgProject::get_verbose() >= 1)
00773 {
00774 switch(token_id(token))
00775 {
00776 case T_PP_DEFINE: std::cout << "Skip White: #define\n"; break;
00777 case T_PP_IF: std::cout << "Skip White: #if\n"; break;
00778 case T_PP_IFDEF: std::cout << "Skip White: #ifdef\n"; break;
00779 case T_PP_IFNDEF: std::cout << "Skip White: #ifndef\n"; break;
00780 case T_PP_ELSE: std::cout << "Skip White: #else\n"; break;
00781 case T_PP_ELIF: std::cout << "Skip White: #elif\n"; break;
00782 case T_PP_ENDIF: std::cout << "Skip White: #endif\n"; break;
00783 case T_PP_ERROR: std::cout << "Skip White: #error\n"; break;
00784 case T_PP_LINE: std::cout << "Skip White: #line\n"; break;
00785 case T_PP_PRAGMA: std::cout << "Skip White: #pragma\n"; break;
00786 case T_PP_UNDEF: std::cout << "Skip White: #undef\n"; break;
00787 case T_PP_WARNING: std::cout << "Skip White: #warning\n"; break;
00788 case T_PP_INCLUDE: std::cout << "Skip White: #include \"...\"\n"; break;
00789 case T_PP_QHEADER: std::cout << "Skip White: #include <...>\n"; break;
00790 case T_PP_HHEADER: std::cout << "Skip White: #include ...\n"; break;
00791 default: std::cout << "Skip White: <something else (" << token.get_value() << ")>\n"; break;
00792 }
00793 }
00794 if (skip)
00795 {
00796 skipped_token(token, true);
00797 }
00798 else
00799 {
00800 if (skippedTokenStream != NULL)
00801 {
00802 if(SgProject::get_verbose() >= 1)
00803 {
00804 std::cout << "Whitespace makes us pop skipped tokens: " << boost::wave::util::impl::as_string(*skippedTokenStream).c_str() << std::endl;
00805 }
00806 flush_token_stream();
00807 }
00808 else if(SgProject::get_verbose() >= 1)
00809 std::cout << "Token stream is null?" << std::endl;
00810 }
00811
00812 if(SgProject::get_verbose() >= 1)
00813 std::cout << "MAX_SKIP_WHITESPACE: " << token.get_value().c_str() << std::endl;
00814 return false;
00815 }
00816
00817
00819
00820
00821
00822
00823
00825 void attach_line_to_macro_call();
00826
00827
00828 template<typename IteratorT>
00829 void attach_line_to_macro_call(std::vector<IteratorT*> vec){
00830 }
00831
00832 template <typename StringT, typename IteratorT>
00833 inline StringT
00834 as_string(IteratorT it, IteratorT end)
00835 {
00836 StringT result;
00837 for (; it != end; ++it)
00838 {
00839 result += (*it).get_value();
00840 }
00841 return result;
00842 }
00843 };
00844
00845
00846 template <typename TokenT>
00847 bool AttributeListMap::found_include_directive(TokenT directive, std::string relname, std::string absname )
00848 {
00849 boost::wave::token_id wave_typeid = boost::wave::token_id(directive);
00850
00851 switch(wave_typeid)
00852 {
00853 case boost::wave::T_PP_INCLUDE:
00854 break;
00855 case boost::wave::T_EOI:
00856 break;
00857 default:
00858
00859 if( directive.get_position().get_file().size() == 0 ) break;
00860
00861 PreprocessingInfo::r_include_directive* inclDir = new PreprocessingInfo::r_include_directive;
00862
00863 inclDir->directive = directive;
00864 inclDir->absname = absname;
00865 inclDir->relname = relname;
00866
00867 std::string filename(directive.get_position().get_file().c_str());
00868 if (currentMapOfAttributes.find(filename)==currentMapOfAttributes.end())
00869 currentMapOfAttributes[filename] = new ROSEAttributesList();
00870 currentMapOfAttributes.find(filename)->second->addElement(*(new PreprocessingInfo(inclDir, PreprocessingInfo::before ) ));
00871 break;
00872 }
00873 return false;
00874 }
00875
00876 #endif
00877
00878