1 #ifndef __ROSEAttributesList_H__
2 #define __ROSEAttributesList_H__
11 #include "general_token_defs.h"
56 #ifdef ROSE_DEBIAN_OS_VENDOR
57 #if (ROSE_BOOST_VERSION == 105400)
58 #define ROSE_SKIP_COMPILATION_OF_WAVE
66 #define ROSE_SKIP_COMPILATION_OF_WAVE
72 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
74 #if (!defined(_MSC_VER) || (_MSC_VER > 1600))
75 #include <boost/preprocessor/iteration/iterate.hpp>
77 #include <boost/wave.hpp>
79 #include <boost/wave/cpplexer/cpp_lex_token.hpp>
80 #include <boost/wave/cpplexer/cpp_lex_iterator.hpp>
85 #pragma message ("Boost preprocessor and wave not included yet for VC++ 10.0")
92 #ifndef NAMESPACE_IS_BROKEN
105 extern std::map<std::string,ROSEAttributesList* > mapFilenameToAttributes;
117 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
119 typedef boost::wave::cpplexer::lex_token<> token_type;
120 typedef std::vector<token_type> token_container;
121 typedef std::list<token_type> token_list_container;
122 typedef std::vector<std::list<token_type> > token_container_container;
157 CpreprocessorUnknownDeclaration,
161 CplusplusStyleComment,
168 CpreprocessorBlankLine,
171 CpreprocessorIncludeDeclaration,
172 CpreprocessorIncludeNextDeclaration,
173 CpreprocessorDefineDeclaration,
174 CpreprocessorUndefDeclaration,
175 CpreprocessorIfdefDeclaration,
176 CpreprocessorIfndefDeclaration,
177 CpreprocessorIfDeclaration,
178 CpreprocessorDeadIfDeclaration,
179 CpreprocessorElseDeclaration,
180 CpreprocessorElifDeclaration,
181 CpreprocessorEndifDeclaration,
182 CpreprocessorLineDeclaration,
183 CpreprocessorErrorDeclaration,
186 CpreprocessorWarningDeclaration,
187 CpreprocessorEmptyDeclaration,
206 ClinkageSpecificationStart,
207 ClinkageSpecificationEnd,
210 CpreprocessorIdentDeclaration,
222 CpreprocessorCompilerGeneratedLinemarker,
232 CpreprocessorEnd_ifDeclaration,
248 std::string internalString;
253 DirectiveType whatSortOfDirective;
259 int lineNumberForCompilerGeneratedLinemarker;
260 std::string filenameForCompilerGeneratedLinemarker;
261 std::string optionalflagsForCompilerGeneratedLinemarker;
268 bool p_isTransformation;
284 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
288 token_container* tokenStream;
295 token_type directive;
304 bool is_functionlike;
306 token_type macro_name;
307 token_container paramaters;
308 token_list_container definition;
309 r_macro_def() : macro_name(), paramaters(),definition() {}
316 typedef struct r_macro_call
318 bool is_functionlike;
320 token_type macro_call;
321 token_container_container arguments;
322 token_container expanded_macro;
325 std::string get_expanded_string()
327 std::ostringstream os;
328 token_container::const_iterator iter;
329 for (iter=expanded_macro.begin(); iter!=expanded_macro.end(); iter++)
330 os << (*iter).get_value();
334 r_macro_call() : macro_call(), arguments(),expanded_macro() {}
340 bool is_functionlike;
342 token_type macro_call;
343 token_container_container arguments;
344 token_container expanded_macro;
348 std::string get_expanded_string();
371 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
397 const std::string & filenameString,
int line_no ,
int col_no,
403 void display(
const std::string & label)
const;
406 int getLineNumber()
const;
407 int getColumnNumber()
const;
408 std::string getString()
const;
409 void setString (
const std::string & s );
410 int getStringLength()
const;
411 DirectiveType getTypeOfDirective()
const;
412 void setTypeOfDirective(DirectiveType);
417 std::string getFilename()
const;
418 int getFileId()
const;
421 int getNumberOfLines()
const;
422 int getColumnNumberOfEndOfString()
const;
429 static std::string directiveTypeName (
const DirectiveType & directive);
434 unsigned int packed_size ()
const;
437 char* packed()
const;
438 void unpacked(
char* storePointer );
446 std::string get_filename_from_include_directive();
449 int get_lineNumberForCompilerGeneratedLinemarker();
450 std::string get_filenameForCompilerGeneratedLinemarker();
451 std::string get_optionalflagsForCompilerGeneratedLinemarker();
454 void set_lineNumberForCompilerGeneratedLinemarker(
int x );
455 void set_filenameForCompilerGeneratedLinemarker( std::string x );
456 void set_optionalflagsForCompilerGeneratedLinemarker( std::string x );
459 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
469 const token_container* get_token_stream();
470 void push_front_token_stream(token_type tok);
471 void push_back_token_stream(token_type tok);
480 bool isSelfReferential();
481 std::string getMacroName();
484 bool isTransformation()
const;
485 void setAsTransformation();
486 void unsetAsTransformation();
493 typedef Rose_STL_Container<PreprocessingInfo*> AttachedPreprocessingInfoType;
499 std::vector<PreprocessingInfo*> attributeList;
505 LexTokenStreamTypePointer rawTokenStream;
509 std::string fileName;
521 std::set<int> filenameIdSet;
532 enum languageTypeEnum
534 e_unknown_language = 0,
537 e_Fortran77_language = 3,
538 e_Fortran9x_language = 4,
546 void addElement(PreprocessingInfo::DirectiveType,
const std::string & pLine,
const std::string & filename,
int lineNumber,
int columnNumber,
int numberOfLines);
562 void setFileName(
const std::string & fName);
563 std::string getFileName();
566 void setIndex(
int i);
572 void deepClean(
void);
579 std::vector<PreprocessingInfo*> & getList() {
return attributeList; };
581 void display (
const std::string & label );
584 void set_rawTokenStream( LexTokenStreamTypePointer s );
585 LexTokenStreamTypePointer get_rawTokenStream();
589 void generatePreprocessorDirectivesAndCommentsForAST(
const std::string & filename );
596 void collectPreprocessorDirectivesAndCommentsForAST(
const std::string & filename, languageTypeEnum languageType );
599 bool isFortran77Comment(
const std::string & line );
600 bool isFortran90Comment(
const std::string & line );
601 bool isCppDirective(
const std::string & line, PreprocessingInfo::DirectiveType & cppDeclarationKind, std::string & restOfTheLine );
606 void generateFileIdListFromLineDirectives();
609 std::set<int> & get_filenameIdSet();
630 std::map<std::string, ROSEAttributesList*> attributeListMap;
643 bool isInList (
const std::string & fName );
647 void dumpContents(
void);
648 void deepClean(
void);
654 std::map<std::string, ROSEAttributesList*> & getList() {
return attributeListMap; };
655 void display (
const std::string & label );
660 #ifndef ROSE_SKIP_COMPILATION_OF_WAVE
662 extern token_container wave_tokenStream;