001 //
002 // Generated by JTB 1.1.2
003 //
004
005 package jtb.cparser.visitor;
006 import jtb.cparser.syntaxtree.*;
007 import java.util.*;
008
009 /**
010 * Provides default methods which visit each node in the tree in depth-first
011 * order. Your visitors may extend this class.
012 */
013 public class DepthFirstVisitor implements Visitor {
014 //
015 // Auto class visitors--probably don't need to be overridden.
016 //
017 public void visit(NodeList n) {
018 for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); )
019 (e.nextElement()).accept(this);
020 }
021
022 public void visit(NodeListOptional n) {
023 if ( n.present() )
024 for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); )
025 (e.nextElement()).accept(this);
026 }
027
028 public void visit(NodeOptional n) {
029 if ( n.present() )
030 n.node.accept(this);
031 }
032
033 public void visit(NodeSequence n) {
034 for ( Enumeration<Node> e = n.elements(); e.hasMoreElements(); )
035 (e.nextElement()).accept(this);
036 }
037
038 public void visit(NodeToken n) { }
039
040 //
041 // User-generated visitor methods below
042 //
043
044 /**
045 * f0 -> ( ExternalDeclaration() )+
046 */
047 public void visit(TranslationUnit n) {
048 n.f0.accept(this);
049 }
050
051 /**
052 * f0 -> ( FunctionDefinition() | Declaration() )
053 */
054 public void visit(ExternalDeclaration n) {
055 n.f0.accept(this);
056 }
057
058 /**
059 * f0 -> [ DeclarationSpecifiers() ]
060 * f1 -> Declarator()
061 * f2 -> [ DeclarationList() ]
062 * f3 -> CompoundStatement()
063 */
064 public void visit(FunctionDefinition n) {
065 n.f0.accept(this);
066 n.f1.accept(this);
067 n.f2.accept(this);
068 n.f3.accept(this);
069 }
070
071 /**
072 * f0 -> DeclarationSpecifiers()
073 * f1 -> [ InitDeclaratorList() ]
074 * f2 -> ";"
075 */
076 public void visit(Declaration n) {
077 n.f0.accept(this);
078 n.f1.accept(this);
079 n.f2.accept(this);
080 }
081
082 /**
083 * f0 -> ( Declaration() )+
084 */
085 public void visit(DeclarationList n) {
086 n.f0.accept(this);
087 }
088
089 /**
090 * f0 -> StorageClassSpecifier() [ DeclarationSpecifiers() ]
091 * | TypeSpecifier() [ DeclarationSpecifiers() ]
092 * | TypeQualifier() [ DeclarationSpecifiers() ]
093 */
094 public void visit(DeclarationSpecifiers n) {
095 n.f0.accept(this);
096 }
097
098 /**
099 * f0 -> ( < AUTO > | <REGISTER> | <STATIC> | <EXTERN> | <TYPEDEF> )
100 */
101 public void visit(StorageClassSpecifier n) {
102 n.f0.accept(this);
103 }
104
105 /**
106 * f0 -> ( <VOID> | <CHAR> | <SHORT> | <INT> | <LONG> | <FLOAT> | <DOUBLE> | <SIGNED> | <UNSIGNED> | StructOrUnionSpecifier() | EnumSpecifier() | TypedefName() )
107 */
108 public void visit(TypeSpecifier n) {
109 n.f0.accept(this);
110 }
111
112 /**
113 * f0 -> ( <CONST> | <VOLATILE> )
114 */
115 public void visit(TypeQualifier n) {
116 n.f0.accept(this);
117 }
118
119 /**
120
121 * f0 -> StructOrUnion()
122 * f1 -> ( [ <IDENTIFIER> ] "{" StructDeclarationList() "}" | <IDENTIFIER> )
123 */
124 public void visit(StructOrUnionSpecifier n) {
125 n.f0.accept(this);
126 n.f1.accept(this);
127 }
128
129 /**
130 * f0 -> ( <STRUCT> | <UNION> )
131 */
132 public void visit(StructOrUnion n) {
133 n.f0.accept(this);
134 }
135
136 /**
137 * f0 -> ( StructDeclaration() )+
138 */
139 public void visit(StructDeclarationList n) {
140 n.f0.accept(this);
141 }
142
143 /**
144 * f0 -> InitDeclarator()
145 * f1 -> ( "," InitDeclarator() )*
146 */
147 public void visit(InitDeclaratorList n) {
148 n.f0.accept(this);
149 n.f1.accept(this);
150 }
151
152 /**
153 * f0 -> Declarator()
154 * f1 -> [ "=" Initializer() ]
155 */
156 public void visit(InitDeclarator n) {
157 n.f0.accept(this);
158 n.f1.accept(this);
159 }
160
161 /**
162 * f0 -> SpecifierQualifierList()
163 * f1 -> StructDeclaratorList()
164 * f2 -> ";"
165 */
166 public void visit(StructDeclaration n) {
167 n.f0.accept(this);
168 n.f1.accept(this);
169 n.f2.accept(this);
170 }
171
172 /**
173 * f0 -> TypeSpecifier() [ SpecifierQualifierList() ]
174 * | TypeQualifier() [ SpecifierQualifierList() ]
175 */
176 public void visit(SpecifierQualifierList n) {
177 n.f0.accept(this);
178 }
179
180 /**
181 * f0 -> StructDeclarator()
182 * f1 -> ( "," StructDeclarator() )*
183 */
184 public void visit(StructDeclaratorList n) {
185 n.f0.accept(this);
186 n.f1.accept(this);
187 }
188
189 /**
190 * f0 -> ( Declarator() | [ Declarator() ] ":" ConstantExpression() )
191 */
192 public void visit(StructDeclarator n) {
193 n.f0.accept(this);
194 }
195
196 /**
197 * f0 -> <ENUM>
198 * f1 -> ( [ <IDENTIFIER> ] "{" EnumeratorList() "}" | <IDENTIFIER> )
199 */
200 public void visit(EnumSpecifier n) {
201 n.f0.accept(this);
202 n.f1.accept(this);
203 }
204
205 /**
206 * f0 -> Enumerator()
207 * f1 -> ( "," Enumerator() )*
208 */
209 public void visit(EnumeratorList n) {
210 n.f0.accept(this);
211 n.f1.accept(this);
212 }
213
214 /**
215 * f0 -> <IDENTIFIER>
216 * f1 -> [ "=" ConstantExpression() ]
217 */
218 public void visit(Enumerator n) {
219 n.f0.accept(this);
220 n.f1.accept(this);
221 }
222
223 /**
224 * f0 -> [ Pointer() ]
225 * f1 -> DirectDeclarator()
226 */
227 public void visit(Declarator n) {
228 n.f0.accept(this);
229 n.f1.accept(this);
230 }
231
232 /**
233 * f0 -> ( t=<IDENTIFIER> | "(" Declarator() ")" )
234 * f1 -> ( "[" [ ConstantExpression() ] "]" | "(" ParameterTypeList() ")" | "(" [ IdentifierList() ] ")" )*
235 */
236 public void visit(DirectDeclarator n) {
237 n.f0.accept(this);
238 n.f1.accept(this);
239 }
240
241 /**
242 * f0 -> "*"
243 * f1 -> [ TypeQualifierList() ]
244 * f2 -> [ Pointer() ]
245 */
246 public void visit(Pointer n) {
247 n.f0.accept(this);
248 n.f1.accept(this);
249 n.f2.accept(this);
250 }
251
252 /**
253 * f0 -> ( TypeQualifier() )+
254 */
255 public void visit(TypeQualifierList n) {
256 n.f0.accept(this);
257 }
258
259 /**
260 * f0 -> ParameterList()
261 * f1 -> [ "," "..." ]
262 */
263 public void visit(ParameterTypeList n) {
264 n.f0.accept(this);
265 n.f1.accept(this);
266 }
267
268 /**
269 * f0 -> ParameterDeclaration()
270 * f1 -> ( "," ParameterDeclaration() )*
271 */
272 public void visit(ParameterList n) {
273 n.f0.accept(this);
274 n.f1.accept(this);
275 }
276
277 /**
278 * f0 -> DeclarationSpecifiers()
279 * f1 -> ( Declarator() | [ AbstractDeclarator() ] )
280 */
281 public void visit(ParameterDeclaration n) {
282 n.f0.accept(this);
283 n.f1.accept(this);
284 }
285
286 /**
287 * f0 -> <IDENTIFIER>
288 * f1 -> ( "," <IDENTIFIER> )*
289 */
290 public void visit(IdentifierList n) {
291 n.f0.accept(this);
292 n.f1.accept(this);
293 }
294
295 /**
296 * f0 -> ( AssignmentExpression() | "{" InitializerList() [ "," ] "}" )
297 */
298 public void visit(Initializer n) {
299 n.f0.accept(this);
300 }
301
302 /**
303 * f0 -> Initializer()
304 * f1 -> ( "," Initializer() )*
305 */
306 public void visit(InitializerList n) {
307 n.f0.accept(this);
308 n.f1.accept(this);
309 }
310
311 /**
312 * f0 -> SpecifierQualifierList()
313 * f1 -> [ AbstractDeclarator() ]
314 */
315 public void visit(TypeName n) {
316 n.f0.accept(this);
317 n.f1.accept(this);
318 }
319
320 /**
321 * f0 -> ( Pointer() | [ Pointer() ] DirectAbstractDeclarator() )
322 */
323 public void visit(AbstractDeclarator n) {
324 n.f0.accept(this);
325 }
326
327 /**
328 * f0 -> ( "(" AbstractDeclarator() ")" | "[" [ ConstantExpression() ] "]" | "(" [ ParameterTypeList() ] ")" )
329 * f1 -> ( "[" [ ConstantExpression() ] "]" | "(" [ ParameterTypeList() ] ")" )*
330 */
331 public void visit(DirectAbstractDeclarator n) {
332 n.f0.accept(this);
333 n.f1.accept(this);
334 }
335
336 /**
337 * f0 -> <IDENTIFIER>
338 */
339 public void visit(TypedefName n) {
340 n.f0.accept(this);
341 }
342
343 /**
344 * f0 -> ( LabeledStatement() | ExpressionStatement() | CompoundStatement() | SelectionStatement() | IterationStatement() | JumpStatement() )
345 */
346 public void visit(Statement n) {
347 n.f0.accept(this);
348 }
349
350 /**
351 * f0 -> ( <IDENTIFIER> ":" Statement() | <CASE> ConstantExpression() ":" Statement() | <DFLT> ":" Statement() )
352 */
353 public void visit(LabeledStatement n) {
354 n.f0.accept(this);
355 }
356
357 /**
358 * f0 -> [ Expression() ]
359 * f1 -> ";"
360 */
361 public void visit(ExpressionStatement n) {
362 n.f0.accept(this);
363 n.f1.accept(this);
364 }
365
366 /**
367 * f0 -> "{"
368 * f1 -> [ DeclarationList() ]
369 * f2 -> [ StatementList() ]
370 * f3 -> "}"
371 */
372 public void visit(CompoundStatement n) {
373 n.f0.accept(this);
374 n.f1.accept(this);
375 n.f2.accept(this);
376 n.f3.accept(this);
377 }
378
379 /**
380 * f0 -> ( Statement() )+
381 */
382 public void visit(StatementList n) {
383 n.f0.accept(this);
384 }
385
386 /**
387 * f0 -> ( <IF> "(" Expression() ")" Statement() [ <ELSE> Statement() ] | <SWITCH> "(" Expression() ")" Statement() )
388 */
389 public void visit(SelectionStatement n) {
390 n.f0.accept(this);
391 }
392
393 /**
394 * f0 -> ( <WHILE> "(" Expression() ")" Statement() | <DO> Statement() <WHILE> "(" Expression() ")" ";" | <FOR> "(" [ Expression() ] ";" [ Expression() ] ";" [ Expression() ] ")" Statement() )
395 */
396 public void visit(IterationStatement n) {
397 n.f0.accept(this);
398 }
399
400 /**
401 * f0 -> ( <GOTO> <IDENTIFIER> ";" | <CONTINUE> ";" | <BREAK> ";" | <RETURN> [ Expression() ] ";" )
402 */
403 public void visit(JumpStatement n) {
404 n.f0.accept(this);
405 }
406
407 /**
408 * f0 -> AssignmentExpression()
409 * f1 -> ( "," AssignmentExpression() )*
410 */
411 public void visit(Expression n) {
412 n.f0.accept(this);
413 n.f1.accept(this);
414 }
415
416 /**
417 * f0 -> UnaryExpression() AssignmentOperator() AssignmentExpression()
418 * | ConditionalExpression()
419 */
420 public void visit(AssignmentExpression n) {
421 n.f0.accept(this);
422 }
423
424 /**
425 * f0 -> ( "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | "&=" | "^=" | "|=" )
426 */
427 public void visit(AssignmentOperator n) {
428 n.f0.accept(this);
429 }
430
431 /**
432 * f0 -> LogicalORExpression()
433 * f1 -> [ "?" Expression() ":" ConditionalExpression() ]
434 */
435 public void visit(ConditionalExpression n) {
436 n.f0.accept(this);
437 n.f1.accept(this);
438 }
439
440 /**
441 * f0 -> ConditionalExpression()
442 */
443 public void visit(ConstantExpression n) {
444 n.f0.accept(this);
445 }
446
447 /**
448 * f0 -> LogicalANDExpression()
449 * f1 -> [ "||" LogicalORExpression() ]
450 */
451 public void visit(LogicalORExpression n) {
452 n.f0.accept(this);
453 n.f1.accept(this);
454 }
455
456 /**
457 * f0 -> InclusiveORExpression()
458 * f1 -> [ "&&" LogicalANDExpression() ]
459 */
460 public void visit(LogicalANDExpression n) {
461 n.f0.accept(this);
462 n.f1.accept(this);
463 }
464
465 /**
466 * f0 -> ExclusiveORExpression()
467 * f1 -> [ "|" InclusiveORExpression() ]
468 */
469 public void visit(InclusiveORExpression n) {
470 n.f0.accept(this);
471 n.f1.accept(this);
472 }
473
474 /**
475 * f0 -> ANDExpression()
476 * f1 -> [ "^" ExclusiveORExpression() ]
477 */
478 public void visit(ExclusiveORExpression n) {
479 n.f0.accept(this);
480 n.f1.accept(this);
481 }
482
483 /**
484 * f0 -> EqualityExpression()
485 * f1 -> [ "&" ANDExpression() ]
486 */
487 public void visit(ANDExpression n) {
488 n.f0.accept(this);
489 n.f1.accept(this);
490 }
491
492 /**
493 * f0 -> RelationalExpression()
494 * f1 -> [ ( "==" | "!=" ) EqualityExpression() ]
495 */
496 public void visit(EqualityExpression n) {
497 n.f0.accept(this);
498 n.f1.accept(this);
499 }
500
501 /**
502 * f0 -> ShiftExpression()
503 * f1 -> [ ( "<" | ">" | "<=" | ">=" ) RelationalExpression() ]
504 */
505 public void visit(RelationalExpression n) {
506 n.f0.accept(this);
507 n.f1.accept(this);
508 }
509
510 /**
511 * f0 -> AdditiveExpression()
512 * f1 -> [ ( "<<" | ">>" ) ShiftExpression() ]
513 */
514 public void visit(ShiftExpression n) {
515 n.f0.accept(this);
516 n.f1.accept(this);
517 }
518
519 /**
520 * f0 -> MultiplicativeExpression()
521 * f1 -> [ ( "+" | "-" ) AdditiveExpression() ]
522 */
523 public void visit(AdditiveExpression n) {
524 n.f0.accept(this);
525 n.f1.accept(this);
526 }
527
528 /**
529 * f0 -> CastExpression()
530 * f1 -> [ ( "*" | "/" | "%" ) MultiplicativeExpression() ]
531 */
532 public void visit(MultiplicativeExpression n) {
533 n.f0.accept(this);
534 n.f1.accept(this);
535 }
536
537 /**
538 * f0 -> ( "(" TypeName() ")" CastExpression() | UnaryExpression() )
539 */
540 public void visit(CastExpression n) {
541 n.f0.accept(this);
542 }
543
544 /**
545 * f0 -> ( PostfixExpression() | "++" UnaryExpression() | "--" UnaryExpression() | UnaryOperator() CastExpression() | <SIZEOF> ( UnaryExpression() | "(" TypeName() ")" ) )
546 */
547 public void visit(UnaryExpression n) {
548 n.f0.accept(this);
549 }
550
551 /**
552 * f0 -> ( "&" | "*" | "+" | "-" | "~" | "!" )
553 */
554 public void visit(UnaryOperator n) {
555 n.f0.accept(this);
556 }
557
558 /**
559 * f0 -> PrimaryExpression()
560 * f1 -> ( "[" Expression() "]" | "(" [ ArgumentExpressionList() ] ")" | "." <IDENTIFIER> | "->" <IDENTIFIER> | "++" | "--" )*
561 */
562 public void visit(PostfixExpression n) {
563 n.f0.accept(this);
564 n.f1.accept(this);
565 }
566
567 /**
568 * f0 -> ( <IDENTIFIER> | Constant() | "(" Expression() ")" )
569 */
570 public void visit(PrimaryExpression n) {
571 n.f0.accept(this);
572 }
573
574 /**
575 * f0 -> AssignmentExpression()
576 * f1 -> ( "," AssignmentExpression() )*
577 */
578 public void visit(ArgumentExpressionList n) {
579 n.f0.accept(this);
580 n.f1.accept(this);
581 }
582
583 /**
584 * f0 -> <INTEGER_LITERAL>
585 * | <FLOATING_POINT_LITERAL>
586 * | <CHARACTER_LITERAL>
587 * | <STRING_LITERAL>
588 */
589 public void visit(Constant n) {
590 n.f0.accept(this);
591 }
592
593 }