@sanbus/galley-deno 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 Deno
2
+
3
+ `@sanbus/galley-core` over `Deno.dlopen` and `bindings/c/galley.h`. Zero
4
+ dependencies; the adapter is plain TypeScript run directly by Deno.
5
+
6
+ See `docs/bindings_js_deno.md` and `examples/js/deno` for the consumer flow.
7
+
8
+ One shared library embeds one parser; sessions are not thread-safe.
package/build.ts ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env -S deno run --allow-read --allow-write --allow-run --allow-env
2
+ /**
3
+ * Builds a Galley parser and its shared library for a JavaScript consumer
4
+ * on Deno.
5
+ *
6
+ * Usage (from a language directory, e.g. examples/js/deno):
7
+ * deno task build
8
+ * which runs:
9
+ * deno run --allow-read --allow-write --allow-run --allow-env \
10
+ * ../../../bindings/js/deno/build.ts .
11
+ *
12
+ * Thin wrapper over the shared gate (`../core/build/builder.mjs`), which
13
+ * documents the accepted grammar files and owns the build. For both legs
14
+ * at once, use the single entry instead: `galley build <language-dir>`
15
+ * from `@sanbus/galley`.
16
+ */
17
+
18
+ import { buildParserArtifact } from "../core/build/builder.mjs";
19
+ import { artifactFileName, wasmArtifactFileName } from "../core/src/artifact.ts";
20
+
21
+ const LIBRARY_NAME = "galley-js-deno";
22
+
23
+ function fatal(msg: string): never {
24
+ console.error(`galley-bindings: ${msg}`);
25
+ Deno.exit(1);
26
+ }
27
+
28
+ async function main(): Promise<void> {
29
+ if (Deno.args.length !== 1) fatal("usage: deno task build (runs build.ts <language-dir>)");
30
+ await buildParserArtifact({
31
+ languageDirectory: Deno.args[0],
32
+ libraryName: LIBRARY_NAME,
33
+ platform: Deno.build.os,
34
+ artifactFileName,
35
+ wasmArtifactFileName,
36
+ });
37
+ }
38
+
39
+ main();
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Deno procedure-dispatch installer.
3
+ *
4
+ * Owns the `UnsafeCallback` that the shared JS shim
5
+ * (`galley_install_js_dispatch_id`, generated by `@sanbus/galley-core/build/shim.mjs`)
6
+ * forwards every parser hook through. The registry and the ID-to-name
7
+ * dispatcher live in the core; this module only bridges the native
8
+ * boundary. Unlike Node there is no auto-scan: Deno consumers register
9
+ * hooks explicitly (`installProcedures(await import("./procedures.ts"))`).
10
+ * Libraries that predate integer hook IDs still export the name-carrying
11
+ * `galley_install_js_dispatch`, used as a fallback.
12
+ */
13
+ import type { FfiPort } from "@sanbus/galley-core";
14
+ import type { DenoPort } from "./ffi.ts";
15
+ export declare function ensureDispatchFor(port: DenoPort & FfiPort): void;
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Deno procedure-dispatch installer.
3
+ *
4
+ * Owns the `UnsafeCallback` that the shared JS shim
5
+ * (`galley_install_js_dispatch_id`, generated by `@sanbus/galley-core/build/shim.mjs`)
6
+ * forwards every parser hook through. The registry and the ID-to-name
7
+ * dispatcher live in the core; this module only bridges the native
8
+ * boundary. Unlike Node there is no auto-scan: Deno consumers register
9
+ * hooks explicitly (`installProcedures(await import("./procedures.ts"))`).
10
+ * Libraries that predate integer hook IDs still export the name-carrying
11
+ * `galley_install_js_dispatch`, used as a fallback.
12
+ */
13
+ import { dispatchProcedure } from "@sanbus/galley-core";
14
+ const textDecoder = new TextDecoder();
15
+ // Held to prevent GC of the callbacks; installed per library path.
16
+ // ID and name paths keep separate slots: their signatures differ.
17
+ let dispatchIdCallback = null;
18
+ let dispatchIdPointer = null;
19
+ let dispatchCallback = null;
20
+ let dispatchPointer = null;
21
+ const installedFor = new Set();
22
+ export function ensureDispatchFor(port) {
23
+ if (!port.supportsDispatch) {
24
+ // Library was built for C procedures (no shim); installs will be no-ops.
25
+ return;
26
+ }
27
+ if (installedFor.has(port.libraryPath))
28
+ return;
29
+ if (typeof port.native.galley_install_js_dispatch_id === "function" &&
30
+ port.procedureNames().length > 0) {
31
+ installIdDispatch(port);
32
+ }
33
+ else {
34
+ installNameDispatch(port);
35
+ }
36
+ installedFor.add(port.libraryPath);
37
+ }
38
+ function installIdDispatch(port) {
39
+ if (dispatchIdCallback === null) {
40
+ // Integer hook IDs: no string copy or decode on the hot path. The table
41
+ // is fixed per library build; unknown IDs are silent no-ops.
42
+ const table = port.procedureNames();
43
+ const cb = new Deno.UnsafeCallback({ parameters: ["u32", "pointer"], result: "void" }, (id, argsPtr) => {
44
+ const name = table[id];
45
+ if (name === undefined)
46
+ return;
47
+ dispatchProcedure(name, argsPtr, port);
48
+ });
49
+ // Prevent GC — the trampoline must stay reachable for the process lifetime.
50
+ globalThis.__galley_js_dispatchIdCallback = cb;
51
+ dispatchIdCallback = cb;
52
+ dispatchIdPointer = cb.pointer;
53
+ }
54
+ port.native.galley_install_js_dispatch_id(dispatchIdPointer);
55
+ }
56
+ function installNameDispatch(port) {
57
+ if (dispatchCallback === null) {
58
+ // Signature mirrors Zig: fn([*]const u8, usize, ?*anyopaque) callconv(.c) void.
59
+ const cb = new Deno.UnsafeCallback({ parameters: ["pointer", "usize", "pointer"], result: "void" }, (namePtr, nameLen, argsPtr) => {
60
+ if (namePtr === null)
61
+ return;
62
+ let name;
63
+ try {
64
+ const bytes = new Deno.UnsafePointerView(namePtr).getArrayBuffer(Number(nameLen)).slice(0);
65
+ name = textDecoder.decode(bytes);
66
+ }
67
+ catch (e) {
68
+ console.error("galley procedure dispatch: failed to decode name", e);
69
+ return;
70
+ }
71
+ dispatchProcedure(name, argsPtr, port);
72
+ });
73
+ // Prevent GC — the trampoline must stay reachable for the process lifetime.
74
+ globalThis.__galley_js_dispatchCallback = cb;
75
+ dispatchCallback = cb;
76
+ dispatchPointer = cb.pointer;
77
+ }
78
+ port.native.galley_install_js_dispatch(dispatchPointer);
79
+ }
80
+ //# sourceMappingURL=dispatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../src/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GA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;QACrF,gBAAgB,GAAG,EAAE,CAAC;QACtB,eAAe,GAAG,EAAE,CAAC,OAAO,CAAC;IAC/B,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,0BAA0B,CAAC,eAAoC,CAAC,CAAC;AAC/E,CAAC"}
package/dist/ffi.d.ts ADDED
@@ -0,0 +1,254 @@
1
+ /**
2
+ * Deno adapter for the Galley JavaScript bindings: `Deno.dlopen` bindings
3
+ * over `bindings/c/galley.h`, implementing the core `FfiPort`.
4
+ *
5
+ * Zero dependencies: no npm packages, no build step for the adapter itself.
6
+ * The core (`@sanbus/galley-core`, resolved to its compiled `dist` via the
7
+ * package `deno.json` import map) owns all session logic; memory copying
8
+ * and integer normalization live here. Requires `--allow-ffi` (dlopen),
9
+ * `--allow-read` (library discovery, `parseFile`), and `--allow-env`
10
+ * (library discovery).
11
+ */
12
+ import type { FfiPort, Handle, SessionCOptions, TreeSnapshot, WalkedStep } from "@sanbus/galley-core";
13
+ /** Callable view of the native symbols (see `BASE_SYMBOLS` below). */
14
+ type FfiOut = Uint8Array | Uint32Array | BigUint64Array | BigInt64Array;
15
+ interface GalleySymbols {
16
+ galley_version(): Deno.PointerValue;
17
+ galley_parser_type(): bigint;
18
+ galley_error_recovery_mode(): bigint;
19
+ galley_has_ast(): number;
20
+ galley_has_procedures(): number;
21
+ galley_allows_no_ast_tree_procedures(): number;
22
+ galley_source_retention_enabled(): number;
23
+ galley_has_position_tracking(): number;
24
+ galley_has_input_streaming(): number;
25
+ galley_uses_verbatim(): number;
26
+ galley_stack_overflow_recovery_available(): number;
27
+ galley_symbol_count(): bigint;
28
+ galley_variable_count(): bigint;
29
+ galley_status_string(status: bigint): Deno.PointerValue;
30
+ galley_symbol_name(session: Deno.PointerValue, index: bigint, outData: FfiOut, outLen: FfiOut): bigint;
31
+ galley_symbol_is_terminal(session: Deno.PointerValue, index: bigint): number;
32
+ galley_variable_name(session: Deno.PointerValue, index: bigint, outData: FfiOut, outLen: FfiOut): bigint;
33
+ galley_session_create(): Deno.PointerValue;
34
+ galley_session_create_ex(options: FfiOut): Deno.PointerValue;
35
+ galley_session_destroy(session: Deno.PointerValue): void;
36
+ galley_session_set_message_override(session: Deno.PointerValue, name: FfiOut, nameLen: number, message: FfiOut, messageLen: number): bigint;
37
+ galley_parse(session: Deno.PointerValue, data: FfiOut, len: number): bigint;
38
+ galley_parse_file(session: Deno.PointerValue, path: FfiOut): bigint;
39
+ galley_last_position(session: Deno.PointerValue, outLine: FfiOut, outCol: FfiOut): bigint;
40
+ galley_node_count(session: Deno.PointerValue): bigint;
41
+ galley_reserve_nodes(session: Deno.PointerValue, capacity: bigint): bigint;
42
+ galley_node_capacity(session: Deno.PointerValue): bigint;
43
+ galley_root_node(session: Deno.PointerValue): bigint;
44
+ galley_node_is_valid(session: Deno.PointerValue, node: bigint): number;
45
+ galley_node_child_count(session: Deno.PointerValue, node: bigint): number;
46
+ galley_node_first_child(session: Deno.PointerValue, node: bigint): bigint;
47
+ galley_node_last_child(session: Deno.PointerValue, node: bigint): bigint;
48
+ galley_node_next_sibling(session: Deno.PointerValue, node: bigint): bigint;
49
+ galley_node_prior_sibling(session: Deno.PointerValue, node: bigint): bigint;
50
+ galley_node_parent(session: Deno.PointerValue, node: bigint): bigint;
51
+ galley_tree_snapshot(session: Deno.PointerValue, outParent: FfiOut, outFirstChild: FfiOut, outNext: FfiOut, outChildCount: FfiOut, outVariable: FfiOut, outSpanStart: FfiOut, outSpanLen: FfiOut, capacity: bigint): bigint;
52
+ galley_walker_create(session: Deno.PointerValue, node: bigint, skipSemanticErrors: number): Deno.PointerValue;
53
+ galley_walker_next(walker: Deno.PointerValue, outNode: FfiOut, outDepth: FfiOut, outFlag: FfiOut): number;
54
+ galley_walker_skip_children(walker: Deno.PointerValue): void;
55
+ galley_walker_destroy(walker: Deno.PointerValue): void;
56
+ galley_node_span(session: Deno.PointerValue, node: bigint, outStart: FfiOut, outLen: FfiOut): bigint;
57
+ galley_node_symbol_name(session: Deno.PointerValue, node: bigint, outData: FfiOut, outLen: FfiOut): bigint;
58
+ galley_node_variable_index(session: Deno.PointerValue, node: bigint): bigint;
59
+ galley_node_text(session: Deno.PointerValue, node: bigint, outData: FfiOut, outLen: FfiOut): bigint;
60
+ galley_node_line_column(session: Deno.PointerValue, node: bigint, outLine: FfiOut, outCol: FfiOut): bigint;
61
+ galley_has_diagnostic(session: Deno.PointerValue): number;
62
+ galley_diagnostic_kind(session: Deno.PointerValue): bigint;
63
+ galley_diagnostic_message(session: Deno.PointerValue, out: FfiOut): bigint;
64
+ galley_diagnostic_message_ansi(session: Deno.PointerValue, out: FfiOut): bigint;
65
+ galley_diagnostic_position(session: Deno.PointerValue, outLine: FfiOut, outCol: FfiOut): bigint;
66
+ galley_diagnostic_unexpected_token(session: Deno.PointerValue, outData: FfiOut, outLen: FfiOut): bigint;
67
+ galley_diagnostic_expected_count(session: Deno.PointerValue): bigint;
68
+ galley_diagnostic_expected_at(session: Deno.PointerValue, index: bigint, outData: FfiOut, outLen: FfiOut): bigint;
69
+ galley_diagnostic_context_count(session: Deno.PointerValue): bigint;
70
+ galley_diagnostic_context_at(session: Deno.PointerValue, index: bigint, outData: FfiOut, outLen: FfiOut): bigint;
71
+ galley_diagnostic_indentation(session: Deno.PointerValue, outSpaces: FfiOut, outWidth: FfiOut): bigint;
72
+ galley_syntax_error_count(session: Deno.PointerValue): bigint;
73
+ galley_semantic_error_count(session: Deno.PointerValue): bigint;
74
+ galley_diagnostic_semantic(session: Deno.PointerValue, outVariable: FfiOut, outVariableLen: FfiOut, outMessage: FfiOut, outMessageLen: FfiOut): bigint;
75
+ galley_diagnostic_recovery_kind(session: Deno.PointerValue): bigint;
76
+ galley_diagnostic_recovery_terminal(session: Deno.PointerValue, outData: FfiOut, outLen: FfiOut): bigint;
77
+ galley_diagnostic_recovery_resume(session: Deno.PointerValue, out: FfiOut): bigint;
78
+ galley_diagnostic_recovery_lhs_variable(session: Deno.PointerValue, outData: FfiOut, outLen: FfiOut): bigint;
79
+ galley_diagnostic_recovery_production(session: Deno.PointerValue, outVar: FfiOut, outLen: FfiOut, outIdx: FfiOut): bigint;
80
+ galley_diagnostic_recovery_occurrence(session: Deno.PointerValue, outParent: FfiOut, outParentLen: FfiOut, outRhs: FfiOut, outSym: FfiOut, outVar: FfiOut, outVarLen: FfiOut): bigint;
81
+ galley_recorded_diagnostic_count(session: Deno.PointerValue): bigint;
82
+ galley_recorded_diagnostic_kind(session: Deno.PointerValue, diagIndex: bigint): bigint;
83
+ galley_recorded_diagnostic_position(session: Deno.PointerValue, diagIndex: bigint, outLine: FfiOut, outCol: FfiOut): bigint;
84
+ galley_recorded_unexpected_token(session: Deno.PointerValue, diagIndex: bigint, outData: FfiOut, outLen: FfiOut): bigint;
85
+ galley_recorded_diagnostic_message(session: Deno.PointerValue, diagIndex: bigint, out: FfiOut): bigint;
86
+ galley_recorded_indentation(session: Deno.PointerValue, diagIndex: bigint, outSpaces: FfiOut, outWidth: FfiOut): bigint;
87
+ galley_recorded_semantic(session: Deno.PointerValue, diagIndex: bigint, outVariable: FfiOut, outVariableLen: FfiOut, outMessage: FfiOut, outMessageLen: FfiOut): bigint;
88
+ galley_recorded_expected_count(session: Deno.PointerValue, diagIndex: bigint): bigint;
89
+ galley_recorded_expected_token(session: Deno.PointerValue, diagIndex: bigint, tokenIndex: bigint, outData: FfiOut, outLen: FfiOut): bigint;
90
+ galley_recorded_context_count(session: Deno.PointerValue, diagIndex: bigint): bigint;
91
+ galley_recorded_context_name(session: Deno.PointerValue, diagIndex: bigint, ctxIndex: bigint, outData: FfiOut, outLen: FfiOut): bigint;
92
+ galley_recorded_recovery_kind(session: Deno.PointerValue, diagIndex: bigint): bigint;
93
+ galley_recorded_recovery_terminal(session: Deno.PointerValue, diagIndex: bigint, outData: FfiOut, outLen: FfiOut): bigint;
94
+ galley_recorded_recovery_resume(session: Deno.PointerValue, diagIndex: bigint, out: FfiOut): bigint;
95
+ galley_recorded_recovery_lhs_variable(session: Deno.PointerValue, diagIndex: bigint, outData: FfiOut, outLen: FfiOut): bigint;
96
+ galley_recorded_recovery_production(session: Deno.PointerValue, diagIndex: bigint, outVar: FfiOut, outLen: FfiOut, outIdx: FfiOut): bigint;
97
+ galley_recorded_recovery_occurrence(session: Deno.PointerValue, diagIndex: bigint, outParent: FfiOut, outParentLen: FfiOut, outRhs: FfiOut, outSym: FfiOut, outVar: FfiOut, outVarLen: FfiOut): bigint;
98
+ galley_tree_append_children(session: Deno.PointerValue, parent: bigint, first: bigint): bigint;
99
+ galley_tree_insert_before(session: Deno.PointerValue, target: bigint, first: bigint): bigint;
100
+ galley_tree_insert_after(session: Deno.PointerValue, target: bigint, first: bigint): bigint;
101
+ galley_tree_remove_siblings(session: Deno.PointerValue, node: bigint, count: number, outHead: FfiOut): bigint;
102
+ galley_tree_remove_self(session: Deno.PointerValue, node: bigint, outHead: FfiOut): bigint;
103
+ galley_tree_promote_children_over_wrapper(session: Deno.PointerValue, wrapper: bigint, outHead: FfiOut): bigint;
104
+ galley_tree_clean_children(session: Deno.PointerValue, node: bigint, outHead: FfiOut): bigint;
105
+ galley_tree_unlink_wrapper(session: Deno.PointerValue, wrapper: bigint): bigint;
106
+ galley_tree_insert_children_at(session: Deno.PointerValue, parent: bigint, index: number, first: bigint): bigint;
107
+ galley_tree_remove_children_at(session: Deno.PointerValue, parent: bigint, index: number, count: number, outHead: FfiOut): bigint;
108
+ galley_procedure_session(args: Deno.PointerValue): Deno.PointerValue;
109
+ galley_procedure_current_node(args: Deno.PointerValue): bigint;
110
+ galley_procedure_set_current_node(args: Deno.PointerValue, node: bigint): void;
111
+ galley_procedure_drop_self(args: Deno.PointerValue): bigint;
112
+ galley_procedure_drop_children(args: Deno.PointerValue): bigint;
113
+ galley_procedure_drop_if_empty(args: Deno.PointerValue): bigint;
114
+ galley_procedure_replace_with_children(args: Deno.PointerValue): bigint;
115
+ galley_procedure_context_line(args: Deno.PointerValue): number;
116
+ galley_procedure_context_column(args: Deno.PointerValue): number;
117
+ galley_procedure_report_semantic_error(args: Deno.PointerValue, message: FfiOut, messageLen: number): bigint;
118
+ galley_install_js_dispatch(callback: Deno.PointerValue): void;
119
+ galley_install_js_dispatch_id?(callback: Deno.PointerValue): void;
120
+ galley_js_procedure_count?(): number;
121
+ galley_js_procedure_name_ptr?(index: number): bigint;
122
+ galley_js_procedure_name_len?(index: number): bigint;
123
+ galley_js_procedure_enable?(name: FfiOut, nameLen: number | bigint): number;
124
+ galley_js_procedure_clear?(): void;
125
+ }
126
+ export declare function libFileName(base?: string): string;
127
+ export declare function findLibrary(explicit?: string): string;
128
+ export declare class DenoPort implements FfiPort {
129
+ #private;
130
+ readonly native: GalleySymbols;
131
+ readonly libraryPath: string;
132
+ readonly supportsDispatch: boolean;
133
+ constructor(native: GalleySymbols, libraryPath: string, supportsDispatch: boolean);
134
+ syncProcedures(names: string[]): void;
135
+ procedureNames(): string[];
136
+ version(): string;
137
+ parserType(): number;
138
+ errorRecoveryMode(): number;
139
+ hasAst(): boolean;
140
+ hasProcedures(): boolean;
141
+ allowsNoAstTreeProcedures(): boolean;
142
+ sourceRetentionEnabled(): boolean;
143
+ hasPositionTracking(): boolean;
144
+ hasInputStreaming(): boolean;
145
+ usesVerbatim(): boolean;
146
+ stackOverflowRecoveryAvailable(): boolean;
147
+ symbolCount(): number;
148
+ variableCount(): number;
149
+ statusString(status: number): string | null;
150
+ createSession(options: SessionCOptions | null): Handle;
151
+ destroySession(handle: Handle): void;
152
+ setMessageOverride(handle: Handle, name: Uint8Array, message: Uint8Array): number;
153
+ parse(handle: Handle, data: Uint8Array): number;
154
+ parseFile(handle: Handle, filePath: string): number;
155
+ lastPosition(handle: Handle): [number, number] | null;
156
+ nodeCount(handle: Handle): number;
157
+ reserveNodes(handle: Handle, capacity: bigint): number;
158
+ nodeCapacity(handle: Handle): number;
159
+ rootNode(handle: Handle): bigint;
160
+ nodeValid(handle: Handle, node: bigint): boolean;
161
+ childCount(handle: Handle, node: bigint): number;
162
+ firstChild(handle: Handle, node: bigint): bigint;
163
+ lastChild(handle: Handle, node: bigint): bigint;
164
+ nextSibling(handle: Handle, node: bigint): bigint;
165
+ priorSibling(handle: Handle, node: bigint): bigint;
166
+ parent(handle: Handle, node: bigint): bigint;
167
+ treeSnapshot(handle: Handle): TreeSnapshot;
168
+ walkerCreate(handle: Handle, node: bigint, skipSemanticErrors: boolean): Handle | null;
169
+ walkerNext(walker: Handle): WalkedStep | null;
170
+ walkerSkipChildren(walker: Handle): void;
171
+ walkerDestroy(walker: Handle): void;
172
+ nodeSymbolName(handle: Handle, node: bigint): Uint8Array | null;
173
+ nodeText(handle: Handle, node: bigint): Uint8Array | null;
174
+ nodeSpan(handle: Handle, node: bigint): [bigint, bigint] | null;
175
+ nodeLineColumn(handle: Handle, node: bigint): [number, number] | null;
176
+ nodeVariableIndex(handle: Handle, node: bigint): number;
177
+ symbolNameAt(handle: Handle, index: number): Uint8Array | null;
178
+ symbolIsTerminal(handle: Handle, index: number): boolean;
179
+ variableNameAt(handle: Handle, index: number): Uint8Array | null;
180
+ hasDiagnostic(handle: Handle): boolean;
181
+ diagnosticKind(handle: Handle): number;
182
+ diagnosticMessage(handle: Handle): string | null;
183
+ diagnosticMessageAnsi(handle: Handle): string | null;
184
+ diagnosticPosition(handle: Handle): [number, number] | null;
185
+ diagnosticUnexpectedToken(handle: Handle): Uint8Array | null;
186
+ diagnosticExpectedCount(handle: Handle): number;
187
+ diagnosticExpectedAt(handle: Handle, index: number): Uint8Array | null;
188
+ diagnosticContextCount(handle: Handle): number;
189
+ diagnosticContextAt(handle: Handle, index: number): Uint8Array | null;
190
+ syntaxErrorCount(handle: Handle): number;
191
+ semanticErrorCount(handle: Handle): number;
192
+ diagnosticSemantic(handle: Handle): [string, string] | null;
193
+ diagnosticIndentation(handle: Handle): [number, number] | null;
194
+ diagnosticRecoveryKind(handle: Handle): number;
195
+ diagnosticRecoveryTerminal(handle: Handle): Uint8Array | null;
196
+ diagnosticRecoveryResume(handle: Handle): number | null;
197
+ diagnosticRecoveryLhsVariable(handle: Handle): string | null;
198
+ diagnosticRecoveryProduction(handle: Handle): [string, number] | null;
199
+ diagnosticRecoveryOccurrence(handle: Handle): [string, number, number, string] | null;
200
+ recordedDiagnosticCount(handle: Handle): number;
201
+ recordedDiagnosticKind(handle: Handle, diagIndex: number): number;
202
+ recordedDiagnosticPosition(handle: Handle, diagIndex: number): [number, number] | null;
203
+ recordedUnexpectedToken(handle: Handle, diagIndex: number): Uint8Array | null;
204
+ recordedDiagnosticMessage(handle: Handle, diagIndex: number): string | null;
205
+ recordedIndentation(handle: Handle, diagIndex: number): [number, number] | null;
206
+ recordedSemantic(handle: Handle, diagIndex: number): [string, string] | null;
207
+ recordedExpectedCount(handle: Handle, diagIndex: number): number;
208
+ recordedExpectedToken(handle: Handle, diagIndex: number, tokenIndex: number): Uint8Array | null;
209
+ recordedContextCount(handle: Handle, diagIndex: number): number;
210
+ recordedContextName(handle: Handle, diagIndex: number, contextIndex: number): Uint8Array | null;
211
+ recordedRecoveryKind(handle: Handle, diagIndex: number): number;
212
+ recordedRecoveryTerminal(handle: Handle, diagIndex: number): Uint8Array | null;
213
+ recordedRecoveryResume(handle: Handle, diagIndex: number): number | null;
214
+ recordedRecoveryLhsVariable(handle: Handle, diagIndex: number): string | null;
215
+ recordedRecoveryProduction(handle: Handle, diagIndex: number): [string, number] | null;
216
+ recordedRecoveryOccurrence(handle: Handle, diagIndex: number): [string, number, number, string] | null;
217
+ treeAppendChildren(handle: Handle, parent: bigint, first: bigint): number;
218
+ treeInsertBefore(handle: Handle, target: bigint, first: bigint): number;
219
+ treeInsertAfter(handle: Handle, target: bigint, first: bigint): number;
220
+ treeRemoveSiblings(handle: Handle, node: bigint, count: number): {
221
+ status: number;
222
+ head: bigint;
223
+ };
224
+ treeRemoveSelf(handle: Handle, node: bigint): {
225
+ status: number;
226
+ head: bigint;
227
+ };
228
+ treePromoteChildrenOverWrapper(handle: Handle, wrapper: bigint): {
229
+ status: number;
230
+ head: bigint;
231
+ };
232
+ treeCleanChildren(handle: Handle, node: bigint): {
233
+ status: number;
234
+ head: bigint;
235
+ };
236
+ treeUnlinkWrapper(handle: Handle, wrapper: bigint): number;
237
+ treeInsertChildrenAt(handle: Handle, parent: bigint, index: number, first: bigint): number;
238
+ treeRemoveChildrenAt(handle: Handle, parent: bigint, index: number, count: number): {
239
+ status: number;
240
+ head: bigint;
241
+ };
242
+ procCurrentNode(args: Handle): bigint;
243
+ procSetCurrentNode(args: Handle, node: bigint): void;
244
+ procDropSelf(args: Handle): number;
245
+ procDropChildren(args: Handle): number;
246
+ procDropIfEmpty(args: Handle): number;
247
+ procReplaceWithChildren(args: Handle): number;
248
+ procContextLine(args: Handle): number;
249
+ procContextColumn(args: Handle): number;
250
+ procReportSemanticError(args: Handle, message: Uint8Array): number;
251
+ }
252
+ /** Port for the library at `explicitPath` (or default discovery), cached per path. */
253
+ export declare function getDenoPort(explicitPath?: string): DenoPort;
254
+ export {};