bq2cst 0.4.32 → 0.5.1
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/README.md +2 -1
- package/bq2cst.d.ts +12 -4
- package/bq2cst.js +49 -38
- package/bq2cst_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# bq2cst
|
|
2
2
|
Parse standard SQL, which is a dialect of [BigQuery](https://cloud.google.com/bigquery), into a concrete syntax tree.
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
> [!WARNING]
|
|
5
|
+
> This parser is designed to be used via [prettier-plugin-bq](https://github.com/dr666m1/prettier-plugin-bq).
|
|
5
6
|
|
|
6
7
|
## Features
|
|
7
8
|
- forcused on standard SQL (in other words, other SQL dialects are out of scope)
|
package/bq2cst.d.ts
CHANGED
|
@@ -38,12 +38,12 @@ export type UnknownNode =
|
|
|
38
38
|
| Comment
|
|
39
39
|
| Constraint
|
|
40
40
|
| CreateFunctionStatement
|
|
41
|
+
| CreateIndexStatement
|
|
41
42
|
| CreateModelStatement
|
|
42
43
|
| CreateProcedureStatement
|
|
43
44
|
| CreateReservationStatement
|
|
44
45
|
| CreateRowAccessPolicyStatement
|
|
45
46
|
| CreateSchemaStatement
|
|
46
|
-
| CreateSearchIndexStatement
|
|
47
47
|
| CreateTableStatement
|
|
48
48
|
| CreateViewStatement
|
|
49
49
|
| DeclareStatement
|
|
@@ -653,9 +653,10 @@ export type CreateSchemaStatement = XXXStatement & {
|
|
|
653
653
|
};
|
|
654
654
|
};
|
|
655
655
|
|
|
656
|
-
export type
|
|
657
|
-
node_type: "
|
|
656
|
+
export type CreateIndexStatement = XXXStatement & {
|
|
657
|
+
node_type: "CreateIndexStatement";
|
|
658
658
|
children: {
|
|
659
|
+
or_replace?: NodeVecChild;
|
|
659
660
|
what: NodeChild;
|
|
660
661
|
if_not_exists?: NodeVecChild;
|
|
661
662
|
ident: NodeChild;
|
|
@@ -865,7 +866,7 @@ export type GroupByExprs = BaseNode & {
|
|
|
865
866
|
children: {
|
|
866
867
|
by: NodeChild;
|
|
867
868
|
how?: NodeVecChild;
|
|
868
|
-
exprs
|
|
869
|
+
exprs?: { NodeVec: Expr[] & UnknownNode[] };
|
|
869
870
|
};
|
|
870
871
|
};
|
|
871
872
|
|
|
@@ -1166,6 +1167,13 @@ export type RaiseStatement = XXXStatement & {
|
|
|
1166
1167
|
};
|
|
1167
1168
|
};
|
|
1168
1169
|
|
|
1170
|
+
export type RangeLiteral = Expr & {
|
|
1171
|
+
node_type: "RangeLiteral";
|
|
1172
|
+
children: {
|
|
1173
|
+
type: NodeChild;
|
|
1174
|
+
};
|
|
1175
|
+
};
|
|
1176
|
+
|
|
1169
1177
|
export type RenameColumnClause = BaseNode & {
|
|
1170
1178
|
token: Token;
|
|
1171
1179
|
node_type: "RenameColumnClause";
|
package/bq2cst.js
CHANGED
|
@@ -3,7 +3,7 @@ imports['__wbindgen_placeholder__'] = module.exports;
|
|
|
3
3
|
let wasm;
|
|
4
4
|
const { TextDecoder, TextEncoder } = require(`util`);
|
|
5
5
|
|
|
6
|
-
const heap = new Array(
|
|
6
|
+
const heap = new Array(128).fill(undefined);
|
|
7
7
|
|
|
8
8
|
heap.push(undefined, null, true, false);
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ function getObject(idx) { return heap[idx]; }
|
|
|
12
12
|
let heap_next = heap.length;
|
|
13
13
|
|
|
14
14
|
function dropObject(idx) {
|
|
15
|
-
if (idx <
|
|
15
|
+
if (idx < 132) return;
|
|
16
16
|
heap[idx] = heap_next;
|
|
17
17
|
heap_next = idx;
|
|
18
18
|
}
|
|
@@ -23,32 +23,33 @@ function takeObject(idx) {
|
|
|
23
23
|
return ret;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
function addHeapObject(obj) {
|
|
27
|
+
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
28
|
+
const idx = heap_next;
|
|
29
|
+
heap_next = heap[idx];
|
|
30
|
+
|
|
31
|
+
heap[idx] = obj;
|
|
32
|
+
return idx;
|
|
33
|
+
}
|
|
34
|
+
|
|
26
35
|
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
27
36
|
|
|
28
37
|
cachedTextDecoder.decode();
|
|
29
38
|
|
|
30
|
-
let cachedUint8Memory0 =
|
|
39
|
+
let cachedUint8Memory0 = null;
|
|
31
40
|
|
|
32
41
|
function getUint8Memory0() {
|
|
33
|
-
if (cachedUint8Memory0.byteLength === 0) {
|
|
42
|
+
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
34
43
|
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
35
44
|
}
|
|
36
45
|
return cachedUint8Memory0;
|
|
37
46
|
}
|
|
38
47
|
|
|
39
48
|
function getStringFromWasm0(ptr, len) {
|
|
49
|
+
ptr = ptr >>> 0;
|
|
40
50
|
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
41
51
|
}
|
|
42
52
|
|
|
43
|
-
function addHeapObject(obj) {
|
|
44
|
-
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
45
|
-
const idx = heap_next;
|
|
46
|
-
heap_next = heap[idx];
|
|
47
|
-
|
|
48
|
-
heap[idx] = obj;
|
|
49
|
-
return idx;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
53
|
function debugString(val) {
|
|
53
54
|
// primitive types
|
|
54
55
|
const type = typeof val;
|
|
@@ -135,14 +136,14 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
135
136
|
|
|
136
137
|
if (realloc === undefined) {
|
|
137
138
|
const buf = cachedTextEncoder.encode(arg);
|
|
138
|
-
const ptr = malloc(buf.length);
|
|
139
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
139
140
|
getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
140
141
|
WASM_VECTOR_LEN = buf.length;
|
|
141
142
|
return ptr;
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
let len = arg.length;
|
|
145
|
-
let ptr = malloc(len);
|
|
146
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
146
147
|
|
|
147
148
|
const mem = getUint8Memory0();
|
|
148
149
|
|
|
@@ -158,21 +159,22 @@ function passStringToWasm0(arg, malloc, realloc) {
|
|
|
158
159
|
if (offset !== 0) {
|
|
159
160
|
arg = arg.slice(offset);
|
|
160
161
|
}
|
|
161
|
-
ptr = realloc(ptr, len, len = offset + arg.length * 3);
|
|
162
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
162
163
|
const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
|
|
163
164
|
const ret = encodeString(arg, view);
|
|
164
165
|
|
|
165
166
|
offset += ret.written;
|
|
167
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
166
168
|
}
|
|
167
169
|
|
|
168
170
|
WASM_VECTOR_LEN = offset;
|
|
169
171
|
return ptr;
|
|
170
172
|
}
|
|
171
173
|
|
|
172
|
-
let cachedInt32Memory0 =
|
|
174
|
+
let cachedInt32Memory0 = null;
|
|
173
175
|
|
|
174
176
|
function getInt32Memory0() {
|
|
175
|
-
if (cachedInt32Memory0.byteLength === 0) {
|
|
177
|
+
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) {
|
|
176
178
|
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
|
|
177
179
|
}
|
|
178
180
|
return cachedInt32Memory0;
|
|
@@ -225,6 +227,16 @@ module.exports.__wbindgen_object_drop_ref = function(arg0) {
|
|
|
225
227
|
takeObject(arg0);
|
|
226
228
|
};
|
|
227
229
|
|
|
230
|
+
module.exports.__wbindgen_as_number = function(arg0) {
|
|
231
|
+
const ret = +getObject(arg0);
|
|
232
|
+
return ret;
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
module.exports.__wbindgen_object_clone_ref = function(arg0) {
|
|
236
|
+
const ret = getObject(arg0);
|
|
237
|
+
return addHeapObject(ret);
|
|
238
|
+
};
|
|
239
|
+
|
|
228
240
|
module.exports.__wbindgen_error_new = function(arg0, arg1) {
|
|
229
241
|
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
230
242
|
return addHeapObject(ret);
|
|
@@ -237,25 +249,24 @@ module.exports.__wbg_new_abda76e883ba8a5f = function() {
|
|
|
237
249
|
|
|
238
250
|
module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
|
|
239
251
|
const ret = getObject(arg1).stack;
|
|
240
|
-
const
|
|
241
|
-
const
|
|
242
|
-
getInt32Memory0()[arg0 / 4 + 1] =
|
|
243
|
-
getInt32Memory0()[arg0 / 4 + 0] =
|
|
252
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
253
|
+
const len1 = WASM_VECTOR_LEN;
|
|
254
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
255
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
244
256
|
};
|
|
245
257
|
|
|
246
258
|
module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
|
|
259
|
+
let deferred0_0;
|
|
260
|
+
let deferred0_1;
|
|
247
261
|
try {
|
|
262
|
+
deferred0_0 = arg0;
|
|
263
|
+
deferred0_1 = arg1;
|
|
248
264
|
console.error(getStringFromWasm0(arg0, arg1));
|
|
249
265
|
} finally {
|
|
250
|
-
wasm.__wbindgen_free(
|
|
266
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
251
267
|
}
|
|
252
268
|
};
|
|
253
269
|
|
|
254
|
-
module.exports.__wbindgen_object_clone_ref = function(arg0) {
|
|
255
|
-
const ret = getObject(arg0);
|
|
256
|
-
return addHeapObject(ret);
|
|
257
|
-
};
|
|
258
|
-
|
|
259
270
|
module.exports.__wbindgen_number_new = function(arg0) {
|
|
260
271
|
const ret = arg0;
|
|
261
272
|
return addHeapObject(ret);
|
|
@@ -271,21 +282,21 @@ module.exports.__wbindgen_string_new = function(arg0, arg1) {
|
|
|
271
282
|
return addHeapObject(ret);
|
|
272
283
|
};
|
|
273
284
|
|
|
274
|
-
module.exports.
|
|
285
|
+
module.exports.__wbg_set_2e973e6a06d4c5c3 = function(arg0, arg1, arg2) {
|
|
275
286
|
getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
|
|
276
287
|
};
|
|
277
288
|
|
|
278
|
-
module.exports.
|
|
289
|
+
module.exports.__wbg_new_75208e29bddfd88c = function() {
|
|
279
290
|
const ret = new Array();
|
|
280
291
|
return addHeapObject(ret);
|
|
281
292
|
};
|
|
282
293
|
|
|
283
|
-
module.exports.
|
|
294
|
+
module.exports.__wbg_new_d1cc518eff6805bb = function() {
|
|
284
295
|
const ret = new Map();
|
|
285
296
|
return addHeapObject(ret);
|
|
286
297
|
};
|
|
287
298
|
|
|
288
|
-
module.exports.
|
|
299
|
+
module.exports.__wbg_new_632630b5cec17f21 = function() {
|
|
289
300
|
const ret = new Object();
|
|
290
301
|
return addHeapObject(ret);
|
|
291
302
|
};
|
|
@@ -295,21 +306,21 @@ module.exports.__wbindgen_is_string = function(arg0) {
|
|
|
295
306
|
return ret;
|
|
296
307
|
};
|
|
297
308
|
|
|
298
|
-
module.exports.
|
|
309
|
+
module.exports.__wbg_set_79c308ecd9a1d091 = function(arg0, arg1, arg2) {
|
|
299
310
|
getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
|
|
300
311
|
};
|
|
301
312
|
|
|
302
|
-
module.exports.
|
|
313
|
+
module.exports.__wbg_set_e4cfc2763115ffc7 = function(arg0, arg1, arg2) {
|
|
303
314
|
const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
|
|
304
315
|
return addHeapObject(ret);
|
|
305
316
|
};
|
|
306
317
|
|
|
307
318
|
module.exports.__wbindgen_debug_string = function(arg0, arg1) {
|
|
308
319
|
const ret = debugString(getObject(arg1));
|
|
309
|
-
const
|
|
310
|
-
const
|
|
311
|
-
getInt32Memory0()[arg0 / 4 + 1] =
|
|
312
|
-
getInt32Memory0()[arg0 / 4 + 0] =
|
|
320
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
321
|
+
const len1 = WASM_VECTOR_LEN;
|
|
322
|
+
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
323
|
+
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
313
324
|
};
|
|
314
325
|
|
|
315
326
|
module.exports.__wbindgen_throw = function(arg0, arg1) {
|
package/bq2cst_bg.wasm
CHANGED
|
Binary file
|