galley-js-wasm 0.0.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 ADDED
@@ -0,0 +1,8 @@
1
+ # JavaScript Bindings for WebAssembly
2
+
3
+ `galley-js-core` over a WASI reactor module and `bindings/c/galley.h`. No
4
+ native dependencies beyond the built parser module.
5
+
6
+ See `docs/bindings_js_wasm.md` and `examples/js/wasm` for the consumer flow.
7
+
8
+ One module embeds one parser; sessions are not thread-safe.
package/build.mjs ADDED
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Builds a Galley parser and its WebAssembly module for a JavaScript consumer.
4
+ *
5
+ * Usage:
6
+ * npx galley-js-wasm <language-dir>
7
+ *
8
+ * Thin wrapper over the shared gate (`galley-js-core/build/builder.mjs`),
9
+ * which documents the accepted grammar files and owns the build. For both
10
+ * legs at once, use the single entry instead: `galley build <language-dir>`
11
+ * from `@sanbus-org/galley`.
12
+ */
13
+
14
+ import * as path from "node:path";
15
+ import { fileURLToPath } from "node:url";
16
+ import { buildParserArtifact } from "galley-js-core/build/builder.mjs";
17
+
18
+ const LIBRARY_NAME = "galley-js-wasm";
19
+
20
+ function fatal(message) {
21
+ console.error(`galley-bindings: ${message}`);
22
+ process.exit(1);
23
+ }
24
+
25
+ async function main() {
26
+ if (process.argv.length !== 3) fatal("usage: npx galley-js-wasm <language-dir>");
27
+ await buildParserArtifact({
28
+ languageDirectory: process.argv[2],
29
+ libraryName: LIBRARY_NAME,
30
+ wasm: true,
31
+ posixOnly: false,
32
+ bindingsDirectory: path.dirname(fileURLToPath(import.meta.url)),
33
+ dependencyName: "galley-js-core",
34
+ });
35
+ }
36
+
37
+ main().catch((error) => fatal(error?.message ?? String(error)));
@@ -0,0 +1,12 @@
1
+ /**
2
+ * WebAssembly procedure-dispatch setup.
3
+ *
4
+ * Unlike the native adapters there is nothing to install: the wasm module
5
+ * unconditionally imports `env.galley_js_dispatch_id`, which forwards every
6
+ * parser hook ID to the core registry (unregistered names are no-ops there,
7
+ * matching native semantics). This module only owns the `require()`-based
8
+ * auto-scan of `procedures.*` in the language directory, mirroring the Node
9
+ * adapter. Outside Node (browsers) the scan is skipped — register hooks
10
+ * explicitly with `installProcedures` from `galley-js-core`.
11
+ */
12
+ export declare function ensureDispatch(wasmPath?: string): void;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * WebAssembly procedure-dispatch setup.
3
+ *
4
+ * Unlike the native adapters there is nothing to install: the wasm module
5
+ * unconditionally imports `env.galley_js_dispatch_id`, which forwards every
6
+ * parser hook ID to the core registry (unregistered names are no-ops there,
7
+ * matching native semantics). This module only owns the `require()`-based
8
+ * auto-scan of `procedures.*` in the language directory, mirroring the Node
9
+ * adapter. Outside Node (browsers) the scan is skipped — register hooks
10
+ * explicitly with `installProcedures` from `galley-js-core`.
11
+ */
12
+ import { createRequire } from "node:module";
13
+ import * as path from "node:path";
14
+ import { installProcedures, listProcedures } from "galley-js-core";
15
+ let autoAttempted = false;
16
+ function isProcedureName(name) {
17
+ return name === "reduction" || name.startsWith("reduction_") || name.startsWith("hook_");
18
+ }
19
+ function isNode() {
20
+ return (typeof process !== "undefined" &&
21
+ typeof process.versions?.node === "string");
22
+ }
23
+ export function ensureDispatch(wasmPath) {
24
+ if (listProcedures().length > 0 || autoAttempted)
25
+ return;
26
+ autoAttempted = true;
27
+ if (!isNode())
28
+ return;
29
+ const require = createRequire(import.meta.url);
30
+ const tryLoadModule = (modulePath) => {
31
+ try {
32
+ const loadedModule = require(modulePath);
33
+ let hasHook = false;
34
+ for (const [name, value] of Object.entries(loadedModule)) {
35
+ if (typeof value !== "function" || !isProcedureName(name))
36
+ continue;
37
+ hasHook = true;
38
+ break;
39
+ }
40
+ if (hasHook)
41
+ return installProcedures(loadedModule) > 0;
42
+ const defaultExport = loadedModule.default;
43
+ if (defaultExport && typeof defaultExport === "object") {
44
+ return installProcedures(defaultExport) > 0;
45
+ }
46
+ }
47
+ catch { }
48
+ return false;
49
+ };
50
+ // One place: the directory holding the loaded module. Anything found
51
+ // there belongs to this grammar; nothing else is even looked at.
52
+ // Byte-fed modules ("<bytes>") have no directory: nothing to scan.
53
+ if (!wasmPath || wasmPath === "<bytes>")
54
+ return;
55
+ const baseDirectory = path.dirname(path.resolve(wasmPath));
56
+ const extensions = ["", ".js", ".ts"];
57
+ for (const extension of extensions) {
58
+ if (tryLoadModule(path.join(baseDirectory, `procedures${extension}`)))
59
+ return;
60
+ }
61
+ }
62
+ //# sourceMappingURL=dispatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEnE,IAAI,aAAa,GAAG,KAAK,CAAC;AAE1B,SAAS,eAAe,CAAC,IAAY;IACnC,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;AAC3F,CAAC;AAED,SAAS,MAAM;IACb,OAAO,CACL,OAAO,OAAO,KAAK,WAAW;QAC9B,OAAQ,OAAuD,CAAC,QAAQ,EAAE,IAAI,KAAK,QAAQ,CAC5F,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,QAAiB;IAC9C,IAAI,cAAc,EAAE,CAAC,MAAM,GAAG,CAAC,IAAI,aAAa;QAAE,OAAO;IACzD,aAAa,GAAG,IAAI,CAAC;IACrB,IAAI,CAAC,MAAM,EAAE;QAAE,OAAO;IACtB,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/C,MAAM,aAAa,GAAG,CAAC,UAAkB,EAAW,EAAE;QACpD,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,OAAO,CAAC,UAAU,CAA4B,CAAC;YACpE,IAAI,OAAO,GAAG,KAAK,CAAC;YACpB,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC;gBACzD,IAAI,OAAO,KAAK,KAAK,UAAU,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;oBAAE,SAAS;gBACpE,OAAO,GAAG,IAAI,CAAC;gBACf,MAAM;YACR,CAAC;YACD,IAAI,OAAO;gBAAE,OAAO,iBAAiB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YACxD,MAAM,aAAa,GAAI,YAAwC,CAAC,OAEnD,CAAC;YACd,IAAI,aAAa,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;gBACvD,OAAO,iBAAiB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YAC9C,CAAC;QACH,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QACV,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;IAEF,qEAAqE;IACrE,iEAAiE;IACjE,mEAAmE;IACnE,IAAI,CAAC,QAAQ,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO;IAChD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3D,MAAM,UAAU,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACtC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,aAAa,SAAS,EAAE,CAAC,CAAC;YAAE,OAAO;IAChF,CAAC;AACH,CAAC"}
package/dist/ffi.d.ts ADDED
@@ -0,0 +1,303 @@
1
+ /**
2
+ * WebAssembly adapter for the Galley JavaScript bindings: a `WasmPort`
3
+ * implementing the core `FfiPort` over a WASI reactor module built from
4
+ * `bindings/c/galley.h` (`zig build -Dwasm`, see `build.mjs`).
5
+ *
6
+ * Zero npm dependencies. The module is instantiated with a minimal
7
+ * in-TS `wasi_snapshot_preview1` stub (real `random_get`/`clock_time_get`,
8
+ * filesystem calls report unavailable — the parse path never touches the
9
+ * filesystem) plus an `env.galley_js_dispatch_id` import that forwards
10
+ * procedure-hook IDs to the core registry. All memory copying and integer
11
+ * normalization live here; all session logic lives in `galley-js-core`.
12
+ *
13
+ * Initialization is async (`await init()`), except under Node where the
14
+ * file can be read and instantiated synchronously — `Session` and the
15
+ * module-level queries auto-initialize there, so Node demos stay
16
+ * synchronous. Elsewhere (browsers) the gate throws `NeedInitError` until
17
+ * `await init()` completes. Views into wasm memory are never cached:
18
+ * `malloc` may grow memory and detach old views.
19
+ */
20
+ import type { FfiPort, Handle, SessionCOptions, TreeSnapshot, WalkedStep } from "galley-js-core";
21
+ export declare class NeedInitError extends Error {
22
+ constructor(libraryPath?: string);
23
+ }
24
+ /** Callable view of the wasm exports (wasm32: pointers/i32 are `number`, i64/u64 are `bigint`). */
25
+ interface GalleyWasmExports {
26
+ memory: WebAssembly.Memory;
27
+ _initialize?: unknown;
28
+ galley_js_malloc(len: number): number;
29
+ galley_js_free(ptr: number, len: number): void;
30
+ galley_version(): number;
31
+ galley_parser_type(): bigint;
32
+ galley_error_recovery_mode(): bigint;
33
+ galley_has_ast(): number;
34
+ galley_has_procedures(): number;
35
+ galley_allows_no_ast_tree_procedures(): number;
36
+ galley_source_retention_enabled(): number;
37
+ galley_has_position_tracking(): number;
38
+ galley_has_input_streaming(): number;
39
+ galley_uses_verbatim(): number;
40
+ galley_stack_overflow_recovery_available(): number;
41
+ galley_symbol_count(): bigint;
42
+ galley_variable_count(): bigint;
43
+ galley_status_string(status: bigint): number;
44
+ galley_symbol_name(session: number, index: bigint, outData: number, outLen: number): bigint;
45
+ galley_symbol_is_terminal(session: number, index: bigint): number;
46
+ galley_variable_name(session: number, index: bigint, outData: number, outLen: number): bigint;
47
+ galley_session_create(): number;
48
+ galley_session_create_ex(options: number): number;
49
+ galley_session_destroy(session: number): void;
50
+ galley_session_set_message_override(session: number, name: number, nameLen: number, message: number, messageLen: number): bigint;
51
+ galley_parse(session: number, data: number, len: number): bigint;
52
+ galley_node_count(session: number): bigint;
53
+ galley_reserve_nodes(session: number, capacity: bigint): bigint;
54
+ galley_node_capacity(session: number): bigint;
55
+ galley_root_node(session: number): bigint;
56
+ galley_node_is_valid(session: number, node: bigint): number;
57
+ galley_node_child_count(session: number, node: bigint): number;
58
+ galley_node_first_child(session: number, node: bigint): bigint;
59
+ galley_node_last_child(session: number, node: bigint): bigint;
60
+ galley_node_next_sibling(session: number, node: bigint): bigint;
61
+ galley_node_prior_sibling(session: number, node: bigint): bigint;
62
+ galley_node_parent(session: number, node: bigint): bigint;
63
+ galley_tree_snapshot(session: number, outParent: number, outFirstChild: number, outNext: number, outChildCount: number, outVariable: number, outSpanStart: number, outSpanLen: number, capacity: bigint): bigint;
64
+ galley_walker_create(session: number, node: bigint, skipSemanticErrors: number): number;
65
+ galley_walker_next(walker: number, outNode: number, outDepth: number, outFlag: number): number;
66
+ galley_walker_skip_children(walker: number): void;
67
+ galley_walker_destroy(walker: number): void;
68
+ galley_node_symbol_name(session: number, node: bigint, outData: number, outLen: number): bigint;
69
+ galley_node_text(session: number, node: bigint, outData: number, outLen: number): bigint;
70
+ galley_node_span(session: number, node: bigint, outStart: number, outLen: number): bigint;
71
+ galley_node_line_column(session: number, node: bigint, outLine: number, outCol: number): bigint;
72
+ galley_node_variable_index(session: number, node: bigint): bigint;
73
+ galley_last_position(session: number, outLine: number, outCol: number): bigint;
74
+ galley_has_diagnostic(session: number): number;
75
+ galley_diagnostic_kind(session: number): bigint;
76
+ galley_diagnostic_message(session: number, out: number): bigint;
77
+ galley_diagnostic_message_ansi(session: number, out: number): bigint;
78
+ galley_diagnostic_position(session: number, outLine: number, outCol: number): bigint;
79
+ galley_diagnostic_unexpected_token(session: number, outData: number, outLen: number): bigint;
80
+ galley_diagnostic_expected_count(session: number): bigint;
81
+ galley_diagnostic_expected_at(session: number, index: bigint, outData: number, outLen: number): bigint;
82
+ galley_diagnostic_context_count(session: number): bigint;
83
+ galley_diagnostic_context_at(session: number, index: bigint, outData: number, outLen: number): bigint;
84
+ galley_diagnostic_indentation(session: number, outSpaces: number, outWidth: number): bigint;
85
+ galley_syntax_error_count(session: number): bigint;
86
+ galley_semantic_error_count(session: number): bigint;
87
+ galley_diagnostic_semantic(session: number, outVariable: number, outVariableLen: number, outMessage: number, outMessageLen: number): bigint;
88
+ galley_diagnostic_recovery_kind(session: number): bigint;
89
+ galley_diagnostic_recovery_terminal(session: number, outData: number, outLen: number): bigint;
90
+ galley_diagnostic_recovery_resume(session: number, out: number): bigint;
91
+ galley_diagnostic_recovery_lhs_variable(session: number, outData: number, outLen: number): bigint;
92
+ galley_diagnostic_recovery_production(session: number, outVar: number, outLen: number, outIndex: number): bigint;
93
+ galley_diagnostic_recovery_occurrence(session: number, outParent: number, outParentLen: number, outRhs: number, outSym: number, outVar: number, outVarLen: number): bigint;
94
+ galley_recorded_diagnostic_count(session: number): bigint;
95
+ galley_recorded_diagnostic_kind(session: number, index: bigint): bigint;
96
+ galley_recorded_diagnostic_position(session: number, index: bigint, outLine: number, outCol: number): bigint;
97
+ galley_recorded_unexpected_token(session: number, index: bigint, outData: number, outLen: number): bigint;
98
+ galley_recorded_diagnostic_message(session: number, index: bigint, out: number): bigint;
99
+ galley_recorded_indentation(session: number, index: bigint, outSpaces: number, outWidth: number): bigint;
100
+ galley_recorded_semantic(session: number, index: bigint, outVariable: number, outVariableLen: number, outMessage: number, outMessageLen: number): bigint;
101
+ galley_recorded_expected_count(session: number, index: bigint): bigint;
102
+ galley_recorded_expected_token(session: number, index: bigint, tokenIndex: bigint, outData: number, outLen: number): bigint;
103
+ galley_recorded_context_count(session: number, index: bigint): bigint;
104
+ galley_recorded_context_name(session: number, index: bigint, contextIndex: bigint, outData: number, outLen: number): bigint;
105
+ galley_recorded_diagnostic_recovery_kind(session: number, index: bigint): bigint;
106
+ galley_recorded_recovery_terminal(session: number, index: bigint, outData: number, outLen: number): bigint;
107
+ galley_recorded_recovery_resume(session: number, index: bigint, out: number): bigint;
108
+ galley_recorded_recovery_lhs_variable(session: number, index: bigint, outData: number, outLen: number): bigint;
109
+ galley_recorded_recovery_production(session: number, index: bigint, outVar: number, outLen: number, outIdx: number): bigint;
110
+ galley_recorded_recovery_occurrence(session: number, index: bigint, outParent: number, outParentLen: number, outRhs: number, outSym: number, outVar: number, outVarLen: number): bigint;
111
+ galley_tree_append_children(session: number, parent: bigint, first: bigint): bigint;
112
+ galley_tree_insert_before(session: number, target: bigint, first: bigint): bigint;
113
+ galley_tree_insert_after(session: number, target: bigint, first: bigint): bigint;
114
+ galley_tree_remove_siblings(session: number, node: bigint, count: number, outHead: number): bigint;
115
+ galley_tree_remove_self(session: number, node: bigint, outHead: number): bigint;
116
+ galley_tree_promote_children_over_wrapper(session: number, wrapper: bigint, outHead: number): bigint;
117
+ galley_tree_clean_children(session: number, node: bigint, outHead: number): bigint;
118
+ galley_tree_unlink_wrapper(session: number, wrapper: bigint): bigint;
119
+ galley_tree_insert_children_at(session: number, parent: bigint, index: number, first: bigint): bigint;
120
+ galley_tree_remove_children_at(session: number, parent: bigint, index: number, count: number, outHead: number): bigint;
121
+ galley_procedure_current_node(args: number): bigint;
122
+ galley_procedure_set_current_node(args: number, node: bigint): void;
123
+ galley_procedure_drop_self(args: number): bigint;
124
+ galley_procedure_drop_children(args: number): bigint;
125
+ galley_procedure_drop_if_empty(args: number): bigint;
126
+ galley_procedure_replace_with_children(args: number): bigint;
127
+ galley_procedure_context_line(args: number): number;
128
+ galley_procedure_context_column(args: number): number;
129
+ galley_procedure_report_semantic_error(args: number, message: number, messageLen: number): bigint;
130
+ galley_js_procedure_count?(): number;
131
+ galley_js_procedure_name_ptr?(index: number): number;
132
+ galley_js_procedure_name_len?(index: number): number;
133
+ galley_js_procedure_enable?(namePtr: number, nameLen: number): number;
134
+ galley_js_procedure_clear?(): void;
135
+ }
136
+ export declare function wasmFileName(base?: string): string;
137
+ export declare function findLibrary(explicit?: string): string;
138
+ export interface InitOptions {
139
+ /** Grammar module path. Defaults to discovery (`findLibrary()` under Node). */
140
+ libraryPath?: string;
141
+ /** Raw module bytes (browsers, tests). Wins over `libraryPath`/`url`. */
142
+ bytes?: Uint8Array;
143
+ /** Module URL for `fetch` (browsers). Wins over `libraryPath`. */
144
+ url?: string | URL;
145
+ }
146
+ /** Async entry point; the only way to initialize in browsers. */
147
+ export declare function init(options?: InitOptions): Promise<void>;
148
+ /** Synchronous entry point; Node only (file read + `WebAssembly.Module`). */
149
+ export declare function initSync(options?: InitOptions): void;
150
+ /** Seed the default cache key (used by `init({ bytes })` without a path). */
151
+ export declare function seedDefault(wasmPath: string): void;
152
+ /**
153
+ * Single gate for every consumer: returns the initialized port for a
154
+ * grammar, auto-initializing synchronously under Node. Throws
155
+ * `NeedInitError` anywhere synchronous initialization is impossible.
156
+ */
157
+ export declare function getWasmPort(libraryPath?: string): WasmPort;
158
+ /**
159
+ * The wasm `FfiPort`: normalizes the reactor module's i32/i64 boundary
160
+ * into the structured values the core expects. Memory is allocated with
161
+ * the guest's `galley_js_malloc`/`galley_js_free`; every view is fresh
162
+ * because allocation may grow (and detach) memory.
163
+ */
164
+ export declare class WasmPort implements FfiPort {
165
+ #private;
166
+ readonly wasm: GalleyWasmExports;
167
+ readonly libraryPath: string;
168
+ constructor(wasm: GalleyWasmExports, libraryPath: string);
169
+ /** Guest hook entry: decode the name and forward to the core registry. */
170
+ dispatchFromGuest(namePtr: number, nameLen: number, argsPtr: number): void;
171
+ /** Guest hook entry (current builds): integer hook ID, no strings cross. */
172
+ dispatchFromGuestById(id: number, argsPtr: number): void;
173
+ procedureNames(): string[];
174
+ private memoryBytes;
175
+ private dataView;
176
+ private malloc;
177
+ private free;
178
+ /** Copy guest bytes out (owned copy, valid after the next call). */
179
+ private readBytes;
180
+ private readCString;
181
+ /** Copy host bytes in; zero-length inputs still get a non-null slot. */
182
+ private writeBytes;
183
+ version(): string;
184
+ parserType(): number;
185
+ errorRecoveryMode(): number;
186
+ hasAst(): boolean;
187
+ hasProcedures(): boolean;
188
+ allowsNoAstTreeProcedures(): boolean;
189
+ sourceRetentionEnabled(): boolean;
190
+ hasPositionTracking(): boolean;
191
+ hasInputStreaming(): boolean;
192
+ usesVerbatim(): boolean;
193
+ stackOverflowRecoveryAvailable(): boolean;
194
+ symbolCount(): number;
195
+ variableCount(): number;
196
+ statusString(status: number): string | null;
197
+ createSession(options: SessionCOptions | null): Handle;
198
+ destroySession(handle: Handle): void;
199
+ setMessageOverride(handle: Handle, name: Uint8Array, message: Uint8Array): number;
200
+ parse(handle: Handle, data: Uint8Array): number;
201
+ parseFile(handle: Handle, filePath: string): number;
202
+ lastPosition(handle: Handle): [number, number] | null;
203
+ nodeCount(handle: Handle): number;
204
+ reserveNodes(handle: Handle, capacity: bigint): number;
205
+ nodeCapacity(handle: Handle): number;
206
+ rootNode(handle: Handle): bigint;
207
+ nodeValid(handle: Handle, node: bigint): boolean;
208
+ childCount(handle: Handle, node: bigint): number;
209
+ firstChild(handle: Handle, node: bigint): bigint;
210
+ lastChild(handle: Handle, node: bigint): bigint;
211
+ nextSibling(handle: Handle, node: bigint): bigint;
212
+ priorSibling(handle: Handle, node: bigint): bigint;
213
+ parent(handle: Handle, node: bigint): bigint;
214
+ treeSnapshot(handle: Handle): TreeSnapshot;
215
+ walkerCreate(handle: Handle, node: bigint, skipSemanticErrors: boolean): Handle | null;
216
+ walkerNext(walker: Handle): WalkedStep | null;
217
+ walkerSkipChildren(walker: Handle): void;
218
+ walkerDestroy(walker: Handle): void;
219
+ /** Read a guest `(data, len)` byte pair; null on negative status. */
220
+ private tryCopyBytes;
221
+ private readSemanticPair;
222
+ nodeSymbolName(handle: Handle, node: bigint): Uint8Array | null;
223
+ nodeText(handle: Handle, node: bigint): Uint8Array | null;
224
+ nodeSpan(handle: Handle, node: bigint): [bigint, bigint] | null;
225
+ nodeLineColumn(handle: Handle, node: bigint): [number, number] | null;
226
+ nodeVariableIndex(handle: Handle, node: bigint): number;
227
+ symbolNameAt(handle: Handle, index: number): Uint8Array | null;
228
+ symbolIsTerminal(handle: Handle, index: number): boolean;
229
+ variableNameAt(handle: Handle, index: number): Uint8Array | null;
230
+ hasDiagnostic(handle: Handle): boolean;
231
+ diagnosticKind(handle: Handle): number;
232
+ diagnosticMessage(handle: Handle): string | null;
233
+ diagnosticMessageAnsi(handle: Handle): string | null;
234
+ diagnosticPosition(handle: Handle): [number, number] | null;
235
+ diagnosticUnexpectedToken(handle: Handle): Uint8Array | null;
236
+ diagnosticExpectedCount(handle: Handle): number;
237
+ diagnosticExpectedAt(handle: Handle, index: number): Uint8Array | null;
238
+ diagnosticContextCount(handle: Handle): number;
239
+ diagnosticContextAt(handle: Handle, index: number): Uint8Array | null;
240
+ syntaxErrorCount(handle: Handle): number;
241
+ semanticErrorCount(handle: Handle): number;
242
+ diagnosticSemantic(handle: Handle): [string, string] | null;
243
+ diagnosticIndentation(handle: Handle): [number, number] | null;
244
+ diagnosticRecoveryKind(handle: Handle): number;
245
+ diagnosticRecoveryTerminal(handle: Handle): Uint8Array | null;
246
+ diagnosticRecoveryResume(handle: Handle): number | null;
247
+ diagnosticRecoveryLhsVariable(handle: Handle): string | null;
248
+ diagnosticRecoveryProduction(handle: Handle): [string, number] | null;
249
+ diagnosticRecoveryOccurrence(handle: Handle): [string, number, number, string] | null;
250
+ recordedDiagnosticCount(handle: Handle): number;
251
+ recordedDiagnosticKind(handle: Handle, diagIndex: number): number;
252
+ recordedDiagnosticPosition(handle: Handle, diagIndex: number): [number, number] | null;
253
+ recordedUnexpectedToken(handle: Handle, diagIndex: number): Uint8Array | null;
254
+ recordedDiagnosticMessage(handle: Handle, diagIndex: number): string | null;
255
+ recordedIndentation(handle: Handle, diagIndex: number): [number, number] | null;
256
+ recordedSemantic(handle: Handle, diagIndex: number): [string, string] | null;
257
+ recordedExpectedCount(handle: Handle, diagIndex: number): number;
258
+ recordedExpectedToken(handle: Handle, diagIndex: number, tokenIndex: number): Uint8Array | null;
259
+ recordedContextCount(handle: Handle, diagIndex: number): number;
260
+ recordedContextName(handle: Handle, diagIndex: number, contextIndex: number): Uint8Array | null;
261
+ recordedRecoveryKind(handle: Handle, diagIndex: number): number;
262
+ recordedRecoveryTerminal(handle: Handle, diagIndex: number): Uint8Array | null;
263
+ recordedRecoveryResume(handle: Handle, diagIndex: number): number | null;
264
+ recordedRecoveryLhsVariable(handle: Handle, diagIndex: number): string | null;
265
+ recordedRecoveryProduction(handle: Handle, diagIndex: number): [string, number] | null;
266
+ recordedRecoveryOccurrence(handle: Handle, diagIndex: number): [string, number, number, string] | null;
267
+ treeAppendChildren(handle: Handle, parent: bigint, first: bigint): number;
268
+ treeInsertBefore(handle: Handle, target: bigint, first: bigint): number;
269
+ treeInsertAfter(handle: Handle, target: bigint, first: bigint): number;
270
+ treeRemoveSiblings(handle: Handle, node: bigint, count: number): {
271
+ status: number;
272
+ head: bigint;
273
+ };
274
+ treeRemoveSelf(handle: Handle, node: bigint): {
275
+ status: number;
276
+ head: bigint;
277
+ };
278
+ treePromoteChildrenOverWrapper(handle: Handle, wrapper: bigint): {
279
+ status: number;
280
+ head: bigint;
281
+ };
282
+ treeCleanChildren(handle: Handle, node: bigint): {
283
+ status: number;
284
+ head: bigint;
285
+ };
286
+ treeUnlinkWrapper(handle: Handle, wrapper: bigint): number;
287
+ treeInsertChildrenAt(handle: Handle, parent: bigint, index: number, first: bigint): number;
288
+ treeRemoveChildrenAt(handle: Handle, parent: bigint, index: number, count: number): {
289
+ status: number;
290
+ head: bigint;
291
+ };
292
+ procCurrentNode(args: Handle): bigint;
293
+ procSetCurrentNode(args: Handle, node: bigint): void;
294
+ procDropSelf(args: Handle): number;
295
+ procDropChildren(args: Handle): number;
296
+ procDropIfEmpty(args: Handle): number;
297
+ procReplaceWithChildren(args: Handle): number;
298
+ procContextLine(args: Handle): number;
299
+ procContextColumn(args: Handle): number;
300
+ procReportSemanticError(args: Handle, message: Uint8Array): number;
301
+ syncProcedures(names: string[]): void;
302
+ }
303
+ export {};