KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > python > parser > Visitor


1 package org.python.parser;
2
3 import org.python.parser.ast.*;
4
5 public class Visitor extends VisitorBase {
6
7     /**
8      * Visit each of the children one by one.
9      * @args node The node whose children will be visited.
10      */

11     public void traverse(SimpleNode node) throws Exception JavaDoc {
12         node.traverse(this);
13     }
14
15
16     public void visit(SimpleNode[] nodes) throws Exception JavaDoc {
17         for (int i = 0; i < nodes.length; i++) {
18             visit(nodes[i]);
19         }
20     }
21
22     /**
23      * Visit the node by calling a visitXXX method.
24      */

25     public Object JavaDoc visit(SimpleNode node) throws Exception JavaDoc {
26         open_level(node);
27         Object JavaDoc ret = node.accept(this);
28         close_level(node);
29         return ret;
30     }
31
32
33     protected Object JavaDoc unhandled_node(SimpleNode node) throws Exception JavaDoc {
34         return this;
35     }
36
37     protected void open_level(SimpleNode node) throws Exception JavaDoc {
38     }
39
40     protected void close_level(SimpleNode node) throws Exception JavaDoc {
41     }
42 }
43
Popular Tags