001: /**
002: *
003: * Copyright 2005 Jeremy Rayner
004: *
005: * Licensed under the Apache License, Version 2.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: **/package org.codehaus.groovy.antlr.treewalker;
018:
019: import java.util.List;
020: import java.util.ArrayList;
021:
022: import org.codehaus.groovy.antlr.GroovySourceAST;
023: import org.codehaus.groovy.antlr.AntlrASTProcessor;
024: import org.codehaus.groovy.antlr.parser.GroovyTokenTypes;
025:
026: import antlr.collections.AST;
027:
028: /**
029: * Helper Class for Antlr AST traversal and visitation.
030: *
031: * @author <a href="mailto:groovy@ross-rayner.com">Jeremy Rayner</a>
032: * @version $Revision: 4538 $
033: */
034:
035: public abstract class TraversalHelper implements AntlrASTProcessor {
036: protected List unvisitedNodes;
037: private Visitor v;
038:
039: public TraversalHelper(Visitor visitor) {
040: this .unvisitedNodes = new ArrayList();
041: this .v = visitor;
042: }
043:
044: protected void setUp(GroovySourceAST ast) {
045: v.setUp();
046: }
047:
048: protected void tearDown(GroovySourceAST ast) {
049: v.tearDown();
050: }
051:
052: protected void push(GroovySourceAST ast) {
053: v.push(ast);
054: }
055:
056: protected GroovySourceAST pop() {
057: return v.pop();
058: }
059:
060: protected void visitNode(GroovySourceAST ast, int n) {
061: if (ast != null) {
062: switch (ast.getType()) {
063: case GroovyTokenTypes.ABSTRACT:
064: v.visitAbstract(ast, n);
065: break;
066: case GroovyTokenTypes.ANNOTATION:
067: v.visitAnnotation(ast, n);
068: break;
069: case GroovyTokenTypes.ANNOTATIONS:
070: v.visitAnnotations(ast, n);
071: break;
072: case GroovyTokenTypes.ANNOTATION_ARRAY_INIT:
073: v.visitAnnotationArrayInit(ast, n);
074: break; // obsolete?
075: case GroovyTokenTypes.ANNOTATION_DEF:
076: v.visitAnnotationDef(ast, n);
077: break;
078: case GroovyTokenTypes.ANNOTATION_FIELD_DEF:
079: v.visitAnnotationFieldDef(ast, n);
080: break;
081: case GroovyTokenTypes.ANNOTATION_MEMBER_VALUE_PAIR:
082: v.visitAnnotationMemberValuePair(ast, n);
083: break;
084: case GroovyTokenTypes.ARRAY_DECLARATOR:
085: v.visitArrayDeclarator(ast, n);
086: break;
087: case GroovyTokenTypes.ASSIGN:
088: v.visitAssign(ast, n);
089: break;
090: case GroovyTokenTypes.AT:
091: v.visitAt(ast, n);
092: break;
093: case GroovyTokenTypes.BAND:
094: v.visitBand(ast, n);
095: break;
096: case GroovyTokenTypes.BAND_ASSIGN:
097: v.visitBandAssign(ast, n);
098: break;
099: case GroovyTokenTypes.BIG_SUFFIX:
100: v.visitBigSuffix(ast, n);
101: break;
102: case GroovyTokenTypes.BLOCK:
103: v.visitBlock(ast, n);
104: break;
105: case GroovyTokenTypes.BNOT:
106: v.visitBnot(ast, n);
107: break;
108: case GroovyTokenTypes.BOR:
109: v.visitBor(ast, n);
110: break;
111: case GroovyTokenTypes.BOR_ASSIGN:
112: v.visitBorAssign(ast, n);
113: break;
114: case GroovyTokenTypes.BSR:
115: v.visitBsr(ast, n);
116: break;
117: case GroovyTokenTypes.BSR_ASSIGN:
118: v.visitBsrAssign(ast, n);
119: break;
120: case GroovyTokenTypes.BXOR:
121: v.visitBxor(ast, n);
122: break;
123: case GroovyTokenTypes.BXOR_ASSIGN:
124: v.visitBxorAssign(ast, n);
125: break;
126: case GroovyTokenTypes.CASE_GROUP:
127: v.visitCaseGroup(ast, n);
128: break;
129: case GroovyTokenTypes.CLASS_DEF:
130: v.visitClassDef(ast, n);
131: break;
132: case GroovyTokenTypes.CLOSABLE_BLOCK:
133: v.visitClosedBlock(ast, n);
134: break;
135: case GroovyTokenTypes.CLOSABLE_BLOCK_OP:
136: v.visitClosureOp(ast, n);
137: break;
138: case GroovyTokenTypes.COLON:
139: v.visitColon(ast, n);
140: break;
141: case GroovyTokenTypes.COMMA:
142: v.visitComma(ast, n);
143: break;
144: case GroovyTokenTypes.COMPARE_TO:
145: v.visitCompareTo(ast, n);
146: break;
147: case GroovyTokenTypes.CTOR_CALL:
148: v.visitCtorCall(ast, n);
149: break;
150: case GroovyTokenTypes.CTOR_IDENT:
151: v.visitCtorIdent(ast, n);
152: break;
153: case GroovyTokenTypes.DEC:
154: v.visitDec(ast, n);
155: break;
156: case GroovyTokenTypes.DIGIT:
157: v.visitDigit(ast, n);
158: break;
159: case GroovyTokenTypes.DIV:
160: v.visitDiv(ast, n);
161: break;
162: case GroovyTokenTypes.DIV_ASSIGN:
163: v.visitDivAssign(ast, n);
164: break;
165: case GroovyTokenTypes.DOLLAR:
166: v.visitDollar(ast, n);
167: break;
168: case GroovyTokenTypes.DOT:
169: v.visitDot(ast, n);
170: break;
171: case GroovyTokenTypes.DYNAMIC_MEMBER:
172: v.visitDynamicMember(ast, n);
173: break;
174: case GroovyTokenTypes.ELIST:
175: v.visitElist(ast, n);
176: break;
177: case GroovyTokenTypes.EMPTY_STAT:
178: v.visitEmptyStat(ast, n);
179: break;
180: case GroovyTokenTypes.ENUM_CONSTANT_DEF:
181: v.visitEnumConstantDef(ast, n);
182: break;
183: case GroovyTokenTypes.ENUM_DEF:
184: v.visitEnumDef(ast, n);
185: break;
186: case GroovyTokenTypes.EOF:
187: v.visitEof(ast, n);
188: break;
189: case GroovyTokenTypes.EQUAL:
190: v.visitEqual(ast, n);
191: break;
192: case GroovyTokenTypes.ESC:
193: v.visitEsc(ast, n);
194: break;
195: case GroovyTokenTypes.EXPONENT:
196: v.visitExponent(ast, n);
197: break;
198: case GroovyTokenTypes.EXPR:
199: v.visitExpr(ast, n);
200: break;
201: case GroovyTokenTypes.EXTENDS_CLAUSE:
202: v.visitExtendsClause(ast, n);
203: break;
204: case GroovyTokenTypes.FINAL:
205: v.visitFinal(ast, n);
206: break;
207: case GroovyTokenTypes.FLOAT_SUFFIX:
208: v.visitFloatSuffix(ast, n);
209: break;
210: case GroovyTokenTypes.FOR_CONDITION:
211: v.visitForCondition(ast, n);
212: break;
213: case GroovyTokenTypes.FOR_EACH_CLAUSE:
214: v.visitForEachClause(ast, n);
215: break;
216: case GroovyTokenTypes.FOR_INIT:
217: v.visitForInit(ast, n);
218: break;
219: case GroovyTokenTypes.FOR_IN_ITERABLE:
220: v.visitForInIterable(ast, n);
221: break;
222: case GroovyTokenTypes.FOR_ITERATOR:
223: v.visitForIterator(ast, n);
224: break;
225: case GroovyTokenTypes.GE:
226: v.visitGe(ast, n);
227: break;
228: case GroovyTokenTypes.GT:
229: v.visitGt(ast, n);
230: break;
231: case GroovyTokenTypes.HEX_DIGIT:
232: v.visitHexDigit(ast, n);
233: break;
234: case GroovyTokenTypes.IDENT:
235: v.visitIdent(ast, n);
236: break;
237: case GroovyTokenTypes.IMPLEMENTS_CLAUSE:
238: v.visitImplementsClause(ast, n);
239: break;
240: case GroovyTokenTypes.IMPLICIT_PARAMETERS:
241: v.visitImplicitParameters(ast, n);
242: break;
243: case GroovyTokenTypes.IMPORT:
244: v.visitImport(ast, n);
245: break;
246: case GroovyTokenTypes.INC:
247: v.visitInc(ast, n);
248: break;
249: case GroovyTokenTypes.INDEX_OP:
250: v.visitIndexOp(ast, n);
251: break;
252: case GroovyTokenTypes.INSTANCE_INIT:
253: v.visitInstanceInit(ast, n);
254: break;
255: case GroovyTokenTypes.INTERFACE_DEF:
256: v.visitInterfaceDef(ast, n);
257: break;
258: case GroovyTokenTypes.LABELED_ARG:
259: v.visitLabeledArg(ast, n);
260: break;
261: case GroovyTokenTypes.LABELED_STAT:
262: v.visitLabeledStat(ast, n);
263: break;
264: case GroovyTokenTypes.LAND:
265: v.visitLand(ast, n);
266: break;
267: case GroovyTokenTypes.LBRACK:
268: v.visitLbrack(ast, n);
269: break;
270: case GroovyTokenTypes.LCURLY:
271: v.visitLcurly(ast, n);
272: break;
273: case GroovyTokenTypes.LE:
274: v.visitLe(ast, n);
275: break;
276: case GroovyTokenTypes.LETTER:
277: v.visitLetter(ast, n);
278: break;
279: case GroovyTokenTypes.LIST_CONSTRUCTOR:
280: v.visitListConstructor(ast, n);
281: break;
282: case GroovyTokenTypes.LITERAL_any:
283: v.visitLiteralAny(ast, n);
284: break;
285: case GroovyTokenTypes.LITERAL_as:
286: v.visitLiteralAs(ast, n);
287: break;
288: case GroovyTokenTypes.LITERAL_assert:
289: v.visitLiteralAssert(ast, n);
290: break;
291: case GroovyTokenTypes.LITERAL_boolean:
292: v.visitLiteralBoolean(ast, n);
293: break;
294: case GroovyTokenTypes.LITERAL_break:
295: v.visitLiteralBreak(ast, n);
296: break;
297: case GroovyTokenTypes.LITERAL_byte:
298: v.visitLiteralByte(ast, n);
299: break;
300: case GroovyTokenTypes.LITERAL_case:
301: v.visitLiteralCase(ast, n);
302: break;
303: case GroovyTokenTypes.LITERAL_catch:
304: v.visitLiteralCatch(ast, n);
305: break;
306: case GroovyTokenTypes.LITERAL_char:
307: v.visitLiteralChar(ast, n);
308: break;
309: case GroovyTokenTypes.LITERAL_class:
310: v.visitLiteralClass(ast, n);
311: break;
312: case GroovyTokenTypes.LITERAL_continue:
313: v.visitLiteralContinue(ast, n);
314: break;
315: case GroovyTokenTypes.LITERAL_def:
316: v.visitLiteralDef(ast, n);
317: break;
318: case GroovyTokenTypes.LITERAL_default:
319: v.visitLiteralDefault(ast, n);
320: break;
321: case GroovyTokenTypes.LITERAL_double:
322: v.visitLiteralDouble(ast, n);
323: break;
324: case GroovyTokenTypes.LITERAL_else:
325: v.visitLiteralElse(ast, n);
326: break;
327: case GroovyTokenTypes.LITERAL_enum:
328: v.visitLiteralEnum(ast, n);
329: break;
330: case GroovyTokenTypes.LITERAL_extends:
331: v.visitLiteralExtends(ast, n);
332: break;
333: case GroovyTokenTypes.LITERAL_false:
334: v.visitLiteralFalse(ast, n);
335: break;
336: case GroovyTokenTypes.LITERAL_finally:
337: v.visitLiteralFinally(ast, n);
338: break;
339: case GroovyTokenTypes.LITERAL_float:
340: v.visitLiteralFloat(ast, n);
341: break;
342: case GroovyTokenTypes.LITERAL_for:
343: v.visitLiteralFor(ast, n);
344: break;
345: case GroovyTokenTypes.LITERAL_if:
346: v.visitLiteralIf(ast, n);
347: break;
348: case GroovyTokenTypes.LITERAL_implements :
349: v.visitLiteralImplements(ast, n);
350: break;
351: case GroovyTokenTypes.LITERAL_import:
352: v.visitLiteralImport(ast, n);
353: break;
354: case GroovyTokenTypes.LITERAL_in:
355: v.visitLiteralIn(ast, n);
356: break;
357: case GroovyTokenTypes.LITERAL_instanceof :
358: v.visitLiteralInstanceof(ast, n);
359: break;
360: case GroovyTokenTypes.LITERAL_int:
361: v.visitLiteralInt(ast, n);
362: break;
363: case GroovyTokenTypes.LITERAL_interface:
364: v.visitLiteralInterface(ast, n);
365: break;
366: case GroovyTokenTypes.LITERAL_long:
367: v.visitLiteralLong(ast, n);
368: break;
369: case GroovyTokenTypes.LITERAL_native:
370: v.visitLiteralNative(ast, n);
371: break;
372: case GroovyTokenTypes.LITERAL_new:
373: v.visitLiteralNew(ast, n);
374: break;
375: case GroovyTokenTypes.LITERAL_null:
376: v.visitLiteralNull(ast, n);
377: break;
378: case GroovyTokenTypes.LITERAL_package:
379: v.visitLiteralPackage(ast, n);
380: break;
381: case GroovyTokenTypes.LITERAL_private:
382: v.visitLiteralPrivate(ast, n);
383: break;
384: case GroovyTokenTypes.LITERAL_protected:
385: v.visitLiteralProtected(ast, n);
386: break;
387: case GroovyTokenTypes.LITERAL_public:
388: v.visitLiteralPublic(ast, n);
389: break;
390: case GroovyTokenTypes.LITERAL_return:
391: v.visitLiteralReturn(ast, n);
392: break;
393: case GroovyTokenTypes.LITERAL_short:
394: v.visitLiteralShort(ast, n);
395: break;
396: case GroovyTokenTypes.LITERAL_static:
397: v.visitLiteralStatic(ast, n);
398: break;
399: case GroovyTokenTypes.LITERAL_super :
400: v.visitLiteralSuper(ast, n);
401: break;
402: case GroovyTokenTypes.LITERAL_switch:
403: v.visitLiteralSwitch(ast, n);
404: break;
405: case GroovyTokenTypes.LITERAL_synchronized:
406: v.visitLiteralSynchronized(ast, n);
407: break;
408: case GroovyTokenTypes.LITERAL_this :
409: v.visitLiteralThis(ast, n);
410: break;
411: case GroovyTokenTypes.LITERAL_threadsafe:
412: v.visitLiteralThreadsafe(ast, n);
413: break;
414: case GroovyTokenTypes.LITERAL_throw:
415: v.visitLiteralThrow(ast, n);
416: break;
417: case GroovyTokenTypes.LITERAL_throws:
418: v.visitLiteralThrows(ast, n);
419: break;
420: case GroovyTokenTypes.LITERAL_transient:
421: v.visitLiteralTransient(ast, n);
422: break;
423: case GroovyTokenTypes.LITERAL_true:
424: v.visitLiteralTrue(ast, n);
425: break;
426: case GroovyTokenTypes.LITERAL_try:
427: v.visitLiteralTry(ast, n);
428: break;
429: case GroovyTokenTypes.LITERAL_void:
430: v.visitLiteralVoid(ast, n);
431: break;
432: case GroovyTokenTypes.LITERAL_volatile:
433: v.visitLiteralVolatile(ast, n);
434: break;
435: case GroovyTokenTypes.LITERAL_while:
436: v.visitLiteralWhile(ast, n);
437: break;
438: case GroovyTokenTypes.LITERAL_with:
439: v.visitLiteralWith(ast, n);
440: break;
441: case GroovyTokenTypes.LNOT:
442: v.visitLnot(ast, n);
443: break;
444: case GroovyTokenTypes.LOR:
445: v.visitLor(ast, n);
446: break;
447: case GroovyTokenTypes.LPAREN:
448: v.visitLparen(ast, n);
449: break;
450: case GroovyTokenTypes.LT:
451: v.visitLt(ast, n);
452: break;
453: case GroovyTokenTypes.MAP_CONSTRUCTOR:
454: v.visitMapConstructor(ast, n);
455: break;
456: case GroovyTokenTypes.MEMBER_POINTER:
457: v.visitMemberPointer(ast, n);
458: break;
459: case GroovyTokenTypes.METHOD_CALL:
460: v.visitMethodCall(ast, n);
461: break;
462: case GroovyTokenTypes.METHOD_DEF:
463: v.visitMethodDef(ast, n);
464: break;
465: case GroovyTokenTypes.MINUS:
466: v.visitMinus(ast, n);
467: break;
468: case GroovyTokenTypes.MINUS_ASSIGN:
469: v.visitMinusAssign(ast, n);
470: break;
471: case GroovyTokenTypes.ML_COMMENT:
472: v.visitMlComment(ast, n);
473: break;
474: case GroovyTokenTypes.MOD:
475: v.visitMod(ast, n);
476: break;
477: case GroovyTokenTypes.MODIFIERS:
478: v.visitModifiers(ast, n);
479: break;
480: case GroovyTokenTypes.MOD_ASSIGN:
481: v.visitModAssign(ast, n);
482: break;
483: case GroovyTokenTypes.NLS:
484: v.visitNls(ast, n);
485: break;
486: case GroovyTokenTypes.NOT_EQUAL:
487: v.visitNotEqual(ast, n);
488: break;
489: case GroovyTokenTypes.NULL_TREE_LOOKAHEAD:
490: v.visitNullTreeLookahead(ast, n);
491: break;
492: case GroovyTokenTypes.NUM_BIG_DECIMAL:
493: v.visitNumBigDecimal(ast, n);
494: break;
495: case GroovyTokenTypes.NUM_BIG_INT:
496: v.visitNumBigInt(ast, n);
497: break;
498: case GroovyTokenTypes.NUM_DOUBLE:
499: v.visitNumDouble(ast, n);
500: break;
501: case GroovyTokenTypes.NUM_FLOAT:
502: v.visitNumFloat(ast, n);
503: break;
504: case GroovyTokenTypes.NUM_INT:
505: v.visitNumInt(ast, n);
506: break;
507: case GroovyTokenTypes.NUM_LONG:
508: v.visitNumLong(ast, n);
509: break;
510: case GroovyTokenTypes.OBJBLOCK:
511: v.visitObjblock(ast, n);
512: break;
513: case GroovyTokenTypes.ONE_NL:
514: v.visitOneNl(ast, n);
515: break;
516: case GroovyTokenTypes.OPTIONAL_DOT:
517: v.visitOptionalDot(ast, n);
518: break;
519: case GroovyTokenTypes.PACKAGE_DEF:
520: v.visitPackageDef(ast, n);
521: break;
522: case GroovyTokenTypes.PARAMETERS:
523: v.visitParameters(ast, n);
524: break;
525: case GroovyTokenTypes.PARAMETER_DEF:
526: v.visitParameterDef(ast, n);
527: break;
528: case GroovyTokenTypes.PLUS:
529: v.visitPlus(ast, n);
530: break;
531: case GroovyTokenTypes.PLUS_ASSIGN:
532: v.visitPlusAssign(ast, n);
533: break;
534: case GroovyTokenTypes.POST_DEC:
535: v.visitPostDec(ast, n);
536: break;
537: case GroovyTokenTypes.POST_INC:
538: v.visitPostInc(ast, n);
539: break;
540: case GroovyTokenTypes.QUESTION:
541: v.visitQuestion(ast, n);
542: break;
543: case GroovyTokenTypes.RANGE_EXCLUSIVE:
544: v.visitRangeExclusive(ast, n);
545: break;
546: case GroovyTokenTypes.RANGE_INCLUSIVE:
547: v.visitRangeInclusive(ast, n);
548: break;
549: case GroovyTokenTypes.RBRACK:
550: v.visitRbrack(ast, n);
551: break;
552: case GroovyTokenTypes.RCURLY:
553: v.visitRcurly(ast, n);
554: break;
555: case GroovyTokenTypes.REGEXP_CTOR_END:
556: v.visitRegexpCtorEnd(ast, n);
557: break;
558: case GroovyTokenTypes.REGEXP_LITERAL:
559: v.visitRegexpLiteral(ast, n);
560: break;
561: case GroovyTokenTypes.REGEXP_SYMBOL:
562: v.visitRegexpSymbol(ast, n);
563: break;
564: case GroovyTokenTypes.REGEX_FIND:
565: v.visitRegexFind(ast, n);
566: break;
567: case GroovyTokenTypes.REGEX_MATCH:
568: v.visitRegexMatch(ast, n);
569: break;
570: case GroovyTokenTypes.RPAREN:
571: v.visitRparen(ast, n);
572: break;
573: case GroovyTokenTypes.SCOPE_ESCAPE:
574: v.visitScopeEscape(ast, n);
575: break;
576: case GroovyTokenTypes.SELECT_SLOT:
577: v.visitSelectSlot(ast, n);
578: break;
579: case GroovyTokenTypes.SEMI:
580: v.visitSemi(ast, n);
581: break;
582: case GroovyTokenTypes.SH_COMMENT:
583: v.visitShComment(ast, n);
584: break;
585: case GroovyTokenTypes.SL:
586: v.visitSl(ast, n);
587: break;
588: case GroovyTokenTypes.SLIST:
589: v.visitSlist(ast, n);
590: break;
591: case GroovyTokenTypes.SL_ASSIGN:
592: v.visitSlAssign(ast, n);
593: break;
594: case GroovyTokenTypes.SL_COMMENT:
595: v.visitSlComment(ast, n);
596: break;
597: case GroovyTokenTypes.SPREAD_ARG:
598: v.visitSpreadArg(ast, n);
599: break;
600: case GroovyTokenTypes.SPREAD_DOT:
601: v.visitSpreadDot(ast, n);
602: break;
603: case GroovyTokenTypes.SPREAD_MAP_ARG:
604: v.visitSpreadMapArg(ast, n);
605: break;
606: case GroovyTokenTypes.SR:
607: v.visitSr(ast, n);
608: break;
609: case GroovyTokenTypes.SR_ASSIGN:
610: v.visitSrAssign(ast, n);
611: break;
612: case GroovyTokenTypes.STAR:
613: v.visitStar(ast, n);
614: break;
615: case GroovyTokenTypes.STAR_ASSIGN:
616: v.visitStarAssign(ast, n);
617: break;
618: case GroovyTokenTypes.STAR_STAR:
619: v.visitStarStar(ast, n);
620: break;
621: case GroovyTokenTypes.STAR_STAR_ASSIGN:
622: v.visitStarStarAssign(ast, n);
623: break;
624: case GroovyTokenTypes.STATIC_IMPORT:
625: v.visitStaticImport(ast, n);
626: break;
627: case GroovyTokenTypes.STATIC_INIT:
628: v.visitStaticInit(ast, n);
629: break;
630: case GroovyTokenTypes.STRICTFP:
631: v.visitStrictfp(ast, n);
632: break;
633: case GroovyTokenTypes.STRING_CH:
634: v.visitStringCh(ast, n);
635: break;
636: case GroovyTokenTypes.STRING_CONSTRUCTOR:
637: v.visitStringConstructor(ast, n);
638: break;
639: case GroovyTokenTypes.STRING_CTOR_END:
640: v.visitStringCtorEnd(ast, n);
641: break;
642: case GroovyTokenTypes.STRING_CTOR_MIDDLE:
643: v.visitStringCtorMiddle(ast, n);
644: break;
645: case GroovyTokenTypes.STRING_CTOR_START:
646: v.visitStringCtorStart(ast, n);
647: break;
648: case GroovyTokenTypes.STRING_LITERAL:
649: v.visitStringLiteral(ast, n);
650: break;
651: case GroovyTokenTypes.STRING_NL:
652: v.visitStringNl(ast, n);
653: break;
654: case GroovyTokenTypes.SUPER_CTOR_CALL:
655: v.visitSuperCtorCall(ast, n);
656: break;
657: case GroovyTokenTypes.TRIPLE_DOT:
658: v.visitTripleDot(ast, n);
659: break;
660: case GroovyTokenTypes.TYPE:
661: v.visitType(ast, n);
662: break;
663: case GroovyTokenTypes.TYPECAST:
664: v.visitTypecast(ast, n);
665: break;
666: case GroovyTokenTypes.TYPE_ARGUMENT:
667: v.visitTypeArgument(ast, n);
668: break;
669: case GroovyTokenTypes.TYPE_ARGUMENTS:
670: v.visitTypeArguments(ast, n);
671: break;
672: case GroovyTokenTypes.TYPE_LOWER_BOUNDS:
673: v.visitTypeLowerBounds(ast, n);
674: break;
675: case GroovyTokenTypes.TYPE_PARAMETER:
676: v.visitTypeParameter(ast, n);
677: break;
678: case GroovyTokenTypes.TYPE_PARAMETERS:
679: v.visitTypeParameters(ast, n);
680: break;
681: case GroovyTokenTypes.TYPE_UPPER_BOUNDS:
682: v.visitTypeUpperBounds(ast, n);
683: break;
684: case GroovyTokenTypes.UNARY_MINUS:
685: v.visitUnaryMinus(ast, n);
686: break;
687: case GroovyTokenTypes.UNARY_PLUS:
688: v.visitUnaryPlus(ast, n);
689: break;
690: case GroovyTokenTypes.UNUSED_CONST:
691: v.visitUnusedConst(ast, n);
692: break;
693: case GroovyTokenTypes.UNUSED_DO:
694: v.visitUnusedDo(ast, n);
695: break;
696: case GroovyTokenTypes.UNUSED_GOTO:
697: v.visitUnusedGoto(ast, n);
698: break;
699: case GroovyTokenTypes.VARIABLE_DEF:
700: v.visitVariableDef(ast, n);
701: break;
702: case GroovyTokenTypes.VARIABLE_PARAMETER_DEF:
703: v.visitVariableParameterDef(ast, n);
704: break;
705: case GroovyTokenTypes.VOCAB:
706: v.visitVocab(ast, n);
707: break;
708: case GroovyTokenTypes.WILDCARD_TYPE:
709: v.visitWildcardType(ast, n);
710: break;
711: case GroovyTokenTypes.WS:
712: v.visitWs(ast, n);
713: break;
714:
715: default:
716: v.visitDefault(ast, n);
717: break;
718: }
719: } else {
720: // the supplied AST was null
721: v.visitDefault(null, n);
722: }
723: }
724:
725: protected abstract void accept(GroovySourceAST currentNode);
726:
727: protected void accept_v_FirstChildsFirstChild_v_Child2_Child3_v_Child4_v___v_LastChild(
728: GroovySourceAST t) {
729: openingVisit(t);
730: GroovySourceAST expr2 = t.childAt(0);
731: skip(expr2);
732: accept(expr2.childAt(0));
733: closingVisit(t);
734:
735: GroovySourceAST sibling = (GroovySourceAST) expr2
736: .getNextSibling();
737: boolean firstSList = true;
738: while (sibling != null) {
739: if (!firstSList) {
740: subsequentVisit(t);
741: }
742: firstSList = false;
743: accept(sibling);
744: sibling = (GroovySourceAST) sibling.getNextSibling();
745: }
746: }
747:
748: protected void accept_v_FirstChildsFirstChild_v_RestOfTheChildren(
749: GroovySourceAST t) {
750: openingVisit(t);
751: GroovySourceAST expr = t.childAt(0);
752: skip(expr);
753: accept(expr.childAt(0));
754: closingVisit(t);
755: acceptSiblings(expr);
756: }
757:
758: protected void accept_FirstChild_v_SecondChild(GroovySourceAST t) {
759: accept(t.childAt(0));
760: subsequentVisit(t);
761: accept(t.childAt(1));
762: }
763:
764: protected void accept_FirstChild_v_SecondChild_v(GroovySourceAST t) {
765: accept(t.childAt(0));
766: openingVisit(t);
767: accept(t.childAt(1));
768: closingVisit(t);
769: }
770:
771: protected void accept_FirstChild_v_SecondChildsChildren_v(
772: GroovySourceAST t) {
773: accept(t.childAt(0));
774:
775: openingVisit(t);
776: GroovySourceAST secondChild = t.childAt(1);
777: if (secondChild != null) {
778: acceptChildren(secondChild);
779: }
780: closingVisit(t);
781: }
782:
783: protected void accept_v_FirstChild_SecondChild_v_ThirdChild_v(
784: GroovySourceAST t) {
785: openingVisit(t);
786: accept(t.childAt(0));
787: accept(t.childAt(1));
788: subsequentVisit(t);
789: accept(t.childAt(2));
790: closingVisit(t);
791: }
792:
793: protected void accept_FirstChild_v_SecondChild_v_ThirdChild_v(
794: GroovySourceAST t) {
795: accept(t.childAt(0));
796: openingVisit(t);
797: accept(t.childAt(1));
798: subsequentVisit(t);
799: accept(t.childAt(2));
800: closingVisit(t);
801: }
802:
803: protected void accept_FirstSecondAndThirdChild_v_v_ForthChild(
804: GroovySourceAST t) {
805: GroovySourceAST child1 = (GroovySourceAST) t.getFirstChild();
806: if (child1 != null) {
807: accept(child1);
808: GroovySourceAST child2 = (GroovySourceAST) child1
809: .getNextSibling();
810: if (child2 != null) {
811: accept(child2);
812: GroovySourceAST child3 = (GroovySourceAST) child2
813: .getNextSibling();
814: if (child3 != null) {
815: accept(child3);
816: openingVisit(t);
817: GroovySourceAST child4 = (GroovySourceAST) child3
818: .getNextSibling();
819: if (child4 != null) {
820: subsequentVisit(t);
821: accept(child4);
822: }
823: }
824: }
825: }
826: }
827:
828: protected void accept_v_FirstChild_2ndv_SecondChild_v___LastChild_v(
829: GroovySourceAST t) {
830: openingVisit(t);
831: GroovySourceAST child = (GroovySourceAST) t.getFirstChild();
832: if (child != null) {
833: accept(child);
834: GroovySourceAST sibling = (GroovySourceAST) child
835: .getNextSibling();
836: if (sibling != null) {
837: secondVisit(t);
838: accept(sibling);
839: sibling = (GroovySourceAST) sibling.getNextSibling();
840: while (sibling != null) {
841: subsequentVisit(t);
842: accept(sibling);
843: sibling = (GroovySourceAST) sibling
844: .getNextSibling();
845: }
846: }
847: }
848: closingVisit(t);
849: }
850:
851: protected void accept_v_FirstChild_v_SecondChild_v___LastChild_v(
852: GroovySourceAST t) {
853: openingVisit(t);
854: GroovySourceAST child = (GroovySourceAST) t.getFirstChild();
855: if (child != null) {
856: accept(child);
857: GroovySourceAST sibling = (GroovySourceAST) child
858: .getNextSibling();
859: while (sibling != null) {
860: subsequentVisit(t);
861: accept(sibling);
862: sibling = (GroovySourceAST) sibling.getNextSibling();
863: }
864: }
865: closingVisit(t);
866: }
867:
868: protected void accept_v_FirstChild_v(GroovySourceAST t) {
869: openingVisit(t);
870: accept(t.childAt(0));
871: closingVisit(t);
872: }
873:
874: protected void accept_v_AllChildren_v_Siblings(GroovySourceAST t) {
875: openingVisit(t);
876: acceptChildren(t);
877: closingVisit(t);
878: acceptSiblings(t);
879: }
880:
881: protected void accept_v_AllChildren_v(GroovySourceAST t) {
882: openingVisit(t);
883: acceptChildren(t);
884: closingVisit(t);
885: }
886:
887: protected void accept_FirstChild_v_RestOfTheChildren(
888: GroovySourceAST t) {
889: accept(t.childAt(0));
890: openingVisit(t);
891: closingVisit(t);
892: acceptSiblings(t.childAt(0));
893: }
894:
895: protected void accept_FirstChild_v_RestOfTheChildren_v_LastChild(
896: GroovySourceAST t) {
897: int count = 0;
898: accept(t.childAt(0));
899: count++;
900: openingVisit(t);
901: if (t.childAt(0) != null) {
902: GroovySourceAST sibling = (GroovySourceAST) t.childAt(0)
903: .getNextSibling();
904: while (sibling != null) {
905: if (count == t.getNumberOfChildren() - 1) {
906: closingVisit(t);
907: }
908: accept(sibling);
909: count++;
910: sibling = (GroovySourceAST) sibling.getNextSibling();
911: }
912: }
913:
914: }
915:
916: protected void accept_FirstChild_v_RestOfTheChildren_v(
917: GroovySourceAST t) {
918: accept(t.childAt(0));
919: openingVisit(t);
920: acceptSiblings(t.childAt(0));
921: closingVisit(t);
922: }
923:
924: protected void accept_v_FirstChild_v_RestOfTheChildren(
925: GroovySourceAST t) {
926: accept_v_FirstChild_v(t);
927: acceptSiblings(t.childAt(0));
928: }
929:
930: protected void accept_v_FirstChild_v_RestOfTheChildren_v(
931: GroovySourceAST t) {
932: openingVisit(t);
933: accept(t.childAt(0));
934: subsequentVisit(t);
935: acceptSiblings(t.childAt(0));
936: closingVisit(t);
937: }
938:
939: protected void acceptSiblings(GroovySourceAST t) {
940: if (t != null) {
941: GroovySourceAST sibling = (GroovySourceAST) t
942: .getNextSibling();
943: while (sibling != null) {
944: accept(sibling);
945: sibling = (GroovySourceAST) sibling.getNextSibling();
946: }
947: }
948: }
949:
950: protected void acceptChildren(GroovySourceAST t) {
951: if (t != null) {
952: GroovySourceAST child = (GroovySourceAST) t.getFirstChild();
953: if (child != null) {
954: accept(child);
955: acceptSiblings(child);
956: }
957: }
958: }
959:
960: protected void skip(GroovySourceAST expr) {
961: unvisitedNodes.remove(expr);
962: }
963:
964: protected void openingVisit(GroovySourceAST t) {
965: unvisitedNodes.remove(t);
966:
967: int n = Visitor.OPENING_VISIT;
968: visitNode(t, n);
969: }
970:
971: protected void secondVisit(GroovySourceAST t) {
972: int n = Visitor.SECOND_VISIT;
973: visitNode(t, n);
974: }
975:
976: protected void subsequentVisit(GroovySourceAST t) {
977: int n = Visitor.SUBSEQUENT_VISIT;
978: visitNode(t, n);
979: }
980:
981: protected void closingVisit(GroovySourceAST t) {
982: int n = Visitor.CLOSING_VISIT;
983: visitNode(t, n);
984: }
985:
986: public AST process(AST t) {
987: GroovySourceAST node = (GroovySourceAST) t;
988:
989: // process each node in turn
990: setUp(node);
991: accept(node);
992: acceptSiblings(node);
993: tearDown(node);
994: return null;
995: }
996: }
|