UNPKG

antlr-ng

Version:

Next generation ANTLR Tool

20 lines (19 loc) 915 B
import { CommonTree } from "./CommonTree.js"; import type { TreeVisitorAction } from "./TreeVisitorAction.js"; /** * Do a depth first walk of a tree, applying pre() and post() actions as we discover and finish nodes. */ export declare class TreeVisitor { /** * Visit every node in tree t and trigger an action for each node before/after having visited all of its children. * Execute both actions even if t has no children. If a child visit yields a new child, it can update its * parent's child list or just return the new child. The child update code works even if the child visit * alters its parent and returns the new tree. * * @param t The tree to visit. * @param action The action to trigger for each node. * * @returns The result of applying post action to this node. */ visit(t: CommonTree, action?: TreeVisitorAction<CommonTree>): CommonTree; }