ROSE 0.11.145.147
rose_attributes_list.h
1#ifndef __ROSEAttributesList_H__
2#define __ROSEAttributesList_H__
3
4//#include "setup.h"
5
6//#include <list>
7//#include <vector>
8#include <map>
9
10// Include the ROSE lex specific definitions of tokens
11#include "general_token_defs.h"
12
13// #ifdef CAN_NOT_COMPILE_WITH_ROSE
14// #warning "CAN_NOT_COMPILE_WITH_ROSE IS defined"
15// #else
16// #warning "CAN_NOT_COMPILE_WITH_ROSE is NOT defined"
17// #endif
18
19// DQ (2/28/2010): Skip this if we are compiling ROSE using ROSE.
20// This is being used in place of the CAN_NOT_COMPILE_WITH_ROSE macro.
21// Note that CAN_NOT_COMPILE_WITH_ROSE is set by the following projects:
22// 1) projects/DocumentationGenerator
23// 2) projects/haskellport
24// in their Makefile.am files. I think that using CXX_IS_ROSE_ANALYSIS
25// will be equivalent (used to indicate the a ROSE translator is being
26// used to compile the ROSE source code).
27// However, it might be that this is equivalent to the USE_ROSE macro,
28// which is set for all ROSE translators when they compile any code.
29// DQ (12/22/2008): I would appreciate it if this were a better name...
30// #if !CAN_NOT_COMPILE_WITH_ROSE
31// #ifndef USE_ROSE
32
33// DQ (5/21/2010): I have built a separate macro for tuning off the compilation of WAVE
34// since it is done only for the purpose of allowing ROSE based projects:
35// 1) projects/DocumentationGenerator
36// 2) projects/haskellport
37// to process the ROSE files cleanly. ROSE can however process and compile ROSE
38// (including a slightly modified version of WAVE that EDG will accept) and we
39// separately test this in noightly tests. The previous 5/18/2010 fix to permit
40// the Haskell support to skip processign WAVE turned this off and broke the nightly
41// tests of ROSE compiling ROSE. This use of the macro ROSE_SKIP_COMPILATION_OF_WAVE
42// it menat to be turned on by ROSE based tools that need to process the ROSE code
43// and which currently fail (because of Wave) and so turn of the processing of Wave
44// for those tools.
45// #ifdef USE_ROSE
46// #define ROSE_SKIP_COMPILATION_OF_WAVE
47// #endif
48
49// DQ (2/27/2016): Check for DEBIAN and Boost 1.54 and disable WAVE (not found in
50// Boost 1.54, for Debian OS installations, as I understand it). This is a fix
51// for a bug identified to be specific to Boost 1.54 on Debian systems, so that
52// is why it is so specific in deactivating boost::wave. To support this the
53// boost::wave support had to be revisited to permit it to NOT be a dependence.
54// We shuld put in place tests that make sure it does not accedently become a
55// dependence in the future.
56#ifdef ROSE_DEBIAN_OS_VENDOR
57 #if (ROSE_BOOST_VERSION == 105400)
58 #define ROSE_SKIP_COMPILATION_OF_WAVE
59 #endif
60#endif
61
62#if __sun
63 // PP 05/16/19
64 // Continue skipping WAVE until it is needed
65 // (after boost 1.65 is working on Solaris, WAVE should also work)
66 #define ROSE_SKIP_COMPILATION_OF_WAVE
67#endif
68
69// DQ (2/27/2016): Test compilation of ROSE without boost::wave support.
70// #define ROSE_SKIP_COMPILATION_OF_WAVE
71
72#ifndef ROSE_SKIP_COMPILATION_OF_WAVE
73// #if _MSC_VER < 1600 // 1600 == VC++ 10.0
74 #if (!defined(_MSC_VER) || (_MSC_VER > 1600))
75 #include <boost/preprocessor/iteration/iterate.hpp> // Liao, 7/10/2009, required by GCC 4.4.0 for a #define line of BOOST_PP_ITERATION_DEPTH
76 #ifdef _MSC_VER
77 #include <boost/wave.hpp> // CH (4/7/2010): Put this header here to avoid compiling error about mismatch between defination and declaration
78 #endif
79 #include <boost/wave/cpplexer/cpp_lex_token.hpp> // token class
80 #include <boost/wave/cpplexer/cpp_lex_iterator.hpp> // lexer type
81 #else
82// #warning "Setting CAN_NOT_COMPILE_WITH_ROSE to value = 1"
83// #define CAN_NOT_COMPILE_WITH_ROSE 1
84// tps (12/4/2009) : This is not found in VC++ 10.0 and Boost 1.4
85 #pragma message ("Boost preprocessor and wave not included yet for VC++ 10.0")
86
87 #endif
88#endif
89
90//template boost::wave::cpplexer::impl::token_data<std::string, boost::wave::util::file_position_type>::delete(std::size_t) ;
91// DQ (10/16/2002): Required for compiling with SUN 5.2 C++ compiler
92#ifndef NAMESPACE_IS_BROKEN
93// DQ (12/30/2005): This is a Bad Bad thing to do (I can explain)
94// it hides names in the global namespace and causes errors in
95// otherwise valid and useful code. Where it is needed it should
96// appear only in *.C files (and only ones not included for template
97// instantiation reasons) else they effect user who use ROSE unexpectedly.
98// using namespace std;
99#endif
100
101class ROSE_DLL_API PreprocessingInfo;
103//AS(01/04/07) Global map of filenames to PreprocessingInfo*'s as it is inefficient
104//to get this by a traversal of the AST
105extern std::map<std::string,ROSEAttributesList* > mapFilenameToAttributes;
106
107
108// DQ (4/19/2006): Forward declaration so that PreprocessingInfo can
109// contain a pointer to a Sg_File_Info object.
110class Sg_File_Info;
111
112// DQ (1/21/2008): Need forward declaration
113class SgFile;
114
115// #if !CAN_NOT_COMPILE_WITH_ROSE
116// #ifndef USE_ROSE
117#ifndef ROSE_SKIP_COMPILATION_OF_WAVE
118
119typedef boost::wave::cpplexer::lex_token<> token_type;
120typedef std::vector<token_type> token_container;
121typedef std::list<token_type> token_list_container;
122typedef std::vector<std::list<token_type> > token_container_container;
123
124#endif
125
128 {
129 public:
130 // DQ (10/15/2002) moved this to nested scope to avoid global name pollution :-).
134 {
135 defaultValue = 0, // let the zero value be an error value
136 undef = 1, // Position of the directive is only going to be defined
137 // when the preprocessing object is copied into the AST,
138 // it remains undefined before that
139 before = 2, // Directive goes before the correponding code segment
140 after = 3, // Directive goes after the correponding code segment
141 inside = 4, // Directive goes inside the correponding code segment (as in between "{" and "}" of an empty basic block)
142 // Rasmussen (12/14/2022): Added end_of to support unparsing at end of a statement (for example)
143 end_of = 5, // Directive goes at the end of the correponding code segment
144
145 // DQ (7/19/2008): Added additional fields so that we could use this enum type in the AstUnparseAttribute
146 before_syntax = 6, // We still have to specify the syntax
147 after_syntax = 7 // We still have to specify the syntax
148 };
149
150 // Enum type to help classify the type for string that has been saved.
151 // This helps in the unparsing to make sure that line feeds are introduced properly.
152 //
153 // Rama (08/17/07): Adding a CpreprocessorDeadIfDeclaration and its support
154 // in various files.
155 enum DirectiveType
156 {
157 // This is treated as an error
158 CpreprocessorUnknownDeclaration,
159
160 // These are a classification for comments
161 C_StyleComment,
162 CplusplusStyleComment,
163 FortranStyleComment,
164
165 // FMZ(5/14/2010): Added freeform comments (started with "!")
166 F90StyleComment,
167
168 // Rasmussen (11/3/2020): Added Ada and Jovial comments
169 AdaStyleComment,
170 JovialStyleComment,
171
172 // DQ (11/20/2008): Added classification for blank line (a language independent form of comment).
173 CpreprocessorBlankLine,
174
175 // These used to be translated into IR nodes (and will be in the future).
176 CpreprocessorIncludeDeclaration,
177 CpreprocessorIncludeNextDeclaration,
178 CpreprocessorDefineDeclaration,
179 CpreprocessorUndefDeclaration,
180 CpreprocessorIfdefDeclaration,
181 CpreprocessorIfndefDeclaration,
182 CpreprocessorIfDeclaration,
183 CpreprocessorDeadIfDeclaration,
184 CpreprocessorElseDeclaration,
185 CpreprocessorElifDeclaration,
186 CpreprocessorEndifDeclaration,
187 CpreprocessorElsifDeclaration, // PP (27/11/23): Ada "elsif"
188 CpreprocessorEnd_ifDeclaration, // PP (10/1/21): Ada "end if"
189 CpreprocessorLineDeclaration,
190 CpreprocessorErrorDeclaration,
191
192 // DQ (10/19/2005): Added CPP warning directive
193 CpreprocessorWarningDeclaration,
194 CpreprocessorEmptyDeclaration,
195
196 // AS (11/18/05): Added macro support (these are generated by the Wave
197 // support, but need to be better documented as to what they mean).
198 CSkippedToken,
199 CMacroCall,
200
201 // AS & LIAO (8/12/2008): A PreprocessingInfo that is a
202 // hand made MacroCall that will expand into a valid statement.
203 CMacroCallStatement,
204
205 // DQ (11/28/2008): What does this mean!
206 // A line replacement will replace a sub-tree in the AST
207 // after a node with position (filename,line)
208 LineReplacement,
209
210 // The is the 'extern "C" {' construct. Note that this is not captured in
211 // the EDG AST and it is required to be captured as part of the CPP and
212 // comment preprocessing.
213 ClinkageSpecificationStart,
214 ClinkageSpecificationEnd,
215
216 // DQ (11/17/2008): Added support for #ident
217 CpreprocessorIdentDeclaration,
218
219 // DQ (11/17/2008): This handles the case CPP declarations (called "linemarkers")
220 // (see Google for more details) such as: "# 1 "test2008_05.F90"", "# 1 "<built-in>"",
221 // "# 1 "<command line>"" "# 1 "test2008_05.F90""
222 // The first token is the line number,
223 // the second token is the filename (or string),
224 // the optional tokens (zero or more) are flags:
225 // '1' indicates the start of a new file.
226 // '2' indicates returning to a file (having included another file).
227 // '3' indicates that the following text comes from a system header file, so certain warnings should be supressed.
228 // '4' indicates that the following text should be treated as being wrapped in an implicit 'extern "C"' block
229 CpreprocessorCompilerGeneratedLinemarker,
230
231 // DQ (2/2/2014): permit raw text to be specified as a extremely simple way to add text to the unparsing of the AST.
232 // Note that it is the user's responcability to have the text be legal code. Additionall any language constructs
233 // added using this mechanism will ot show up in the AST. So it is not possible to reference functions (for example)
234 // added using this mechanism to build function calls as transformation elsewhere in the code. But one could add
235 // the function via AST transformations and the function body using a mechanism provided here and that would define
236 // a simple appoach to adding large complex functions for which it is impractical to build up an AST.
237 RawText,
238
239 LastDirectiveType
240 };
241
242 // DQ (7/10/2004): Make the data private
243 private:
244
245 // DQ (4/19/2006): Use the SgFileInfo object to hold the more complete
246 // information about the filename, line number, and column number.
247 Sg_File_Info* file_info;
248 // int lineNumber;
249 // int columnNumber;
250
251 // Use string class to improve implementation
252 // char* stringPointer;
253 std::string internalString;
254
255 int numberOfLines;
256
257 // enum value representing a classification of the different types of directives
258 DirectiveType whatSortOfDirective;
259
260 // Corresponding enum value
261 RelativePositionType relativePosition;
262
263 // DQ (11/28/2008): Support for CPP generated linemarkers
264 int lineNumberForCompilerGeneratedLinemarker;
265 std::string filenameForCompilerGeneratedLinemarker;
266 std::string optionalflagsForCompilerGeneratedLinemarker;
267
268 // DQ (1/15/2015): Adding support for token-based unparsing. When new comments and CPP directives are added we need
269 // to record these as a kind of transformation that will trigger the token stream representation to NOT be used and
270 // the comments and CPP directives unparsed from the AST seperately from the associated IR node being unparsed from
271 // the AST. The problem is that we wnat to record where there might be comments or CPP directives removed and having
272 // a flag here is not going to work for that. so we have to also record that the ROSEAttributesList has changed.
273 bool p_isTransformation;
274
275// This is part of Wave support in ROSE.
276// #ifndef USE_ROSE
277 public:
278/*
279 // AS using the lexer_token from boost_wave in order to store structures
280 typedef boost::wave::cpplexer::lex_token<> token_type;
281 typedef std::vector<token_type> token_container;
282 typedef std::list<token_type> token_list_container;
283 typedef std::vector<std::list<token_type> > token_container_container;
284*/
285 private:
286 // FIXME: To support Jochens AST binary save work the tokenSteam must
287 // have a pointer type.
288
289#ifndef ROSE_SKIP_COMPILATION_OF_WAVE
290 // A stream of tokens representing the current prerpocessing info
291 // object. This is equivalent to the internal string, but of cause
292 // contains more information since it is a tokenized stream.
293 token_container* tokenStream;
294
295 public:
296 typedef struct r_include_directive
297 {
298 // The parameter 'directive' contains the (expanded) file name found after
299 // the #include directive. This has the format '<file>', '"file"' or 'file'.
300 token_type directive;
301 // The paths plus name to the include directive filename
302 std::string absname;
303 std::string relname;
305
306 // Internal representation of a macro #define directive
307 typedef struct r_macro_def
308 {
309 bool is_functionlike;
310 bool is_predefined;
311 token_type macro_name;
312 token_container paramaters;
313 token_list_container definition;
314 r_macro_def() : macro_name(), paramaters(),definition() {}
316
317 // Internal representation of a macro call
318 // e.g #define MACRO_CALL int x;
319 // MACRO_CALL
320#if 0
321 typedef struct r_macro_call
322 {
323 bool is_functionlike;
324 PreprocessingInfo* macro_def;
325 token_type macro_call;
326 token_container_container arguments;
327 token_container expanded_macro;
328
329 // Get string representation of the expanded macro
330 std::string get_expanded_string()
331 {
332 std::ostringstream os;
333 token_container::const_iterator iter;
334 for (iter=expanded_macro.begin(); iter!=expanded_macro.end(); iter++)
335 os << (*iter).get_value();
336 return os.str();
337 }
338
339 r_macro_call() : macro_call(), arguments(),expanded_macro() {}
340 } rose_macro_call;
341#else
342 // DQ (3/9/2013): Modified to address SWIG error.
344 {
345 bool is_functionlike;
346 PreprocessingInfo* macro_def;
347 token_type macro_call;
348 token_container_container arguments;
349 token_container expanded_macro;
350
351 // DQ (3/9/2013): The function definition is moved to the source file to get around SWIG error.
352 // Get string representation of the expanded macro
353 std::string get_expanded_string();
354
355 // DQ (3/9/2013): The function definition is moved to the source file to get around SWIG error.
357 };
358#endif
359
360 private:
361 // AS add macro definition
362 rose_macro_definition* macroDef;
363 // AS add macro call
364 rose_macro_call* macroCall;
365 // AS include directive
366 rose_include_directive* includeDirective;
367
368#endif
369
370 // member functions
371 public:
374
375// #ifndef USE_ROSE
376#ifndef ROSE_SKIP_COMPILATION_OF_WAVE
377 // AS (112105) Added constructors to support macros
378 PreprocessingInfo(token_container, DirectiveType, RelativePositionType);
381 PreprocessingInfo(token_type, token_list_container, bool, DirectiveType,RelativePositionType);
383#endif
384
385 // This constructor is called from the C++ code generated from the lex file (preproc.lex)
386 // PreprocessingInfo(DirectiveType, const char *inputStringPointer, int line_no , int col_no,
387 // int nol, RelativePositionType relPos, bool copiedFlag, bool unparsedFlag) ROSE_DEPRECATED_FUNCTION;
388
389 // DQ (7/19/2008): I have removed the bool copiedFlag and bool unparsedFlag parameters because they are not used
390 // and are present only because in an older implementation of the unparser it would make the PreprocessingInfo
391 // as unparsed (and maybe copied) but this sort of side-effect of the unparser was later removed to make the
392 // unparsing side-effect free.
393 // DQ (4/19/2006): Use the SgFileInfo object to hold the more complete
394 // information about the filename, line number, and column number.
395 // DQ (3/15/2006): Build constructor that uses C++ string as input (to replace the char* based constructor)
396 // PreprocessingInfo(DirectiveType, const std::string inputString, int line_no , int col_no,
397 // int nol, RelativePositionType relPos, bool copiedFlag, bool unparsedFlag);
398 // PreprocessingInfo(DirectiveType, const std::string & inputString,
399 // const std::string & filenameString, int line_no , int col_no,
400 // int nol, RelativePositionType relPos, bool copiedFlag, bool unparsedFlag );
401 PreprocessingInfo(DirectiveType, const std::string & inputString,
402 const std::string & filenameString, int line_no , int col_no,
403 int nol, RelativePositionType relPos );
404
405 // Copy constructor
406 PreprocessingInfo(const PreprocessingInfo &prepInfo);
407
408 void display(const std::string & label) const;
409
410 // Access functions
411 int getLineNumber() const;
412 int getColumnNumber() const;
413 std::string getString() const;
414 void setString ( const std::string & s );
415 int getStringLength() const;
416 DirectiveType getTypeOfDirective() const;
417 void setTypeOfDirective(DirectiveType);
418 RelativePositionType getRelativePosition(void) const;
419 void setRelativePosition(RelativePositionType relPos);
420
421 // DQ (2/27/2019): Adding support for CPP directives and comments to have filename information (already present, but we need to access it).
422 std::string getFilename() const;
423 int getFileId() const;
424
425 // Number of lines occupied by this comment (count the number of line feeds)
426 int getNumberOfLines() const;
427 int getColumnNumberOfEndOfString() const; // only correct for single line directives
428
429 // Used in unparse to string mechanism
430 // char* removeLeadingWhiteSpace (const char* inputStringPointer);
431
432 // DQ (8/6/2006): Modified to make these static functions
433 // useful for debugging
434 static std::string directiveTypeName (const DirectiveType & directive);
435 static std::string relativePositionName (const RelativePositionType & position);
436
437 // JH (01/03/2006) methods for packing the PreprocessingInfo data, in order to store it into
438 // a file and rebuild it!
439 unsigned int packed_size () const;
440
441 // JH (01/032006) This pack methods might cause memory leaks. Think of deleting them after stored to file ...
442 char* packed() const;
443 void unpacked( char* storePointer );
444
445 // DQ (4/19/2006): Added Sg_File_Info objects to each PreprocessingInfo object
446 Sg_File_Info* get_file_info() const;
447 void set_file_info( Sg_File_Info* info );
448
449 // DQ (8/26/2020): include directive have a filename imbedded inside, and we need to
450 // extract that for from tools (e.g. the fixup for initializers from include files).
451 std::string get_filename_from_include_directive();
452
453 // DQ (11/28/2008): Support for CPP generated linemarkers
454 int get_lineNumberForCompilerGeneratedLinemarker();
455 std::string get_filenameForCompilerGeneratedLinemarker();
456 std::string get_optionalflagsForCompilerGeneratedLinemarker();
457
458 // DQ (11/28/2008): Support for CPP generated linemarkers
459 void set_lineNumberForCompilerGeneratedLinemarker( int x );
460 void set_filenameForCompilerGeneratedLinemarker( std::string x );
461 void set_optionalflagsForCompilerGeneratedLinemarker( std::string x );
462
463// #ifndef USE_ROSE
464#ifndef ROSE_SKIP_COMPILATION_OF_WAVE
465 // Wave specific member functions.
466 public:
467 // Access functions to get the macro call or macro definition.
468 // These are NULL if the type is not CMacroCall or
469 // CpreprocessorDefineDeclaration
470 rose_macro_call* get_macro_call();
471 rose_macro_definition* get_macro_def();
472 rose_include_directive* get_include_directive();
473
474 const token_container* get_token_stream();
475 void push_front_token_stream(token_type tok);
476 void push_back_token_stream(token_type tok);
477
478#endif
479
480 // DQ (12/30/2013): Adding support to supress output of macros that are self-referential.
481 // e.g. "#define foo X->foo", which would be expanded a second time in the backend processing.
482 // Note that if we don't output the #define, then we still might have a problem if there was
483 // code that depended upon a "#ifdef foo". So this handling is not without some risk, but it
484 // always better to use the token stream unparsing for these cases.
485 bool isSelfReferential();
486 std::string getMacroName();
487
488 // DQ (1/15/2015): Adding support for token-based unparsing. Access function for new data member.
489 bool isTransformation() const;
490 void setAsTransformation();
491 void unsetAsTransformation();
492 };
493
494// DQ (10/15/2002) Changed list element from "PreprocessingInfo" to
495// "PreprocessingInfo*" to avoid redundant copying of internal data.
496// Define a new data type for the container that stores the
497// PreprocessingInfo objects attached to an AST node
498typedef Rose_STL_Container<PreprocessingInfo*> AttachedPreprocessingInfoType;
499
501 {
502 private:
503 // DQ replaced use of old list class with STL
504 std::vector<PreprocessingInfo*> attributeList;
505
506 // DQ (1/9/2021): Added comment.
507 // Note that the token stream is contained in the ROSEAttributesList list which before this just held
508 // the comments and CPP directives. This is OK, but the makes of the types and data members are less
509 // than ideal.
510 LexTokenStreamTypePointer rawTokenStream;
511
512 // [DT] 3/15/2000 -- Name of file from which the directives come.
513 // char fileName[256];
514 std::string fileName;
515
516 // 3/16/2000 -- Index into the list. Not sure if this is really
517 // necessary. See implementation in unparser.C.
518 //
519 // This is where the current line number is stored while we
520 // go off and unparse a different include file. This really should have
521 // been stored in a static structure (I think) rather than in this list.
522 int index;
523
524 // DQ (12/15/2012): Save file ids that are from filenames referenced in #line
525 // directives, these will be considered equivalent to the input source filename.
526 std::set<int> filenameIdSet;
527
528 // DQ (1/15/2015): Adding support for token-based unparsing. When new comments and CPP directives are added we need
529 // to record these as a kind of transformation that will trigger the token stream representation to NOT be used and
530 // the comments and CPP directives unparsed from the AST seperately from the associated IR node being unparsed from
531 // the AST. The problem is that we want to record where there might be comments or CPP directives removed and having
532 // a flag here is not going to work for that, so we have to also record that the ROSEAttributesList has changed.
533 // bool p_isTransformation;
534
535 public:
536 // DQ (11/19/2008): Added language selection support for handling comments
537 enum languageTypeEnum
538 {
539 e_unknown_language = 0,
540 e_C_language = 1,
541 e_Cxx_language = 2,
542 e_Fortran77_language = 3,
543 e_Fortran9x_language = 4,
544 e_Ada_language = 5,
545 e_lastLanguage
546 };
547
550 // DQ (4/19/2006): Adding SgFileInfo objects so we need to pass in a filename string
551 // void addElement(PreprocessingInfo::DirectiveType, const char *pLine, int lineNumber, int columnNumber, int numberOfLines);
552 void addElement(PreprocessingInfo::DirectiveType, const std::string & pLine, const std::string & filename, int lineNumber, int columnNumber, int numberOfLines);
553#if 1
554 // DQ (5/9/2007): This is required for WAVE support.
555 // DQ (4/13/2007): I would like to remove this function, but it is used by WAVE support within ROSE.
556 void addElement( PreprocessingInfo &pRef );
557#endif
558 // void addElements( ROSEAttributesList &);
559 void moveElements( ROSEAttributesList &);
560
561#if 1
562 // DQ (5/9/2007): This is required for WAVE support.
563 // DQ (4/13/2007): I would like to remove this function
564 void insertElement( PreprocessingInfo & pRef );
565#endif
566
567 // [DT] 3/15/2000 -- Interface to fileName member.
568 void setFileName(const std::string & fName);
569 std::string getFileName();
570
571 // 3/16/2000 -- Interface to index member.
572 void setIndex(int i);
573 int getIndex();
574
575 PreprocessingInfo* operator[](int i);
576 int size(void);
577 int getLength(void);
578 void deepClean(void);
579 void clean(void);
580
581 // DQ (9/19/2013): generate the number associated with each position relative to the attached IR node.
582 // size_t numberByRelativePosition(PreprocessingInfo::RelativePositionType pos);
583
584 // Access function for list
585 std::vector<PreprocessingInfo*> & getList() { return attributeList; };
586
587 void display ( const std::string & label ); // DQ 02/18/2001 -- For debugging.
588
589 // DQ (1/21/2008): Added access function to save the raw token stream from the lex pass.
590 void set_rawTokenStream( LexTokenStreamTypePointer s );
591 LexTokenStreamTypePointer get_rawTokenStream();
592
593 // This function processes the token stream to generate the input for what weaves the
594 // CPP directives and comments into the AST. All other tokens are ignore in this pass.
595 void generatePreprocessorDirectivesAndCommentsForAST( const std::string & filename );
596
597 // DQ (11/26/2008): This is old code!
598 // Collection comments and CPP directives for fixed format (easier case)
599 // void collectFixedFormatPreprocessorDirectivesAndCommentsForAST( const std::string & filename );
600
601 // DQ (11/16/2008): Adding support for recognition of CPP directives outside of the lex tokenization.
602 void collectPreprocessorDirectivesAndCommentsForAST( const std::string & filename, languageTypeEnum languageType );
603
604 // DQ (11/17/2008): Refactored the code.
605 bool isFortran77Comment( const std::string & line );
606 bool isFortran90Comment( const std::string & line );
607 bool isCppDirective( const std::string & line, PreprocessingInfo::DirectiveType & cppDeclarationKind, std::string & restOfTheLine );
608
609 // DQ (12/15/2012): traverse the attributeList and process all of the #line directives to generate a
610 // list of file ids that should be considered equivalent to that of the input source file's filename.
611 // std::set<int> generateFileIdListFromLineDirectives();
612 void generateFileIdListFromLineDirectives();
613
614 // DQ (12/15/2012): Added access function.
615 std::set<int> & get_filenameIdSet();
616
617 // DQ (9/29/2013): Added to support adding processed CPP directives and comments as tokens to token list.
618 PreprocessingInfo* lastElement();
619
620 // DQ (1/15/2015): Adding support for token-based unparsing. Access function for new data member.
621 // bool isTransformation() const;
622 // void setAsTransformation();
623 // void unsetAsTransformation();
624 };
625
626//
627// [DT] 3/16/2000 -- Want to have preprocessing info for
628// each file included from the main source file.
629//
631 {
632 private:
633 // DQ replaced use of old list class with STL
634 // std::vector<ROSEAttributesList*> attributeListList;
635 // std::map<std::string,ROSEAttributesList*>* attrMap;
636 std::map<std::string, ROSEAttributesList*> attributeListMap;
637
638 public:
641 // void addList ( ROSEAttributesList* listPointer );
642 void addList ( std::string fileName, ROSEAttributesList* listPointer );
643 // void addList(ROSEAttributesList &aRef);
644 // void insertList(ROSEAttributesList &aRef);
645 // ROSEAttributesList* operator[](int i);
646 // ROSEAttributesList* findList ( const std::string & fName );
647
648 // Check to see if the ROSEAttributesList for the fName (filename) is in the container
649 bool isInList ( const std::string & fName );
650
651 // int size(void);
652 // int getLength(void);
653 void dumpContents(void); // [DT] 3/16/2000 -- For debugging.
654 void deepClean(void);
655 void clean(void);
656 ROSEAttributesList & operator[]( const std::string & fName);
657
658 // Access function for list
659 // std::vector<ROSEAttributesList*> & getList() { return attributeListList; };
660 std::map<std::string, ROSEAttributesList*> & getList() { return attributeListMap; };
661 void display ( const std::string & label ); // DQ 02/18/2001 -- For debugging.
662 };
663
664
665// #ifndef USE_ROSE
666#ifndef ROSE_SKIP_COMPILATION_OF_WAVE
667
668extern token_container wave_tokenStream;
669
670#endif
671
672#endif
For preprocessing information including source comments, include , if, define, etc.
RelativePositionType
MK: Enum type to store if the directive goes before or after the corresponding line of source code.
This class represents a source file for a project (which may contian many source files and or directo...
This class represents the location of the code associated with the IR node in the original source cod...