childrenfunctionfunction children(n: Node): readonly Node[]The children of a node: every node in one of its fields, in the order of the text.
| Parameter | What it is |
|---|---|
n | a node |
Returns: its children
Walks over a tree (commons lang-sql 0002-sql-ast-parser FR-016): the children of a node in the order of the text, a depth-first walk with enter and leave, the nodes of one kind typed as that kind, and a fold from the leaves. children is one switch on kind that ends with absurd, so a kind added to the tree does not compile until it says what its children are.
const tables = findAll(script, "table").map((t) => t.name.parts.map((p) => p.name).join("."));Spec: 0002-sql-ast-parser FR-016
childrenfunctionfunction children(n: Node): readonly Node[]The children of a node: every node in one of its fields, in the order of the text.
| Parameter | What it is |
|---|---|
n | a node |
Returns: its children
findAllfunctionfunction findAll<K extends Kind>(root: Node, kind: K): readonly NodeOf<K>[]Every node of one kind in a tree, in the order of the text, typed as that kind.
| Parameter | What it is |
|---|---|
root | the tree |
kind | a kind of node |
Returns: the nodes of that kind
foldfunctionfunction fold<R>(root: Node, f: (node: Node, results: readonly R[]) => R): RCombines a tree from its leaves: each node's result is made from the node and its children's results.
| Parameter | What it is |
|---|---|
root | the tree |
f | the combination |
Returns: the root's result
Visitorinterfaceno test imports itinterface VisitorWhat a walk calls at each node.
| Member | Type | What it is |
|---|---|---|
enter? | ((node: Node, parent: Node | undefined) => boolean | undefined) | Called before a node's children; returning false skips them (and leave). |
leave? | ((node: Node, parent: Node | undefined) => void) | Called after a node's children. |
walkfunctionfunction walk(root: Node, visitor: Visitor): voidWalks a tree depth first.
| Parameter | What it is |
|---|---|
root | where to begin |
visitor | what to call at each node |