@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
14 lines (13 loc) • 1.12 kB
TypeScript
import type { NoInfo, RNode } from '../model';
/** Return `true` to stop visiting from this node (i.e., do not continue to visit this node *and* the children) */
export type OnEnter<OtherInfo> = (node: RNode<OtherInfo>) => (boolean | void);
/** Similar to {@link OnEnter} but called when leaving a node. Can't stop exploration as the subtree is already visited! */
export type OnExit<OtherInfo> = (node: RNode<OtherInfo>) => void;
/**
* Visits all node ids within a tree given by a respective root node using a depth-first search with prefix order.
*
* @param nodes - The root id nodes to start collecting from
* @param onVisit - Called before visiting the subtree of each node. Can be used to stop visiting the subtree starting with this node (return `true` stop)
* @param onExit - Called after the subtree of a node has been visited, called for leafs too (even though their subtree is empty)
*/
export declare function visitAst<OtherInfo = NoInfo>(nodes: RNode<OtherInfo> | (RNode<OtherInfo> | null | undefined)[] | undefined, onVisit?: OnEnter<OtherInfo>, onExit?: OnExit<OtherInfo>): void;