Dispatches a node to its specific visit<NodeType>/visit_<NodeType>
method if one is defined on the instance, falling back to
NodeVisitor.genericVisit otherwise.
The AST node to visit.
Whatever the matched visitor method (or genericVisit)
returns; the base implementation imposes no fixed return type since
subclasses may return arbitrary values from their visit methods.
Default visit behavior used when a subclass has not defined a
visit<NodeType>/visit_<NodeType> method for node's type: it
recurses into each child node (found by scanning own properties for
arrays/objects that look like AST nodes) by calling
NodeVisitor.visit on them, without collecting or returning any
results.
The AST node whose children should be visited.
Base class for writing tree-walking visitors over an AST, mirroring Python's
ast.NodeVisitor.Subclasses define
visit<NodeType>(orvisit_<NodeType>) methods for the node types they care about, e.g.visitFunctionDefforFunctionDefnodes. Any node type without a matching method falls back to NodeVisitor.genericVisit, which simply recurses into the node's children without doing anything else. Visitor methods are responsible for calling NodeVisitor.visit (orgenericVisit) themselves if they want traversal to continue into a node's children.Example