parsanol 0.10.44 → 0.10.45
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 +42 -0
- package/dist/browser.d.ts +16 -0
- package/dist/browser.js +43 -0
- package/dist/runtime-core.d.ts +162 -0
- package/dist/runtime-core.js +268 -0
- package/dist/runtime.d.ts +5 -121
- package/dist/runtime.js +5 -176
- package/package.json +21 -5
- package/vendor/parsanol-wasm/BUILT_FROM +1 -1
- package/vendor/parsanol-wasm/BUILT_FROM.json +29 -0
- package/vendor/parsanol-wasm/LICENSE +21 -0
- package/vendor/parsanol-wasm/parsanol.cjs +37 -0
- package/vendor/parsanol-wasm/parsanol.d.ts +6 -0
- package/vendor/parsanol-wasm/parsanol_bg.wasm +0 -0
- package/vendor/parsanol-wasm/parsanol_bg.wasm.d.ts +17 -15
- package/vendor/parsanol-web/BUILT_FROM.json +24 -0
- package/vendor/parsanol-web/LICENSE +21 -0
- package/vendor/parsanol-web/README.md +36 -0
- package/vendor/parsanol-web/parsanol.d.ts +251 -0
- package/vendor/parsanol-web/parsanol.js +803 -0
- package/vendor/parsanol-web/parsanol_bg.wasm +0 -0
- package/vendor/parsanol-web/parsanol_bg.wasm.d.ts +58 -0
package/dist/runtime.js
CHANGED
|
@@ -44,57 +44,12 @@ function wasm() {
|
|
|
44
44
|
}
|
|
45
45
|
return wasmModule;
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
export class PargRuntime {
|
|
52
|
-
artifact;
|
|
53
|
-
schema;
|
|
54
|
-
renderSpec;
|
|
55
|
-
entry;
|
|
56
|
-
defaultEntry;
|
|
57
|
-
/** parsanol-ts#5 provenance: SHA-256 of the .parg source text and the
|
|
58
|
-
* compiler version. Null for artifacts compiled before these fields
|
|
59
|
-
* existed (unverifiable, not stale). */
|
|
60
|
-
sourceHash;
|
|
61
|
-
compilerVersion;
|
|
62
|
-
source;
|
|
63
|
-
/** ruby#377 semantics fingerprint: stable across producer metadata
|
|
64
|
-
* (compiler_version, unicode_tables), so gates can tell "re-baked by
|
|
65
|
-
* a newer compiler" from "the grammar changed". Null for artifacts
|
|
66
|
-
* baked before the field existed (parsanol >= 1.3.117 / rs 0.19.14). */
|
|
67
|
-
semanticsHash;
|
|
68
|
-
envelope;
|
|
47
|
+
import { PargRuntimeCore } from "./runtime-core.js";
|
|
48
|
+
export { deriveTemplate, renderSegments, materializeFromSchema, RecursionLimitExceeded, CallDepthLimitExceeded, ShapeDepthLimitExceeded } from "./runtime-core.js";
|
|
49
|
+
/** Node entry: preserves synchronous WASM initialization and filesystem helpers. */
|
|
50
|
+
export class PargRuntime extends PargRuntimeCore {
|
|
69
51
|
constructor(artifactJson, entry) {
|
|
70
|
-
|
|
71
|
-
this.envelope = parsed;
|
|
72
|
-
// Dynamic artifacts (parsanol-ruby#129 runtime state / custom atoms)
|
|
73
|
-
// carry Ruby closures; their grammars deserialize portably but parse
|
|
74
|
-
// only on a Ruby runtime. Fail here, at the boundary, with the
|
|
75
|
-
// routing answer instead of a wasm deserialization error deep in the
|
|
76
|
-
// atom tree.
|
|
77
|
-
if (parsed["dynamic"] === true) {
|
|
78
|
-
throw new Error("this artifact uses PARG runtime state or custom atoms and parses " +
|
|
79
|
-
"only on a Ruby runtime (parsanol-ruby#129)");
|
|
80
|
-
}
|
|
81
|
-
this.artifact = new (wasm().PargArtifactJs)(artifactJson);
|
|
82
|
-
this.schema = JSON.parse(this.artifact.schema());
|
|
83
|
-
this.renderSpec =
|
|
84
|
-
parsed["render"] ?? {};
|
|
85
|
-
// The compiler bakes default_entry: JSON key order is not preserved
|
|
86
|
-
// across engines, so the sorted entry list cannot rederive it.
|
|
87
|
-
this.defaultEntry = parsed["default_entry"] ?? null;
|
|
88
|
-
this.sourceHash = parsed["source_hash"] ?? null;
|
|
89
|
-
this.compilerVersion = parsed["compiler_version"] ?? null;
|
|
90
|
-
this.source = parsed["source"] ?? null;
|
|
91
|
-
this.semanticsHash = parsed["semantics_hash"] ?? null;
|
|
92
|
-
this.entry = entry ?? this.defaultEntry ?? this.artifact.entryNames()[0];
|
|
93
|
-
}
|
|
94
|
-
/** The wire-format family ("parsanol-tree/v2"): a shape bump requires a
|
|
95
|
-
* new engine family; same-shape artifacts parse identically forever. */
|
|
96
|
-
get shape() {
|
|
97
|
-
return this.envelope["shape"] ?? null;
|
|
52
|
+
super(artifactJson, entry, wasm);
|
|
98
53
|
}
|
|
99
54
|
/** True when this artifact was compiled from `source` (the current .parg
|
|
100
55
|
* revision). The compiler bakes a bare hex digest; artifacts without the
|
|
@@ -120,130 +75,4 @@ export class PargRuntime {
|
|
|
120
75
|
}
|
|
121
76
|
return PargRuntime.fromFile(join(base, `${grammar}.json`), entry);
|
|
122
77
|
}
|
|
123
|
-
/** Parse with the native wasm engine; returns the parsanol-shape tree. */
|
|
124
|
-
parseShape(input) {
|
|
125
|
-
return JSON.parse(this.artifact.parseShape(this.entry, input));
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* Best-effort recovery (TODO.sota/1): never throws. Success returns
|
|
129
|
-
* `{ ok: true, shape }`; failure returns
|
|
130
|
-
* `{ ok: false, captures, error, consumed_upto }` — the captures
|
|
131
|
-
* observed before the failure plus the failure wire.
|
|
132
|
-
*/
|
|
133
|
-
parseShapeRecovering(input) {
|
|
134
|
-
return JSON.parse(this.artifact.parseShapeRecovering(this.entry, input));
|
|
135
|
-
}
|
|
136
|
-
/** Apply the entry's bindings to a parsanol-shape tree. */
|
|
137
|
-
applyBindings(shape) {
|
|
138
|
-
return JSON.parse(this.artifact.applyBindings(this.entry, JSON.stringify(shape)));
|
|
139
|
-
}
|
|
140
|
-
/** Apply an entry's DECLARED bindings artifact (parsanol-ruby#432) to
|
|
141
|
-
* a parsanol-shape tree. The engine verifies the artifact (kind,
|
|
142
|
-
* canonical-JSON checksum, `ts` target pin, binding version) and
|
|
143
|
-
* pair-checks it against this artifact by grammar source hash before
|
|
144
|
-
* the shared apply core runs — the JSON materialized is the JSON the
|
|
145
|
-
* checksum pinned. */
|
|
146
|
-
applyBindingsArtifact(bindingsJson, shape) {
|
|
147
|
-
return JSON.parse(this.artifact.applyBindingsArtifact(bindingsJson, this.entry, JSON.stringify(shape)));
|
|
148
|
-
}
|
|
149
|
-
/** Parse and bind in one step. */
|
|
150
|
-
parseAndBind(input) {
|
|
151
|
-
try {
|
|
152
|
-
return JSON.parse(this.artifact.parseAndBind(this.entry, input));
|
|
153
|
-
}
|
|
154
|
-
catch {
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Schema-driven materialization: the schema (from the artifact, not
|
|
160
|
-
* hand-written model code) declares the fields a data model must
|
|
161
|
-
* implement; the bound captures populate a structurally-typed object.
|
|
162
|
-
* Card `1*`/`*` fields become arrays; `0..1` fields become nullable.
|
|
163
|
-
*/
|
|
164
|
-
materialize(input) {
|
|
165
|
-
const bound = this.parseAndBind(input);
|
|
166
|
-
if (bound === null)
|
|
167
|
-
return null;
|
|
168
|
-
const schema = this.schema[this.entry];
|
|
169
|
-
if (!schema)
|
|
170
|
-
throw new Error(`artifact has no schema for entry ${this.entry}`);
|
|
171
|
-
return materializeFromSchema(schema, bound);
|
|
172
|
-
}
|
|
173
|
-
/** Render the identifier string from a bound map (F6). */
|
|
174
|
-
render(bound, variant = "default") {
|
|
175
|
-
return renderSegments((this.renderSpec[variant] ?? null), bound);
|
|
176
|
-
}
|
|
177
|
-
/** Parse, bind, and render in one step. */
|
|
178
|
-
renderString(input, variant = "default") {
|
|
179
|
-
const bound = this.parseAndBind(input);
|
|
180
|
-
return bound === null ? null : this.render(bound, variant);
|
|
181
|
-
}
|
|
182
|
-
/** Evaluate a named derive spec against a bound map (F6). */
|
|
183
|
-
derive(name, bound) {
|
|
184
|
-
return deriveTemplate((this.envelope["derive"] ?? {}), name, bound);
|
|
185
|
-
}
|
|
186
|
-
/** Parse, bind, and evaluate a derive spec in one step. */
|
|
187
|
-
deriveString(input, name) {
|
|
188
|
-
const bound = this.parseAndBind(input);
|
|
189
|
-
return bound === null ? null : this.derive(name, bound);
|
|
190
|
-
}
|
|
191
|
-
/** Run the artifact's embedded tests; empty list means green. */
|
|
192
|
-
runTests() {
|
|
193
|
-
return JSON.parse(this.artifact.runTests());
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
/** F6 v1 derive evaluator: {field} interpolates from the bound map. */
|
|
197
|
-
export function deriveTemplate(derive, name, bound) {
|
|
198
|
-
const template = derive[name];
|
|
199
|
-
if (template === undefined)
|
|
200
|
-
throw new Error(`derive spec ${name} not declared`);
|
|
201
|
-
return template.replace(/\{(\w+)\}/g, (_, field) => {
|
|
202
|
-
const value = bound[field];
|
|
203
|
-
return value === undefined || value === null ? "" : String(value);
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
/** F6 v1 generic renderer: field / literal / cond-presence segments. */
|
|
207
|
-
export function renderSegments(segments, bound) {
|
|
208
|
-
let out = "";
|
|
209
|
-
for (const segment of segments ?? []) {
|
|
210
|
-
if (segment.type === "field") {
|
|
211
|
-
const value = bound[segment.field];
|
|
212
|
-
out += value === undefined || value === null ? "" : String(value);
|
|
213
|
-
}
|
|
214
|
-
else if (segment.type === "literal") {
|
|
215
|
-
out += segment.text;
|
|
216
|
-
}
|
|
217
|
-
else if (segment.type === "cond") {
|
|
218
|
-
const value = bound[segment.field];
|
|
219
|
-
if (value !== undefined && value !== null)
|
|
220
|
-
out += renderSegments(segment.then, bound);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
return out;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* Schema-driven materialization independent of any wasm handle —
|
|
227
|
-
* the same function the model layer will build on (T2 codegen emits the
|
|
228
|
-
* static view of exactly these fields).
|
|
229
|
-
*/
|
|
230
|
-
export function materializeFromSchema(schema, bound) {
|
|
231
|
-
const attributes = {};
|
|
232
|
-
for (const [path, requirements] of Object.entries(schema.fields)) {
|
|
233
|
-
const leaf = path.includes("[]")
|
|
234
|
-
? (path.split("].").pop() ?? path)
|
|
235
|
-
: path;
|
|
236
|
-
const value = bound[leaf];
|
|
237
|
-
if (requirements.card.endsWith("*")) {
|
|
238
|
-
const list = Array.isArray(value) ? value : value === undefined ? [] : [value];
|
|
239
|
-
attributes[leaf] = list;
|
|
240
|
-
}
|
|
241
|
-
else if (requirements.card === "0..1") {
|
|
242
|
-
attributes[leaf] = value === undefined ? null : value;
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
attributes[leaf] = value;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
return { entry: schema.root, attributes };
|
|
249
78
|
}
|
package/package.json
CHANGED
|
@@ -1,24 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "parsanol",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.45",
|
|
4
4
|
"description": "PARG artifact runtime for TypeScript — checksum-verified artifact load, wasm parse, bindings, schema-driven materialization",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/runtime.js",
|
|
7
7
|
"types": "dist/runtime.d.ts",
|
|
8
8
|
"exports": {
|
|
9
|
-
".":
|
|
10
|
-
|
|
9
|
+
".": {
|
|
10
|
+
"browser": {
|
|
11
|
+
"types": "./dist/browser.d.ts",
|
|
12
|
+
"default": "./dist/browser.js"
|
|
13
|
+
},
|
|
14
|
+
"types": "./dist/runtime.d.ts",
|
|
15
|
+
"default": "./dist/runtime.js"
|
|
16
|
+
},
|
|
17
|
+
"./suite": "./dist/suite.js",
|
|
18
|
+
"./browser": {
|
|
19
|
+
"types": "./dist/browser.d.ts",
|
|
20
|
+
"default": "./dist/browser.js"
|
|
21
|
+
}
|
|
11
22
|
},
|
|
12
23
|
"files": [
|
|
13
24
|
"dist/",
|
|
14
|
-
"vendor/parsanol-wasm/"
|
|
25
|
+
"vendor/parsanol-wasm/",
|
|
26
|
+
"vendor/parsanol-web/"
|
|
15
27
|
],
|
|
16
28
|
"scripts": {
|
|
17
29
|
"build": "tsc -p tsconfig.json",
|
|
18
30
|
"test": "npm run build && npx tsc -p tsconfig.test.json && node --test dist-test/test/*.test.js",
|
|
19
31
|
"refresh-wasm": "bash scripts/refresh-wasm.sh",
|
|
20
32
|
"prepublishOnly": "npm run build",
|
|
21
|
-
"bench": "node bench/bench.mjs"
|
|
33
|
+
"bench": "node bench/bench.mjs",
|
|
34
|
+
"test:browser": "npm run build && python3 scripts/test-browser.py",
|
|
35
|
+
"refresh-web-wasm": "python3 scripts/refresh-web-wasm.py",
|
|
36
|
+
"refresh-wasm-candidate": "python3 scripts/build-wasm-candidate.py",
|
|
37
|
+
"prepare": "npm run build"
|
|
22
38
|
},
|
|
23
39
|
"engines": {
|
|
24
40
|
"node": ">=22"
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
c780fe98c15ab73696d42641d1a7ca5db6df3c27
|
|
2
2
|
built with: wasm-pack build --target=nodejs --features wasm (from parsanol-rs/parsanol)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"repository": "https://github.com/parsanol/parsanol-rs",
|
|
3
|
+
"upstream_base": "74d6aa27987db8d3ffa38eb38a7e89c0d1b28da2",
|
|
4
|
+
"source_commit": "c780fe98c15ab73696d42641d1a7ca5db6df3c27",
|
|
5
|
+
"built_source_commit": "c780fe98c15ab73696d42641d1a7ca5db6df3c27",
|
|
6
|
+
"source_tree": "d788f65b16879df853bc23b872d641a920b93328",
|
|
7
|
+
"built_source_tree_equal": true,
|
|
8
|
+
"crate_version": "0.20.13",
|
|
9
|
+
"unreleased_candidate": false,
|
|
10
|
+
"target": "nodejs",
|
|
11
|
+
"profile": "release",
|
|
12
|
+
"rust": "1.98.0",
|
|
13
|
+
"wasm_bindgen": "0.2.130",
|
|
14
|
+
"wasm_stack_bytes": 8388608,
|
|
15
|
+
"resource_limits": {
|
|
16
|
+
"rule_reference_recursion": 1000,
|
|
17
|
+
"wasm_vm_atom_calls": 1024
|
|
18
|
+
},
|
|
19
|
+
"lockfile": "scripts/wasm-build/Cargo.lock",
|
|
20
|
+
"lockfile_sha256": "4faf8a884579e1a9901a53ef6678f2f20658282def2e335c3f250861d2b01e7c",
|
|
21
|
+
"files": {
|
|
22
|
+
"parsanol_bg.wasm": "fe0bb759f7dcc0278c534a96d67dfd57eae70a9f5331eb8e9a617b767e813d9a",
|
|
23
|
+
"parsanol.d.ts": "080f641f566eade5118d0583bad85ad8b8fe428c1e92fe49b41fc115fd0940e2",
|
|
24
|
+
"LICENSE": "47f4778bc0bfbeb3614d173dd1ec09ddd8cab994039193e2d3de2edcd7886c7e",
|
|
25
|
+
"parsanol.cjs": "7f76854b4fae589e870f70480b226fbbf11ab3389de84f33af64890740cad02f",
|
|
26
|
+
"parsanol_bg.wasm.d.ts": "ac620c8e3f325ba0e2ca1206887e5918711f8bbb19dd3b79458703ec8d6b36b1"
|
|
27
|
+
},
|
|
28
|
+
"shape_json_max_depth": 512
|
|
29
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Ribose Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -150,6 +150,36 @@ class PargArtifactJs {
|
|
|
150
150
|
}
|
|
151
151
|
return takeFromExternrefTable0(ret[0]);
|
|
152
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Explicit compatibility without changing parseShape defaults.
|
|
155
|
+
* The JSON envelope contains either shape or causal error diagnostics;
|
|
156
|
+
* it does not claim best-effort recovery captures.
|
|
157
|
+
* @param {string} entry
|
|
158
|
+
* @param {string} input
|
|
159
|
+
* @param {string} compatibility
|
|
160
|
+
* @returns {string}
|
|
161
|
+
*/
|
|
162
|
+
parseShapeWithCompatibility(entry, input, compatibility) {
|
|
163
|
+
let ptr0, len0, ptr1, len1, ptr2, len2;
|
|
164
|
+
try {
|
|
165
|
+
ptr0 = passStringToWasm0(entry, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
166
|
+
len0 = WASM_VECTOR_LEN;
|
|
167
|
+
ptr1 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
168
|
+
len1 = WASM_VECTOR_LEN;
|
|
169
|
+
ptr2 = passStringToWasm0(compatibility, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
170
|
+
len2 = WASM_VECTOR_LEN;
|
|
171
|
+
} catch (e) {
|
|
172
|
+
if (ptr2) { wasm.__wbindgen_free(ptr2, len2 * 1, 1); }
|
|
173
|
+
if (ptr1) { wasm.__wbindgen_free(ptr1, len1 * 1, 1); }
|
|
174
|
+
if (ptr0) { wasm.__wbindgen_free(ptr0, len0 * 1, 1); }
|
|
175
|
+
throw e;
|
|
176
|
+
}
|
|
177
|
+
const ret = wasm.pargartifactjs_parseShapeWithCompatibility(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
178
|
+
if (ret[2]) {
|
|
179
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
180
|
+
}
|
|
181
|
+
return takeFromExternrefTable0(ret[0]);
|
|
182
|
+
}
|
|
153
183
|
/**
|
|
154
184
|
* Parse an entry with the native engine; returns the parsanol-shape
|
|
155
185
|
* tree as JSON text.
|
|
@@ -462,6 +492,10 @@ function __wbg_get_imports() {
|
|
|
462
492
|
const ret = new Array();
|
|
463
493
|
return ret;
|
|
464
494
|
},
|
|
495
|
+
__wbg_new_787b9fb330d55d78: function(arg0, arg1) {
|
|
496
|
+
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
497
|
+
return ret;
|
|
498
|
+
},
|
|
465
499
|
__wbg_new_bb74001155cb8ca8: function() {
|
|
466
500
|
const ret = new Error();
|
|
467
501
|
return ret;
|
|
@@ -478,6 +512,9 @@ function __wbg_get_imports() {
|
|
|
478
512
|
const ret = Reflect.set(arg0, arg1, arg2);
|
|
479
513
|
return ret;
|
|
480
514
|
}, arguments); },
|
|
515
|
+
__wbg_set_name_822e3903f3184979: function(arg0, arg1, arg2) {
|
|
516
|
+
arg0.name = getStringFromWasm0(arg1, arg2);
|
|
517
|
+
},
|
|
481
518
|
__wbg_stack_575c4e0918581b9c: function(arg0, arg1) {
|
|
482
519
|
const ret = arg1.stack;
|
|
483
520
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -42,6 +42,12 @@ export class PargArtifactJs {
|
|
|
42
42
|
* `{"ok": false, "captures": ..., "error": ..., "consumed_upto"}`.
|
|
43
43
|
*/
|
|
44
44
|
parseShapeRecovering(entry: string, input: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Explicit compatibility without changing parseShape defaults.
|
|
47
|
+
* The JSON envelope contains either shape or causal error diagnostics;
|
|
48
|
+
* it does not claim best-effort recovery captures.
|
|
49
|
+
*/
|
|
50
|
+
parseShapeWithCompatibility(entry: string, input: string, compatibility: string): string;
|
|
45
51
|
/**
|
|
46
52
|
* Parse an entry with the native engine; returns the parsanol-shape
|
|
47
53
|
* tree as JSON text.
|
|
Binary file
|
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const __wbg_pargartifactjs_free: (a: number, b: number) => void;
|
|
5
|
-
export const __wbg_wasmparser_free: (a: number, b: number) => void;
|
|
6
|
-
export const compileSource: (a: number, b: number) => [number, number, number, number];
|
|
7
|
-
export const pargartifactjs_applyBindings: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
8
|
-
export const pargartifactjs_applyBindingsArtifact: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
9
|
-
export const pargartifactjs_entryNames: (a: number) => [number, number];
|
|
10
|
-
export const pargartifactjs_new: (a: number, b: number) => [number, number, number];
|
|
11
|
-
export const pargartifactjs_parseAndBind: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
12
|
-
export const pargartifactjs_parseShape: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
13
|
-
export const pargartifactjs_parseShapeRecovering: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
14
|
-
export const pargartifactjs_runTests: (a: number) => [number, number, number];
|
|
15
|
-
export const pargartifactjs_schema: (a: number) => [number, number, number];
|
|
16
|
-
export const pargartifactjs_schemaTypescript: (a: number) => [number, number, number];
|
|
17
|
-
export const pargartifactjs_semanticsHash: (a: number) => any;
|
|
18
4
|
export const parsanol_c_last_error: () => number;
|
|
19
5
|
export const parsanol_c_parse: (a: bigint, b: number, c: number, d: number) => number;
|
|
20
6
|
export const parsanol_c_parse_len: (a: bigint, b: number, c: number, d: number, e: number) => number;
|
|
@@ -29,6 +15,7 @@ export const parsanol_parg_error: (a: number, b: number) => number;
|
|
|
29
15
|
export const parsanol_parg_free: (a: number) => void;
|
|
30
16
|
export const parsanol_parg_parse: (a: number, b: number) => number;
|
|
31
17
|
export const parsanol_parg_parse_recovering: (a: number, b: number, c: number) => number;
|
|
18
|
+
export const parsanol_parg_parse_with_compatibility: (a: number, b: number, c: number, d: number) => number;
|
|
32
19
|
export const parsanol_parse: (a: number, b: number, c: number) => number;
|
|
33
20
|
export const parsanol_parse_end_pos: (a: number, b: number) => number;
|
|
34
21
|
export const parsanol_parse_simple: (a: number, b: number) => number;
|
|
@@ -38,13 +25,28 @@ export const parsanol_result_error: (a: number) => number;
|
|
|
38
25
|
export const parsanol_result_free: (a: number) => void;
|
|
39
26
|
export const parsanol_result_success: (a: number) => number;
|
|
40
27
|
export const parsanol_version: () => number;
|
|
28
|
+
export const parsanol_string_free: (a: number) => void;
|
|
29
|
+
export const __wbg_pargartifactjs_free: (a: number, b: number) => void;
|
|
30
|
+
export const __wbg_wasmparser_free: (a: number, b: number) => void;
|
|
31
|
+
export const compileSource: (a: number, b: number) => [number, number, number, number];
|
|
32
|
+
export const pargartifactjs_applyBindings: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
33
|
+
export const pargartifactjs_applyBindingsArtifact: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
34
|
+
export const pargartifactjs_entryNames: (a: number) => [number, number];
|
|
35
|
+
export const pargartifactjs_new: (a: number, b: number) => [number, number, number];
|
|
36
|
+
export const pargartifactjs_parseAndBind: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
37
|
+
export const pargartifactjs_parseShape: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
38
|
+
export const pargartifactjs_parseShapeRecovering: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
|
|
39
|
+
export const pargartifactjs_parseShapeWithCompatibility: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
40
|
+
export const pargartifactjs_runTests: (a: number) => [number, number, number];
|
|
41
|
+
export const pargartifactjs_schema: (a: number) => [number, number, number];
|
|
42
|
+
export const pargartifactjs_schemaTypescript: (a: number) => [number, number, number];
|
|
43
|
+
export const pargartifactjs_semanticsHash: (a: number) => any;
|
|
41
44
|
export const setPanicHook: () => void;
|
|
42
45
|
export const wasmparser_fromArtifact: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
43
46
|
export const wasmparser_new: (a: number, b: number) => [number, number, number];
|
|
44
47
|
export const wasmparser_parse: (a: number, b: number, c: number) => [number, number, number];
|
|
45
48
|
export const wasmparser_parse_flat: (a: number, b: number, c: number) => [number, number, number, number];
|
|
46
49
|
export const wasmparser_parse_json: (a: number, b: number, c: number) => [number, number, number, number];
|
|
47
|
-
export const parsanol_string_free: (a: number) => void;
|
|
48
50
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
49
51
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
50
52
|
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"target": "web",
|
|
3
|
+
"repository": "https://github.com/parsanol/parsanol-rs",
|
|
4
|
+
"tarball_sha256": "1be9dbad6c46af7002f8d0da8d3d73983b05d5b1789ca7ea9b8123f1bedf04f2",
|
|
5
|
+
"files": {
|
|
6
|
+
"parsanol_bg.wasm": "fe0bb759f7dcc0278c534a96d67dfd57eae70a9f5331eb8e9a617b767e813d9a",
|
|
7
|
+
"parsanol.d.ts": "26d9e1c0146687b14e7178e41af3e97e6178857c0d784ebb1034a3dd4e72ac58",
|
|
8
|
+
"LICENSE": "47f4778bc0bfbeb3614d173dd1ec09ddd8cab994039193e2d3de2edcd7886c7e",
|
|
9
|
+
"parsanol.js": "5a2c63258b262951933f6ba5cd31cf66b99fcdb48ab1db2e150ef6872f159ba7",
|
|
10
|
+
"parsanol_bg.wasm.d.ts": "ac620c8e3f325ba0e2ca1206887e5918711f8bbb19dd3b79458703ec8d6b36b1",
|
|
11
|
+
"README.md": "a5baa46b19a57b5414bf87484585b4f2916c940a4ae4f0844ba4d6bc85d32fc9"
|
|
12
|
+
},
|
|
13
|
+
"source_commit": "c780fe98c15ab73696d42641d1a7ca5db6df3c27",
|
|
14
|
+
"crate_version": "0.20.13",
|
|
15
|
+
"unreleased_candidate": false,
|
|
16
|
+
"profile": "release",
|
|
17
|
+
"built_source_commit": "c780fe98c15ab73696d42641d1a7ca5db6df3c27",
|
|
18
|
+
"built_source_tree_equal": true,
|
|
19
|
+
"lockfile_sha256": "4faf8a884579e1a9901a53ef6678f2f20658282def2e335c3f250861d2b01e7c",
|
|
20
|
+
"rust": "1.98.0",
|
|
21
|
+
"wasm_bindgen": "0.2.130",
|
|
22
|
+
"wasm_stack_bytes": 8388608,
|
|
23
|
+
"lockfile": "scripts/wasm-build/Cargo.lock"
|
|
24
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Ribose Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# @parsanol/wasm
|
|
2
|
+
|
|
3
|
+
Parsanol PEG parser — WebAssembly bindings (checksummed
|
|
4
|
+
parsanol-tree/v2 artifacts; parse, shape, recovery, bindings,
|
|
5
|
+
schema types).
|
|
6
|
+
|
|
7
|
+
## Browser
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import init, { PargArtifactJs } from "@parsanol/wasm";
|
|
11
|
+
await init(); // fetches parsanol_bg.wasm next to the module
|
|
12
|
+
const parg = new PargArtifactJs(artifactJson);
|
|
13
|
+
const bound = parg.parseAndBind("identifier", "iso 12345");
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Node
|
|
17
|
+
|
|
18
|
+
The default init fetches relative to the module, which Node's fetch
|
|
19
|
+
does not serve; read the bytes and hand them to `initSync` (plain
|
|
20
|
+
`initSync(bytes)` works but warns as deprecated):
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import { initSync, PargArtifactJs } from "@parsanol/wasm";
|
|
24
|
+
import { readFileSync } from "node:fs";
|
|
25
|
+
|
|
26
|
+
initSync({ module: readFileSync("node_modules/@parsanol/wasm/parsanol_bg.wasm") });
|
|
27
|
+
const parg = new PargArtifactJs(artifactJson);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Notes
|
|
31
|
+
|
|
32
|
+
- `parseAndBind` returns `{}` when the entry declares no
|
|
33
|
+
`bindings` block — the parse succeeded, nothing was bound.
|
|
34
|
+
- The async bootstrap is the package DEFAULT export
|
|
35
|
+
(`__wbg_init(module_or_path?)`); `setPanicHook` installs the panic
|
|
36
|
+
hook directly and is called by the bootstrap.
|