@omgbase/oqx 0.20.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +65 -0
- package/dist/ast.d.ts +20 -2
- package/dist/ast.d.ts.map +1 -1
- package/dist/ast.js +11 -1
- package/dist/ast.js.map +1 -1
- package/dist/build.d.ts +4 -1
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +3 -0
- package/dist/build.js.map +1 -1
- package/dist/engine.d.ts +1 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +45 -3
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/lexer.d.ts +3 -3
- package/dist/lexer.d.ts.map +1 -1
- package/dist/lexer.js +92 -5
- package/dist/lexer.js.map +1 -1
- package/dist/optimize/analysis.d.ts.map +1 -1
- package/dist/optimize/analysis.js +8 -1
- package/dist/optimize/analysis.js.map +1 -1
- package/dist/parser.d.ts.map +1 -1
- package/dist/parser.js +58 -5
- package/dist/parser.js.map +1 -1
- package/dist/print.js +36 -17
- package/dist/print.js.map +1 -1
- package/dist/references.d.ts +26 -0
- package/dist/references.d.ts.map +1 -0
- package/dist/references.js +225 -0
- package/dist/references.js.map +1 -0
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js +4 -0
- package/dist/resolve.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/walk.d.ts.map +1 -1
- package/dist/walk.js +8 -3
- package/dist/walk.js.map +1 -1
- package/package.json +1 -1
- package/src/ast.ts +31 -3
- package/src/build.ts +4 -1
- package/src/engine.ts +40 -3
- package/src/index.ts +3 -1
- package/src/lexer.ts +86 -10
- package/src/optimize/analysis.ts +9 -1
- package/src/parser.ts +51 -6
- package/src/print.ts +34 -7
- package/src/references.ts +238 -0
- package/src/resolve.ts +4 -0
- package/src/version.ts +1 -1
- package/src/walk.ts +7 -3
package/src/walk.ts
CHANGED
|
@@ -97,9 +97,13 @@ export const CHILDREN: { readonly [K in AstKind]: readonly ChildKey[] } = {
|
|
|
97
97
|
in: [{ key: "left" }, { key: "right" }],
|
|
98
98
|
range: [{ key: "lo" }, { key: "hi" }],
|
|
99
99
|
tuple: [{ key: "items" }],
|
|
100
|
+
// The interpolations; the text parts between them are strings, not nodes.
|
|
101
|
+
template: [{ key: "parts" }],
|
|
100
102
|
};
|
|
101
103
|
|
|
102
|
-
|
|
104
|
+
/** A child slot's value: a node, a list of nodes (a template's `parts` also
|
|
105
|
+
* holds its text strings, which the walks skip), or `null`. */
|
|
106
|
+
type Slot = AstNode | (AstNode | string)[] | null;
|
|
103
107
|
|
|
104
108
|
function slot(node: AstNode, key: string): Slot {
|
|
105
109
|
return (node as unknown as Record<string, Slot>)[key] ?? null;
|
|
@@ -134,7 +138,7 @@ export function visit(root: AstNode, visitor: Visitor): void {
|
|
|
134
138
|
if (v === null) continue;
|
|
135
139
|
const c = child.clause ?? clause;
|
|
136
140
|
const d = depth + childDepth(node, child, path);
|
|
137
|
-
if (Array.isArray(v)) for (const x of v) go(x, c, d);
|
|
141
|
+
if (Array.isArray(v)) { for (const x of v) if (typeof x !== "string") go(x, c, d); }
|
|
138
142
|
else go(v, c, d);
|
|
139
143
|
}
|
|
140
144
|
path.pop();
|
|
@@ -162,7 +166,7 @@ export function transform<T extends Query | Subquery>(root: T, f: (expr: Expr, c
|
|
|
162
166
|
let next: Slot;
|
|
163
167
|
if (Array.isArray(v)) {
|
|
164
168
|
let changed = false;
|
|
165
|
-
const mapped = v.map((x) => { const y = go(x, c, d); if (y !== x) changed = true; return y; });
|
|
169
|
+
const mapped = v.map((x) => { if (typeof x === "string") return x; const y = go(x, c, d); if (y !== x) changed = true; return y; });
|
|
166
170
|
next = changed ? mapped : v;
|
|
167
171
|
} else next = go(v, c, d);
|
|
168
172
|
if (next !== v) out = { ...out, [child.key]: next } as AstNode;
|