univac
Version:
Generate AST of lots of common programming languages using antlr4. JavaScript API and CLI tool.
23 lines (22 loc) • 1 kB
TypeScript
import { Node, NodePositionLineColumn } from './types';
export declare function printNodeText(text: string, maxLength?: number, escape?: boolean): string;
export declare function visitDescendants({ node: n, visitor: v, childrenFirst, parent, level }: {
node: Node;
visitor: (n: Node, parent?: Node | undefined, level?: number | undefined) => boolean;
childrenFirst?: boolean;
parent?: Node;
level?: number;
}): boolean;
/**
* Adds parents to given node and descendants. If parents are detected, it does nothing. Useful in cases where the ast was generated without parents to add them programmatically after.
*/
export declare function addParents(n: Node): void;
/**
* Gets the minimal node containing given position
*/
export declare function getNodeAtPosition(node: Node, position: NodePositionLineColumn): Node | undefined;
export declare function printNode({ node, level }: {
node: Node;
level?: number;
}): string;
export declare function getNodeId(n: Node): any;