01: package org.python.parser;
02:
03: import org.python.parser.ast.*;
04:
05: public class Visitor extends VisitorBase {
06:
07: /**
08: * Visit each of the children one by one.
09: * @args node The node whose children will be visited.
10: */
11: public void traverse(SimpleNode node) throws Exception {
12: node.traverse(this );
13: }
14:
15: public void visit(SimpleNode[] nodes) throws Exception {
16: for (int i = 0; i < nodes.length; i++) {
17: visit(nodes[i]);
18: }
19: }
20:
21: /**
22: * Visit the node by calling a visitXXX method.
23: */
24: public Object visit(SimpleNode node) throws Exception {
25: open_level(node);
26: Object ret = node.accept(this );
27: close_level(node);
28: return ret;
29: }
30:
31: protected Object unhandled_node(SimpleNode node) throws Exception {
32: return this ;
33: }
34:
35: protected void open_level(SimpleNode node) throws Exception {
36: }
37:
38: protected void close_level(SimpleNode node) throws Exception {
39: }
40: }
|