@parsanol/wasm 0.8.11
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 +2058 -0
- package/package.json +38 -0
- package/parsanol.d.ts +131 -0
- package/parsanol.js +446 -0
- package/parsanol_bg.wasm +0 -0
- package/parsanol_bg.wasm.d.ts +37 -0
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@parsanol/wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"Ribose Inc. <open.source@ribose.com>"
|
|
6
|
+
],
|
|
7
|
+
"description": "Parsanol PEG parser — WebAssembly bindings",
|
|
8
|
+
"version": "0.8.11",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/parsanol/parsanol-rs"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"parsanol_bg.wasm",
|
|
16
|
+
"parsanol_bg.wasm.d.ts",
|
|
17
|
+
"parsanol.js",
|
|
18
|
+
"parsanol.d.ts"
|
|
19
|
+
],
|
|
20
|
+
"homepage": "https://github.com/parsanol/parsanol-rs",
|
|
21
|
+
"types": "parsanol.d.ts",
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"./snippets/*"
|
|
24
|
+
],
|
|
25
|
+
"keywords": [
|
|
26
|
+
"parser",
|
|
27
|
+
"peg",
|
|
28
|
+
"wasm",
|
|
29
|
+
"rust"
|
|
30
|
+
],
|
|
31
|
+
"module": "parsanol.js",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./parsanol.d.ts",
|
|
35
|
+
"default": "./parsanol.js"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
package/parsanol.d.ts
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* WASM parser instance
|
|
6
|
+
*
|
|
7
|
+
* Create with `new WasmParser(grammarJson)` and parse with `parse(input)`.
|
|
8
|
+
*/
|
|
9
|
+
export class WasmParser {
|
|
10
|
+
free(): void;
|
|
11
|
+
[Symbol.dispose](): void;
|
|
12
|
+
/**
|
|
13
|
+
* Create a new parser from grammar JSON
|
|
14
|
+
*
|
|
15
|
+
* # Arguments
|
|
16
|
+
* * `grammar_json` - JSON string representing the grammar
|
|
17
|
+
*
|
|
18
|
+
* # Returns
|
|
19
|
+
* A new WasmParser instance
|
|
20
|
+
*
|
|
21
|
+
* # Throws
|
|
22
|
+
* If the grammar JSON is invalid
|
|
23
|
+
*/
|
|
24
|
+
constructor(grammar_json: string);
|
|
25
|
+
/**
|
|
26
|
+
* Parse input and return JavaScript AST
|
|
27
|
+
*
|
|
28
|
+
* # Arguments
|
|
29
|
+
* * `input` - The input string to parse
|
|
30
|
+
*
|
|
31
|
+
* # Returns
|
|
32
|
+
* A JavaScript object representing the parsed AST
|
|
33
|
+
*
|
|
34
|
+
* # Throws
|
|
35
|
+
* If parsing fails
|
|
36
|
+
*/
|
|
37
|
+
parse(input: string): any;
|
|
38
|
+
/**
|
|
39
|
+
* Parse and return flat array (for Opal compatibility)
|
|
40
|
+
*
|
|
41
|
+
* # Arguments
|
|
42
|
+
* * `input` - The input string to parse
|
|
43
|
+
*
|
|
44
|
+
* # Returns
|
|
45
|
+
* A Uint32Array containing the flattened AST
|
|
46
|
+
*
|
|
47
|
+
* # Throws
|
|
48
|
+
* If parsing fails
|
|
49
|
+
*/
|
|
50
|
+
parse_flat(input: string): BigUint64Array;
|
|
51
|
+
/**
|
|
52
|
+
* Parse and return JSON string
|
|
53
|
+
*
|
|
54
|
+
* # Arguments
|
|
55
|
+
* * `input` - The input string to parse
|
|
56
|
+
*
|
|
57
|
+
* # Returns
|
|
58
|
+
* A JSON string representing the parsed AST
|
|
59
|
+
*
|
|
60
|
+
* # Throws
|
|
61
|
+
* If parsing fails
|
|
62
|
+
*/
|
|
63
|
+
parse_json(input: string): string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Initialize function for WASM
|
|
68
|
+
*/
|
|
69
|
+
export function init(): void;
|
|
70
|
+
|
|
71
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
72
|
+
|
|
73
|
+
export interface InitOutput {
|
|
74
|
+
readonly memory: WebAssembly.Memory;
|
|
75
|
+
readonly __wbg_wasmparser_free: (a: number, b: number) => void;
|
|
76
|
+
readonly parsanol_c_last_error: () => number;
|
|
77
|
+
readonly parsanol_c_parse: (a: bigint, b: number, c: number, d: number) => number;
|
|
78
|
+
readonly parsanol_c_parse_len: (a: bigint, b: number, c: number, d: number, e: number) => number;
|
|
79
|
+
readonly parsanol_c_register: (a: number) => bigint;
|
|
80
|
+
readonly parsanol_c_release: (a: bigint) => void;
|
|
81
|
+
readonly parsanol_grammar_atom_count: (a: number) => number;
|
|
82
|
+
readonly parsanol_grammar_free: (a: number) => void;
|
|
83
|
+
readonly parsanol_grammar_new: (a: number) => number;
|
|
84
|
+
readonly parsanol_grammar_new_with_error: (a: number, b: number) => number;
|
|
85
|
+
readonly parsanol_grammar_root: (a: number) => number;
|
|
86
|
+
readonly parsanol_parse: (a: number, b: number, c: number) => number;
|
|
87
|
+
readonly parsanol_parse_end_pos: (a: number, b: number) => number;
|
|
88
|
+
readonly parsanol_parse_simple: (a: number, b: number) => number;
|
|
89
|
+
readonly parsanol_result_ast_json: (a: number) => number;
|
|
90
|
+
readonly parsanol_result_end_pos: (a: number) => number;
|
|
91
|
+
readonly parsanol_result_error: (a: number) => number;
|
|
92
|
+
readonly parsanol_result_free: (a: number) => void;
|
|
93
|
+
readonly parsanol_result_success: (a: number) => number;
|
|
94
|
+
readonly parsanol_string_free: (a: number) => void;
|
|
95
|
+
readonly parsanol_version: () => number;
|
|
96
|
+
readonly wasmparser_new: (a: number, b: number) => [number, number, number];
|
|
97
|
+
readonly wasmparser_parse: (a: number, b: number, c: number) => [number, number, number];
|
|
98
|
+
readonly wasmparser_parse_flat: (a: number, b: number, c: number) => [number, number, number, number];
|
|
99
|
+
readonly wasmparser_parse_json: (a: number, b: number, c: number) => [number, number, number, number];
|
|
100
|
+
readonly init: () => void;
|
|
101
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
102
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
103
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
104
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
105
|
+
readonly __externref_table_alloc: () => number;
|
|
106
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
107
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
108
|
+
readonly __wbindgen_start: () => void;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
115
|
+
* a precompiled `WebAssembly.Module`.
|
|
116
|
+
*
|
|
117
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
118
|
+
*
|
|
119
|
+
* @returns {InitOutput}
|
|
120
|
+
*/
|
|
121
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
125
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
126
|
+
*
|
|
127
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
128
|
+
*
|
|
129
|
+
* @returns {Promise<InitOutput>}
|
|
130
|
+
*/
|
|
131
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/parsanol.js
ADDED
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
/* @ts-self-types="./parsanol.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WASM parser instance
|
|
5
|
+
*
|
|
6
|
+
* Create with `new WasmParser(grammarJson)` and parse with `parse(input)`.
|
|
7
|
+
*/
|
|
8
|
+
export class WasmParser {
|
|
9
|
+
__destroy_into_raw() {
|
|
10
|
+
const ptr = this.__wbg_ptr;
|
|
11
|
+
this.__wbg_ptr = 0;
|
|
12
|
+
WasmParserFinalization.unregister(this);
|
|
13
|
+
return ptr;
|
|
14
|
+
}
|
|
15
|
+
free() {
|
|
16
|
+
const ptr = this.__destroy_into_raw();
|
|
17
|
+
wasm.__wbg_wasmparser_free(ptr, 0);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create a new parser from grammar JSON
|
|
21
|
+
*
|
|
22
|
+
* # Arguments
|
|
23
|
+
* * `grammar_json` - JSON string representing the grammar
|
|
24
|
+
*
|
|
25
|
+
* # Returns
|
|
26
|
+
* A new WasmParser instance
|
|
27
|
+
*
|
|
28
|
+
* # Throws
|
|
29
|
+
* If the grammar JSON is invalid
|
|
30
|
+
* @param {string} grammar_json
|
|
31
|
+
*/
|
|
32
|
+
constructor(grammar_json) {
|
|
33
|
+
const ptr0 = passStringToWasm0(grammar_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
34
|
+
const len0 = WASM_VECTOR_LEN;
|
|
35
|
+
const ret = wasm.wasmparser_new(ptr0, len0);
|
|
36
|
+
if (ret[2]) {
|
|
37
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
38
|
+
}
|
|
39
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
40
|
+
WasmParserFinalization.register(this, this.__wbg_ptr, this);
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Parse input and return JavaScript AST
|
|
45
|
+
*
|
|
46
|
+
* # Arguments
|
|
47
|
+
* * `input` - The input string to parse
|
|
48
|
+
*
|
|
49
|
+
* # Returns
|
|
50
|
+
* A JavaScript object representing the parsed AST
|
|
51
|
+
*
|
|
52
|
+
* # Throws
|
|
53
|
+
* If parsing fails
|
|
54
|
+
* @param {string} input
|
|
55
|
+
* @returns {any}
|
|
56
|
+
*/
|
|
57
|
+
parse(input) {
|
|
58
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
59
|
+
const len0 = WASM_VECTOR_LEN;
|
|
60
|
+
const ret = wasm.wasmparser_parse(this.__wbg_ptr, ptr0, len0);
|
|
61
|
+
if (ret[2]) {
|
|
62
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
63
|
+
}
|
|
64
|
+
return takeFromExternrefTable0(ret[0]);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Parse and return flat array (for Opal compatibility)
|
|
68
|
+
*
|
|
69
|
+
* # Arguments
|
|
70
|
+
* * `input` - The input string to parse
|
|
71
|
+
*
|
|
72
|
+
* # Returns
|
|
73
|
+
* A Uint32Array containing the flattened AST
|
|
74
|
+
*
|
|
75
|
+
* # Throws
|
|
76
|
+
* If parsing fails
|
|
77
|
+
* @param {string} input
|
|
78
|
+
* @returns {BigUint64Array}
|
|
79
|
+
*/
|
|
80
|
+
parse_flat(input) {
|
|
81
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
82
|
+
const len0 = WASM_VECTOR_LEN;
|
|
83
|
+
const ret = wasm.wasmparser_parse_flat(this.__wbg_ptr, ptr0, len0);
|
|
84
|
+
if (ret[3]) {
|
|
85
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
86
|
+
}
|
|
87
|
+
var v2 = getArrayU64FromWasm0(ret[0], ret[1]).slice();
|
|
88
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
89
|
+
return v2;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Parse and return JSON string
|
|
93
|
+
*
|
|
94
|
+
* # Arguments
|
|
95
|
+
* * `input` - The input string to parse
|
|
96
|
+
*
|
|
97
|
+
* # Returns
|
|
98
|
+
* A JSON string representing the parsed AST
|
|
99
|
+
*
|
|
100
|
+
* # Throws
|
|
101
|
+
* If parsing fails
|
|
102
|
+
* @param {string} input
|
|
103
|
+
* @returns {string}
|
|
104
|
+
*/
|
|
105
|
+
parse_json(input) {
|
|
106
|
+
let deferred3_0;
|
|
107
|
+
let deferred3_1;
|
|
108
|
+
try {
|
|
109
|
+
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
110
|
+
const len0 = WASM_VECTOR_LEN;
|
|
111
|
+
const ret = wasm.wasmparser_parse_json(this.__wbg_ptr, ptr0, len0);
|
|
112
|
+
var ptr2 = ret[0];
|
|
113
|
+
var len2 = ret[1];
|
|
114
|
+
if (ret[3]) {
|
|
115
|
+
ptr2 = 0; len2 = 0;
|
|
116
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
117
|
+
}
|
|
118
|
+
deferred3_0 = ptr2;
|
|
119
|
+
deferred3_1 = len2;
|
|
120
|
+
return getStringFromWasm0(ptr2, len2);
|
|
121
|
+
} finally {
|
|
122
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (Symbol.dispose) WasmParser.prototype[Symbol.dispose] = WasmParser.prototype.free;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Initialize function for WASM
|
|
130
|
+
*/
|
|
131
|
+
export function init() {
|
|
132
|
+
wasm.init();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function __wbg_get_imports() {
|
|
136
|
+
const import0 = {
|
|
137
|
+
__proto__: null,
|
|
138
|
+
__wbg___wbindgen_string_get_395e606bd0ee4427: function(arg0, arg1) {
|
|
139
|
+
const obj = arg1;
|
|
140
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
141
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
142
|
+
var len1 = WASM_VECTOR_LEN;
|
|
143
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
144
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
145
|
+
},
|
|
146
|
+
__wbg___wbindgen_throw_6ddd609b62940d55: function(arg0, arg1) {
|
|
147
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
148
|
+
},
|
|
149
|
+
__wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
|
|
150
|
+
let deferred0_0;
|
|
151
|
+
let deferred0_1;
|
|
152
|
+
try {
|
|
153
|
+
deferred0_0 = arg0;
|
|
154
|
+
deferred0_1 = arg1;
|
|
155
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
156
|
+
} finally {
|
|
157
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
__wbg_getRandomValues_3f44b700395062e5: function() { return handleError(function (arg0, arg1) {
|
|
161
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
162
|
+
}, arguments); },
|
|
163
|
+
__wbg_new_227d7c05414eb861: function() {
|
|
164
|
+
const ret = new Error();
|
|
165
|
+
return ret;
|
|
166
|
+
},
|
|
167
|
+
__wbg_new_a70fbab9066b301f: function() {
|
|
168
|
+
const ret = new Array();
|
|
169
|
+
return ret;
|
|
170
|
+
},
|
|
171
|
+
__wbg_new_ab79df5bd7c26067: function() {
|
|
172
|
+
const ret = new Object();
|
|
173
|
+
return ret;
|
|
174
|
+
},
|
|
175
|
+
__wbg_push_e87b0e732085a946: function(arg0, arg1) {
|
|
176
|
+
const ret = arg0.push(arg1);
|
|
177
|
+
return ret;
|
|
178
|
+
},
|
|
179
|
+
__wbg_set_7eaa4f96924fd6b3: function() { return handleError(function (arg0, arg1, arg2) {
|
|
180
|
+
const ret = Reflect.set(arg0, arg1, arg2);
|
|
181
|
+
return ret;
|
|
182
|
+
}, arguments); },
|
|
183
|
+
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
184
|
+
const ret = arg1.stack;
|
|
185
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
186
|
+
const len1 = WASM_VECTOR_LEN;
|
|
187
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
188
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
189
|
+
},
|
|
190
|
+
__wbg_stringify_5ae93966a84901ac: function() { return handleError(function (arg0) {
|
|
191
|
+
const ret = JSON.stringify(arg0);
|
|
192
|
+
return ret;
|
|
193
|
+
}, arguments); },
|
|
194
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
195
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
196
|
+
const ret = arg0;
|
|
197
|
+
return ret;
|
|
198
|
+
},
|
|
199
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
200
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
201
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
202
|
+
return ret;
|
|
203
|
+
},
|
|
204
|
+
__wbindgen_init_externref_table: function() {
|
|
205
|
+
const table = wasm.__wbindgen_externrefs;
|
|
206
|
+
const offset = table.grow(4);
|
|
207
|
+
table.set(0, undefined);
|
|
208
|
+
table.set(offset + 0, undefined);
|
|
209
|
+
table.set(offset + 1, null);
|
|
210
|
+
table.set(offset + 2, true);
|
|
211
|
+
table.set(offset + 3, false);
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
return {
|
|
215
|
+
__proto__: null,
|
|
216
|
+
"./parsanol_bg.js": import0,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const WasmParserFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
221
|
+
? { register: () => {}, unregister: () => {} }
|
|
222
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmparser_free(ptr >>> 0, 1));
|
|
223
|
+
|
|
224
|
+
function addToExternrefTable0(obj) {
|
|
225
|
+
const idx = wasm.__externref_table_alloc();
|
|
226
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
227
|
+
return idx;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function getArrayU64FromWasm0(ptr, len) {
|
|
231
|
+
ptr = ptr >>> 0;
|
|
232
|
+
return getBigUint64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
236
|
+
ptr = ptr >>> 0;
|
|
237
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
let cachedBigUint64ArrayMemory0 = null;
|
|
241
|
+
function getBigUint64ArrayMemory0() {
|
|
242
|
+
if (cachedBigUint64ArrayMemory0 === null || cachedBigUint64ArrayMemory0.byteLength === 0) {
|
|
243
|
+
cachedBigUint64ArrayMemory0 = new BigUint64Array(wasm.memory.buffer);
|
|
244
|
+
}
|
|
245
|
+
return cachedBigUint64ArrayMemory0;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
let cachedDataViewMemory0 = null;
|
|
249
|
+
function getDataViewMemory0() {
|
|
250
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
251
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
252
|
+
}
|
|
253
|
+
return cachedDataViewMemory0;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function getStringFromWasm0(ptr, len) {
|
|
257
|
+
ptr = ptr >>> 0;
|
|
258
|
+
return decodeText(ptr, len);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
let cachedUint8ArrayMemory0 = null;
|
|
262
|
+
function getUint8ArrayMemory0() {
|
|
263
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
264
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
265
|
+
}
|
|
266
|
+
return cachedUint8ArrayMemory0;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function handleError(f, args) {
|
|
270
|
+
try {
|
|
271
|
+
return f.apply(this, args);
|
|
272
|
+
} catch (e) {
|
|
273
|
+
const idx = addToExternrefTable0(e);
|
|
274
|
+
wasm.__wbindgen_exn_store(idx);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function isLikeNone(x) {
|
|
279
|
+
return x === undefined || x === null;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
283
|
+
if (realloc === undefined) {
|
|
284
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
285
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
286
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
287
|
+
WASM_VECTOR_LEN = buf.length;
|
|
288
|
+
return ptr;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
let len = arg.length;
|
|
292
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
293
|
+
|
|
294
|
+
const mem = getUint8ArrayMemory0();
|
|
295
|
+
|
|
296
|
+
let offset = 0;
|
|
297
|
+
|
|
298
|
+
for (; offset < len; offset++) {
|
|
299
|
+
const code = arg.charCodeAt(offset);
|
|
300
|
+
if (code > 0x7F) break;
|
|
301
|
+
mem[ptr + offset] = code;
|
|
302
|
+
}
|
|
303
|
+
if (offset !== len) {
|
|
304
|
+
if (offset !== 0) {
|
|
305
|
+
arg = arg.slice(offset);
|
|
306
|
+
}
|
|
307
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
308
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
309
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
310
|
+
|
|
311
|
+
offset += ret.written;
|
|
312
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
WASM_VECTOR_LEN = offset;
|
|
316
|
+
return ptr;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function takeFromExternrefTable0(idx) {
|
|
320
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
321
|
+
wasm.__externref_table_dealloc(idx);
|
|
322
|
+
return value;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
326
|
+
cachedTextDecoder.decode();
|
|
327
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
328
|
+
let numBytesDecoded = 0;
|
|
329
|
+
function decodeText(ptr, len) {
|
|
330
|
+
numBytesDecoded += len;
|
|
331
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
332
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
333
|
+
cachedTextDecoder.decode();
|
|
334
|
+
numBytesDecoded = len;
|
|
335
|
+
}
|
|
336
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
const cachedTextEncoder = new TextEncoder();
|
|
340
|
+
|
|
341
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
342
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
343
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
344
|
+
view.set(buf);
|
|
345
|
+
return {
|
|
346
|
+
read: arg.length,
|
|
347
|
+
written: buf.length
|
|
348
|
+
};
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
let WASM_VECTOR_LEN = 0;
|
|
353
|
+
|
|
354
|
+
let wasmModule, wasm;
|
|
355
|
+
function __wbg_finalize_init(instance, module) {
|
|
356
|
+
wasm = instance.exports;
|
|
357
|
+
wasmModule = module;
|
|
358
|
+
cachedBigUint64ArrayMemory0 = null;
|
|
359
|
+
cachedDataViewMemory0 = null;
|
|
360
|
+
cachedUint8ArrayMemory0 = null;
|
|
361
|
+
wasm.__wbindgen_start();
|
|
362
|
+
return wasm;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
async function __wbg_load(module, imports) {
|
|
366
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
367
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
368
|
+
try {
|
|
369
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
370
|
+
} catch (e) {
|
|
371
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
372
|
+
|
|
373
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
374
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
375
|
+
|
|
376
|
+
} else { throw e; }
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
const bytes = await module.arrayBuffer();
|
|
381
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
382
|
+
} else {
|
|
383
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
384
|
+
|
|
385
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
386
|
+
return { instance, module };
|
|
387
|
+
} else {
|
|
388
|
+
return instance;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
function expectedResponseType(type) {
|
|
393
|
+
switch (type) {
|
|
394
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
395
|
+
}
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function initSync(module) {
|
|
401
|
+
if (wasm !== undefined) return wasm;
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
if (module !== undefined) {
|
|
405
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
406
|
+
({module} = module)
|
|
407
|
+
} else {
|
|
408
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
const imports = __wbg_get_imports();
|
|
413
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
414
|
+
module = new WebAssembly.Module(module);
|
|
415
|
+
}
|
|
416
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
417
|
+
return __wbg_finalize_init(instance, module);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
async function __wbg_init(module_or_path) {
|
|
421
|
+
if (wasm !== undefined) return wasm;
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
if (module_or_path !== undefined) {
|
|
425
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
426
|
+
({module_or_path} = module_or_path)
|
|
427
|
+
} else {
|
|
428
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
if (module_or_path === undefined) {
|
|
433
|
+
module_or_path = new URL('parsanol_bg.wasm', import.meta.url);
|
|
434
|
+
}
|
|
435
|
+
const imports = __wbg_get_imports();
|
|
436
|
+
|
|
437
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
438
|
+
module_or_path = fetch(module_or_path);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
442
|
+
|
|
443
|
+
return __wbg_finalize_init(instance, module);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
export { initSync, __wbg_init as default };
|
package/parsanol_bg.wasm
ADDED
|
Binary file
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_wasmparser_free: (a: number, b: number) => void;
|
|
5
|
+
export const parsanol_c_last_error: () => number;
|
|
6
|
+
export const parsanol_c_parse: (a: bigint, b: number, c: number, d: number) => number;
|
|
7
|
+
export const parsanol_c_parse_len: (a: bigint, b: number, c: number, d: number, e: number) => number;
|
|
8
|
+
export const parsanol_c_register: (a: number) => bigint;
|
|
9
|
+
export const parsanol_c_release: (a: bigint) => void;
|
|
10
|
+
export const parsanol_grammar_atom_count: (a: number) => number;
|
|
11
|
+
export const parsanol_grammar_free: (a: number) => void;
|
|
12
|
+
export const parsanol_grammar_new: (a: number) => number;
|
|
13
|
+
export const parsanol_grammar_new_with_error: (a: number, b: number) => number;
|
|
14
|
+
export const parsanol_grammar_root: (a: number) => number;
|
|
15
|
+
export const parsanol_parse: (a: number, b: number, c: number) => number;
|
|
16
|
+
export const parsanol_parse_end_pos: (a: number, b: number) => number;
|
|
17
|
+
export const parsanol_parse_simple: (a: number, b: number) => number;
|
|
18
|
+
export const parsanol_result_ast_json: (a: number) => number;
|
|
19
|
+
export const parsanol_result_end_pos: (a: number) => number;
|
|
20
|
+
export const parsanol_result_error: (a: number) => number;
|
|
21
|
+
export const parsanol_result_free: (a: number) => void;
|
|
22
|
+
export const parsanol_result_success: (a: number) => number;
|
|
23
|
+
export const parsanol_string_free: (a: number) => void;
|
|
24
|
+
export const parsanol_version: () => number;
|
|
25
|
+
export const wasmparser_new: (a: number, b: number) => [number, number, number];
|
|
26
|
+
export const wasmparser_parse: (a: number, b: number, c: number) => [number, number, number];
|
|
27
|
+
export const wasmparser_parse_flat: (a: number, b: number, c: number) => [number, number, number, number];
|
|
28
|
+
export const wasmparser_parse_json: (a: number, b: number, c: number) => [number, number, number, number];
|
|
29
|
+
export const init: () => void;
|
|
30
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
31
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
32
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
33
|
+
export const __wbindgen_exn_store: (a: number) => void;
|
|
34
|
+
export const __externref_table_alloc: () => number;
|
|
35
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
36
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
37
|
+
export const __wbindgen_start: () => void;
|