View Javadoc

    1   /***
    2    *
    3    * Copyright 2005 Jeremy Rayner
    4    *
    5    * Licensed under the Apache License, Version 2.0 (the "License");
    6    * you may not use this file except in compliance with the License.
    7    * You may obtain a copy of the License at
    8    *
    9    * http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   *
    17   **/
    18  package org.codehaus.groovy.antlr.treewalker;
    19
    20  import java.util.List;
    21  import java.util.ArrayList;
    22  import java.util.Stack;
    23
    24  import org.codehaus.groovy.antlr.GroovySourceAST;
    25  import org.codehaus.groovy.antlr.AntlrASTProcessor;
    26  import org.codehaus.groovy.antlr.parser.GroovyTokenTypes;
    27
    28  import antlr.collections.AST;
    29
    30  /***
    31   * Helper Class for Antlr AST traversal and visitation.
    32   *
    33   * @author <a href="mailto:groovy@ross-rayner.com">Jeremy Rayner</a>
    34   * @version $Revision: 1.8 $
    35   */
    36
    37  public abstract class TraversalHelper implements AntlrASTProcessor {
    38      protected List unvisitedNodes;
    39      private Visitor v;
    40
    41      public TraversalHelper(Visitor visitor) {
    42          this.unvisitedNodes = new ArrayList();
    43          this.v = visitor;
    44      }
    45
    46      protected void setUp(GroovySourceAST ast) {
    47          v.setUp();
    48      }
    49      protected void tearDown(GroovySourceAST ast) {
    50          v.tearDown();
    51      }
    52
    53      protected void push(GroovySourceAST ast) {
    54          v.push(ast);
    55      }
    56      protected GroovySourceAST pop() {
    57          return v.pop();
    58      }
    59
    60      protected void visitNode(GroovySourceAST ast, int n) {
    61          if (ast != null) {
    62              switch (ast.getType()) {
    63                  case GroovyTokenTypes.ABSTRACT                      :   v.visitAbstract(ast,n);                     break;
    64                  case GroovyTokenTypes.ANNOTATION                    :   v.visitAnnotation(ast,n);                   break;
    65                  case GroovyTokenTypes.ANNOTATIONS                   :   v.visitAnnotations(ast,n);                  break;
    66                  case GroovyTokenTypes.ANNOTATION_ARRAY_INIT         :   v.visitAnnotationArrayInit(ast,n);          break;
    67                  case GroovyTokenTypes.ANNOTATION_DEF                :   v.visitAnnotationDef(ast,n);                break;
    68                  case GroovyTokenTypes.ANNOTATION_FIELD_DEF          :   v.visitAnnotationFieldDef(ast,n);           break;
    69                  case GroovyTokenTypes.ANNOTATION_MEMBER_VALUE_PAIR  :   v.visitAnnotationMemberValuePair(ast,n);    break;
    70                  case GroovyTokenTypes.ARRAY_DECLARATOR              :   v.visitArrayDeclarator(ast,n);              break;
    71                  case GroovyTokenTypes.ASSIGN                        :   v.visitAssign(ast,n);                       break;
    72                  case GroovyTokenTypes.AT                            :   v.visitAt(ast,n);                           break;
    73                  case GroovyTokenTypes.BAND                          :   v.visitBand(ast,n);                         break;
    74                  case GroovyTokenTypes.BAND_ASSIGN                   :   v.visitBandAssign(ast,n);                   break;
    75                  case GroovyTokenTypes.BIG_SUFFIX                    :   v.visitBigSuffix(ast,n);                    break;
    76                  case GroovyTokenTypes.BLOCK                         :   v.visitBlock(ast,n);                        break;
    77                  case GroovyTokenTypes.BNOT                          :   v.visitBnot(ast,n);                         break;
    78                  case GroovyTokenTypes.BOR                           :   v.visitBor(ast,n);                          break;
    79                  case GroovyTokenTypes.BOR_ASSIGN                    :   v.visitBorAssign(ast,n);                    break;
    80                  case GroovyTokenTypes.BSR                           :   v.visitBsr(ast,n);                          break;
    81                  case GroovyTokenTypes.BSR_ASSIGN                    :   v.visitBsrAssign(ast,n);                    break;
    82                  case GroovyTokenTypes.BXOR                          :   v.visitBxor(ast,n);                         break;
    83                  case GroovyTokenTypes.BXOR_ASSIGN                   :   v.visitBxorAssign(ast,n);                   break;
    84                  case GroovyTokenTypes.CASE_GROUP                    :   v.visitCaseGroup(ast,n);                    break;
    85                  case GroovyTokenTypes.CLASS_DEF                     :   v.visitClassDef(ast,n);                     break;
    86                  case GroovyTokenTypes.CLOSED_BLOCK                  :   v.visitClosedBlock(ast,n);                  break;
    87                  case GroovyTokenTypes.CLOSURE_OP                    :   v.visitClosureOp(ast,n);                    break;
    88                  case GroovyTokenTypes.COLON                         :   v.visitColon(ast,n);                        break;
    89                  case GroovyTokenTypes.COMMA                         :   v.visitComma(ast,n);                        break;
    90                  case GroovyTokenTypes.COMPARE_TO                    :   v.visitCompareTo(ast,n);                    break;
    91                  case GroovyTokenTypes.CTOR_CALL                     :   v.visitCtorCall(ast,n);                     break;
    92                  case GroovyTokenTypes.CTOR_IDENT                    :   v.visitCtorIdent(ast,n);                    break;
    93                  case GroovyTokenTypes.DEC                           :   v.visitDec(ast,n);                          break;
    94                  case GroovyTokenTypes.DIGIT                         :   v.visitDigit(ast,n);                        break;
    95                  case GroovyTokenTypes.DIV                           :   v.visitDiv(ast,n);                          break;
    96                  case GroovyTokenTypes.DIV_ASSIGN                    :   v.visitDivAssign(ast,n);                    break;
    97                  case GroovyTokenTypes.DOLLAR                        :   v.visitDollar(ast,n);                       break;
    98                  case GroovyTokenTypes.DOT                           :   v.visitDot(ast,n);                          break;
    99                  case GroovyTokenTypes.DYNAMIC_MEMBER                :   v.visitDynamicMember(ast,n);                break;
    100                 case GroovyTokenTypes.ELIST                         :   v.visitElist(ast,n);                        break;
    101                 case GroovyTokenTypes.EMPTY_STAT                    :   v.visitEmptyStat(ast,n);                    break;
    102                 case GroovyTokenTypes.ENUM_CONSTANT_DEF             :   v.visitEnumConstantDef(ast,n);              break;
    103                 case GroovyTokenTypes.ENUM_DEF                      :   v.visitEnumDef(ast,n);                      break;
    104                 case GroovyTokenTypes.EOF                           :   v.visitEof(ast,n);                          break;
    105                 case GroovyTokenTypes.EQUAL                         :   v.visitEqual(ast,n);                        break;
    106                 case GroovyTokenTypes.ESC                           :   v.visitEsc(ast,n);                          break;
    107                 case GroovyTokenTypes.EXPONENT                      :   v.visitExponent(ast,n);                     break;
    108                 case GroovyTokenTypes.EXPR                          :   v.visitExpr(ast,n);                         break;
    109                 case GroovyTokenTypes.EXTENDS_CLAUSE                :   v.visitExtendsClause(ast,n);                break;
    110                 case GroovyTokenTypes.FINAL                         :   v.visitFinal(ast,n);                        break;
    111                 case GroovyTokenTypes.FLOAT_SUFFIX                  :   v.visitFloatSuffix(ast,n);                  break;
    112                 case GroovyTokenTypes.FOR_CONDITION                 :   v.visitForCondition(ast,n);                 break;
    113                 case GroovyTokenTypes.FOR_EACH_CLAUSE               :   v.visitForEachClause(ast,n);                break;
    114                 case GroovyTokenTypes.FOR_INIT                      :   v.visitForInit(ast,n);                      break;
    115                 case GroovyTokenTypes.FOR_IN_ITERABLE               :   v.visitForInIterable(ast,n);                break;
    116                 case GroovyTokenTypes.FOR_ITERATOR                  :   v.visitForIterator(ast,n);                  break;
    117                 case GroovyTokenTypes.GE                            :   v.visitGe(ast,n);                           break;
    118                 case GroovyTokenTypes.GT                            :   v.visitGt(ast,n);                           break;
    119                 case GroovyTokenTypes.HEX_DIGIT                     :   v.visitHexDigit(ast,n);                     break;
    120                 case GroovyTokenTypes.IDENT                         :   v.visitIdent(ast,n);                        break;
    121                 case GroovyTokenTypes.IMPLEMENTS_CLAUSE             :   v.visitImplementsClause(ast,n);             break;
    122                 case GroovyTokenTypes.IMPLICIT_PARAMETERS           :   v.visitImplicitParameters(ast,n);           break;
    123                 case GroovyTokenTypes.IMPORT                        :   v.visitImport(ast,n);                       break;
    124                 case GroovyTokenTypes.INC                           :   v.visitInc(ast,n);                          break;
    125                 case GroovyTokenTypes.INDEX_OP                      :   v.visitIndexOp(ast,n);                      break;
    126                 case GroovyTokenTypes.INSTANCE_INIT                 :   v.visitInstanceInit(ast,n);                 break;
    127                 case GroovyTokenTypes.INTERFACE_DEF                 :   v.visitInterfaceDef(ast,n);                 break;
    128                 case GroovyTokenTypes.LABELED_ARG                   :   v.visitLabeledArg(ast,n);                   break;
    129                 case GroovyTokenTypes.LABELED_STAT                  :   v.visitLabeledStat(ast,n);                  break;
    130                 case GroovyTokenTypes.LAND                          :   v.visitLand(ast,n);                         break;
    131                 case GroovyTokenTypes.LBRACK                        :   v.visitLbrack(ast,n);                       break;
    132                 case GroovyTokenTypes.LCURLY                        :   v.visitLcurly(ast,n);                       break;
    133                 case GroovyTokenTypes.LE                            :   v.visitLe(ast,n);                           break;
    134                 case GroovyTokenTypes.LETTER                        :   v.visitLetter(ast,n);                       break;
    135                 case GroovyTokenTypes.LIST_CONSTRUCTOR              :   v.visitListConstructor(ast,n);              break;
    136                 case GroovyTokenTypes.LITERAL_any                   :   v.visitLiteralAny(ast,n);                   break;
    137                 case GroovyTokenTypes.LITERAL_as                    :   v.visitLiteralAs(ast,n);                    break;
    138                 case GroovyTokenTypes.LITERAL_assert                :   v.visitLiteralAssert(ast,n);                break;
    139                 case GroovyTokenTypes.LITERAL_boolean               :   v.visitLiteralBoolean(ast,n);               break;
    140                 case GroovyTokenTypes.LITERAL_break                 :   v.visitLiteralBreak(ast,n);                 break;
    141                 case GroovyTokenTypes.LITERAL_byte                  :   v.visitLiteralByte(ast,n);                  break;
    142                 case GroovyTokenTypes.LITERAL_case                  :   v.visitLiteralCase(ast,n);                  break;
    143                 case GroovyTokenTypes.LITERAL_catch                 :   v.visitLiteralCatch(ast,n);                 break;
    144                 case GroovyTokenTypes.LITERAL_char                  :   v.visitLiteralChar(ast,n);                  break;
    145                 case GroovyTokenTypes.LITERAL_class                 :   v.visitLiteralClass(ast,n);                 break;
    146                 case GroovyTokenTypes.LITERAL_continue              :   v.visitLiteralContinue(ast,n);              break;
    147                 case GroovyTokenTypes.LITERAL_def                   :   v.visitLiteralDef(ast,n);                   break;
    148                 case GroovyTokenTypes.LITERAL_default               :   v.visitLiteralDefault(ast,n);               break;
    149                 case GroovyTokenTypes.LITERAL_double                :   v.visitLiteralDouble(ast,n);                break;
    150                 case GroovyTokenTypes.LITERAL_else                  :   v.visitLiteralElse(ast,n);                  break;
    151                 case GroovyTokenTypes.LITERAL_enum                  :   v.visitLiteralEnum(ast,n);                  break;
    152                 case GroovyTokenTypes.LITERAL_extends               :   v.visitLiteralExtends(ast,n);               break;
    153                 case GroovyTokenTypes.LITERAL_false                 :   v.visitLiteralFalse(ast,n);                 break;
    154                 case GroovyTokenTypes.LITERAL_finally               :   v.visitLiteralFinally(ast,n);               break;
    155                 case GroovyTokenTypes.LITERAL_float                 :   v.visitLiteralFloat(ast,n);                 break;
    156                 case GroovyTokenTypes.LITERAL_for                   :   v.visitLiteralFor(ast,n);                   break;
    157                 case GroovyTokenTypes.LITERAL_if                    :   v.visitLiteralIf(ast,n);                    break;
    158                 case GroovyTokenTypes.LITERAL_implements            :   v.visitLiteralImplements(ast,n);            break;
    159                 case GroovyTokenTypes.LITERAL_import                :   v.visitLiteralImport(ast,n);                break;
    160                 case GroovyTokenTypes.LITERAL_in                    :   v.visitLiteralIn(ast,n);                    break;
    161                 case GroovyTokenTypes.LITERAL_instanceof            :   v.visitLiteralInstanceof(ast,n);            break;
    162                 case GroovyTokenTypes.LITERAL_int                   :   v.visitLiteralInt(ast,n);                   break;
    163                 case GroovyTokenTypes.LITERAL_interface             :   v.visitLiteralInterface(ast,n);             break;
    164                 case GroovyTokenTypes.LITERAL_long                  :   v.visitLiteralLong(ast,n);                  break;
    165                 case GroovyTokenTypes.LITERAL_native                :   v.visitLiteralNative(ast,n);                break;
    166                 case GroovyTokenTypes.LITERAL_new                   :   v.visitLiteralNew(ast,n);                   break;
    167                 case GroovyTokenTypes.LITERAL_null                  :   v.visitLiteralNull(ast,n);                  break;
    168                 case GroovyTokenTypes.LITERAL_package               :   v.visitLiteralPackage(ast,n);               break;
    169                 case GroovyTokenTypes.LITERAL_private               :   v.visitLiteralPrivate(ast,n);               break;
    170                 case GroovyTokenTypes.LITERAL_protected             :   v.visitLiteralProtected(ast,n);             break;
    171                 case GroovyTokenTypes.LITERAL_public                :   v.visitLiteralPublic(ast,n);                break;
    172                 case GroovyTokenTypes.LITERAL_return                :   v.visitLiteralReturn(ast,n);                break;
    173                 case GroovyTokenTypes.LITERAL_short                 :   v.visitLiteralShort(ast,n);                 break;
    174                 case GroovyTokenTypes.LITERAL_static                :   v.visitLiteralStatic(ast,n);                break;
    175                 case GroovyTokenTypes.LITERAL_super                 :   v.visitLiteralSuper(ast,n);                 break;
    176                 case GroovyTokenTypes.LITERAL_switch                :   v.visitLiteralSwitch(ast,n);                break;
    177                 case GroovyTokenTypes.LITERAL_synchronized          :   v.visitLiteralSynchronized(ast,n);          break;
    178                 case GroovyTokenTypes.LITERAL_this                  :   v.visitLiteralThis(ast,n);                  break;
    179                 case GroovyTokenTypes.LITERAL_threadsafe            :   v.visitLiteralThreadsafe(ast,n);            break;
    180                 case GroovyTokenTypes.LITERAL_throw                 :   v.visitLiteralThrow(ast,n);                 break;
    181                 case GroovyTokenTypes.LITERAL_throws                :   v.visitLiteralThrows(ast,n);                break;
    182                 case GroovyTokenTypes.LITERAL_transient             :   v.visitLiteralTransient(ast,n);             break;
    183                 case GroovyTokenTypes.LITERAL_true                  :   v.visitLiteralTrue(ast,n);                  break;
    184                 case GroovyTokenTypes.LITERAL_try                   :   v.visitLiteralTry(ast,n);                   break;
    185                 case GroovyTokenTypes.LITERAL_void                  :   v.visitLiteralVoid(ast,n);                  break;
    186                 case GroovyTokenTypes.LITERAL_volatile              :   v.visitLiteralVolatile(ast,n);              break;
    187                 case GroovyTokenTypes.LITERAL_while                 :   v.visitLiteralWhile(ast,n);                 break;
    188                 case GroovyTokenTypes.LITERAL_with                  :   v.visitLiteralWith(ast,n);                  break;
    189                 case GroovyTokenTypes.LNOT                          :   v.visitLnot(ast,n);                         break;
    190                 case GroovyTokenTypes.LOR                           :   v.visitLor(ast,n);                          break;
    191                 case GroovyTokenTypes.LPAREN                        :   v.visitLparen(ast,n);                       break;
    192                 case GroovyTokenTypes.LT                            :   v.visitLt(ast,n);                           break;
    193                 case GroovyTokenTypes.MAP_CONSTRUCTOR               :   v.visitMapConstructor(ast,n);               break;
    194                 case GroovyTokenTypes.MEMBER_POINTER                :   v.visitMemberPointer(ast,n);                break;
    195                 case GroovyTokenTypes.METHOD_CALL                   :   v.visitMethodCall(ast,n);                   break;
    196                 case GroovyTokenTypes.METHOD_DEF                    :   v.visitMethodDef(ast,n);                    break;
    197                 case GroovyTokenTypes.MINUS                         :   v.visitMinus(ast,n);                        break;
    198                 case GroovyTokenTypes.MINUS_ASSIGN                  :   v.visitMinusAssign(ast,n);                  break;
    199                 case GroovyTokenTypes.ML_COMMENT                    :   v.visitMlComment(ast,n);                    break;
    200                 case GroovyTokenTypes.MOD                           :   v.visitMod(ast,n);                          break;
    201                 case GroovyTokenTypes.MODIFIERS                     :   v.visitModifiers(ast,n);                    break;
    202                 case GroovyTokenTypes.MOD_ASSIGN                    :   v.visitModAssign(ast,n);                    break;
    203                 case GroovyTokenTypes.NLS                           :   v.visitNls(ast,n);                          break;
    204                 case GroovyTokenTypes.NOT_EQUAL                     :   v.visitNotEqual(ast,n);                     break;
    205                 case GroovyTokenTypes.NULL_TREE_LOOKAHEAD           :   v.visitNullTreeLookahead(ast,n);            break;
    206                 case GroovyTokenTypes.NUM_BIG_DECIMAL               :   v.visitNumBigDecimal(ast,n);                break;
    207                 case GroovyTokenTypes.NUM_BIG_INT                   :   v.visitNumBigInt(ast,n);                    break;
    208                 case GroovyTokenTypes.NUM_DOUBLE                    :   v.visitNumDouble(ast,n);                    break;
    209                 case GroovyTokenTypes.NUM_FLOAT                     :   v.visitNumFloat(ast,n);                     break;
    210                 case GroovyTokenTypes.NUM_INT                       :   v.visitNumInt(ast,n);                       break;
    211                 case GroovyTokenTypes.NUM_LONG                      :   v.visitNumLong(ast,n);                      break;
    212                 case GroovyTokenTypes.OBJBLOCK                      :   v.visitObjblock(ast,n);                     break;
    213                 case GroovyTokenTypes.ONE_NL                        :   v.visitOneNl(ast,n);                        break;
    214                 case GroovyTokenTypes.OPTIONAL_DOT                  :   v.visitOptionalDot(ast,n);                  break;
    215                 case GroovyTokenTypes.PACKAGE_DEF                   :   v.visitPackageDef(ast,n);                   break;
    216                 case GroovyTokenTypes.PARAMETERS                    :   v.visitParameters(ast,n);                   break;
    217                 case GroovyTokenTypes.PARAMETER_DEF                 :   v.visitParameterDef(ast,n);                 break;
    218                 case GroovyTokenTypes.PLUS                          :   v.visitPlus(ast,n);                         break;
    219                 case GroovyTokenTypes.PLUS_ASSIGN                   :   v.visitPlusAssign(ast,n);                   break;
    220                 case GroovyTokenTypes.POST_DEC                      :   v.visitPostDec(ast,n);                      break;
    221                 case GroovyTokenTypes.POST_INC                      :   v.visitPostInc(ast,n);                      break;
    222                 case GroovyTokenTypes.QUESTION                      :   v.visitQuestion(ast,n);                     break;
    223                 case GroovyTokenTypes.RANGE_EXCLUSIVE               :   v.visitRangeExclusive(ast,n);               break;
    224                 case GroovyTokenTypes.RANGE_INCLUSIVE               :   v.visitRangeInclusive(ast,n);               break;
    225                 case GroovyTokenTypes.RBRACK                        :   v.visitRbrack(ast,n);                       break;
    226                 case GroovyTokenTypes.RCURLY                        :   v.visitRcurly(ast,n);                       break;
    227                 case GroovyTokenTypes.REGEXP_CTOR_END               :   v.visitRegexpCtorEnd(ast,n);                break;
    228                 case GroovyTokenTypes.REGEXP_LITERAL                :   v.visitRegexpLiteral(ast,n);                break;
    229                 case GroovyTokenTypes.REGEXP_SYMBOL                 :   v.visitRegexpSymbol(ast,n);                 break;
    230                 case GroovyTokenTypes.REGEX_FIND                    :   v.visitRegexFind(ast,n);                    break;
    231                 case GroovyTokenTypes.REGEX_MATCH                   :   v.visitRegexMatch(ast,n);                   break;
    232                 case GroovyTokenTypes.RPAREN                        :   v.visitRparen(ast,n);                       break;
    233                 case GroovyTokenTypes.SCOPE_ESCAPE                  :   v.visitScopeEscape(ast,n);                  break;
    234                 case GroovyTokenTypes.SELECT_SLOT                   :   v.visitSelectSlot(ast,n);                   break;
    235                 case GroovyTokenTypes.SEMI                          :   v.visitSemi(ast,n);                         break;
    236                 case GroovyTokenTypes.SH_COMMENT                    :   v.visitShComment(ast,n);                    break;
    237                 case GroovyTokenTypes.SL                            :   v.visitSl(ast,n);                           break;
    238                 case GroovyTokenTypes.SLIST                         :   v.visitSlist(ast,n);                        break;
    239                 case GroovyTokenTypes.SL_ASSIGN                     :   v.visitSlAssign(ast,n);                     break;
    240                 case GroovyTokenTypes.SL_COMMENT                    :   v.visitSlComment(ast,n);                    break;
    241                 case GroovyTokenTypes.SPREAD_ARG                    :   v.visitSpreadArg(ast,n);                    break;
    242                 case GroovyTokenTypes.SPREAD_DOT                    :   v.visitSpreadDot(ast,n);                    break;
    243                 case GroovyTokenTypes.SPREAD_MAP_ARG                :   v.visitSpreadMapArg(ast,n);                 break;
    244                 case GroovyTokenTypes.SR                            :   v.visitSr(ast,n);                           break;
    245                 case GroovyTokenTypes.SR_ASSIGN                     :   v.visitSrAssign(ast,n);                     break;
    246                 case GroovyTokenTypes.STAR                          :   v.visitStar(ast,n);                         break;
    247                 case GroovyTokenTypes.STAR_ASSIGN                   :   v.visitStarAssign(ast,n);                   break;
    248                 case GroovyTokenTypes.STAR_STAR                     :   v.visitStarStar(ast,n);                     break;
    249                 case GroovyTokenTypes.STAR_STAR_ASSIGN              :   v.visitStarStarAssign(ast,n);               break;
    250                 case GroovyTokenTypes.STATIC_IMPORT                 :   v.visitStaticImport(ast,n);                 break;
    251                 case GroovyTokenTypes.STATIC_INIT                   :   v.visitStaticInit(ast,n);                   break;
    252                 case GroovyTokenTypes.STRICTFP                      :   v.visitStrictfp(ast,n);                     break;
    253                 case GroovyTokenTypes.STRING_CH                     :   v.visitStringCh(ast,n);                     break;
    254                 case GroovyTokenTypes.STRING_CONSTRUCTOR            :   v.visitStringConstructor(ast,n);            break;
    255                 case GroovyTokenTypes.STRING_CTOR_END               :   v.visitStringCtorEnd(ast,n);                break;
    256                 case GroovyTokenTypes.STRING_CTOR_MIDDLE            :   v.visitStringCtorMiddle(ast,n);             break;
    257                 case GroovyTokenTypes.STRING_CTOR_START             :   v.visitStringCtorStart(ast,n);              break;
    258                 case GroovyTokenTypes.STRING_LITERAL                :   v.visitStringLiteral(ast,n);                break;
    259                 case GroovyTokenTypes.STRING_NL                     :   v.visitStringNl(ast,n);                     break;
    260                 case GroovyTokenTypes.SUPER_CTOR_CALL               :   v.visitSuperCtorCall(ast,n);                break;
    261                 case GroovyTokenTypes.TRIPLE_DOT                    :   v.visitTripleDot(ast,n);                    break;
    262                 case GroovyTokenTypes.TYPE                          :   v.visitType(ast,n);                         break;
    263                 case GroovyTokenTypes.TYPECAST                      :   v.visitTypecast(ast,n);                     break;
    264                 case GroovyTokenTypes.TYPE_ARGUMENT                 :   v.visitTypeArgument(ast,n);                 break;
    265                 case GroovyTokenTypes.TYPE_ARGUMENTS                :   v.visitTypeArguments(ast,n);                break;
    266                 case GroovyTokenTypes.TYPE_LOWER_BOUNDS             :   v.visitTypeLowerBounds(ast,n);              break;
    267                 case GroovyTokenTypes.TYPE_PARAMETER                :   v.visitTypeParameter(ast,n);                break;
    268                 case GroovyTokenTypes.TYPE_PARAMETERS               :   v.visitTypeParameters(ast,n);               break;
    269                 case GroovyTokenTypes.TYPE_UPPER_BOUNDS             :   v.visitTypeUpperBounds(ast,n);              break;
    270                 case GroovyTokenTypes.UNARY_MINUS                   :   v.visitUnaryMinus(ast,n);                   break;
    271                 case GroovyTokenTypes.UNARY_PLUS                    :   v.visitUnaryPlus(ast,n);                    break;
    272                 case GroovyTokenTypes.UNUSED_CONST                  :   v.visitUnusedConst(ast,n);                  break;
    273                 case GroovyTokenTypes.UNUSED_DO                     :   v.visitUnusedDo(ast,n);                     break;
    274                 case GroovyTokenTypes.UNUSED_GOTO                   :   v.visitUnusedGoto(ast,n);                   break;
    275                 case GroovyTokenTypes.VARIABLE_DEF                  :   v.visitVariableDef(ast,n);                  break;
    276                 case GroovyTokenTypes.VARIABLE_PARAMETER_DEF        :   v.visitVariableParameterDef(ast,n);         break;
    277                 case GroovyTokenTypes.VOCAB                         :   v.visitVocab(ast,n);                        break;
    278                 case GroovyTokenTypes.WILDCARD_TYPE                 :   v.visitWildcardType(ast,n);                 break;
    279                 case GroovyTokenTypes.WS                            :   v.visitWs(ast,n);                           break;
    280
    281
    282                 default                                             :   v.visitDefault(ast,n);                      break;
    283             }
    284         } else {
    285             // the supplied AST was null
    286             v.visitDefault(null,n);
    287         }
    288     }
    289     protected abstract void accept(GroovySourceAST currentNode);
    290
    291     protected void accept_v_FirstChildsFirstChild_v_Child2_Child3_v_Child4_v___v_LastChild(GroovySourceAST t) {
    292         openingVisit(t);
    293         GroovySourceAST expr2 = t.childAt(0);
    294         skip(expr2);
    295         accept(expr2.childAt(0));
    296         closingVisit(t);
    297
    298         GroovySourceAST sibling = (GroovySourceAST)expr2.getNextSibling();
    299         boolean firstSList = true;
    300         while (sibling != null) {
    301             if (!firstSList) {
    302                 subsequentVisit(t);
    303             }
    304             firstSList = false;
    305             accept(sibling);
    306             sibling = (GroovySourceAST)sibling.getNextSibling();
    307         }
    308     }
    309
    310     protected void accept_v_FirstChildsFirstChild_v_RestOfTheChildren(GroovySourceAST t) {
    311         openingVisit(t);
    312         GroovySourceAST expr = t.childAt(0);
    313         skip(expr);
    314         accept(expr.childAt(0));
    315         closingVisit(t);
    316         acceptSiblings(expr);
    317     }
    318
    319     protected void accept_FirstChild_v_SecondChild(GroovySourceAST t) {
    320         accept(t.childAt(0));
    321         subsequentVisit(t);
    322         accept(t.childAt(1));
    323     }
    324     protected void accept_FirstChild_v_SecondChild_v(GroovySourceAST t) {
    325         accept(t.childAt(0));
    326         openingVisit(t);
    327         accept(t.childAt(1));
    328         closingVisit(t);
    329     }
    330
    331     protected void accept_FirstChild_v_SecondChildsChildren_v(GroovySourceAST t) {
    332         accept(t.childAt(0));
    333
    334         openingVisit(t);
    335         GroovySourceAST secondChild = t.childAt(1);
    336         if (secondChild != null) {
    337             acceptChildren(secondChild);
    338         }
    339         closingVisit(t);
    340     }
    341
    342     protected void accept_FirstChild_v_SecondChild_v_ThirdChild_v(GroovySourceAST t) {
    343         accept(t.childAt(0));
    344         openingVisit(t);
    345         accept(t.childAt(1));
    346         subsequentVisit(t);
    347         accept(t.childAt(2));
    348         closingVisit(t);
    349     }
    350     protected void accept_v_FirstChild_v_SecondChild_v___LastChild_v(GroovySourceAST t) {
    351         openingVisit(t);
    352         GroovySourceAST child = (GroovySourceAST)t.getFirstChild();
    353         if (child != null){
    354             accept(child);
    355             GroovySourceAST sibling = (GroovySourceAST)child.getNextSibling();
    356             while (sibling != null) {
    357                 subsequentVisit(t);
    358                 accept(sibling);
    359                 sibling = (GroovySourceAST)sibling.getNextSibling();
    360             }
    361         }
    362         closingVisit(t);
    363     }
    364
    365     protected void accept_v_FirstChild_v(GroovySourceAST t) {
    366         openingVisit(t);
    367         accept(t.childAt(0));
    368         closingVisit(t);
    369     }
    370
    371     protected void accept_v_AllChildren_v_Siblings(GroovySourceAST t) {
    372         openingVisit(t);
    373         acceptChildren(t);
    374         closingVisit(t);
    375         acceptSiblings(t);
    376     }
    377
    378     protected void accept_v_AllChildren_v(GroovySourceAST t) {
    379         openingVisit(t);
    380         acceptChildren(t);
    381         closingVisit(t);
    382     }
    383
    384     protected void accept_FirstChild_v_RestOfTheChildren(GroovySourceAST t) {
    385         accept(t.childAt(0));
    386         openingVisit(t);
    387         closingVisit(t);
    388         acceptSiblings(t.childAt(0));
    389     }
    390     protected void accept_FirstChild_v_RestOfTheChildren_v_LastChild(GroovySourceAST t) {
    391         int count = 0;
    392         accept(t.childAt(0));
    393         count++;
    394         openingVisit(t);
    395         if (t.childAt(0) != null) {
    396             GroovySourceAST sibling = (GroovySourceAST)t.childAt(0).getNextSibling();
    397             while (sibling != null) {
    398                 if (count == t.getNumberOfChildren() - 1) {closingVisit(t);}
    399                 accept(sibling);
    400                 count++;
    401                 sibling = (GroovySourceAST)sibling.getNextSibling();
    402             }
    403         }
    404
    405
    406     }
    407     protected void accept_FirstChild_v_RestOfTheChildren_v(GroovySourceAST t) {
    408         accept(t.childAt(0));
    409         openingVisit(t);
    410         acceptSiblings(t.childAt(0));
    411         closingVisit(t);
    412     }
    413     protected void accept_v_FirstChild_v_RestOfTheChildren(GroovySourceAST t) {
    414         accept_v_FirstChild_v(t);
    415         acceptSiblings(t.childAt(0));
    416     }
    417
    418     protected void accept_v_FirstChild_v_RestOfTheChildren_v(GroovySourceAST t) {
    419         openingVisit(t);
    420         accept(t.childAt(0));
    421         subsequentVisit(t);
    422         acceptSiblings(t.childAt(0));
    423         closingVisit(t);
    424     }
    425
    426     protected void acceptSiblings(GroovySourceAST t) {
    427         if (t != null) {
    428             GroovySourceAST sibling = (GroovySourceAST)t.getNextSibling();
    429             while (sibling != null) {
    430                 accept(sibling);
    431                 sibling = (GroovySourceAST)sibling.getNextSibling();
    432             }
    433         }
    434     }
    435
    436     protected void acceptChildren(GroovySourceAST t) {
    437         if (t != null) {
    438             GroovySourceAST child = (GroovySourceAST)t.getFirstChild();
    439             if (child != null){
    440                 accept(child);
    441                 acceptSiblings(child);
    442             }
    443         }
    444     }
    445
    446     protected void skip(GroovySourceAST expr) {
    447         unvisitedNodes.remove(expr);
    448     }
    449
    450     protected void openingVisit(GroovySourceAST t) {
    451         unvisitedNodes.remove(t);
    452
    453         int n = Visitor.OPENING_VISIT;
    454         visitNode(t, n);
    455     }
    456
    457     protected void subsequentVisit(GroovySourceAST t) {
    458         int n = Visitor.SUBSEQUENT_VISIT;
    459         visitNode(t, n);
    460     }
    461
    462     protected void closingVisit(GroovySourceAST t) {
    463         int n = Visitor.CLOSING_VISIT;
    464         visitNode(t, n);
    465     }
    466
    467     public AST process(AST t) {
    468         GroovySourceAST node = (GroovySourceAST) t;
    469
    470         // process each node in turn
    471         setUp(node);
    472         accept(node);
    473         acceptSiblings(node);
    474         tearDown(node);
    475         return null;
    476     }
    477 }