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 **/
018 package org.codehaus.groovy.antlr.treewalker;
019
020 import org.codehaus.groovy.antlr.GroovySourceAST;
021
022 /**
023 * A simple preorder traversal over the supplied antlr AST.
024 *
025 * @author <a href="mailto:groovy@ross-rayner.com">Jeremy Rayner</a>
026 * @version $Revision: 3626 $
027 */
028 public class PreOrderTraversal extends TraversalHelper {
029
030 /**
031 * A simple preorder traversal over the supplied antlr AST.
032 * @param visitor the Visitor to call for each node visited
033 */
034 public PreOrderTraversal(Visitor visitor) {
035 super(visitor);
036 }
037
038 public void accept(GroovySourceAST currentNode) {
039 push(currentNode);
040 openingVisit(currentNode);
041 acceptChildren(currentNode);
042 closingVisit(currentNode);
043 pop();
044 }
045 }