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
106
// Dynamic sons, no daughters.
107
PreElifPart () : PreTreeComposite (-1, 0) {};
110
void addSons (PreTree* a, PreTree* b)
111
{ add_son (a); add_son (b); };
113
void accept (PreVisitor& v)
115
v.visitPreElifPart_Pre (this);
116
v.iterateNodes (this);
117
v.visitPreElifPart_Post (this);
122
// The #if directive.
123
class PreIfDirective : public PreTreeComposite
127
PreIfDirective (PreTree* a, PreTree* b)
128
: PreTreeComposite (2, 1) // 2 sons, 1 daughter.
129
{ add_son (a); add_son (b); };
131
void accept (PreVisitor& v)
133
v.visitPreIfDirective_Pre (this);
134
v.iterateNodes (this);
135
v.visitPreIfDirective_Post (this);
140
// The #ifdef directive.
141
class PreIfdefDirective : public PreTreeComposite
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); };
152
void accept (PreVisitor& v)
154
v.visitPreIfdefDirective_Pre (this);
155
v.iterateNodes (this);
156
v.visitPreIfdefDirective_Post (this);
161
// The #ifndef directive.
162
class PreIfndefDirective : public PreTreeComposite
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); };
173
void accept (PreVisitor& v)
175
v.visitPreIfndefDirective_Pre (this);
176
v.iterateNodes (this);
177
v.visitPreIfndefDirective_Post (this);
182
// The #elif directive.
183
class PreElifDirective : public PreTreeComposite
187
PreElifDirective (PreTree* a, PreTree* b)
188
: PreTreeComposite (2, 1) // 2 sons, 1 daughter.
189
{ add_son (a); add_son (b); };
191
void accept (PreVisitor& v)
193
v.visitPreElifDirective_Pre (this);
194
v.iterateNodes (this);
195
v.visitPreElifDirective_Post (this);
200
// The #else directive.
201
class PreElseDirective : public PreTreeComposite
205
PreElseDirective (PreTree* a, PreTree* b)
206
: PreTreeComposite (2, 0) // 2 sons, no daughters.
207
{ add_son (a); add_son (b); };
209
void accept (PreVisitor& v)
211
v.visitPreElseDirective_Pre (this);
212
v.iterateNodes (this);
213
v.visitPreElseDirective_Post (this);
218
// The #endif directive.
219
class PreEndifDirective : public PreTreeComposite
223
PreEndifDirective (PreTree* a, PreTree* b)
224
: PreTreeComposite (2, 0) // 2 sons, no daughters.
225
{ add_son (a); add_son (b); };
227
void accept (PreVisitor& v)
229
v.visitPreEndifDirective_Pre (this);
230
v.iterateNodes (this);
231
v.visitPreEndifDirective_Post (this);
236
// The #include and #include_next directive.
237
class PreIncludeDirective : public PreTreeComposite
243
PreIncludeDirective (PreTree* a, PreTree* b)
244
: PreTreeComposite (2, 1) // 2 sons, 1 daughter.
245
{ add_son (a); add_son (b); _depth = -1; };
247
void accept (PreVisitor& v)
249
v.visitPreIncludeDirective_Pre (this);
250
v.iterateNodes (this);
251
v.visitPreIncludeDirective_Post (this);
264
bool is_forced () const {
265
return !((Unit*)startToken ()->belonging_to ())->isFile ();
270
// The #assert directive.
271
class PreAssertDirective : public PreTreeComposite
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); };
282
void accept (PreVisitor& v)
284
v.visitPreAssertDirective_Pre (this);
285
v.iterateNodes (this);
286
v.visitPreAssertDirective_Post (this);
291
// The #unassert directive.
292
class PreUnassertDirective : public PreTreeComposite
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); };
303
void accept (PreVisitor& v)
305
v.visitPreUnassertDirective_Pre (this);
306
v.iterateNodes (this);
307
v.visitPreUnassertDirective_Post (this);
312
// The #define directive that defines function-like macros.
313
// Like: #define FUNCTION (id,...,id) ... ... ...
314
class PreDefineFunctionDirective : public PreTreeComposite
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); }
326
PreDefineFunctionDirective (PreTree* a, PreTree* b,
327
PreTree* c, PreTree* d,
328
PreTree* e, PreTree* f,
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); }
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); }
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); }
346
void accept (PreVisitor& v)
348
v.visitPreDefineFunctionDirective_Pre (this);
349
v.iterateNodes (this);
350
v.visitPreDefineFunctionDirective_Post (this);
355
// The #define directive that defines symbolic constants macros.
356
// Like: #define CONSTANT ... ... ...
357
class PreDefineConstantDirective : public PreTreeComposite
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); };
368
void accept (PreVisitor& v)
370
v.visitPreDefineConstantDirective_Pre (this);
371
v.iterateNodes (this);
372
v.visitPreDefineConstantDirective_Post (this);
377
// The #undef directive.
378
class PreUndefDirective : public PreTreeComposite
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); };
389
void accept (PreVisitor& v)
391
v.visitPreUndefDirective_Pre (this);
392
v.iterateNodes (this);
393
v.visitPreUndefDirective_Post (this);
398
// The #warning directive.
399
class PreWarningDirective : public PreTreeComposite
403
PreWarningDirective (PreTree* a, PreTree* b)
404
: PreTreeComposite (2, 0) // 2 sons, no daughters.
405
{ add_son (a); add_son (b); };
407
void accept (PreVisitor& v)
409
v.visitPreWarningDirective_Pre (this);
410
v.iterateNodes (this);
411
v.visitPreWarningDirective_Post (this);
416
// The #error directive.
417
class PreErrorDirective : public PreTreeComposite
421
PreErrorDirective (PreTree* a, PreTree* b)
422
: PreTreeComposite (2, 0) // 2 sons, no daughters.
423
{ add_son (a); add_son (b); };
425
void accept (PreVisitor& v)
427
v.visitPreErrorDirective_Pre (this);
428
v.iterateNodes (this);
429
v.visitPreErrorDirective_Post (this);
434
// Collects comma separated argument identifiers for a function-like macro.
435
// Like: id, id, ..., id.
436
class PreIdentifierList : public PreTreeComposite
439
// Dynamic sons, no daughters.
440
PreIdentifierList (PreTree* a) : PreTreeComposite (-1, 0)
444
void addSons (PreTree* a, PreTree* b)
445
{ add_son (a); add_son (b); };
447
void accept (PreVisitor& v)
449
v.visitPreIdentifierList_Pre (this);
450
v.iterateNodes (this);
451
v.visitPreIdentifierList_Post (this);
456
// Collects every kind of token (except comments) for the macro body.
457
class PreTokenList : public PreTreeComposite
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.
467
PreTokenList () : PreTreeComposite (0, 0) // no sons, no daughters.
470
void accept (PreVisitor& v)
472
v.visitPreTokenList_Pre (this);
473
v.iterateNodes (this);
474
v.visitPreTokenList_Post (this);
479
// Contains every kind of token (except comments) for the macro body.
480
class PreTokenListPart : public PreTreeComposite
483
// Dynamic sons, no daughters.
484
PreTokenListPart (PreTree* a) : PreTreeComposite (-1, 0)
487
void accept (PreVisitor& v)
489
v.visitPreTokenListPart_Pre (this);
490
v.iterateNodes (this);
491
v.visitPreTokenListPart_Post (this);
496
// Semantic node for conditionals.
497
class PreCondSemNode : public PreTree
499
// Boolean value of the condition of a conditional.
504
PreCondSemNode (bool value) : _value (value) {};
506
void accept (PreVisitor& v)
508
v.visitPreCondSemNode (this);
511
// Get the value of the conditional.
512
bool value () const { return _value; }
516
// Semantic node for the #include directive.
517
class PreInclSemNode : public PreTree
519
// Pointer of the included file unit.
522
// true if the inclusion was not done, because of an active include
528
PreInclSemNode (Unit* unit, bool guarded) :
529
_unit (unit), _guarded (guarded) {};
531
void accept (PreVisitor& v)
533
v.visitPreInclSemNode (this);
536
// Get the included file unit.
537
Unit* unit () const { return _unit; }
539
// Check if the inclusion was not done, because of an include guard
540
bool guarded () const { return _guarded; }
544
// Special parse error node to show the location of an error in the
545
// preprocessor syntax tree.
546
class PreError : public PreTree
552
void accept (PreVisitor& v)
554
v.visitPreError (this);
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 {
144
PreElifPart () : PreTreeComposite (-1, 0) {}
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);
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);
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 {
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);
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);
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 {
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);
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);
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);
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 {
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);
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);
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);
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 {
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);
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);
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 {
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);
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);
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 {
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);
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);
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
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);
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);
348
/** Get the depth of nested inclusion.
349
* \return The depth or -1 for a top-level include. */
353
/** Set the depth of nested inclusion.
354
* \param d The depth of inclusion. */
359
/** Check if this is a forced include (given by command line). */
360
bool is_forced () const {
361
return !((Unit*)startToken ()->belonging_to ())->isFile ();
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 {
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);
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);
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);
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 {
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);
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);
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);
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 {
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);
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);
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);
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);
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);
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 {
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);
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);
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);
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 {
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);
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);
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);
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 {
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);
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);
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 {
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);
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);
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 {
615
* \param id An identifier. */
616
PreIdentifierList (PreTree* id) : PreTreeComposite (-1, 0) {
620
/** Add two sons, a comma and an identifier.
622
* \param id An identifier. */
623
void addSons (PreTree* c, PreTree* id) {
624
add_son (c); add_son (id);
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);
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 {
644
PreTokenList () : PreTreeComposite (0, 0) {}
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);
652
* \param tl The token list. */
653
PreTokenList (PreTree* tl) : PreTreeComposite (1, 0) {
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);
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 {
674
* \param tl The token list. */
675
PreTokenListPart (PreTree* tl) : PreTreeComposite (-1, 0) {
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);
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.
699
* \param value The calculated value of the condition. */
700
PreCondSemNode (bool value) : _value (value) {}
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);
710
/** Get the calculated value of the condition. */
711
bool value () const { return _value; }
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.
722
// True if the inclusion was not done, because of an active include guard.
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) {}
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);
740
/** Get the token unit of the included file. */
741
Unit* unit () const { return _unit; }
743
/** Check if the inclusion was not done due to an include guard. */
744
bool guarded () const { return _guarded; }
748
/** \class PreError PreTreeNodes.h Puma/PreTreeNodes.h
749
* Preprocessor tree node representing a parse error. */
750
class PreError : public PreTree {
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);
559
765
} // namespace Puma