~ubuntu-branches/ubuntu/jaunty/aspectc++/jaunty

« back to all changes in this revision

Viewing changes to Puma/gen-release/step1/inc/Puma/PreTreeNodes.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-07-07 14:41:02 UTC
  • mfrom: (1.1.3 upstream) (6.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080707144102-lzml7t07f3sl00r5
Tags: 1.0pre4~svn.20080711-1
* new upstream snapshot.
* include all upstream documentation. Clarifying emails regarding
  licensing has been included into debian/copyright.
* reformat description following recomendations of
  http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description
  (Closes: #480316)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#ifndef __pre_syntax_tree_nodes__
20
20
#define __pre_syntax_tree_nodes__
21
21
 
22
 
// Contains all node classes for the preprocessor syntax tree.
 
22
/** \file 
 
23
 *  Preprocessor syntax tree classes. */
23
24
 
24
25
#include "Puma/Unit.h"
25
26
#include "Puma/PreVisitor.h"
29
30
namespace Puma {
30
31
 
31
32
 
32
 
// The root node of the preprocessor syntax tree.
 
33
/** \class PreProgram PreTreeNodes.h Puma/PreTreeNodes.h
 
34
 *  The root node of the preprocessor syntax tree. */
33
35
class PreProgram : public PreTreeComposite {
34
36
public:
35
 
  PreProgram (PreTree* a) : PreTreeComposite (1, 0) 
36
 
    { add_son (a); };
 
37
  /** Constructor.
 
38
   *  \param g The group of preprocessor directives. */
 
39
  PreProgram (PreTree* g) : PreTreeComposite (1, 0) { 
 
40
    add_son (g); 
 
41
  }
37
42
 
 
43
  /** Part of the tree visitor pattern. Calls the node
 
44
   *  visiting functions suitable for this node type. 
 
45
   *  \param v The visitor object on which to call the 
 
46
   *           visiting functions. */
38
47
  void accept (PreVisitor &v) {
39
48
    v.visitPreProgram_Pre (this);
40
49
    v.iterateNodes (this);
43
52
};      
44
53
 
45
54
 
46
 
// Assemble groups of directive groups to a `super' group => the program.
 
55
/** \class PreDirectiveGroups PreTreeNodes.h Puma/PreTreeNodes.h
 
56
 *  Preprocessor tree node representing the directive groups in the program. */
47
57
class PreDirectiveGroups : public PreTreeComposite {
48
58
public:
49
 
  PreDirectiveGroups () : PreTreeComposite (-1, 0) {};
 
59
  /** Constructor. */
 
60
  PreDirectiveGroups () : PreTreeComposite (-1, 0) {}
50
61
 
 
62
  /** Part of the tree visitor pattern. Calls the node
 
63
   *  visiting functions suitable for this node type. 
 
64
   *  \param v The visitor object on which to call the 
 
65
   *           visiting functions. */
51
66
  void accept (PreVisitor& v) {
52
67
    v.visitPreDirectiveGroups_Pre (this);
53
68
    v.iterateNodes (this);
56
71
};      
57
72
 
58
73
 
59
 
// Assemble conditional directives to a logical group.
60
 
// Like: #if ... #elif ... #else ... #endif.
 
74
/** \class PreConditionalGroup PreTreeNodes.h Puma/PreTreeNodes.h
 
75
 *  Preprocessor tree node representing a group of conditional directives. 
 
76
 *  Example: \code #if ... #elif ... #else ... #endif \endcode */
61
77
class PreConditionalGroup : public PreTreeComposite {
62
78
public:
63
 
  PreConditionalGroup (PreTree* a, PreTree* b, PreTree* c) : 
64
 
    PreTreeComposite (3, 0) // 3 sons, no daughters.
65
 
    { add_son (a); add_son (b); add_son (c); };
66
 
        
67
 
  PreConditionalGroup (PreTree* a, PreTree* b, PreTree* c, PreTree* d) : 
68
 
    PreTreeComposite (4, 0) // 4 sons, no daughters.
69
 
    { add_son (a); add_son (b); add_son (c); add_son (d); };
 
79
  /** Constructor. 
 
80
   *  \param i The \#if part.
 
81
   *  \param dg The directive group.
 
82
   *  \param ei The \#endif part. */
 
83
  PreConditionalGroup (PreTree* i, PreTree* dg, PreTree* ei) : PreTreeComposite (3, 0) { 
 
84
    add_son (i); add_son (dg); add_son (ei); 
 
85
  }
 
86
  /** Constructor. 
 
87
   *  \param i The \#if part.
 
88
   *  \param e The \#elif or \#else part.
 
89
   *  \param dg The directive group.
 
90
   *  \param ei The \#endif part. */
 
91
  PreConditionalGroup (PreTree* i, PreTree* e, PreTree* dg, PreTree* ei) : PreTreeComposite (4, 0) { 
 
92
    add_son (i); add_son (e); add_son (dg); add_son (ei); 
 
93
  }
70
94
 
 
95
  /** Part of the tree visitor pattern. Calls the node
 
96
   *  visiting functions suitable for this node type. 
 
97
   *  \param v The visitor object on which to call the 
 
98
   *           visiting functions. */
71
99
  void accept (PreVisitor& v) {
72
100
    v.visitPreConditionalGroup_Pre (this);
73
101
    v.iterateNodes (this);
76
104
};      
77
105
 
78
106
 
79
 
// Assemble conditional directives within the else part of a 
80
 
// conditional group to a logical group.
81
 
// Like: ... #elif ... #elif ... #elif ... #else.
 
107
/** \class PreElsePart PreTreeNodes.h Puma/PreTreeNodes.h
 
108
 *  Preprocessor tree node representing a group of directives 
 
109
 *  in the \#else part of an \#if conditional. */
82
110
class PreElsePart : public PreTreeComposite {
83
111
public:
84
 
  PreElsePart (PreTree* a, PreTree* b) : 
85
 
    PreTreeComposite (2, 0) // 2 sons, no daughters.
86
 
    { add_son (a); add_son (b); };
87
 
                                        
88
 
  PreElsePart (PreTree* a, PreTree* b, PreTree* c) : 
89
 
    PreTreeComposite (3, 0) // 3 sons, no daughters.
90
 
    { add_son (a); add_son (b); add_son (c); };
 
112
  /** Constructor. 
 
113
   *  \param dg The directive group.
 
114
   *  \param el The \#else directive. */
 
115
  PreElsePart (PreTree* dg, PreTree* el) : PreTreeComposite (2, 0) { 
 
116
    add_son (dg); add_son (el); 
 
117
  }
 
118
  /** Constructor. 
 
119
   *  \param ei The preceding \#elif part.
 
120
   *  \param dg The directive group.
 
121
   *  \param el The \#else directive. */
 
122
  PreElsePart (PreTree* ei, PreTree* dg, PreTree* el) : PreTreeComposite (3, 0) { 
 
123
    add_son (ei); add_son (dg); add_son (el); 
 
124
  }
91
125
 
 
126
  /** Part of the tree visitor pattern. Calls the node
 
127
   *  visiting functions suitable for this node type. 
 
128
   *  \param v The visitor object on which to call the 
 
129
   *           visiting functions. */
92
130
  void accept (PreVisitor& v) {
93
131
    v.visitPreElsePart_Pre (this);
94
132
    v.iterateNodes (this);
97
135
};      
98
136
 
99
137
 
100
 
// Assemble conditional directives in the elif part of a conditional 
101
 
// group to a logical group.
102
 
// Like: ... #elif ... #elif ... #elif.
103
 
class PreElifPart : public PreTreeComposite
104
 
 {
105
 
    public:
106
 
                                // Dynamic sons, no daughters.
107
 
        PreElifPart () : PreTreeComposite (-1, 0) {};
108
 
        
109
 
        // Add two sons.
110
 
        void addSons (PreTree* a, PreTree* b)
111
 
            { add_son (a); add_son (b); };
112
 
 
113
 
        void accept (PreVisitor& v)
114
 
        {
115
 
            v.visitPreElifPart_Pre (this);
116
 
            v.iterateNodes (this);
117
 
            v.visitPreElifPart_Post (this);
118
 
        }
119
 
 };      
120
 
 
121
 
 
122
 
// The #if directive.
123
 
class PreIfDirective : public PreTreeComposite
124
 
 {
125
 
    public:
126
 
                                        
127
 
        PreIfDirective (PreTree* a, PreTree* b) 
128
 
                        : PreTreeComposite (2, 1) // 2 sons, 1 daughter.
129
 
            { add_son (a); add_son (b); };
130
 
 
131
 
        void accept (PreVisitor& v)
132
 
        {
133
 
            v.visitPreIfDirective_Pre (this);
134
 
            v.iterateNodes (this);
135
 
            v.visitPreIfDirective_Post (this);
136
 
        }
137
 
 };      
138
 
 
139
 
 
140
 
// The #ifdef directive.
141
 
class PreIfdefDirective : public PreTreeComposite
142
 
 {
143
 
    public:
144
 
                                        
145
 
        PreIfdefDirective (PreTree* a, PreTree* b, PreTree* c) 
146
 
                        : PreTreeComposite (3, 1) // 3 sons, 1 daughter.
147
 
            { add_son (a); add_son (b); add_son (c); };
148
 
        PreIfdefDirective (PreTree* a, PreTree* b) 
149
 
                        : PreTreeComposite (2, 0) // 2 sons, no daughter.
150
 
            { add_son (a); add_son (b); };
151
 
 
152
 
        void accept (PreVisitor& v)
153
 
        {
154
 
            v.visitPreIfdefDirective_Pre (this);
155
 
            v.iterateNodes (this);
156
 
            v.visitPreIfdefDirective_Post (this);
157
 
        }
158
 
 };      
159
 
 
160
 
 
161
 
// The #ifndef directive.
162
 
class PreIfndefDirective : public PreTreeComposite
163
 
 {
164
 
    public:
165
 
                                        
166
 
        PreIfndefDirective (PreTree* a, PreTree* b, PreTree* c) 
167
 
                        : PreTreeComposite (3, 1) // 3 sons, 1 daughter.
168
 
            { add_son (a); add_son (b); add_son (c); };
169
 
        PreIfndefDirective (PreTree* a, PreTree* b) 
170
 
                        : PreTreeComposite (2, 0) // 2 sons, no daughter.
171
 
            { add_son (a); add_son (b); };
172
 
 
173
 
        void accept (PreVisitor& v)
174
 
        {
175
 
            v.visitPreIfndefDirective_Pre (this);
176
 
            v.iterateNodes (this);
177
 
            v.visitPreIfndefDirective_Post (this);
178
 
        }
179
 
 };      
180
 
 
181
 
 
182
 
// The #elif directive.
183
 
class PreElifDirective : public PreTreeComposite
184
 
 {
185
 
    public:
186
 
                                        
187
 
        PreElifDirective (PreTree* a, PreTree* b) 
188
 
                        : PreTreeComposite (2, 1) // 2 sons, 1 daughter.
189
 
            { add_son (a); add_son (b); };
190
 
 
191
 
        void accept (PreVisitor& v)
192
 
        {
193
 
            v.visitPreElifDirective_Pre (this);
194
 
            v.iterateNodes (this);
195
 
            v.visitPreElifDirective_Post (this);
196
 
        }
197
 
 };      
198
 
 
199
 
 
200
 
// The #else directive.
201
 
class PreElseDirective : public PreTreeComposite
202
 
 {
203
 
    public:
204
 
                                        
205
 
        PreElseDirective (PreTree* a, PreTree* b) 
206
 
                        : PreTreeComposite (2, 0) // 2 sons, no daughters.
207
 
            { add_son (a); add_son (b); };
208
 
 
209
 
        void accept (PreVisitor& v)
210
 
        {
211
 
            v.visitPreElseDirective_Pre (this);
212
 
            v.iterateNodes (this);
213
 
            v.visitPreElseDirective_Post (this);
214
 
        }
215
 
 };      
216
 
 
217
 
 
218
 
// The #endif directive.
219
 
class PreEndifDirective : public PreTreeComposite
220
 
 {
221
 
    public:
222
 
                                        
223
 
        PreEndifDirective (PreTree* a, PreTree* b) 
224
 
                        : PreTreeComposite (2, 0) // 2 sons, no daughters.
225
 
            { add_son (a); add_son (b); };
226
 
 
227
 
        void accept (PreVisitor& v)
228
 
        {
229
 
            v.visitPreEndifDirective_Pre (this);
230
 
            v.iterateNodes (this);
231
 
            v.visitPreEndifDirective_Post (this);
232
 
        }
233
 
 };      
234
 
 
235
 
 
236
 
// The #include and #include_next directive.
237
 
class PreIncludeDirective : public PreTreeComposite
238
 
 {
239
 
        int _depth;
240
 
 
241
 
    public:
242
 
                                        
243
 
        PreIncludeDirective (PreTree* a, PreTree* b) 
244
 
                        : PreTreeComposite (2, 1) // 2 sons, 1 daughter.
245
 
            { add_son (a); add_son (b); _depth = -1; };
246
 
 
247
 
        void accept (PreVisitor& v)
248
 
        {
249
 
            v.visitPreIncludeDirective_Pre (this);
250
 
            v.iterateNodes (this);
251
 
            v.visitPreIncludeDirective_Post (this);
252
 
        }
253
 
        
254
 
        int depth () const 
255
 
        {
256
 
            return _depth;
257
 
        }
258
 
 
259
 
        void depth (int d)
260
 
        {
261
 
            _depth = d;
262
 
        }
263
 
        
264
 
        bool is_forced () const {
265
 
          return !((Unit*)startToken ()->belonging_to ())->isFile ();
266
 
        }
267
 
 };      
268
 
 
269
 
 
270
 
// The #assert directive.
271
 
class PreAssertDirective : public PreTreeComposite
272
 
 {
273
 
    public:
274
 
                                        
275
 
        PreAssertDirective (PreTree* a, PreTree* b, PreTree* c) 
276
 
                        : PreTreeComposite (3, 0) // 3 sons, no daughters.
277
 
            { add_son (a); add_son (b); add_son (c); };
278
 
        PreAssertDirective (PreTree* a, PreTree* b) 
279
 
                        : PreTreeComposite (2, 0) // 2 sons, no daughters.
280
 
            { add_son (a); add_son (b); };
281
 
 
282
 
        void accept (PreVisitor& v)
283
 
        {
284
 
            v.visitPreAssertDirective_Pre (this);
285
 
            v.iterateNodes (this);
286
 
            v.visitPreAssertDirective_Post (this);
287
 
        }
288
 
 };      
289
 
 
290
 
 
291
 
// The #unassert directive.
292
 
class PreUnassertDirective : public PreTreeComposite
293
 
 {
294
 
    public:
295
 
                                        
296
 
        PreUnassertDirective (PreTree* a, PreTree* b, PreTree* c) 
297
 
                        : PreTreeComposite (3, 0) // 3 sons, no daughters.
298
 
            { add_son (a); add_son (b); add_son (c); };
299
 
        PreUnassertDirective (PreTree* a, PreTree* b) 
300
 
                        : PreTreeComposite (2, 0) // 2 sons, no daughters.
301
 
            { add_son (a); add_son (b); };
302
 
 
303
 
        void accept (PreVisitor& v)
304
 
        {
305
 
            v.visitPreUnassertDirective_Pre (this);
306
 
            v.iterateNodes (this);
307
 
            v.visitPreUnassertDirective_Post (this);
308
 
        }
309
 
 };      
310
 
 
311
 
 
312
 
// The #define directive that defines function-like macros.
313
 
// Like: #define FUNCTION (id,...,id) ... ... ...
314
 
class PreDefineFunctionDirective : public PreTreeComposite
315
 
 {
316
 
    public:
317
 
                                        
318
 
        PreDefineFunctionDirective (PreTree* a, PreTree* b, 
319
 
                                    PreTree* c, PreTree* d, 
320
 
                                    PreTree* e, PreTree* f, 
321
 
                                    PreTree* g, PreTree* h) 
322
 
                        : PreTreeComposite (8, 0) // 8 sons, no daughters.
323
 
            { add_son (a); add_son (b); add_son (c); add_son (d);
324
 
              add_son (e); add_son (f); add_son (g); add_son (h); }
325
 
 
326
 
        PreDefineFunctionDirective (PreTree* a, PreTree* b, 
327
 
                                    PreTree* c, PreTree* d, 
328
 
                                    PreTree* e, PreTree* f, 
329
 
                                    PreTree* g) 
330
 
                        : PreTreeComposite (7, 0) // 7 sons, no daughters.
331
 
            { add_son (a); add_son (b); add_son (c); add_son (d);
332
 
              add_son (e); add_son (f); add_son (g); }
333
 
 
334
 
        PreDefineFunctionDirective (PreTree* a, PreTree* b, 
335
 
                                    PreTree* c, PreTree* d, 
336
 
                                    PreTree* e, PreTree* f) 
337
 
                        : PreTreeComposite (6, 0) // 6 sons, no daughters.
338
 
            { add_son (a); add_son (b); add_son (c); add_son (d);
339
 
              add_son (e); add_son (f); }
340
 
        
341
 
        PreDefineFunctionDirective (PreTree* a, PreTree* b, PreTree* c, 
342
 
                                   PreTree* d, PreTree* e) 
343
 
                        : PreTreeComposite (5, 0) // 5 sons, no daughters.
344
 
            { add_son (a); add_son (b); add_son (c); add_son (d); add_son (e); }
345
 
 
346
 
        void accept (PreVisitor& v)
347
 
        {
348
 
            v.visitPreDefineFunctionDirective_Pre (this);
349
 
            v.iterateNodes (this);
350
 
            v.visitPreDefineFunctionDirective_Post (this);
351
 
        }
352
 
 };              
353
 
 
354
 
 
355
 
// The #define directive that defines symbolic constants macros.
356
 
// Like: #define CONSTANT ... ... ...
357
 
class PreDefineConstantDirective : public PreTreeComposite
358
 
 {
359
 
    public:
360
 
                                        
361
 
        PreDefineConstantDirective (PreTree* a, PreTree* b, PreTree* c) 
362
 
                        : PreTreeComposite (3, 0) // 3 sons, no daughters.
363
 
            { add_son (a); add_son (b); add_son (c); };
364
 
        PreDefineConstantDirective (PreTree* a, PreTree* b) 
365
 
                        : PreTreeComposite (2, 0) // 2 sons, no daughters.
366
 
            { add_son (a); add_son (b); };
367
 
 
368
 
        void accept (PreVisitor& v)
369
 
        {
370
 
            v.visitPreDefineConstantDirective_Pre (this);
371
 
            v.iterateNodes (this);
372
 
            v.visitPreDefineConstantDirective_Post (this);
373
 
        }
374
 
 };      
375
 
 
376
 
 
377
 
// The #undef directive.
378
 
class PreUndefDirective : public PreTreeComposite
379
 
 {
380
 
    public:
381
 
                                        
382
 
        PreUndefDirective (PreTree* a, PreTree* b, PreTree* c) 
383
 
                        : PreTreeComposite (3, 0) // 3 sons, no daughters.
384
 
            { add_son (a); add_son (b); add_son (c); };
385
 
        PreUndefDirective (PreTree* a, PreTree* b) 
386
 
                        : PreTreeComposite (2, 0) // 2 sons, no daughters.
387
 
            { add_son (a); add_son (b); };
388
 
 
389
 
        void accept (PreVisitor& v)
390
 
        {
391
 
            v.visitPreUndefDirective_Pre (this);
392
 
            v.iterateNodes (this);
393
 
            v.visitPreUndefDirective_Post (this);
394
 
        }
395
 
 };      
396
 
 
397
 
 
398
 
// The #warning directive.
399
 
class PreWarningDirective : public PreTreeComposite
400
 
 {
401
 
    public:
402
 
                                        
403
 
        PreWarningDirective (PreTree* a, PreTree* b) 
404
 
                        : PreTreeComposite (2, 0) // 2 sons, no daughters.
405
 
            { add_son (a); add_son (b); };
406
 
 
407
 
        void accept (PreVisitor& v)
408
 
        {
409
 
            v.visitPreWarningDirective_Pre (this);
410
 
            v.iterateNodes (this);
411
 
            v.visitPreWarningDirective_Post (this);
412
 
        }
413
 
 };      
414
 
 
415
 
 
416
 
// The #error directive.
417
 
class PreErrorDirective : public PreTreeComposite
418
 
 {
419
 
    public:
420
 
                                        
421
 
        PreErrorDirective (PreTree* a, PreTree* b) 
422
 
                        : PreTreeComposite (2, 0) // 2 sons, no daughters.
423
 
            { add_son (a); add_son (b); };
424
 
 
425
 
        void accept (PreVisitor& v)
426
 
        {
427
 
            v.visitPreErrorDirective_Pre (this);
428
 
            v.iterateNodes (this);
429
 
            v.visitPreErrorDirective_Post (this);
430
 
        }
431
 
 };      
432
 
 
433
 
 
434
 
// Collects comma separated argument identifiers for a function-like macro.
435
 
// Like: id, id, ..., id.
436
 
class PreIdentifierList : public PreTreeComposite
437
 
 {
438
 
    public:
439
 
                                        // Dynamic sons, no daughters. 
440
 
        PreIdentifierList (PreTree* a) : PreTreeComposite (-1, 0)
441
 
            { add_son (a); };
442
 
        
443
 
        // Add two sons.
444
 
        void addSons (PreTree* a, PreTree* b)
445
 
            { add_son (a); add_son (b); };
446
 
 
447
 
        void accept (PreVisitor& v)
448
 
        {
449
 
            v.visitPreIdentifierList_Pre (this);
450
 
            v.iterateNodes (this);
451
 
            v.visitPreIdentifierList_Post (this);
452
 
        }
453
 
 };      
454
 
 
455
 
 
456
 
// Collects every kind of token  (except comments) for the macro body.
457
 
class PreTokenList : public PreTreeComposite
458
 
 {
459
 
    public:
460
 
                                        
461
 
        PreTokenList (PreTree* a, PreTree* b) 
462
 
                        : PreTreeComposite (2, 0) // 2 sons, no daughters.
463
 
            { add_son (a); add_son (b); };
464
 
        PreTokenList (PreTree* a) 
465
 
                        : PreTreeComposite (1, 0) // 1 son, no daughters.
466
 
            { add_son (a); };
467
 
        PreTokenList () : PreTreeComposite (0, 0) // no sons, no daughters.
468
 
            { };
469
 
        
470
 
        void accept (PreVisitor& v)
471
 
        {
472
 
            v.visitPreTokenList_Pre (this);
473
 
            v.iterateNodes (this);
474
 
            v.visitPreTokenList_Post (this);
475
 
        }
476
 
 };      
477
 
 
478
 
 
479
 
// Contains every kind of token  (except comments) for the macro body.
480
 
class PreTokenListPart : public PreTreeComposite
481
 
 {
482
 
    public:
483
 
                                        // Dynamic sons, no daughters.
484
 
        PreTokenListPart (PreTree* a) : PreTreeComposite (-1, 0)
485
 
            { add_son (a); };
486
 
        
487
 
        void accept (PreVisitor& v)
488
 
        {
489
 
            v.visitPreTokenListPart_Pre (this);
490
 
            v.iterateNodes (this);
491
 
            v.visitPreTokenListPart_Post (this);
492
 
        }
493
 
 };      
494
 
 
495
 
 
496
 
// Semantic node for conditionals.
497
 
class PreCondSemNode : public PreTree
498
 
 {
499
 
        // Boolean value of the condition of a conditional.
500
 
        bool _value;
501
 
 
502
 
    public:
503
 
 
504
 
        PreCondSemNode (bool value) : _value (value) {};
505
 
        
506
 
        void accept (PreVisitor& v)
507
 
        {
508
 
            v.visitPreCondSemNode (this);
509
 
        }
510
 
        
511
 
        // Get the value of the conditional.
512
 
        bool value () const { return _value; }
513
 
 };      
514
 
 
515
 
 
516
 
// Semantic node for the #include directive.
517
 
class PreInclSemNode : public PreTree
518
 
 {
519
 
        // Pointer of the included file unit.
520
 
        Unit* _unit;
521
 
        
522
 
        // true if the inclusion was not done, because of an active include
523
 
        // guard
524
 
        bool _guarded;
525
 
 
526
 
    public:
527
 
 
528
 
        PreInclSemNode (Unit* unit, bool guarded) :
529
 
          _unit (unit), _guarded (guarded) {};
530
 
        
531
 
        void accept (PreVisitor& v)
532
 
        {
533
 
            v.visitPreInclSemNode (this);
534
 
        }
535
 
        
536
 
        // Get the included file unit.
537
 
        Unit* unit () const { return _unit; }
538
 
        
539
 
        // Check if the inclusion was not done, because of an include guard
540
 
        bool guarded () const { return _guarded; }
541
 
 };      
542
 
 
543
 
 
544
 
// Special parse error node to show the location of an error in the
545
 
// preprocessor syntax tree.
546
 
class PreError : public PreTree
547
 
 {
548
 
    public:
549
 
 
550
 
        PreError () {};
551
 
        
552
 
        void accept (PreVisitor& v)
553
 
        {
554
 
            v.visitPreError (this);
555
 
        }
556
 
 };      
 
138
/** \class PreElifPart PreTreeNodes.h Puma/PreTreeNodes.h
 
139
 *  Preprocessor tree node representing a group of directives 
 
140
 *  in the \#elif part of an \#if conditional. */
 
141
class PreElifPart : public PreTreeComposite {
 
142
public:
 
143
  /** Constructor. */
 
144
  PreElifPart () : PreTreeComposite (-1, 0) {}
 
145
        
 
146
  /** Add two sons, a directive group and a \#elif directive.
 
147
   *  \param dg The directive group.
 
148
   *  \param el The \#elif directive. */
 
149
  void addSons (PreTree* dg, PreTree* el) { 
 
150
    add_son (dg); add_son (el); 
 
151
  }
 
152
 
 
153
  /** Part of the tree visitor pattern. Calls the node
 
154
   *  visiting functions suitable for this node type. 
 
155
   *  \param v The visitor object on which to call the 
 
156
   *           visiting functions. */
 
157
  void accept (PreVisitor& v) {
 
158
    v.visitPreElifPart_Pre (this);
 
159
    v.iterateNodes (this);
 
160
    v.visitPreElifPart_Post (this);
 
161
  }
 
162
};      
 
163
 
 
164
 
 
165
/** \class PreIfDirective PreTreeNodes.h Puma/PreTreeNodes.h
 
166
 *  Preprocessor tree node representing an \#if directive. 
 
167
 *  Example: \code #if OSTYPE==Linux \endcode */
 
168
class PreIfDirective : public PreTreeComposite {
 
169
public:
 
170
  /** Constructor.
 
171
   *  \param i The \#if token.
 
172
   *  \param c The condition. */
 
173
  PreIfDirective (PreTree* i, PreTree* c) : PreTreeComposite (2, 1) { 
 
174
    add_son (i); add_son (c); 
 
175
  }
 
176
 
 
177
  /** Part of the tree visitor pattern. Calls the node
 
178
   *  visiting functions suitable for this node type. 
 
179
   *  \param v The visitor object on which to call the 
 
180
   *           visiting functions. */
 
181
  void accept (PreVisitor& v) {
 
182
    v.visitPreIfDirective_Pre (this);
 
183
    v.iterateNodes (this);
 
184
    v.visitPreIfDirective_Post (this);
 
185
  }
 
186
};      
 
187
 
 
188
 
 
189
/** \class PreIfdefDirective PreTreeNodes.h Puma/PreTreeNodes.h
 
190
 *  Preprocessor tree node representing an \#ifdef directive. 
 
191
 *  Example: \code #ifdef Linux \endcode */
 
192
class PreIfdefDirective : public PreTreeComposite {
 
193
public:
 
194
  /** Constructor. 
 
195
   *  \param i The \#ifdef token.
 
196
   *  \param n The name of the macro. 
 
197
   *  \param tl The remaining tokens of the line. */
 
198
  PreIfdefDirective (PreTree* i, PreTree* n, PreTree* tl) : PreTreeComposite (3, 1) { 
 
199
    add_son (i); add_son (n); add_son (tl); 
 
200
  }
 
201
  /** Constructor. 
 
202
   *  \param i The \#ifdef token.
 
203
   *  \param tl The remaining tokens of the line. */
 
204
  PreIfdefDirective (PreTree* i, PreTree* tl) : PreTreeComposite (2, 0) { 
 
205
    add_son (i); add_son (tl); 
 
206
  }
 
207
 
 
208
  /** Part of the tree visitor pattern. Calls the node
 
209
   *  visiting functions suitable for this node type. 
 
210
   *  \param v The visitor object on which to call the 
 
211
   *           visiting functions. */
 
212
  void accept (PreVisitor& v) {
 
213
    v.visitPreIfdefDirective_Pre (this);
 
214
    v.iterateNodes (this);
 
215
    v.visitPreIfdefDirective_Post (this);
 
216
  }
 
217
};      
 
218
 
 
219
 
 
220
/** \class PreIfndefDirective PreTreeNodes.h Puma/PreTreeNodes.h
 
221
 *  Preprocessor tree node representing an \#ifndef directive. 
 
222
 *  Example: \code #ifndef Linux \endcode */
 
223
class PreIfndefDirective : public PreTreeComposite {
 
224
public:
 
225
  /** Constructor. 
 
226
   *  \param i The \#ifndef token.
 
227
   *  \param n The name of the macro. 
 
228
   *  \param tl The remaining tokens of the line. */
 
229
  PreIfndefDirective (PreTree* i, PreTree* n, PreTree* tl) : PreTreeComposite (3, 1) { 
 
230
    add_son (i); add_son (n); add_son (tl); 
 
231
  }
 
232
  /** Constructor. 
 
233
   *  \param i The \#ifndef token.
 
234
   *  \param tl The remaining tokens of the line. */
 
235
  PreIfndefDirective (PreTree* i, PreTree* tl) : PreTreeComposite (2, 0) { 
 
236
    add_son (i); add_son (tl); 
 
237
  }
 
238
 
 
239
  /** Part of the tree visitor pattern. Calls the node
 
240
   *  visiting functions suitable for this node type. 
 
241
   *  \param v The visitor object on which to call the 
 
242
   *           visiting functions. */
 
243
  void accept (PreVisitor& v) {
 
244
    v.visitPreIfndefDirective_Pre (this);
 
245
    v.iterateNodes (this);
 
246
    v.visitPreIfndefDirective_Post (this);
 
247
  }
 
248
};      
 
249
 
 
250
 
 
251
/** \class PreElifDirective PreTreeNodes.h Puma/PreTreeNodes.h
 
252
 *  Preprocessor tree node representing an \#elif directive. 
 
253
 *  Example: \code #elif OSTYPE==linux \endcode */
 
254
class PreElifDirective : public PreTreeComposite {
 
255
public:
 
256
  /** Constructor. 
 
257
   *  \param e The \#elif token.
 
258
   *  \param c The condition. */
 
259
  PreElifDirective (PreTree* e, PreTree* c) : PreTreeComposite (2, 1) { 
 
260
    add_son (e); add_son (c); 
 
261
  }
 
262
 
 
263
  /** Part of the tree visitor pattern. Calls the node
 
264
   *  visiting functions suitable for this node type. 
 
265
   *  \param v The visitor object on which to call the 
 
266
   *           visiting functions. */
 
267
  void accept (PreVisitor& v) {
 
268
    v.visitPreElifDirective_Pre (this);
 
269
    v.iterateNodes (this);
 
270
    v.visitPreElifDirective_Post (this);
 
271
  }
 
272
};      
 
273
 
 
274
 
 
275
/** \class PreElseDirective PreTreeNodes.h Puma/PreTreeNodes.h
 
276
 *  Preprocessor tree node representing an \#else directive. 
 
277
 *  Example: \code #else \endcode */
 
278
class PreElseDirective : public PreTreeComposite {
 
279
public:
 
280
  /** Constructor. 
 
281
   *  \param e The \#else token.
 
282
   *  \param tl The remaining tokens of the line. */
 
283
  PreElseDirective (PreTree* e, PreTree* tl) : PreTreeComposite (2, 0) { 
 
284
    add_son (e); add_son (tl); 
 
285
  }
 
286
 
 
287
  /** Part of the tree visitor pattern. Calls the node
 
288
   *  visiting functions suitable for this node type. 
 
289
   *  \param v The visitor object on which to call the 
 
290
   *           visiting functions. */
 
291
  void accept (PreVisitor& v) {
 
292
    v.visitPreElseDirective_Pre (this);
 
293
    v.iterateNodes (this);
 
294
    v.visitPreElseDirective_Post (this);
 
295
  }
 
296
};      
 
297
 
 
298
 
 
299
/** \class PreEndifDirective PreTreeNodes.h Puma/PreTreeNodes.h
 
300
 *  Preprocessor tree node representing an \#endif directive. 
 
301
 *  Example: \code #endif \endcode */
 
302
class PreEndifDirective : public PreTreeComposite {
 
303
public:
 
304
  /** Constructor. 
 
305
   *  \param e The \#endif token.
 
306
   *  \param tl The remaining tokens of the line. */
 
307
  PreEndifDirective (PreTree* e, PreTree* tl) : PreTreeComposite (2, 0) { 
 
308
    add_son (e); add_son (tl); 
 
309
  }
 
310
 
 
311
  /** Part of the tree visitor pattern. Calls the node
 
312
   *  visiting functions suitable for this node type. 
 
313
   *  \param v The visitor object on which to call the 
 
314
   *           visiting functions. */
 
315
  void accept (PreVisitor& v) {
 
316
    v.visitPreEndifDirective_Pre (this);
 
317
    v.iterateNodes (this);
 
318
    v.visitPreEndifDirective_Post (this);
 
319
  }
 
320
};      
 
321
 
 
322
 
 
323
/** \class PreIncludeDirective PreTreeNodes.h Puma/PreTreeNodes.h
 
324
 *  Preprocessor tree node representing an \#include or \#include_next directive. 
 
325
 *  Example: \code #include <stdio.h> \endcode */
 
326
class PreIncludeDirective : public PreTreeComposite {
 
327
  int _depth; // depth of nested includes
 
328
 
 
329
public:
 
330
  /** Constructor. 
 
331
   *  \param i The \#include or \#include_next token. 
 
332
   *  \param tl The remaining tokens of the line containing the file to include. */
 
333
  PreIncludeDirective (PreTree* i, PreTree* tl) : PreTreeComposite (2, 1) { 
 
334
    add_son (i); add_son (tl); 
 
335
    _depth = -1; 
 
336
  }
 
337
 
 
338
  /** Part of the tree visitor pattern. Calls the node
 
339
   *  visiting functions suitable for this node type. 
 
340
   *  \param v The visitor object on which to call the 
 
341
   *           visiting functions. */
 
342
  void accept (PreVisitor& v) {
 
343
    v.visitPreIncludeDirective_Pre (this);
 
344
    v.iterateNodes (this);
 
345
    v.visitPreIncludeDirective_Post (this);
 
346
  }
 
347
        
 
348
  /** Get the depth of nested inclusion. 
 
349
   *  \return The depth or -1 for a top-level include. */
 
350
  int depth () const {
 
351
    return _depth;
 
352
  }
 
353
  /** Set the depth of nested inclusion. 
 
354
   *  \param d The depth of inclusion. */
 
355
  void depth (int d) {
 
356
    _depth = d;
 
357
  }
 
358
        
 
359
  /** Check if this is a forced include (given by command line). */
 
360
  bool is_forced () const {
 
361
    return !((Unit*)startToken ()->belonging_to ())->isFile ();
 
362
  }
 
363
};      
 
364
 
 
365
 
 
366
/** \class PreAssertDirective PreTreeNodes.h Puma/PreTreeNodes.h
 
367
 *  Preprocessor tree node representing an \#assert directive. 
 
368
 *  Example: \code #assert OSTYPE (linux) \endcode */
 
369
class PreAssertDirective : public PreTreeComposite {
 
370
public:
 
371
  /** Constructor. 
 
372
   *  \param a The \#assert token.
 
373
   *  \param p The predicate name.
 
374
   *  \param an The answer to the predicate. */
 
375
  PreAssertDirective (PreTree* a, PreTree* p, PreTree* an) : PreTreeComposite (3, 0) { 
 
376
    add_son (a); add_son (p); add_son (an); 
 
377
  }
 
378
  /** Constructor. 
 
379
   *  \param a The \#assert token.
 
380
   *  \param tl The remaining tokens of the line. */
 
381
  PreAssertDirective (PreTree* a, PreTree* tl) : PreTreeComposite (2, 0) { 
 
382
    add_son (a); add_son (tl); 
 
383
  }
 
384
 
 
385
  /** Part of the tree visitor pattern. Calls the node
 
386
   *  visiting functions suitable for this node type. 
 
387
   *  \param v The visitor object on which to call the 
 
388
   *           visiting functions. */
 
389
  void accept (PreVisitor& v) {
 
390
    v.visitPreAssertDirective_Pre (this);
 
391
    v.iterateNodes (this);
 
392
    v.visitPreAssertDirective_Post (this);
 
393
  }
 
394
};      
 
395
 
 
396
 
 
397
/** \class PreUnassertDirective PreTreeNodes.h Puma/PreTreeNodes.h
 
398
 *  Preprocessor tree node representing an \#unassert directive. 
 
399
 *  Example: \code #unassert OSTYPE \endcode */
 
400
class PreUnassertDirective : public PreTreeComposite {
 
401
public:
 
402
  /** Constructor. 
 
403
   *  \param ua The \#unassert token. 
 
404
   *  \param n The name of the predicate.
 
405
   *  \param tl The remaining tokens of the line. */
 
406
  PreUnassertDirective (PreTree* ua, PreTree* n, PreTree* tl) : PreTreeComposite (3, 0) { 
 
407
    add_son (ua); add_son (n); add_son (tl); 
 
408
  }
 
409
  /** Constructor. 
 
410
   *  \param ua The \#unassert token. 
 
411
   *  \param tl The remaining tokens of the line. */
 
412
  PreUnassertDirective (PreTree* ua, PreTree* tl) : PreTreeComposite (2, 0) { 
 
413
    add_son (ua); add_son (tl); 
 
414
  }
 
415
 
 
416
  /** Part of the tree visitor pattern. Calls the node
 
417
   *  visiting functions suitable for this node type. 
 
418
   *  \param v The visitor object on which to call the 
 
419
   *           visiting functions. */
 
420
  void accept (PreVisitor& v) {
 
421
    v.visitPreUnassertDirective_Pre (this);
 
422
    v.iterateNodes (this);
 
423
    v.visitPreUnassertDirective_Post (this);
 
424
  }
 
425
};      
 
426
 
 
427
 
 
428
/** \class PreDefineFunctionDirective PreTreeNodes.h Puma/PreTreeNodes.h
 
429
 *  Preprocessor tree node representing a \#define directive for function-like macros. 
 
430
 *  Example: \code #define MUL(a,b) (a * b) \endcode */
 
431
class PreDefineFunctionDirective : public PreTreeComposite {
 
432
public:
 
433
  /** Constructor. 
 
434
   *  \param a The \#define token.
 
435
   *  \param b The macro name.
 
436
   *  \param c Left parenthesis before the parameter list.
 
437
   *  \param d The macro parameter list. 
 
438
   *  \param e Comma before the last parameter.
 
439
   *  \param f The token '...'.
 
440
   *  \param g Right parenthesis behind the parameter list.
 
441
   *  \param h The macro body. */
 
442
  PreDefineFunctionDirective (PreTree* a, PreTree* b, PreTree* c, PreTree* d, 
 
443
   PreTree* e, PreTree* f, PreTree* g, PreTree* h) : PreTreeComposite (8, 0) { 
 
444
    add_son (a); add_son (b); add_son (c); add_son (d);
 
445
    add_son (e); add_son (f); add_son (g); add_son (h); 
 
446
  }
 
447
 
 
448
  /** Constructor. 
 
449
   *  \param a The \#define token.
 
450
   *  \param b The macro name.
 
451
   *  \param c Left parenthesis before the parameter list.
 
452
   *  \param d The macro parameter list. 
 
453
   *  \param e The token '...'.
 
454
   *  \param f Right parenthesis behind the parameter list.
 
455
   *  \param g The macro body. */
 
456
  PreDefineFunctionDirective (PreTree* a, PreTree* b, PreTree* c, PreTree* d, 
 
457
   PreTree* e, PreTree* f, PreTree* g) : PreTreeComposite (7, 0) { 
 
458
    add_son (a); add_son (b); add_son (c); add_son (d);
 
459
    add_son (e); add_son (f); add_son (g); 
 
460
  }
 
461
 
 
462
  /** Constructor. 
 
463
   *  \param a The \#define token.
 
464
   *  \param b The macro name.
 
465
   *  \param c Left parenthesis before the parameter list.
 
466
   *  \param d The macro parameter list. 
 
467
   *  \param e Right parenthesis behind the parameter list.
 
468
   *  \param f The macro body. */
 
469
  PreDefineFunctionDirective (PreTree* a, PreTree* b, PreTree* c, PreTree* d, 
 
470
   PreTree* e, PreTree* f) : PreTreeComposite (6, 0) { 
 
471
    add_son (a); add_son (b); add_son (c); 
 
472
    add_son (d); add_son (e); add_son (f); 
 
473
  }
 
474
        
 
475
  /** Constructor. 
 
476
   *  \param a The \#define token.
 
477
   *  \param b The macro name.
 
478
   *  \param c Left parenthesis before the parameter list.
 
479
   *  \param d Right parenthesis behind the parameter list.
 
480
   *  \param e The macro body. */
 
481
  PreDefineFunctionDirective (PreTree* a, PreTree* b, PreTree* c, 
 
482
   PreTree* d, PreTree* e) : PreTreeComposite (5, 0) { 
 
483
    add_son (a); add_son (b); add_son (c); add_son (d); add_son (e); 
 
484
  }
 
485
 
 
486
  /** Part of the tree visitor pattern. Calls the node
 
487
   *  visiting functions suitable for this node type. 
 
488
   *  \param v The visitor object on which to call the 
 
489
   *           visiting functions. */
 
490
  void accept (PreVisitor& v) {
 
491
    v.visitPreDefineFunctionDirective_Pre (this);
 
492
    v.iterateNodes (this);
 
493
    v.visitPreDefineFunctionDirective_Post (this);
 
494
  }
 
495
};   
 
496
 
 
497
 
 
498
/** \class PreDefineConstantDirective PreTreeNodes.h Puma/PreTreeNodes.h
 
499
 *  Preprocessor tree node representing a \#define directive for constants. 
 
500
 *  Example: \code #define CONSTANT 1 \endcode */
 
501
class PreDefineConstantDirective : public PreTreeComposite {
 
502
public:
 
503
  /** Constructor. 
 
504
   *  \param d The \#define token.
 
505
   *  \param n The name of the constant.
 
506
   *  \param v The constant value. */
 
507
  PreDefineConstantDirective (PreTree* d, PreTree* n, PreTree* v) : PreTreeComposite (3, 0) { 
 
508
    add_son (d); add_son (n); add_son (v); 
 
509
  }
 
510
  /** Constructor. 
 
511
   *  \param d The \#define token.
 
512
   *  \param tl The remaining tokens of the line. */
 
513
  PreDefineConstantDirective (PreTree* d, PreTree* tl) : PreTreeComposite (2, 0) { 
 
514
    add_son (d); add_son (tl); 
 
515
  }
 
516
 
 
517
  /** Part of the tree visitor pattern. Calls the node
 
518
   *  visiting functions suitable for this node type. 
 
519
   *  \param v The visitor object on which to call the 
 
520
   *           visiting functions. */
 
521
  void accept (PreVisitor& v) {
 
522
    v.visitPreDefineConstantDirective_Pre (this);
 
523
    v.iterateNodes (this);
 
524
    v.visitPreDefineConstantDirective_Post (this);
 
525
  }
 
526
};      
 
527
 
 
528
 
 
529
/** \class PreUndefDirective PreTreeNodes.h Puma/PreTreeNodes.h
 
530
 *  Preprocessor tree node representing an \#undef directive. 
 
531
 *  Example: \code #undef MACRO \endcode */
 
532
class PreUndefDirective : public PreTreeComposite {
 
533
public:
 
534
  /** Constructor. 
 
535
   *  \param u The \#undef token. 
 
536
   *  \param m The name of the macro to undefine. 
 
537
   *  \param tl The remaining tokens of the line. */
 
538
  PreUndefDirective (PreTree* u, PreTree* m, PreTree* tl) : PreTreeComposite (3, 0) { 
 
539
    add_son (u); add_son (m); add_son (tl); 
 
540
  }
 
541
  /** Constructor. 
 
542
   *  \param u The \#undef token.
 
543
   *  \param tl The remaining tokens of the line. */
 
544
  PreUndefDirective (PreTree* u, PreTree* tl) : PreTreeComposite (2, 0) { 
 
545
    add_son (u); add_son (tl); 
 
546
  }
 
547
 
 
548
  /** Part of the tree visitor pattern. Calls the node
 
549
   *  visiting functions suitable for this node type. 
 
550
   *  \param v The visitor object on which to call the 
 
551
   *           visiting functions. */
 
552
  void accept (PreVisitor& v) {
 
553
    v.visitPreUndefDirective_Pre (this);
 
554
    v.iterateNodes (this);
 
555
    v.visitPreUndefDirective_Post (this);
 
556
  }
 
557
};      
 
558
 
 
559
 
 
560
/** \class PreWarningDirective PreTreeNodes.h Puma/PreTreeNodes.h
 
561
 *  Preprocessor tree node representing a \#warning directive. 
 
562
 *  Example: \code #warning This is a warning. \endcode */
 
563
class PreWarningDirective : public PreTreeComposite {
 
564
public:
 
565
  /** Constructor. 
 
566
   *  \param w The \#warning token. 
 
567
   *  \param m The warning message. */
 
568
  PreWarningDirective (PreTree* w, PreTree* m) : PreTreeComposite (2, 0) { 
 
569
    add_son (w); add_son (m); 
 
570
  }
 
571
 
 
572
  /** Part of the tree visitor pattern. Calls the node
 
573
   *  visiting functions suitable for this node type. 
 
574
   *  \param v The visitor object on which to call the 
 
575
   *           visiting functions. */
 
576
  void accept (PreVisitor& v) {
 
577
    v.visitPreWarningDirective_Pre (this);
 
578
    v.iterateNodes (this);
 
579
    v.visitPreWarningDirective_Post (this);
 
580
  }
 
581
};      
 
582
 
 
583
 
 
584
/** \class PreErrorDirective PreTreeNodes.h Puma/PreTreeNodes.h
 
585
 *  Preprocessor tree node representing an \#error directive. 
 
586
 *  Example: \code #error This is an error. \endcode */
 
587
class PreErrorDirective : public PreTreeComposite {
 
588
public:
 
589
  /** Constructor. 
 
590
   *  \param e The \#error token.
 
591
   *  \param m The error message. */
 
592
  PreErrorDirective (PreTree* e, PreTree* m) : PreTreeComposite (2, 0) { 
 
593
    add_son (e); add_son (m); 
 
594
  }
 
595
 
 
596
  /** Part of the tree visitor pattern. Calls the node
 
597
   *  visiting functions suitable for this node type. 
 
598
   *  \param v The visitor object on which to call the 
 
599
   *           visiting functions. */
 
600
  void accept (PreVisitor& v) {
 
601
    v.visitPreErrorDirective_Pre (this);
 
602
    v.iterateNodes (this);
 
603
    v.visitPreErrorDirective_Post (this);
 
604
  }
 
605
};      
 
606
 
 
607
 
 
608
/** \class PreIdentifierList PreTreeNodes.h Puma/PreTreeNodes.h
 
609
 *  Preprocessor tree node representing the identifier list of a 
 
610
 *  function-like macro definition. 
 
611
 *  Example: \code a,b,c \endcode */
 
612
class PreIdentifierList : public PreTreeComposite {
 
613
public:
 
614
  /** Constructor. 
 
615
   *  \param id An identifier. */
 
616
  PreIdentifierList (PreTree* id) : PreTreeComposite (-1, 0) { 
 
617
    add_son (id); 
 
618
  }
 
619
        
 
620
  /** Add two sons, a comma and an identifier.
 
621
   *  \param c A comma.
 
622
   *  \param id An identifier. */
 
623
  void addSons (PreTree* c, PreTree* id) { 
 
624
    add_son (c); add_son (id); 
 
625
  }
 
626
 
 
627
  /** Part of the tree visitor pattern. Calls the node
 
628
   *  visiting functions suitable for this node type. 
 
629
   *  \param v The visitor object on which to call the 
 
630
   *           visiting functions. */
 
631
  void accept (PreVisitor& v) {
 
632
    v.visitPreIdentifierList_Pre (this);
 
633
    v.iterateNodes (this);
 
634
    v.visitPreIdentifierList_Post (this);
 
635
  }
 
636
};
 
637
 
 
638
 
 
639
/** \class PreTokenList PreTreeNodes.h Puma/PreTreeNodes.h
 
640
 *  Preprocessor tree node representing the token list of a macro body. */
 
641
class PreTokenList : public PreTreeComposite {
 
642
public:
 
643
  /** Constructor. */
 
644
  PreTokenList () : PreTreeComposite (0, 0) {}
 
645
  /** Constructor. 
 
646
   *  \param tl The token list. 
 
647
   *  \param nl The newline token. */
 
648
  PreTokenList (PreTree* tl, PreTree* nl) : PreTreeComposite (2, 0) { 
 
649
    add_son (tl); add_son (nl); 
 
650
  }
 
651
  /** Constructor. 
 
652
   *  \param tl The token list. */
 
653
  PreTokenList (PreTree* tl) : PreTreeComposite (1, 0) { 
 
654
    add_son (tl); 
 
655
  }
 
656
        
 
657
  /** Part of the tree visitor pattern. Calls the node
 
658
   *  visiting functions suitable for this node type. 
 
659
   *  \param v The visitor object on which to call the 
 
660
   *           visiting functions. */
 
661
  void accept (PreVisitor& v) {
 
662
    v.visitPreTokenList_Pre (this);
 
663
    v.iterateNodes (this);
 
664
    v.visitPreTokenList_Post (this);
 
665
  }
 
666
};      
 
667
 
 
668
 
 
669
/** \class PreTokenListPart PreTreeNodes.h Puma/PreTreeNodes.h
 
670
 *  Preprocessor tree node representing a part of the token list of a macro body. */
 
671
class PreTokenListPart : public PreTreeComposite {
 
672
public:
 
673
  /** Constructor. 
 
674
   *  \param tl The token list. */
 
675
  PreTokenListPart (PreTree* tl) : PreTreeComposite (-1, 0) { 
 
676
    add_son (tl); 
 
677
  }
 
678
        
 
679
  /** Part of the tree visitor pattern. Calls the node
 
680
   *  visiting functions suitable for this node type. 
 
681
   *  \param v The visitor object on which to call the 
 
682
   *           visiting functions. */
 
683
  void accept (PreVisitor& v) {
 
684
    v.visitPreTokenListPart_Pre (this);
 
685
    v.iterateNodes (this);
 
686
    v.visitPreTokenListPart_Post (this);
 
687
  }
 
688
};      
 
689
 
 
690
 
 
691
/** \class PreCondSemNode PreTreeNodes.h Puma/PreTreeNodes.h
 
692
 *  Preprocessor semantic tree node for conditions. */
 
693
class PreCondSemNode : public PreTree {
 
694
  // The calculated value of the condition.
 
695
  bool _value;
 
696
 
 
697
public:
 
698
  /** Constructor. 
 
699
   *  \param value The calculated value of the condition. */
 
700
  PreCondSemNode (bool value) : _value (value) {}
 
701
        
 
702
  /** Part of the tree visitor pattern. Calls the node
 
703
   *  visiting functions suitable for this node type. 
 
704
   *  \param v The visitor object on which to call the 
 
705
   *           visiting functions. */
 
706
  void accept (PreVisitor& v) {
 
707
    v.visitPreCondSemNode (this);
 
708
  }
 
709
        
 
710
  /** Get the calculated value of the condition. */
 
711
  bool value () const { return _value; }
 
712
};      
 
713
 
 
714
 
 
715
/** \class PreInclSemNode PreTreeNodes.h Puma/PreTreeNodes.h
 
716
 *  Preprocessor semantic tree node for the \#include directive
 
717
 *  containing the unit to include. */
 
718
class PreInclSemNode : public PreTree {
 
719
  // Pointer to the included file unit.
 
720
  Unit* _unit;
 
721
        
 
722
  // True if the inclusion was not done, because of an active include guard.
 
723
  bool _guarded;
 
724
 
 
725
public:
 
726
  /** Constructor. 
 
727
   *  \param unit The unit containing the tokens of the include file.
 
728
   *  \param guarded True if the inclusion was not done due to an include guard. */
 
729
  PreInclSemNode (Unit* unit, bool guarded) :
 
730
    _unit (unit), _guarded (guarded) {}
 
731
        
 
732
  /** Part of the tree visitor pattern. Calls the node
 
733
   *  visiting functions suitable for this node type. 
 
734
   *  \param v The visitor object on which to call the 
 
735
   *           visiting functions. */
 
736
  void accept (PreVisitor& v) {
 
737
    v.visitPreInclSemNode (this);
 
738
  }
 
739
        
 
740
  /** Get the token unit of the included file. */
 
741
  Unit* unit () const { return _unit; }
 
742
        
 
743
  /** Check if the inclusion was not done due to an include guard. */
 
744
  bool guarded () const { return _guarded; }
 
745
};      
 
746
 
 
747
 
 
748
/** \class PreError PreTreeNodes.h Puma/PreTreeNodes.h
 
749
 *  Preprocessor tree node representing a parse error. */
 
750
class PreError : public PreTree {
 
751
public:
 
752
  /** Constructor. */
 
753
  PreError () {}
 
754
        
 
755
  /** Part of the tree visitor pattern. Calls the node
 
756
   *  visiting functions suitable for this node type. 
 
757
   *  \param v The visitor object on which to call the 
 
758
   *           visiting functions. */
 
759
  void accept (PreVisitor& v) {
 
760
    v.visitPreError (this);
 
761
  }
 
762
};      
557
763
 
558
764
 
559
765
} // namespace Puma