@sanbus/galley-core 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 +15 -0
- package/build/builder.mjs +276 -0
- package/build/fixture.mjs +85 -0
- package/build/shim.mjs +216 -0
- package/dist/artifact.d.ts +38 -0
- package/dist/artifact.js +45 -0
- package/dist/artifact.js.map +1 -0
- package/dist/constants.d.ts +34 -0
- package/dist/constants.js +41 -0
- package/dist/constants.js.map +1 -0
- package/dist/diagnostic.d.ts +34 -0
- package/dist/diagnostic.js +28 -0
- package/dist/diagnostic.js.map +1 -0
- package/dist/errors.d.ts +22 -0
- package/dist/errors.js +38 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/names.d.ts +20 -0
- package/dist/names.js +29 -0
- package/dist/names.js.map +1 -0
- package/dist/node.d.ts +45 -0
- package/dist/node.js +137 -0
- package/dist/node.js.map +1 -0
- package/dist/port.d.ts +193 -0
- package/dist/port.js +14 -0
- package/dist/port.js.map +1 -0
- package/dist/procedures.d.ts +62 -0
- package/dist/procedures.js +154 -0
- package/dist/procedures.js.map +1 -0
- package/dist/session.d.ts +123 -0
- package/dist/session.js +599 -0
- package/dist/session.js.map +1 -0
- package/dist/text.d.ts +7 -0
- package/dist/text.js +16 -0
- package/dist/text.js.map +1 -0
- package/package.json +31 -0
- package/src/artifact.ts +62 -0
- package/src/constants.ts +47 -0
- package/src/diagnostic.ts +48 -0
- package/src/errors.ts +49 -0
- package/src/index.ts +53 -0
- package/src/node.ts +154 -0
- package/src/port.ts +213 -0
- package/src/procedures.ts +169 -0
- package/src/session.ts +747 -0
- package/src/text.ts +19 -0
package/dist/session.js
ADDED
|
@@ -0,0 +1,599 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parsing session bound to this library's parser.
|
|
3
|
+
* Mirrors Python/Rust/Go sessions over `bindings/c/galley.h`.
|
|
4
|
+
*
|
|
5
|
+
* Runtime-neutral: all native calls go through the injected {@link FfiPort}.
|
|
6
|
+
* Each adapter (`bindings/js/node`, `../bun`, `../deno`) subclasses `Session`
|
|
7
|
+
* to supply its port from `SessionOptions.libraryPath`.
|
|
8
|
+
*/
|
|
9
|
+
import { INVALID_NODE } from "./constants.js";
|
|
10
|
+
import { GalleyError } from "./errors.js";
|
|
11
|
+
import { decodeUtf8, encodeUtf8 } from "./text.js";
|
|
12
|
+
import { Node } from "./node.js";
|
|
13
|
+
import { listProcedures, setParsingSession } from "./procedures.js";
|
|
14
|
+
function defaultOptions() {
|
|
15
|
+
return {
|
|
16
|
+
maxErrors: 10,
|
|
17
|
+
recoveryWindow: 500,
|
|
18
|
+
stackOverflowRecovery: false,
|
|
19
|
+
syntaxErrorStackDepth: 0,
|
|
20
|
+
verbosity: 0,
|
|
21
|
+
astPreallocationRatio: -1.0,
|
|
22
|
+
astPreallocationCap: 0,
|
|
23
|
+
messageOverrides: {},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function toNodeAddress(node) {
|
|
27
|
+
if (typeof node === "bigint")
|
|
28
|
+
return node;
|
|
29
|
+
if (typeof node === "number")
|
|
30
|
+
return BigInt(node);
|
|
31
|
+
return node.address;
|
|
32
|
+
}
|
|
33
|
+
function isInvalid(addr) {
|
|
34
|
+
return addr === INVALID_NODE;
|
|
35
|
+
}
|
|
36
|
+
function optNode(session, addr) {
|
|
37
|
+
if (isInvalid(addr))
|
|
38
|
+
return null;
|
|
39
|
+
return new Node(session, addr);
|
|
40
|
+
}
|
|
41
|
+
export class Session {
|
|
42
|
+
#handle = null;
|
|
43
|
+
#port;
|
|
44
|
+
#closed = false;
|
|
45
|
+
constructor(port, options = {}) {
|
|
46
|
+
const merged = { ...defaultOptions(), ...options };
|
|
47
|
+
const overrides = options.messageOverrides ?? merged.messageOverrides;
|
|
48
|
+
this.#port = port;
|
|
49
|
+
const hasNonDefault = options.maxErrors !== undefined ||
|
|
50
|
+
options.recoveryWindow !== undefined ||
|
|
51
|
+
options.stackOverflowRecovery !== undefined ||
|
|
52
|
+
options.syntaxErrorStackDepth !== undefined ||
|
|
53
|
+
options.verbosity !== undefined ||
|
|
54
|
+
options.astPreallocationRatio !== undefined ||
|
|
55
|
+
options.astPreallocationCap !== undefined;
|
|
56
|
+
let cOptions = null;
|
|
57
|
+
if (hasNonDefault) {
|
|
58
|
+
cOptions = {
|
|
59
|
+
maxErrors: merged.maxErrors,
|
|
60
|
+
recoveryWindow: merged.recoveryWindow,
|
|
61
|
+
stackOverflowRecovery: merged.stackOverflowRecovery ? 1 : 0,
|
|
62
|
+
syntaxErrorStackDepth: merged.syntaxErrorStackDepth,
|
|
63
|
+
verbosity: merged.verbosity,
|
|
64
|
+
astPreallocationRatio: merged.astPreallocationRatio,
|
|
65
|
+
astPreallocationCap: typeof merged.astPreallocationCap === "bigint"
|
|
66
|
+
? merged.astPreallocationCap
|
|
67
|
+
: BigInt(merged.astPreallocationCap),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const handle = this.#port.createSession(cOptions);
|
|
71
|
+
if (handle === null || handle === undefined) {
|
|
72
|
+
throw new GalleyError("out of memory", -7, null);
|
|
73
|
+
}
|
|
74
|
+
this.#handle = handle;
|
|
75
|
+
for (const [name, message] of Object.entries(overrides)) {
|
|
76
|
+
const st = this.#port.setMessageOverride(this.#handle, encodeUtf8(name), encodeUtf8(message));
|
|
77
|
+
if (st < 0) {
|
|
78
|
+
const err = this.#errorFromStatus(st, "failed to register message override");
|
|
79
|
+
this.close();
|
|
80
|
+
throw err;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
get isClosed() {
|
|
85
|
+
return this.#closed || this.#handle === null;
|
|
86
|
+
}
|
|
87
|
+
#requireHandle() {
|
|
88
|
+
if (this.#closed || this.#handle === null)
|
|
89
|
+
throw new Error("session is closed");
|
|
90
|
+
return this.#handle;
|
|
91
|
+
}
|
|
92
|
+
#statusMessage(status) {
|
|
93
|
+
const s = this.#port.statusString(status);
|
|
94
|
+
return s ?? "unknown galley error";
|
|
95
|
+
}
|
|
96
|
+
#errorFromStatus(status, fallback) {
|
|
97
|
+
let diag = null;
|
|
98
|
+
try {
|
|
99
|
+
if (this.#handle !== null && this.#port.hasDiagnostic(this.#handle)) {
|
|
100
|
+
diag = this.#buildDiagnosticSingular();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// ignore
|
|
105
|
+
}
|
|
106
|
+
const message = fallback ?? diag?.message ?? this.#statusMessage(status);
|
|
107
|
+
return new GalleyError(message, status, diag);
|
|
108
|
+
}
|
|
109
|
+
#checkStatus(status, fallback) {
|
|
110
|
+
if (status < 0)
|
|
111
|
+
throw this.#errorFromStatus(status, fallback);
|
|
112
|
+
}
|
|
113
|
+
// -- parser metadata (mirror galley.h; bound to this session's artifact) --
|
|
114
|
+
version() {
|
|
115
|
+
return this.#port.version();
|
|
116
|
+
}
|
|
117
|
+
parserType() {
|
|
118
|
+
return this.#port.parserType();
|
|
119
|
+
}
|
|
120
|
+
errorRecoveryMode() {
|
|
121
|
+
return this.#port.errorRecoveryMode();
|
|
122
|
+
}
|
|
123
|
+
hasAst() {
|
|
124
|
+
return this.#port.hasAst();
|
|
125
|
+
}
|
|
126
|
+
hasProcedures() {
|
|
127
|
+
return this.#port.hasProcedures();
|
|
128
|
+
}
|
|
129
|
+
allowsNoAstTreeProcedures() {
|
|
130
|
+
return this.#port.allowsNoAstTreeProcedures();
|
|
131
|
+
}
|
|
132
|
+
sourceRetentionEnabled() {
|
|
133
|
+
return this.#port.sourceRetentionEnabled();
|
|
134
|
+
}
|
|
135
|
+
hasPositionTracking() {
|
|
136
|
+
return this.#port.hasPositionTracking();
|
|
137
|
+
}
|
|
138
|
+
hasInputStreaming() {
|
|
139
|
+
return this.#port.hasInputStreaming();
|
|
140
|
+
}
|
|
141
|
+
usesVerbatim() {
|
|
142
|
+
return this.#port.usesVerbatim();
|
|
143
|
+
}
|
|
144
|
+
stackOverflowRecoveryAvailable() {
|
|
145
|
+
return this.#port.stackOverflowRecoveryAvailable();
|
|
146
|
+
}
|
|
147
|
+
symbolCount() {
|
|
148
|
+
return this.#port.symbolCount();
|
|
149
|
+
}
|
|
150
|
+
variableCount() {
|
|
151
|
+
return this.#port.variableCount();
|
|
152
|
+
}
|
|
153
|
+
statusString(status) {
|
|
154
|
+
return this.#port.statusString(status);
|
|
155
|
+
}
|
|
156
|
+
// -- lifecycle -------------------------------------------------------
|
|
157
|
+
close() {
|
|
158
|
+
if (this.#handle !== null) {
|
|
159
|
+
this.#port.destroySession(this.#handle);
|
|
160
|
+
this.#handle = null;
|
|
161
|
+
}
|
|
162
|
+
this.#closed = true;
|
|
163
|
+
}
|
|
164
|
+
/** For `using session = new Session()` (Explicit Resource Management). */
|
|
165
|
+
[Symbol.dispose]() {
|
|
166
|
+
this.close();
|
|
167
|
+
}
|
|
168
|
+
// -- parsing ---------------------------------------------------------
|
|
169
|
+
parse(input) {
|
|
170
|
+
const handle = this.#requireHandle();
|
|
171
|
+
const buf = typeof input === "string" ? encodeUtf8(input) : input;
|
|
172
|
+
this.#port.syncProcedures(listProcedures());
|
|
173
|
+
const previous = setParsingSession(this);
|
|
174
|
+
let status;
|
|
175
|
+
try {
|
|
176
|
+
status = this.#port.parse(handle, buf);
|
|
177
|
+
}
|
|
178
|
+
finally {
|
|
179
|
+
setParsingSession(previous);
|
|
180
|
+
}
|
|
181
|
+
if (status < 0) {
|
|
182
|
+
throw this.#errorFromStatus(status);
|
|
183
|
+
}
|
|
184
|
+
return status;
|
|
185
|
+
}
|
|
186
|
+
parseSentinel(input) {
|
|
187
|
+
return this.parse(input);
|
|
188
|
+
}
|
|
189
|
+
parseFile(filePath) {
|
|
190
|
+
const handle = this.#requireHandle();
|
|
191
|
+
this.#port.syncProcedures(listProcedures());
|
|
192
|
+
const previous = setParsingSession(this);
|
|
193
|
+
let status;
|
|
194
|
+
try {
|
|
195
|
+
status = this.#port.parseFile(handle, filePath);
|
|
196
|
+
}
|
|
197
|
+
finally {
|
|
198
|
+
setParsingSession(previous);
|
|
199
|
+
}
|
|
200
|
+
if (status < 0) {
|
|
201
|
+
throw this.#errorFromStatus(status);
|
|
202
|
+
}
|
|
203
|
+
return status;
|
|
204
|
+
}
|
|
205
|
+
// -- arena -----------------------------------------------------------
|
|
206
|
+
nodeCount() {
|
|
207
|
+
return this.#port.nodeCount(this.#requireHandle());
|
|
208
|
+
}
|
|
209
|
+
reserveNodes(capacity) {
|
|
210
|
+
const h = this.#requireHandle();
|
|
211
|
+
const st = this.#port.reserveNodes(h, typeof capacity === "bigint" ? capacity : BigInt(capacity));
|
|
212
|
+
this.#checkStatus(st);
|
|
213
|
+
}
|
|
214
|
+
nodeCapacity() {
|
|
215
|
+
return this.#port.nodeCapacity(this.#requireHandle());
|
|
216
|
+
}
|
|
217
|
+
// -- navigation ------------------------------------------------------
|
|
218
|
+
rootNode() {
|
|
219
|
+
const h = this.#requireHandle();
|
|
220
|
+
return optNode(this, this.#port.rootNode(h));
|
|
221
|
+
}
|
|
222
|
+
nodeValid(node) {
|
|
223
|
+
const h = this.#requireHandle();
|
|
224
|
+
return this.#port.nodeValid(h, toNodeAddress(node));
|
|
225
|
+
}
|
|
226
|
+
childCount(node) {
|
|
227
|
+
const h = this.#requireHandle();
|
|
228
|
+
return this.#port.childCount(h, toNodeAddress(node));
|
|
229
|
+
}
|
|
230
|
+
children(node) {
|
|
231
|
+
const h = this.#requireHandle();
|
|
232
|
+
const addr = toNodeAddress(node);
|
|
233
|
+
const count = this.childCount(addr);
|
|
234
|
+
const out = [];
|
|
235
|
+
let child = this.#port.firstChild(h, addr);
|
|
236
|
+
for (let i = 0; i < count; i++) {
|
|
237
|
+
if (isInvalid(child))
|
|
238
|
+
throw new Error("child count changed during iteration");
|
|
239
|
+
out.push(new Node(this, child));
|
|
240
|
+
child = this.#port.nextSibling(h, child);
|
|
241
|
+
}
|
|
242
|
+
return out;
|
|
243
|
+
}
|
|
244
|
+
firstChild(node) {
|
|
245
|
+
const h = this.#requireHandle();
|
|
246
|
+
return optNode(this, this.#port.firstChild(h, toNodeAddress(node)));
|
|
247
|
+
}
|
|
248
|
+
lastChild(node) {
|
|
249
|
+
const h = this.#requireHandle();
|
|
250
|
+
return optNode(this, this.#port.lastChild(h, toNodeAddress(node)));
|
|
251
|
+
}
|
|
252
|
+
nextSibling(node) {
|
|
253
|
+
const h = this.#requireHandle();
|
|
254
|
+
return optNode(this, this.#port.nextSibling(h, toNodeAddress(node)));
|
|
255
|
+
}
|
|
256
|
+
priorSibling(node) {
|
|
257
|
+
const h = this.#requireHandle();
|
|
258
|
+
return optNode(this, this.#port.priorSibling(h, toNodeAddress(node)));
|
|
259
|
+
}
|
|
260
|
+
parent(node) {
|
|
261
|
+
const h = this.#requireHandle();
|
|
262
|
+
return optNode(this, this.#port.parent(h, toNodeAddress(node)));
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Flat bulk read of the most recent successful parse in a single FFI
|
|
266
|
+
* crossing: one array slot per node address. Walk `parent`/`firstChild`/
|
|
267
|
+
* `next` directly instead of one call per node.
|
|
268
|
+
*/
|
|
269
|
+
snapshot() {
|
|
270
|
+
return this.#port.treeSnapshot(this.#requireHandle());
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Pre-order walker over the subtree rooted at `root`, with the root at
|
|
274
|
+
* depth 0. Pass true to prune subtrees rooted at semantic-error nodes.
|
|
275
|
+
* Returns null for invalid roots and builds without AST construction.
|
|
276
|
+
* Close the walker (or use `using`) before closing the session or
|
|
277
|
+
* parsing again.
|
|
278
|
+
*/
|
|
279
|
+
walk(root, skipSemanticErrors = false) {
|
|
280
|
+
const h = this.#requireHandle();
|
|
281
|
+
const handle = this.#port.walkerCreate(h, toNodeAddress(root), skipSemanticErrors);
|
|
282
|
+
if (handle === null || handle === undefined)
|
|
283
|
+
return null;
|
|
284
|
+
return new Walker(this, this.#port, handle);
|
|
285
|
+
}
|
|
286
|
+
symbolNameBytes(node) {
|
|
287
|
+
const h = this.#requireHandle();
|
|
288
|
+
return this.#port.nodeSymbolName(h, toNodeAddress(node));
|
|
289
|
+
}
|
|
290
|
+
symbolName(node) {
|
|
291
|
+
const bytes = this.symbolNameBytes(node);
|
|
292
|
+
if (bytes === null)
|
|
293
|
+
return null;
|
|
294
|
+
return decodeUtf8(bytes);
|
|
295
|
+
}
|
|
296
|
+
text(node) {
|
|
297
|
+
const h = this.#requireHandle();
|
|
298
|
+
return this.#port.nodeText(h, toNodeAddress(node));
|
|
299
|
+
}
|
|
300
|
+
span(node) {
|
|
301
|
+
const h = this.#requireHandle();
|
|
302
|
+
return this.#port.nodeSpan(h, toNodeAddress(node));
|
|
303
|
+
}
|
|
304
|
+
lineColumn(node) {
|
|
305
|
+
const h = this.#requireHandle();
|
|
306
|
+
return this.#port.nodeLineColumn(h, toNodeAddress(node));
|
|
307
|
+
}
|
|
308
|
+
variableIndex(node) {
|
|
309
|
+
const h = this.#requireHandle();
|
|
310
|
+
const idx = this.#port.nodeVariableIndex(h, toNodeAddress(node));
|
|
311
|
+
if (idx === -1)
|
|
312
|
+
return null;
|
|
313
|
+
if (idx < 0)
|
|
314
|
+
throw this.#errorFromStatus(idx);
|
|
315
|
+
return idx;
|
|
316
|
+
}
|
|
317
|
+
lastPosition() {
|
|
318
|
+
const h = this.#requireHandle();
|
|
319
|
+
return this.#port.lastPosition(h);
|
|
320
|
+
}
|
|
321
|
+
hasDiagnostic() {
|
|
322
|
+
const h = this.#requireHandle();
|
|
323
|
+
return this.#port.hasDiagnostic(h);
|
|
324
|
+
}
|
|
325
|
+
setMessageOverride(name, message) {
|
|
326
|
+
const h = this.#requireHandle();
|
|
327
|
+
const st = this.#port.setMessageOverride(h, encodeUtf8(name), encodeUtf8(message));
|
|
328
|
+
this.#checkStatus(st);
|
|
329
|
+
}
|
|
330
|
+
// -- diagnostics -----------------------------------------------------
|
|
331
|
+
#buildDiagnosticSingular() {
|
|
332
|
+
const h = this.#requireHandle();
|
|
333
|
+
const kind = this.#port.diagnosticKind(h);
|
|
334
|
+
const pos = this.#port.diagnosticPosition(h);
|
|
335
|
+
const line = pos ? pos[0] : 0;
|
|
336
|
+
const col = pos ? pos[1] : 0;
|
|
337
|
+
const message = this.#port.diagnosticMessage(h) ?? "";
|
|
338
|
+
const messageAnsi = this.#port.diagnosticMessageAnsi(h) ?? "";
|
|
339
|
+
const unexpected = this.#port.diagnosticUnexpectedToken(h);
|
|
340
|
+
const expectedTokens = [];
|
|
341
|
+
const expCount = this.#port.diagnosticExpectedCount(h);
|
|
342
|
+
if (expCount > 0) {
|
|
343
|
+
for (let i = 0; i < expCount; i++) {
|
|
344
|
+
const b = this.#port.diagnosticExpectedAt(h, i);
|
|
345
|
+
if (b)
|
|
346
|
+
expectedTokens.push(b);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
const context = [];
|
|
350
|
+
const ctxCount = this.#port.diagnosticContextCount(h);
|
|
351
|
+
if (ctxCount > 0) {
|
|
352
|
+
for (let i = 0; i < ctxCount; i++) {
|
|
353
|
+
const b = this.#port.diagnosticContextAt(h, i);
|
|
354
|
+
if (b)
|
|
355
|
+
context.push(decodeUtf8(b));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
const syntaxErrorCount = this.#port.syntaxErrorCount(h);
|
|
359
|
+
const semanticErrorCount = this.#port.semanticErrorCount(h);
|
|
360
|
+
const semantic = this.#port.diagnosticSemantic(h);
|
|
361
|
+
const indentation = this.#port.diagnosticIndentation(h);
|
|
362
|
+
const recovery = this.#readRecoverySingular(h);
|
|
363
|
+
return {
|
|
364
|
+
kind,
|
|
365
|
+
line,
|
|
366
|
+
column: col,
|
|
367
|
+
message,
|
|
368
|
+
messageAnsi,
|
|
369
|
+
unexpectedToken: unexpected,
|
|
370
|
+
expectedTokens,
|
|
371
|
+
context,
|
|
372
|
+
syntaxErrorCount: syntaxErrorCount < 0 ? 0 : syntaxErrorCount,
|
|
373
|
+
semanticErrorCount: semanticErrorCount < 0 ? 0 : semanticErrorCount,
|
|
374
|
+
semantic,
|
|
375
|
+
indentation,
|
|
376
|
+
...recovery,
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
diagnostic() {
|
|
380
|
+
const h = this.#requireHandle();
|
|
381
|
+
if (!this.#port.hasDiagnostic(h))
|
|
382
|
+
return null;
|
|
383
|
+
return this.#buildDiagnosticSingular();
|
|
384
|
+
}
|
|
385
|
+
diagnostics() {
|
|
386
|
+
const h = this.#requireHandle();
|
|
387
|
+
const count = this.#port.recordedDiagnosticCount(h);
|
|
388
|
+
if (count <= 0)
|
|
389
|
+
return [];
|
|
390
|
+
const out = [];
|
|
391
|
+
for (let i = 0; i < count; i++) {
|
|
392
|
+
const d = this.#buildRecordedDiagnostic(i);
|
|
393
|
+
if (d)
|
|
394
|
+
out.push(d);
|
|
395
|
+
}
|
|
396
|
+
return out;
|
|
397
|
+
}
|
|
398
|
+
#buildRecordedDiagnostic(index) {
|
|
399
|
+
const h = this.#requireHandle();
|
|
400
|
+
const pos = this.#port.recordedDiagnosticPosition(h, index);
|
|
401
|
+
if (pos === null)
|
|
402
|
+
return null;
|
|
403
|
+
const kind = this.#port.recordedDiagnosticKind(h, index);
|
|
404
|
+
const [line, col] = pos;
|
|
405
|
+
const message = this.#port.recordedDiagnosticMessage(h, index) ?? "";
|
|
406
|
+
const unexpected = this.#port.recordedUnexpectedToken(h, index);
|
|
407
|
+
const expectedTokens = [];
|
|
408
|
+
const expCount = this.#port.recordedExpectedCount(h, index);
|
|
409
|
+
if (expCount > 0) {
|
|
410
|
+
for (let j = 0; j < expCount; j++) {
|
|
411
|
+
const b = this.#port.recordedExpectedToken(h, index, j);
|
|
412
|
+
if (b)
|
|
413
|
+
expectedTokens.push(b);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
const context = [];
|
|
417
|
+
const ctxCount = this.#port.recordedContextCount(h, index);
|
|
418
|
+
if (ctxCount > 0) {
|
|
419
|
+
for (let j = 0; j < ctxCount; j++) {
|
|
420
|
+
const b = this.#port.recordedContextName(h, index, j);
|
|
421
|
+
if (b)
|
|
422
|
+
context.push(decodeUtf8(b));
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
const indentation = this.#port.recordedIndentation(h, index);
|
|
426
|
+
const semantic = this.#port.recordedSemantic(h, index);
|
|
427
|
+
const recovery = this.#readRecoveryRecorded(h, index);
|
|
428
|
+
return {
|
|
429
|
+
kind,
|
|
430
|
+
line,
|
|
431
|
+
column: col,
|
|
432
|
+
message,
|
|
433
|
+
messageAnsi: message,
|
|
434
|
+
unexpectedToken: unexpected,
|
|
435
|
+
expectedTokens,
|
|
436
|
+
context,
|
|
437
|
+
syntaxErrorCount: 0,
|
|
438
|
+
semanticErrorCount: 0,
|
|
439
|
+
semantic,
|
|
440
|
+
indentation,
|
|
441
|
+
...recovery,
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
// -- recovery ---------------------------------------------------------
|
|
445
|
+
#readRecoverySingular(handle) {
|
|
446
|
+
const h = handle;
|
|
447
|
+
const kindVal = this.#port.diagnosticRecoveryKind(h);
|
|
448
|
+
const recoveryKind = kindVal === 0 ? null : kindVal;
|
|
449
|
+
const terminal = this.#port.diagnosticRecoveryTerminal(h);
|
|
450
|
+
const resume = this.#port.diagnosticRecoveryResume(h);
|
|
451
|
+
const lhs = this.#port.diagnosticRecoveryLhsVariable(h);
|
|
452
|
+
const production = this.#port.diagnosticRecoveryProduction(h);
|
|
453
|
+
const occurrence = this.#port.diagnosticRecoveryOccurrence(h);
|
|
454
|
+
return {
|
|
455
|
+
recoveryKind,
|
|
456
|
+
recoveryTerminal: terminal,
|
|
457
|
+
recoveryResume: resume,
|
|
458
|
+
recoveryLhsVariable: lhs,
|
|
459
|
+
recoveryProduction: production,
|
|
460
|
+
recoveryOccurrence: occurrence,
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
#readRecoveryRecorded(handle, idx) {
|
|
464
|
+
const h = handle;
|
|
465
|
+
const kindVal = this.#port.recordedRecoveryKind(h, idx);
|
|
466
|
+
const recoveryKind = kindVal === 0 ? null : kindVal;
|
|
467
|
+
const terminal = this.#port.recordedRecoveryTerminal(h, idx);
|
|
468
|
+
const resume = this.#port.recordedRecoveryResume(h, idx);
|
|
469
|
+
const lhs = this.#port.recordedRecoveryLhsVariable(h, idx);
|
|
470
|
+
const production = this.#port.recordedRecoveryProduction(h, idx);
|
|
471
|
+
const occurrence = this.#port.recordedRecoveryOccurrence(h, idx);
|
|
472
|
+
return {
|
|
473
|
+
recoveryKind,
|
|
474
|
+
recoveryTerminal: terminal,
|
|
475
|
+
recoveryResume: resume,
|
|
476
|
+
recoveryLhsVariable: lhs,
|
|
477
|
+
recoveryProduction: production,
|
|
478
|
+
recoveryOccurrence: occurrence,
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
// -- tree editing ----------------------------------------------------
|
|
482
|
+
appendChildren(parent, chain) {
|
|
483
|
+
const h = this.#requireHandle();
|
|
484
|
+
this.#checkStatus(this.#port.treeAppendChildren(h, toNodeAddress(parent), toNodeAddress(chain)));
|
|
485
|
+
}
|
|
486
|
+
insertBefore(target, chain) {
|
|
487
|
+
const h = this.#requireHandle();
|
|
488
|
+
this.#checkStatus(this.#port.treeInsertBefore(h, toNodeAddress(target), toNodeAddress(chain)));
|
|
489
|
+
}
|
|
490
|
+
insertAfter(target, chain) {
|
|
491
|
+
const h = this.#requireHandle();
|
|
492
|
+
this.#checkStatus(this.#port.treeInsertAfter(h, toNodeAddress(target), toNodeAddress(chain)));
|
|
493
|
+
}
|
|
494
|
+
removeSiblings(node, count) {
|
|
495
|
+
const h = this.#requireHandle();
|
|
496
|
+
const { status, head } = this.#port.treeRemoveSiblings(h, toNodeAddress(node), count);
|
|
497
|
+
this.#checkStatus(status);
|
|
498
|
+
return optNode(this, head);
|
|
499
|
+
}
|
|
500
|
+
removeSelf(node) {
|
|
501
|
+
const h = this.#requireHandle();
|
|
502
|
+
const { status, head } = this.#port.treeRemoveSelf(h, toNodeAddress(node));
|
|
503
|
+
this.#checkStatus(status);
|
|
504
|
+
return optNode(this, head);
|
|
505
|
+
}
|
|
506
|
+
promoteChildrenOverWrapper(wrapper) {
|
|
507
|
+
const h = this.#requireHandle();
|
|
508
|
+
const { status, head } = this.#port.treePromoteChildrenOverWrapper(h, toNodeAddress(wrapper));
|
|
509
|
+
this.#checkStatus(status);
|
|
510
|
+
return optNode(this, head);
|
|
511
|
+
}
|
|
512
|
+
cleanChildren(node) {
|
|
513
|
+
const h = this.#requireHandle();
|
|
514
|
+
const { status, head } = this.#port.treeCleanChildren(h, toNodeAddress(node));
|
|
515
|
+
this.#checkStatus(status);
|
|
516
|
+
return optNode(this, head);
|
|
517
|
+
}
|
|
518
|
+
unlinkWrapper(wrapper) {
|
|
519
|
+
const h = this.#requireHandle();
|
|
520
|
+
this.#checkStatus(this.#port.treeUnlinkWrapper(h, toNodeAddress(wrapper)));
|
|
521
|
+
}
|
|
522
|
+
insertChildrenAt(parent, index, chain) {
|
|
523
|
+
const h = this.#requireHandle();
|
|
524
|
+
this.#checkStatus(this.#port.treeInsertChildrenAt(h, toNodeAddress(parent), index, toNodeAddress(chain)));
|
|
525
|
+
}
|
|
526
|
+
removeChildrenAt(parent, index, count) {
|
|
527
|
+
const h = this.#requireHandle();
|
|
528
|
+
const { status, head } = this.#port.treeRemoveChildrenAt(h, toNodeAddress(parent), index, count);
|
|
529
|
+
this.#checkStatus(status);
|
|
530
|
+
return optNode(this, head);
|
|
531
|
+
}
|
|
532
|
+
// -- symbol table ----------------------------------------------------
|
|
533
|
+
symbolNameAt(index) {
|
|
534
|
+
const h = this.#requireHandle();
|
|
535
|
+
return this.#port.symbolNameAt(h, index);
|
|
536
|
+
}
|
|
537
|
+
symbolIsTerminal(index) {
|
|
538
|
+
const h = this.#requireHandle();
|
|
539
|
+
return this.#port.symbolIsTerminal(h, index);
|
|
540
|
+
}
|
|
541
|
+
variableNameAt(index) {
|
|
542
|
+
const h = this.#requireHandle();
|
|
543
|
+
return this.#port.variableNameAt(h, index);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Pre-order tree walker over the last successful parse, yielding one
|
|
548
|
+
* {@link WalkStep} per node. Shares the session's node storage: close the
|
|
549
|
+
* walker (or use `using`) before closing the session or parsing again.
|
|
550
|
+
* Created by {@link Session.walk}.
|
|
551
|
+
*/
|
|
552
|
+
export class Walker {
|
|
553
|
+
#session;
|
|
554
|
+
#port;
|
|
555
|
+
#handle;
|
|
556
|
+
constructor(session, port, handle) {
|
|
557
|
+
this.#session = session;
|
|
558
|
+
this.#port = port;
|
|
559
|
+
this.#handle = handle;
|
|
560
|
+
}
|
|
561
|
+
next() {
|
|
562
|
+
if (this.#handle === null)
|
|
563
|
+
return { done: true, value: undefined };
|
|
564
|
+
const step = this.#port.walkerNext(this.#handle);
|
|
565
|
+
if (step === null)
|
|
566
|
+
return { done: true, value: undefined };
|
|
567
|
+
return {
|
|
568
|
+
done: false,
|
|
569
|
+
value: {
|
|
570
|
+
node: new Node(this.#session, step.node),
|
|
571
|
+
depth: step.depth,
|
|
572
|
+
isSemanticError: step.isSemanticError,
|
|
573
|
+
},
|
|
574
|
+
};
|
|
575
|
+
}
|
|
576
|
+
[Symbol.iterator]() {
|
|
577
|
+
return this;
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Prunes the children of the last yielded step; iteration continues with
|
|
581
|
+
* its next sibling. No effect without a last step.
|
|
582
|
+
*/
|
|
583
|
+
skipChildren() {
|
|
584
|
+
if (this.#handle === null)
|
|
585
|
+
return;
|
|
586
|
+
this.#port.walkerSkipChildren(this.#handle);
|
|
587
|
+
}
|
|
588
|
+
close() {
|
|
589
|
+
if (this.#handle !== null) {
|
|
590
|
+
this.#port.walkerDestroy(this.#handle);
|
|
591
|
+
this.#handle = null;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
/** For `using walker = session.walk(...)`. */
|
|
595
|
+
[Symbol.dispose]() {
|
|
596
|
+
this.close();
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAcpE,SAAS,cAAc;IAGrB,OAAO;QACL,SAAS,EAAE,EAAE;QACb,cAAc,EAAE,GAAG;QACnB,qBAAqB,EAAE,KAAK;QAC5B,qBAAqB,EAAE,CAAC;QACxB,SAAS,EAAE,CAAC;QACZ,qBAAqB,EAAE,CAAC,GAAG;QAC3B,mBAAmB,EAAE,CAAC;QACtB,gBAAgB,EAAE,EAAE;KACrB,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,IAA4B;IACjD,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC1C,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;IAClD,OAAQ,IAAa,CAAC,OAAO,CAAC;AAChC,CAAC;AAED,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,IAAI,KAAK,YAAY,CAAC;AAC/B,CAAC;AAED,SAAS,OAAO,CAAC,OAAgB,EAAE,IAAY;IAC7C,IAAI,SAAS,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACjC,OAAO,IAAI,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AACjC,CAAC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AC,OAAO,CAAC,CAAC;QACjD,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QAC3D,OAAO;YACL,IAAI,EAAE,KAAK;YACX,KAAK,EAAE;gBACL,IAAI,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC;gBACxC,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,eAAe,EAAE,IAAI,CAAC,eAAe;aACtC;SACF,CAAC;IACJ,CAAC;IAED,CAAC,MAAM,CAAC,QAAQ,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACH,YAAY;QACV,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI;YAAE,OAAO;QAClC,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK;QACH,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;YAC1B,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACvC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,CAAC;IACH,CAAC;IAED,8CAA8C;IAC9C,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;CACF"}
|
package/dist/text.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UTF-8 helpers shared by the core. `TextEncoder`/`TextDecoder` are provided
|
|
3
|
+
* by Node, Bun, and Deno alike, so the core never touches `Buffer`.
|
|
4
|
+
*/
|
|
5
|
+
export declare function encodeUtf8(text: string): Uint8Array;
|
|
6
|
+
export declare function byteLengthUtf8(text: string): number;
|
|
7
|
+
export declare function decodeUtf8(bytes: Uint8Array): string;
|
package/dist/text.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UTF-8 helpers shared by the core. `TextEncoder`/`TextDecoder` are provided
|
|
3
|
+
* by Node, Bun, and Deno alike, so the core never touches `Buffer`.
|
|
4
|
+
*/
|
|
5
|
+
const encoder = new TextEncoder();
|
|
6
|
+
const decoder = new TextDecoder();
|
|
7
|
+
export function encodeUtf8(text) {
|
|
8
|
+
return encoder.encode(text);
|
|
9
|
+
}
|
|
10
|
+
export function byteLengthUtf8(text) {
|
|
11
|
+
return encoder.encode(text).length;
|
|
12
|
+
}
|
|
13
|
+
export function decodeUtf8(bytes) {
|
|
14
|
+
return decoder.decode(bytes);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=text.js.map
|
package/dist/text.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAClC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAiB;IAC1C,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC"}
|