@vuu-ui/vuu-datatable 0.8.18-debug → 0.8.19-debug
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/cjs/index.js +2 -3396
- package/cjs/index.js.map +4 -4
- package/esm/index.js +1 -3430
- package/esm/index.js.map +4 -4
- package/package.json +10 -10
package/cjs/index.js
CHANGED
|
@@ -26,32 +26,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var __accessCheck = (obj, member, msg) => {
|
|
30
|
-
if (!member.has(obj))
|
|
31
|
-
throw TypeError("Cannot " + msg);
|
|
32
|
-
};
|
|
33
|
-
var __privateGet = (obj, member, getter) => {
|
|
34
|
-
__accessCheck(obj, member, "read from private field");
|
|
35
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
36
|
-
};
|
|
37
|
-
var __privateAdd = (obj, member, value) => {
|
|
38
|
-
if (member.has(obj))
|
|
39
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
40
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
41
|
-
};
|
|
42
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
43
|
-
__accessCheck(obj, member, "write to private field");
|
|
44
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
45
|
-
return value;
|
|
46
|
-
};
|
|
47
|
-
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
48
|
-
set _(value) {
|
|
49
|
-
__privateSet(obj, member, value, setter);
|
|
50
|
-
},
|
|
51
|
-
get _() {
|
|
52
|
-
return __privateGet(obj, member, getter);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
29
|
|
|
56
30
|
// src/index.ts
|
|
57
31
|
var src_exports = {};
|
|
@@ -80,3375 +54,7 @@ var FilterTable = ({
|
|
|
80
54
|
|
|
81
55
|
// src/json-table/JsonTable.tsx
|
|
82
56
|
var import_vuu_table2 = require("@vuu-ui/vuu-table");
|
|
83
|
-
|
|
84
|
-
// ../../node_modules/@lezer/common/dist/index.js
|
|
85
|
-
var DefaultBufferLength = 1024;
|
|
86
|
-
var nextPropID = 0;
|
|
87
|
-
var Range = class {
|
|
88
|
-
constructor(from, to) {
|
|
89
|
-
this.from = from;
|
|
90
|
-
this.to = to;
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
var NodeProp = class {
|
|
94
|
-
/// Create a new node prop type.
|
|
95
|
-
constructor(config = {}) {
|
|
96
|
-
this.id = nextPropID++;
|
|
97
|
-
this.perNode = !!config.perNode;
|
|
98
|
-
this.deserialize = config.deserialize || (() => {
|
|
99
|
-
throw new Error("This node type doesn't define a deserialize function");
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
/// This is meant to be used with
|
|
103
|
-
/// [`NodeSet.extend`](#common.NodeSet.extend) or
|
|
104
|
-
/// [`LRParser.configure`](#lr.ParserConfig.props) to compute
|
|
105
|
-
/// prop values for each node type in the set. Takes a [match
|
|
106
|
-
/// object](#common.NodeType^match) or function that returns undefined
|
|
107
|
-
/// if the node type doesn't get this prop, and the prop's value if
|
|
108
|
-
/// it does.
|
|
109
|
-
add(match) {
|
|
110
|
-
if (this.perNode)
|
|
111
|
-
throw new RangeError("Can't add per-node props to node types");
|
|
112
|
-
if (typeof match != "function")
|
|
113
|
-
match = NodeType.match(match);
|
|
114
|
-
return (type) => {
|
|
115
|
-
let result = match(type);
|
|
116
|
-
return result === void 0 ? null : [this, result];
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
NodeProp.closedBy = new NodeProp({ deserialize: (str) => str.split(" ") });
|
|
121
|
-
NodeProp.openedBy = new NodeProp({ deserialize: (str) => str.split(" ") });
|
|
122
|
-
NodeProp.group = new NodeProp({ deserialize: (str) => str.split(" ") });
|
|
123
|
-
NodeProp.contextHash = new NodeProp({ perNode: true });
|
|
124
|
-
NodeProp.lookAhead = new NodeProp({ perNode: true });
|
|
125
|
-
NodeProp.mounted = new NodeProp({ perNode: true });
|
|
126
|
-
var noProps = /* @__PURE__ */ Object.create(null);
|
|
127
|
-
var NodeType = class _NodeType {
|
|
128
|
-
/// @internal
|
|
129
|
-
constructor(name, props, id, flags = 0) {
|
|
130
|
-
this.name = name;
|
|
131
|
-
this.props = props;
|
|
132
|
-
this.id = id;
|
|
133
|
-
this.flags = flags;
|
|
134
|
-
}
|
|
135
|
-
/// Define a node type.
|
|
136
|
-
static define(spec) {
|
|
137
|
-
let props = spec.props && spec.props.length ? /* @__PURE__ */ Object.create(null) : noProps;
|
|
138
|
-
let flags = (spec.top ? 1 : 0) | (spec.skipped ? 2 : 0) | (spec.error ? 4 : 0) | (spec.name == null ? 8 : 0);
|
|
139
|
-
let type = new _NodeType(spec.name || "", props, spec.id, flags);
|
|
140
|
-
if (spec.props)
|
|
141
|
-
for (let src of spec.props) {
|
|
142
|
-
if (!Array.isArray(src))
|
|
143
|
-
src = src(type);
|
|
144
|
-
if (src) {
|
|
145
|
-
if (src[0].perNode)
|
|
146
|
-
throw new RangeError("Can't store a per-node prop on a node type");
|
|
147
|
-
props[src[0].id] = src[1];
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return type;
|
|
151
|
-
}
|
|
152
|
-
/// Retrieves a node prop for this type. Will return `undefined` if
|
|
153
|
-
/// the prop isn't present on this node.
|
|
154
|
-
prop(prop) {
|
|
155
|
-
return this.props[prop.id];
|
|
156
|
-
}
|
|
157
|
-
/// True when this is the top node of a grammar.
|
|
158
|
-
get isTop() {
|
|
159
|
-
return (this.flags & 1) > 0;
|
|
160
|
-
}
|
|
161
|
-
/// True when this node is produced by a skip rule.
|
|
162
|
-
get isSkipped() {
|
|
163
|
-
return (this.flags & 2) > 0;
|
|
164
|
-
}
|
|
165
|
-
/// Indicates whether this is an error node.
|
|
166
|
-
get isError() {
|
|
167
|
-
return (this.flags & 4) > 0;
|
|
168
|
-
}
|
|
169
|
-
/// When true, this node type doesn't correspond to a user-declared
|
|
170
|
-
/// named node, for example because it is used to cache repetition.
|
|
171
|
-
get isAnonymous() {
|
|
172
|
-
return (this.flags & 8) > 0;
|
|
173
|
-
}
|
|
174
|
-
/// Returns true when this node's name or one of its
|
|
175
|
-
/// [groups](#common.NodeProp^group) matches the given string.
|
|
176
|
-
is(name) {
|
|
177
|
-
if (typeof name == "string") {
|
|
178
|
-
if (this.name == name)
|
|
179
|
-
return true;
|
|
180
|
-
let group = this.prop(NodeProp.group);
|
|
181
|
-
return group ? group.indexOf(name) > -1 : false;
|
|
182
|
-
}
|
|
183
|
-
return this.id == name;
|
|
184
|
-
}
|
|
185
|
-
/// Create a function from node types to arbitrary values by
|
|
186
|
-
/// specifying an object whose property names are node or
|
|
187
|
-
/// [group](#common.NodeProp^group) names. Often useful with
|
|
188
|
-
/// [`NodeProp.add`](#common.NodeProp.add). You can put multiple
|
|
189
|
-
/// names, separated by spaces, in a single property name to map
|
|
190
|
-
/// multiple node names to a single value.
|
|
191
|
-
static match(map) {
|
|
192
|
-
let direct = /* @__PURE__ */ Object.create(null);
|
|
193
|
-
for (let prop in map)
|
|
194
|
-
for (let name of prop.split(" "))
|
|
195
|
-
direct[name] = map[prop];
|
|
196
|
-
return (node) => {
|
|
197
|
-
for (let groups = node.prop(NodeProp.group), i = -1; i < (groups ? groups.length : 0); i++) {
|
|
198
|
-
let found = direct[i < 0 ? node.name : groups[i]];
|
|
199
|
-
if (found)
|
|
200
|
-
return found;
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
NodeType.none = new NodeType(
|
|
206
|
-
"",
|
|
207
|
-
/* @__PURE__ */ Object.create(null),
|
|
208
|
-
0,
|
|
209
|
-
8
|
|
210
|
-
/* NodeFlag.Anonymous */
|
|
211
|
-
);
|
|
212
|
-
var NodeSet = class _NodeSet {
|
|
213
|
-
/// Create a set with the given types. The `id` property of each
|
|
214
|
-
/// type should correspond to its position within the array.
|
|
215
|
-
constructor(types) {
|
|
216
|
-
this.types = types;
|
|
217
|
-
for (let i = 0; i < types.length; i++)
|
|
218
|
-
if (types[i].id != i)
|
|
219
|
-
throw new RangeError("Node type ids should correspond to array positions when creating a node set");
|
|
220
|
-
}
|
|
221
|
-
/// Create a copy of this set with some node properties added. The
|
|
222
|
-
/// arguments to this method can be created with
|
|
223
|
-
/// [`NodeProp.add`](#common.NodeProp.add).
|
|
224
|
-
extend(...props) {
|
|
225
|
-
let newTypes = [];
|
|
226
|
-
for (let type of this.types) {
|
|
227
|
-
let newProps = null;
|
|
228
|
-
for (let source of props) {
|
|
229
|
-
let add = source(type);
|
|
230
|
-
if (add) {
|
|
231
|
-
if (!newProps)
|
|
232
|
-
newProps = Object.assign({}, type.props);
|
|
233
|
-
newProps[add[0].id] = add[1];
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
newTypes.push(newProps ? new NodeType(type.name, newProps, type.id, type.flags) : type);
|
|
237
|
-
}
|
|
238
|
-
return new _NodeSet(newTypes);
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
var CachedNode = /* @__PURE__ */ new WeakMap();
|
|
242
|
-
var CachedInnerNode = /* @__PURE__ */ new WeakMap();
|
|
243
|
-
var IterMode;
|
|
244
|
-
(function(IterMode2) {
|
|
245
|
-
IterMode2[IterMode2["ExcludeBuffers"] = 1] = "ExcludeBuffers";
|
|
246
|
-
IterMode2[IterMode2["IncludeAnonymous"] = 2] = "IncludeAnonymous";
|
|
247
|
-
IterMode2[IterMode2["IgnoreMounts"] = 4] = "IgnoreMounts";
|
|
248
|
-
IterMode2[IterMode2["IgnoreOverlays"] = 8] = "IgnoreOverlays";
|
|
249
|
-
})(IterMode || (IterMode = {}));
|
|
250
|
-
var Tree = class _Tree {
|
|
251
|
-
/// Construct a new tree. See also [`Tree.build`](#common.Tree^build).
|
|
252
|
-
constructor(type, children, positions, length, props) {
|
|
253
|
-
this.type = type;
|
|
254
|
-
this.children = children;
|
|
255
|
-
this.positions = positions;
|
|
256
|
-
this.length = length;
|
|
257
|
-
this.props = null;
|
|
258
|
-
if (props && props.length) {
|
|
259
|
-
this.props = /* @__PURE__ */ Object.create(null);
|
|
260
|
-
for (let [prop, value] of props)
|
|
261
|
-
this.props[typeof prop == "number" ? prop : prop.id] = value;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
/// @internal
|
|
265
|
-
toString() {
|
|
266
|
-
let mounted = this.prop(NodeProp.mounted);
|
|
267
|
-
if (mounted && !mounted.overlay)
|
|
268
|
-
return mounted.tree.toString();
|
|
269
|
-
let children = "";
|
|
270
|
-
for (let ch of this.children) {
|
|
271
|
-
let str = ch.toString();
|
|
272
|
-
if (str) {
|
|
273
|
-
if (children)
|
|
274
|
-
children += ",";
|
|
275
|
-
children += str;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
return !this.type.name ? children : (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (children.length ? "(" + children + ")" : "");
|
|
279
|
-
}
|
|
280
|
-
/// Get a [tree cursor](#common.TreeCursor) positioned at the top of
|
|
281
|
-
/// the tree. Mode can be used to [control](#common.IterMode) which
|
|
282
|
-
/// nodes the cursor visits.
|
|
283
|
-
cursor(mode = 0) {
|
|
284
|
-
return new TreeCursor(this.topNode, mode);
|
|
285
|
-
}
|
|
286
|
-
/// Get a [tree cursor](#common.TreeCursor) pointing into this tree
|
|
287
|
-
/// at the given position and side (see
|
|
288
|
-
/// [`moveTo`](#common.TreeCursor.moveTo).
|
|
289
|
-
cursorAt(pos, side = 0, mode = 0) {
|
|
290
|
-
let scope = CachedNode.get(this) || this.topNode;
|
|
291
|
-
let cursor = new TreeCursor(scope);
|
|
292
|
-
cursor.moveTo(pos, side);
|
|
293
|
-
CachedNode.set(this, cursor._tree);
|
|
294
|
-
return cursor;
|
|
295
|
-
}
|
|
296
|
-
/// Get a [syntax node](#common.SyntaxNode) object for the top of the
|
|
297
|
-
/// tree.
|
|
298
|
-
get topNode() {
|
|
299
|
-
return new TreeNode(this, 0, 0, null);
|
|
300
|
-
}
|
|
301
|
-
/// Get the [syntax node](#common.SyntaxNode) at the given position.
|
|
302
|
-
/// If `side` is -1, this will move into nodes that end at the
|
|
303
|
-
/// position. If 1, it'll move into nodes that start at the
|
|
304
|
-
/// position. With 0, it'll only enter nodes that cover the position
|
|
305
|
-
/// from both sides.
|
|
306
|
-
///
|
|
307
|
-
/// Note that this will not enter
|
|
308
|
-
/// [overlays](#common.MountedTree.overlay), and you often want
|
|
309
|
-
/// [`resolveInner`](#common.Tree.resolveInner) instead.
|
|
310
|
-
resolve(pos, side = 0) {
|
|
311
|
-
let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);
|
|
312
|
-
CachedNode.set(this, node);
|
|
313
|
-
return node;
|
|
314
|
-
}
|
|
315
|
-
/// Like [`resolve`](#common.Tree.resolve), but will enter
|
|
316
|
-
/// [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
|
|
317
|
-
/// pointing into the innermost overlaid tree at the given position
|
|
318
|
-
/// (with parent links going through all parent structure, including
|
|
319
|
-
/// the host trees).
|
|
320
|
-
resolveInner(pos, side = 0) {
|
|
321
|
-
let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);
|
|
322
|
-
CachedInnerNode.set(this, node);
|
|
323
|
-
return node;
|
|
324
|
-
}
|
|
325
|
-
/// Iterate over the tree and its children, calling `enter` for any
|
|
326
|
-
/// node that touches the `from`/`to` region (if given) before
|
|
327
|
-
/// running over such a node's children, and `leave` (if given) when
|
|
328
|
-
/// leaving the node. When `enter` returns `false`, that node will
|
|
329
|
-
/// not have its children iterated over (or `leave` called).
|
|
330
|
-
iterate(spec) {
|
|
331
|
-
let { enter, leave, from = 0, to = this.length } = spec;
|
|
332
|
-
let mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0;
|
|
333
|
-
for (let c = this.cursor(mode | IterMode.IncludeAnonymous); ; ) {
|
|
334
|
-
let entered = false;
|
|
335
|
-
if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) {
|
|
336
|
-
if (c.firstChild())
|
|
337
|
-
continue;
|
|
338
|
-
entered = true;
|
|
339
|
-
}
|
|
340
|
-
for (; ; ) {
|
|
341
|
-
if (entered && leave && (anon || !c.type.isAnonymous))
|
|
342
|
-
leave(c);
|
|
343
|
-
if (c.nextSibling())
|
|
344
|
-
break;
|
|
345
|
-
if (!c.parent())
|
|
346
|
-
return;
|
|
347
|
-
entered = true;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
/// Get the value of the given [node prop](#common.NodeProp) for this
|
|
352
|
-
/// node. Works with both per-node and per-type props.
|
|
353
|
-
prop(prop) {
|
|
354
|
-
return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : void 0;
|
|
355
|
-
}
|
|
356
|
-
/// Returns the node's [per-node props](#common.NodeProp.perNode) in a
|
|
357
|
-
/// format that can be passed to the [`Tree`](#common.Tree)
|
|
358
|
-
/// constructor.
|
|
359
|
-
get propValues() {
|
|
360
|
-
let result = [];
|
|
361
|
-
if (this.props)
|
|
362
|
-
for (let id in this.props)
|
|
363
|
-
result.push([+id, this.props[id]]);
|
|
364
|
-
return result;
|
|
365
|
-
}
|
|
366
|
-
/// Balance the direct children of this tree, producing a copy of
|
|
367
|
-
/// which may have children grouped into subtrees with type
|
|
368
|
-
/// [`NodeType.none`](#common.NodeType^none).
|
|
369
|
-
balance(config = {}) {
|
|
370
|
-
return this.children.length <= 8 ? this : balanceRange(NodeType.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new _Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new _Tree(NodeType.none, children, positions, length)));
|
|
371
|
-
}
|
|
372
|
-
/// Build a tree from a postfix-ordered buffer of node information,
|
|
373
|
-
/// or a cursor over such a buffer.
|
|
374
|
-
static build(data) {
|
|
375
|
-
return buildTree(data);
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
Tree.empty = new Tree(NodeType.none, [], [], 0);
|
|
379
|
-
var FlatBufferCursor = class _FlatBufferCursor {
|
|
380
|
-
constructor(buffer, index) {
|
|
381
|
-
this.buffer = buffer;
|
|
382
|
-
this.index = index;
|
|
383
|
-
}
|
|
384
|
-
get id() {
|
|
385
|
-
return this.buffer[this.index - 4];
|
|
386
|
-
}
|
|
387
|
-
get start() {
|
|
388
|
-
return this.buffer[this.index - 3];
|
|
389
|
-
}
|
|
390
|
-
get end() {
|
|
391
|
-
return this.buffer[this.index - 2];
|
|
392
|
-
}
|
|
393
|
-
get size() {
|
|
394
|
-
return this.buffer[this.index - 1];
|
|
395
|
-
}
|
|
396
|
-
get pos() {
|
|
397
|
-
return this.index;
|
|
398
|
-
}
|
|
399
|
-
next() {
|
|
400
|
-
this.index -= 4;
|
|
401
|
-
}
|
|
402
|
-
fork() {
|
|
403
|
-
return new _FlatBufferCursor(this.buffer, this.index);
|
|
404
|
-
}
|
|
405
|
-
};
|
|
406
|
-
var TreeBuffer = class _TreeBuffer {
|
|
407
|
-
/// Create a tree buffer.
|
|
408
|
-
constructor(buffer, length, set) {
|
|
409
|
-
this.buffer = buffer;
|
|
410
|
-
this.length = length;
|
|
411
|
-
this.set = set;
|
|
412
|
-
}
|
|
413
|
-
/// @internal
|
|
414
|
-
get type() {
|
|
415
|
-
return NodeType.none;
|
|
416
|
-
}
|
|
417
|
-
/// @internal
|
|
418
|
-
toString() {
|
|
419
|
-
let result = [];
|
|
420
|
-
for (let index = 0; index < this.buffer.length; ) {
|
|
421
|
-
result.push(this.childString(index));
|
|
422
|
-
index = this.buffer[index + 3];
|
|
423
|
-
}
|
|
424
|
-
return result.join(",");
|
|
425
|
-
}
|
|
426
|
-
/// @internal
|
|
427
|
-
childString(index) {
|
|
428
|
-
let id = this.buffer[index], endIndex = this.buffer[index + 3];
|
|
429
|
-
let type = this.set.types[id], result = type.name;
|
|
430
|
-
if (/\W/.test(result) && !type.isError)
|
|
431
|
-
result = JSON.stringify(result);
|
|
432
|
-
index += 4;
|
|
433
|
-
if (endIndex == index)
|
|
434
|
-
return result;
|
|
435
|
-
let children = [];
|
|
436
|
-
while (index < endIndex) {
|
|
437
|
-
children.push(this.childString(index));
|
|
438
|
-
index = this.buffer[index + 3];
|
|
439
|
-
}
|
|
440
|
-
return result + "(" + children.join(",") + ")";
|
|
441
|
-
}
|
|
442
|
-
/// @internal
|
|
443
|
-
findChild(startIndex, endIndex, dir, pos, side) {
|
|
444
|
-
let { buffer } = this, pick = -1;
|
|
445
|
-
for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {
|
|
446
|
-
if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {
|
|
447
|
-
pick = i;
|
|
448
|
-
if (dir > 0)
|
|
449
|
-
break;
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
return pick;
|
|
453
|
-
}
|
|
454
|
-
/// @internal
|
|
455
|
-
slice(startI, endI, from) {
|
|
456
|
-
let b = this.buffer;
|
|
457
|
-
let copy = new Uint16Array(endI - startI), len = 0;
|
|
458
|
-
for (let i = startI, j = 0; i < endI; ) {
|
|
459
|
-
copy[j++] = b[i++];
|
|
460
|
-
copy[j++] = b[i++] - from;
|
|
461
|
-
let to = copy[j++] = b[i++] - from;
|
|
462
|
-
copy[j++] = b[i++] - startI;
|
|
463
|
-
len = Math.max(len, to);
|
|
464
|
-
}
|
|
465
|
-
return new _TreeBuffer(copy, len, this.set);
|
|
466
|
-
}
|
|
467
|
-
};
|
|
468
|
-
function checkSide(side, pos, from, to) {
|
|
469
|
-
switch (side) {
|
|
470
|
-
case -2:
|
|
471
|
-
return from < pos;
|
|
472
|
-
case -1:
|
|
473
|
-
return to >= pos && from < pos;
|
|
474
|
-
case 0:
|
|
475
|
-
return from < pos && to > pos;
|
|
476
|
-
case 1:
|
|
477
|
-
return from <= pos && to > pos;
|
|
478
|
-
case 2:
|
|
479
|
-
return to > pos;
|
|
480
|
-
case 4:
|
|
481
|
-
return true;
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
function enterUnfinishedNodesBefore(node, pos) {
|
|
485
|
-
let scan = node.childBefore(pos);
|
|
486
|
-
while (scan) {
|
|
487
|
-
let last = scan.lastChild;
|
|
488
|
-
if (!last || last.to != scan.to)
|
|
489
|
-
break;
|
|
490
|
-
if (last.type.isError && last.from == last.to) {
|
|
491
|
-
node = scan;
|
|
492
|
-
scan = last.prevSibling;
|
|
493
|
-
} else {
|
|
494
|
-
scan = last;
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
return node;
|
|
498
|
-
}
|
|
499
|
-
function resolveNode(node, pos, side, overlays) {
|
|
500
|
-
var _a;
|
|
501
|
-
while (node.from == node.to || (side < 1 ? node.from >= pos : node.from > pos) || (side > -1 ? node.to <= pos : node.to < pos)) {
|
|
502
|
-
let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;
|
|
503
|
-
if (!parent)
|
|
504
|
-
return node;
|
|
505
|
-
node = parent;
|
|
506
|
-
}
|
|
507
|
-
let mode = overlays ? 0 : IterMode.IgnoreOverlays;
|
|
508
|
-
if (overlays)
|
|
509
|
-
for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {
|
|
510
|
-
if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)
|
|
511
|
-
node = parent;
|
|
512
|
-
}
|
|
513
|
-
for (; ; ) {
|
|
514
|
-
let inner = node.enter(pos, side, mode);
|
|
515
|
-
if (!inner)
|
|
516
|
-
return node;
|
|
517
|
-
node = inner;
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
var TreeNode = class _TreeNode {
|
|
521
|
-
constructor(_tree, from, index, _parent) {
|
|
522
|
-
this._tree = _tree;
|
|
523
|
-
this.from = from;
|
|
524
|
-
this.index = index;
|
|
525
|
-
this._parent = _parent;
|
|
526
|
-
}
|
|
527
|
-
get type() {
|
|
528
|
-
return this._tree.type;
|
|
529
|
-
}
|
|
530
|
-
get name() {
|
|
531
|
-
return this._tree.type.name;
|
|
532
|
-
}
|
|
533
|
-
get to() {
|
|
534
|
-
return this.from + this._tree.length;
|
|
535
|
-
}
|
|
536
|
-
nextChild(i, dir, pos, side, mode = 0) {
|
|
537
|
-
for (let parent = this; ; ) {
|
|
538
|
-
for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
|
|
539
|
-
let next = children[i], start = positions[i] + parent.from;
|
|
540
|
-
if (!checkSide(side, pos, start, start + next.length))
|
|
541
|
-
continue;
|
|
542
|
-
if (next instanceof TreeBuffer) {
|
|
543
|
-
if (mode & IterMode.ExcludeBuffers)
|
|
544
|
-
continue;
|
|
545
|
-
let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
|
|
546
|
-
if (index > -1)
|
|
547
|
-
return new BufferNode(new BufferContext(parent, next, i, start), null, index);
|
|
548
|
-
} else if (mode & IterMode.IncludeAnonymous || (!next.type.isAnonymous || hasChild(next))) {
|
|
549
|
-
let mounted;
|
|
550
|
-
if (!(mode & IterMode.IgnoreMounts) && next.props && (mounted = next.prop(NodeProp.mounted)) && !mounted.overlay)
|
|
551
|
-
return new _TreeNode(mounted.tree, start, i, parent);
|
|
552
|
-
let inner = new _TreeNode(next, start, i, parent);
|
|
553
|
-
return mode & IterMode.IncludeAnonymous || !inner.type.isAnonymous ? inner : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
if (mode & IterMode.IncludeAnonymous || !parent.type.isAnonymous)
|
|
557
|
-
return null;
|
|
558
|
-
if (parent.index >= 0)
|
|
559
|
-
i = parent.index + dir;
|
|
560
|
-
else
|
|
561
|
-
i = dir < 0 ? -1 : parent._parent._tree.children.length;
|
|
562
|
-
parent = parent._parent;
|
|
563
|
-
if (!parent)
|
|
564
|
-
return null;
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
get firstChild() {
|
|
568
|
-
return this.nextChild(
|
|
569
|
-
0,
|
|
570
|
-
1,
|
|
571
|
-
0,
|
|
572
|
-
4
|
|
573
|
-
/* Side.DontCare */
|
|
574
|
-
);
|
|
575
|
-
}
|
|
576
|
-
get lastChild() {
|
|
577
|
-
return this.nextChild(
|
|
578
|
-
this._tree.children.length - 1,
|
|
579
|
-
-1,
|
|
580
|
-
0,
|
|
581
|
-
4
|
|
582
|
-
/* Side.DontCare */
|
|
583
|
-
);
|
|
584
|
-
}
|
|
585
|
-
childAfter(pos) {
|
|
586
|
-
return this.nextChild(
|
|
587
|
-
0,
|
|
588
|
-
1,
|
|
589
|
-
pos,
|
|
590
|
-
2
|
|
591
|
-
/* Side.After */
|
|
592
|
-
);
|
|
593
|
-
}
|
|
594
|
-
childBefore(pos) {
|
|
595
|
-
return this.nextChild(
|
|
596
|
-
this._tree.children.length - 1,
|
|
597
|
-
-1,
|
|
598
|
-
pos,
|
|
599
|
-
-2
|
|
600
|
-
/* Side.Before */
|
|
601
|
-
);
|
|
602
|
-
}
|
|
603
|
-
enter(pos, side, mode = 0) {
|
|
604
|
-
let mounted;
|
|
605
|
-
if (!(mode & IterMode.IgnoreOverlays) && (mounted = this._tree.prop(NodeProp.mounted)) && mounted.overlay) {
|
|
606
|
-
let rPos = pos - this.from;
|
|
607
|
-
for (let { from, to } of mounted.overlay) {
|
|
608
|
-
if ((side > 0 ? from <= rPos : from < rPos) && (side < 0 ? to >= rPos : to > rPos))
|
|
609
|
-
return new _TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
return this.nextChild(0, 1, pos, side, mode);
|
|
613
|
-
}
|
|
614
|
-
nextSignificantParent() {
|
|
615
|
-
let val = this;
|
|
616
|
-
while (val.type.isAnonymous && val._parent)
|
|
617
|
-
val = val._parent;
|
|
618
|
-
return val;
|
|
619
|
-
}
|
|
620
|
-
get parent() {
|
|
621
|
-
return this._parent ? this._parent.nextSignificantParent() : null;
|
|
622
|
-
}
|
|
623
|
-
get nextSibling() {
|
|
624
|
-
return this._parent && this.index >= 0 ? this._parent.nextChild(
|
|
625
|
-
this.index + 1,
|
|
626
|
-
1,
|
|
627
|
-
0,
|
|
628
|
-
4
|
|
629
|
-
/* Side.DontCare */
|
|
630
|
-
) : null;
|
|
631
|
-
}
|
|
632
|
-
get prevSibling() {
|
|
633
|
-
return this._parent && this.index >= 0 ? this._parent.nextChild(
|
|
634
|
-
this.index - 1,
|
|
635
|
-
-1,
|
|
636
|
-
0,
|
|
637
|
-
4
|
|
638
|
-
/* Side.DontCare */
|
|
639
|
-
) : null;
|
|
640
|
-
}
|
|
641
|
-
cursor(mode = 0) {
|
|
642
|
-
return new TreeCursor(this, mode);
|
|
643
|
-
}
|
|
644
|
-
get tree() {
|
|
645
|
-
return this._tree;
|
|
646
|
-
}
|
|
647
|
-
toTree() {
|
|
648
|
-
return this._tree;
|
|
649
|
-
}
|
|
650
|
-
resolve(pos, side = 0) {
|
|
651
|
-
return resolveNode(this, pos, side, false);
|
|
652
|
-
}
|
|
653
|
-
resolveInner(pos, side = 0) {
|
|
654
|
-
return resolveNode(this, pos, side, true);
|
|
655
|
-
}
|
|
656
|
-
enterUnfinishedNodesBefore(pos) {
|
|
657
|
-
return enterUnfinishedNodesBefore(this, pos);
|
|
658
|
-
}
|
|
659
|
-
getChild(type, before = null, after = null) {
|
|
660
|
-
let r = getChildren(this, type, before, after);
|
|
661
|
-
return r.length ? r[0] : null;
|
|
662
|
-
}
|
|
663
|
-
getChildren(type, before = null, after = null) {
|
|
664
|
-
return getChildren(this, type, before, after);
|
|
665
|
-
}
|
|
666
|
-
/// @internal
|
|
667
|
-
toString() {
|
|
668
|
-
return this._tree.toString();
|
|
669
|
-
}
|
|
670
|
-
get node() {
|
|
671
|
-
return this;
|
|
672
|
-
}
|
|
673
|
-
matchContext(context) {
|
|
674
|
-
return matchNodeContext(this, context);
|
|
675
|
-
}
|
|
676
|
-
};
|
|
677
|
-
function getChildren(node, type, before, after) {
|
|
678
|
-
let cur = node.cursor(), result = [];
|
|
679
|
-
if (!cur.firstChild())
|
|
680
|
-
return result;
|
|
681
|
-
if (before != null) {
|
|
682
|
-
while (!cur.type.is(before))
|
|
683
|
-
if (!cur.nextSibling())
|
|
684
|
-
return result;
|
|
685
|
-
}
|
|
686
|
-
for (; ; ) {
|
|
687
|
-
if (after != null && cur.type.is(after))
|
|
688
|
-
return result;
|
|
689
|
-
if (cur.type.is(type))
|
|
690
|
-
result.push(cur.node);
|
|
691
|
-
if (!cur.nextSibling())
|
|
692
|
-
return after == null ? result : [];
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
function matchNodeContext(node, context, i = context.length - 1) {
|
|
696
|
-
for (let p = node.parent; i >= 0; p = p.parent) {
|
|
697
|
-
if (!p)
|
|
698
|
-
return false;
|
|
699
|
-
if (!p.type.isAnonymous) {
|
|
700
|
-
if (context[i] && context[i] != p.name)
|
|
701
|
-
return false;
|
|
702
|
-
i--;
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
return true;
|
|
706
|
-
}
|
|
707
|
-
var BufferContext = class {
|
|
708
|
-
constructor(parent, buffer, index, start) {
|
|
709
|
-
this.parent = parent;
|
|
710
|
-
this.buffer = buffer;
|
|
711
|
-
this.index = index;
|
|
712
|
-
this.start = start;
|
|
713
|
-
}
|
|
714
|
-
};
|
|
715
|
-
var BufferNode = class _BufferNode {
|
|
716
|
-
get name() {
|
|
717
|
-
return this.type.name;
|
|
718
|
-
}
|
|
719
|
-
get from() {
|
|
720
|
-
return this.context.start + this.context.buffer.buffer[this.index + 1];
|
|
721
|
-
}
|
|
722
|
-
get to() {
|
|
723
|
-
return this.context.start + this.context.buffer.buffer[this.index + 2];
|
|
724
|
-
}
|
|
725
|
-
constructor(context, _parent, index) {
|
|
726
|
-
this.context = context;
|
|
727
|
-
this._parent = _parent;
|
|
728
|
-
this.index = index;
|
|
729
|
-
this.type = context.buffer.set.types[context.buffer.buffer[index]];
|
|
730
|
-
}
|
|
731
|
-
child(dir, pos, side) {
|
|
732
|
-
let { buffer } = this.context;
|
|
733
|
-
let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
|
|
734
|
-
return index < 0 ? null : new _BufferNode(this.context, this, index);
|
|
735
|
-
}
|
|
736
|
-
get firstChild() {
|
|
737
|
-
return this.child(
|
|
738
|
-
1,
|
|
739
|
-
0,
|
|
740
|
-
4
|
|
741
|
-
/* Side.DontCare */
|
|
742
|
-
);
|
|
743
|
-
}
|
|
744
|
-
get lastChild() {
|
|
745
|
-
return this.child(
|
|
746
|
-
-1,
|
|
747
|
-
0,
|
|
748
|
-
4
|
|
749
|
-
/* Side.DontCare */
|
|
750
|
-
);
|
|
751
|
-
}
|
|
752
|
-
childAfter(pos) {
|
|
753
|
-
return this.child(
|
|
754
|
-
1,
|
|
755
|
-
pos,
|
|
756
|
-
2
|
|
757
|
-
/* Side.After */
|
|
758
|
-
);
|
|
759
|
-
}
|
|
760
|
-
childBefore(pos) {
|
|
761
|
-
return this.child(
|
|
762
|
-
-1,
|
|
763
|
-
pos,
|
|
764
|
-
-2
|
|
765
|
-
/* Side.Before */
|
|
766
|
-
);
|
|
767
|
-
}
|
|
768
|
-
enter(pos, side, mode = 0) {
|
|
769
|
-
if (mode & IterMode.ExcludeBuffers)
|
|
770
|
-
return null;
|
|
771
|
-
let { buffer } = this.context;
|
|
772
|
-
let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
|
|
773
|
-
return index < 0 ? null : new _BufferNode(this.context, this, index);
|
|
774
|
-
}
|
|
775
|
-
get parent() {
|
|
776
|
-
return this._parent || this.context.parent.nextSignificantParent();
|
|
777
|
-
}
|
|
778
|
-
externalSibling(dir) {
|
|
779
|
-
return this._parent ? null : this.context.parent.nextChild(
|
|
780
|
-
this.context.index + dir,
|
|
781
|
-
dir,
|
|
782
|
-
0,
|
|
783
|
-
4
|
|
784
|
-
/* Side.DontCare */
|
|
785
|
-
);
|
|
786
|
-
}
|
|
787
|
-
get nextSibling() {
|
|
788
|
-
let { buffer } = this.context;
|
|
789
|
-
let after = buffer.buffer[this.index + 3];
|
|
790
|
-
if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))
|
|
791
|
-
return new _BufferNode(this.context, this._parent, after);
|
|
792
|
-
return this.externalSibling(1);
|
|
793
|
-
}
|
|
794
|
-
get prevSibling() {
|
|
795
|
-
let { buffer } = this.context;
|
|
796
|
-
let parentStart = this._parent ? this._parent.index + 4 : 0;
|
|
797
|
-
if (this.index == parentStart)
|
|
798
|
-
return this.externalSibling(-1);
|
|
799
|
-
return new _BufferNode(this.context, this._parent, buffer.findChild(
|
|
800
|
-
parentStart,
|
|
801
|
-
this.index,
|
|
802
|
-
-1,
|
|
803
|
-
0,
|
|
804
|
-
4
|
|
805
|
-
/* Side.DontCare */
|
|
806
|
-
));
|
|
807
|
-
}
|
|
808
|
-
cursor(mode = 0) {
|
|
809
|
-
return new TreeCursor(this, mode);
|
|
810
|
-
}
|
|
811
|
-
get tree() {
|
|
812
|
-
return null;
|
|
813
|
-
}
|
|
814
|
-
toTree() {
|
|
815
|
-
let children = [], positions = [];
|
|
816
|
-
let { buffer } = this.context;
|
|
817
|
-
let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
|
|
818
|
-
if (endI > startI) {
|
|
819
|
-
let from = buffer.buffer[this.index + 1];
|
|
820
|
-
children.push(buffer.slice(startI, endI, from));
|
|
821
|
-
positions.push(0);
|
|
822
|
-
}
|
|
823
|
-
return new Tree(this.type, children, positions, this.to - this.from);
|
|
824
|
-
}
|
|
825
|
-
resolve(pos, side = 0) {
|
|
826
|
-
return resolveNode(this, pos, side, false);
|
|
827
|
-
}
|
|
828
|
-
resolveInner(pos, side = 0) {
|
|
829
|
-
return resolveNode(this, pos, side, true);
|
|
830
|
-
}
|
|
831
|
-
enterUnfinishedNodesBefore(pos) {
|
|
832
|
-
return enterUnfinishedNodesBefore(this, pos);
|
|
833
|
-
}
|
|
834
|
-
/// @internal
|
|
835
|
-
toString() {
|
|
836
|
-
return this.context.buffer.childString(this.index);
|
|
837
|
-
}
|
|
838
|
-
getChild(type, before = null, after = null) {
|
|
839
|
-
let r = getChildren(this, type, before, after);
|
|
840
|
-
return r.length ? r[0] : null;
|
|
841
|
-
}
|
|
842
|
-
getChildren(type, before = null, after = null) {
|
|
843
|
-
return getChildren(this, type, before, after);
|
|
844
|
-
}
|
|
845
|
-
get node() {
|
|
846
|
-
return this;
|
|
847
|
-
}
|
|
848
|
-
matchContext(context) {
|
|
849
|
-
return matchNodeContext(this, context);
|
|
850
|
-
}
|
|
851
|
-
};
|
|
852
|
-
var TreeCursor = class {
|
|
853
|
-
/// Shorthand for `.type.name`.
|
|
854
|
-
get name() {
|
|
855
|
-
return this.type.name;
|
|
856
|
-
}
|
|
857
|
-
/// @internal
|
|
858
|
-
constructor(node, mode = 0) {
|
|
859
|
-
this.mode = mode;
|
|
860
|
-
this.buffer = null;
|
|
861
|
-
this.stack = [];
|
|
862
|
-
this.index = 0;
|
|
863
|
-
this.bufferNode = null;
|
|
864
|
-
if (node instanceof TreeNode) {
|
|
865
|
-
this.yieldNode(node);
|
|
866
|
-
} else {
|
|
867
|
-
this._tree = node.context.parent;
|
|
868
|
-
this.buffer = node.context;
|
|
869
|
-
for (let n = node._parent; n; n = n._parent)
|
|
870
|
-
this.stack.unshift(n.index);
|
|
871
|
-
this.bufferNode = node;
|
|
872
|
-
this.yieldBuf(node.index);
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
yieldNode(node) {
|
|
876
|
-
if (!node)
|
|
877
|
-
return false;
|
|
878
|
-
this._tree = node;
|
|
879
|
-
this.type = node.type;
|
|
880
|
-
this.from = node.from;
|
|
881
|
-
this.to = node.to;
|
|
882
|
-
return true;
|
|
883
|
-
}
|
|
884
|
-
yieldBuf(index, type) {
|
|
885
|
-
this.index = index;
|
|
886
|
-
let { start, buffer } = this.buffer;
|
|
887
|
-
this.type = type || buffer.set.types[buffer.buffer[index]];
|
|
888
|
-
this.from = start + buffer.buffer[index + 1];
|
|
889
|
-
this.to = start + buffer.buffer[index + 2];
|
|
890
|
-
return true;
|
|
891
|
-
}
|
|
892
|
-
yield(node) {
|
|
893
|
-
if (!node)
|
|
894
|
-
return false;
|
|
895
|
-
if (node instanceof TreeNode) {
|
|
896
|
-
this.buffer = null;
|
|
897
|
-
return this.yieldNode(node);
|
|
898
|
-
}
|
|
899
|
-
this.buffer = node.context;
|
|
900
|
-
return this.yieldBuf(node.index, node.type);
|
|
901
|
-
}
|
|
902
|
-
/// @internal
|
|
903
|
-
toString() {
|
|
904
|
-
return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
|
|
905
|
-
}
|
|
906
|
-
/// @internal
|
|
907
|
-
enterChild(dir, pos, side) {
|
|
908
|
-
if (!this.buffer)
|
|
909
|
-
return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
|
|
910
|
-
let { buffer } = this.buffer;
|
|
911
|
-
let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
|
|
912
|
-
if (index < 0)
|
|
913
|
-
return false;
|
|
914
|
-
this.stack.push(this.index);
|
|
915
|
-
return this.yieldBuf(index);
|
|
916
|
-
}
|
|
917
|
-
/// Move the cursor to this node's first child. When this returns
|
|
918
|
-
/// false, the node has no child, and the cursor has not been moved.
|
|
919
|
-
firstChild() {
|
|
920
|
-
return this.enterChild(
|
|
921
|
-
1,
|
|
922
|
-
0,
|
|
923
|
-
4
|
|
924
|
-
/* Side.DontCare */
|
|
925
|
-
);
|
|
926
|
-
}
|
|
927
|
-
/// Move the cursor to this node's last child.
|
|
928
|
-
lastChild() {
|
|
929
|
-
return this.enterChild(
|
|
930
|
-
-1,
|
|
931
|
-
0,
|
|
932
|
-
4
|
|
933
|
-
/* Side.DontCare */
|
|
934
|
-
);
|
|
935
|
-
}
|
|
936
|
-
/// Move the cursor to the first child that ends after `pos`.
|
|
937
|
-
childAfter(pos) {
|
|
938
|
-
return this.enterChild(
|
|
939
|
-
1,
|
|
940
|
-
pos,
|
|
941
|
-
2
|
|
942
|
-
/* Side.After */
|
|
943
|
-
);
|
|
944
|
-
}
|
|
945
|
-
/// Move to the last child that starts before `pos`.
|
|
946
|
-
childBefore(pos) {
|
|
947
|
-
return this.enterChild(
|
|
948
|
-
-1,
|
|
949
|
-
pos,
|
|
950
|
-
-2
|
|
951
|
-
/* Side.Before */
|
|
952
|
-
);
|
|
953
|
-
}
|
|
954
|
-
/// Move the cursor to the child around `pos`. If side is -1 the
|
|
955
|
-
/// child may end at that position, when 1 it may start there. This
|
|
956
|
-
/// will also enter [overlaid](#common.MountedTree.overlay)
|
|
957
|
-
/// [mounted](#common.NodeProp^mounted) trees unless `overlays` is
|
|
958
|
-
/// set to false.
|
|
959
|
-
enter(pos, side, mode = this.mode) {
|
|
960
|
-
if (!this.buffer)
|
|
961
|
-
return this.yield(this._tree.enter(pos, side, mode));
|
|
962
|
-
return mode & IterMode.ExcludeBuffers ? false : this.enterChild(1, pos, side);
|
|
963
|
-
}
|
|
964
|
-
/// Move to the node's parent node, if this isn't the top node.
|
|
965
|
-
parent() {
|
|
966
|
-
if (!this.buffer)
|
|
967
|
-
return this.yieldNode(this.mode & IterMode.IncludeAnonymous ? this._tree._parent : this._tree.parent);
|
|
968
|
-
if (this.stack.length)
|
|
969
|
-
return this.yieldBuf(this.stack.pop());
|
|
970
|
-
let parent = this.mode & IterMode.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
|
|
971
|
-
this.buffer = null;
|
|
972
|
-
return this.yieldNode(parent);
|
|
973
|
-
}
|
|
974
|
-
/// @internal
|
|
975
|
-
sibling(dir) {
|
|
976
|
-
if (!this.buffer)
|
|
977
|
-
return !this._tree._parent ? false : this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4, this.mode));
|
|
978
|
-
let { buffer } = this.buffer, d = this.stack.length - 1;
|
|
979
|
-
if (dir < 0) {
|
|
980
|
-
let parentStart = d < 0 ? 0 : this.stack[d] + 4;
|
|
981
|
-
if (this.index != parentStart)
|
|
982
|
-
return this.yieldBuf(buffer.findChild(
|
|
983
|
-
parentStart,
|
|
984
|
-
this.index,
|
|
985
|
-
-1,
|
|
986
|
-
0,
|
|
987
|
-
4
|
|
988
|
-
/* Side.DontCare */
|
|
989
|
-
));
|
|
990
|
-
} else {
|
|
991
|
-
let after = buffer.buffer[this.index + 3];
|
|
992
|
-
if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))
|
|
993
|
-
return this.yieldBuf(after);
|
|
994
|
-
}
|
|
995
|
-
return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4, this.mode)) : false;
|
|
996
|
-
}
|
|
997
|
-
/// Move to this node's next sibling, if any.
|
|
998
|
-
nextSibling() {
|
|
999
|
-
return this.sibling(1);
|
|
1000
|
-
}
|
|
1001
|
-
/// Move to this node's previous sibling, if any.
|
|
1002
|
-
prevSibling() {
|
|
1003
|
-
return this.sibling(-1);
|
|
1004
|
-
}
|
|
1005
|
-
atLastNode(dir) {
|
|
1006
|
-
let index, parent, { buffer } = this;
|
|
1007
|
-
if (buffer) {
|
|
1008
|
-
if (dir > 0) {
|
|
1009
|
-
if (this.index < buffer.buffer.buffer.length)
|
|
1010
|
-
return false;
|
|
1011
|
-
} else {
|
|
1012
|
-
for (let i = 0; i < this.index; i++)
|
|
1013
|
-
if (buffer.buffer.buffer[i + 3] < this.index)
|
|
1014
|
-
return false;
|
|
1015
|
-
}
|
|
1016
|
-
({ index, parent } = buffer);
|
|
1017
|
-
} else {
|
|
1018
|
-
({ index, _parent: parent } = this._tree);
|
|
1019
|
-
}
|
|
1020
|
-
for (; parent; { index, _parent: parent } = parent) {
|
|
1021
|
-
if (index > -1)
|
|
1022
|
-
for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
|
|
1023
|
-
let child = parent._tree.children[i];
|
|
1024
|
-
if (this.mode & IterMode.IncludeAnonymous || child instanceof TreeBuffer || !child.type.isAnonymous || hasChild(child))
|
|
1025
|
-
return false;
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
return true;
|
|
1029
|
-
}
|
|
1030
|
-
move(dir, enter) {
|
|
1031
|
-
if (enter && this.enterChild(
|
|
1032
|
-
dir,
|
|
1033
|
-
0,
|
|
1034
|
-
4
|
|
1035
|
-
/* Side.DontCare */
|
|
1036
|
-
))
|
|
1037
|
-
return true;
|
|
1038
|
-
for (; ; ) {
|
|
1039
|
-
if (this.sibling(dir))
|
|
1040
|
-
return true;
|
|
1041
|
-
if (this.atLastNode(dir) || !this.parent())
|
|
1042
|
-
return false;
|
|
1043
|
-
}
|
|
1044
|
-
}
|
|
1045
|
-
/// Move to the next node in a
|
|
1046
|
-
/// [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
|
|
1047
|
-
/// traversal, going from a node to its first child or, if the
|
|
1048
|
-
/// current node is empty or `enter` is false, its next sibling or
|
|
1049
|
-
/// the next sibling of the first parent node that has one.
|
|
1050
|
-
next(enter = true) {
|
|
1051
|
-
return this.move(1, enter);
|
|
1052
|
-
}
|
|
1053
|
-
/// Move to the next node in a last-to-first pre-order traveral. A
|
|
1054
|
-
/// node is followed by its last child or, if it has none, its
|
|
1055
|
-
/// previous sibling or the previous sibling of the first parent
|
|
1056
|
-
/// node that has one.
|
|
1057
|
-
prev(enter = true) {
|
|
1058
|
-
return this.move(-1, enter);
|
|
1059
|
-
}
|
|
1060
|
-
/// Move the cursor to the innermost node that covers `pos`. If
|
|
1061
|
-
/// `side` is -1, it will enter nodes that end at `pos`. If it is 1,
|
|
1062
|
-
/// it will enter nodes that start at `pos`.
|
|
1063
|
-
moveTo(pos, side = 0) {
|
|
1064
|
-
while (this.from == this.to || (side < 1 ? this.from >= pos : this.from > pos) || (side > -1 ? this.to <= pos : this.to < pos))
|
|
1065
|
-
if (!this.parent())
|
|
1066
|
-
break;
|
|
1067
|
-
while (this.enterChild(1, pos, side)) {
|
|
1068
|
-
}
|
|
1069
|
-
return this;
|
|
1070
|
-
}
|
|
1071
|
-
/// Get a [syntax node](#common.SyntaxNode) at the cursor's current
|
|
1072
|
-
/// position.
|
|
1073
|
-
get node() {
|
|
1074
|
-
if (!this.buffer)
|
|
1075
|
-
return this._tree;
|
|
1076
|
-
let cache = this.bufferNode, result = null, depth = 0;
|
|
1077
|
-
if (cache && cache.context == this.buffer) {
|
|
1078
|
-
scan:
|
|
1079
|
-
for (let index = this.index, d = this.stack.length; d >= 0; ) {
|
|
1080
|
-
for (let c = cache; c; c = c._parent)
|
|
1081
|
-
if (c.index == index) {
|
|
1082
|
-
if (index == this.index)
|
|
1083
|
-
return c;
|
|
1084
|
-
result = c;
|
|
1085
|
-
depth = d + 1;
|
|
1086
|
-
break scan;
|
|
1087
|
-
}
|
|
1088
|
-
index = this.stack[--d];
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
for (let i = depth; i < this.stack.length; i++)
|
|
1092
|
-
result = new BufferNode(this.buffer, result, this.stack[i]);
|
|
1093
|
-
return this.bufferNode = new BufferNode(this.buffer, result, this.index);
|
|
1094
|
-
}
|
|
1095
|
-
/// Get the [tree](#common.Tree) that represents the current node, if
|
|
1096
|
-
/// any. Will return null when the node is in a [tree
|
|
1097
|
-
/// buffer](#common.TreeBuffer).
|
|
1098
|
-
get tree() {
|
|
1099
|
-
return this.buffer ? null : this._tree._tree;
|
|
1100
|
-
}
|
|
1101
|
-
/// Iterate over the current node and all its descendants, calling
|
|
1102
|
-
/// `enter` when entering a node and `leave`, if given, when leaving
|
|
1103
|
-
/// one. When `enter` returns `false`, any children of that node are
|
|
1104
|
-
/// skipped, and `leave` isn't called for it.
|
|
1105
|
-
iterate(enter, leave) {
|
|
1106
|
-
for (let depth = 0; ; ) {
|
|
1107
|
-
let mustLeave = false;
|
|
1108
|
-
if (this.type.isAnonymous || enter(this) !== false) {
|
|
1109
|
-
if (this.firstChild()) {
|
|
1110
|
-
depth++;
|
|
1111
|
-
continue;
|
|
1112
|
-
}
|
|
1113
|
-
if (!this.type.isAnonymous)
|
|
1114
|
-
mustLeave = true;
|
|
1115
|
-
}
|
|
1116
|
-
for (; ; ) {
|
|
1117
|
-
if (mustLeave && leave)
|
|
1118
|
-
leave(this);
|
|
1119
|
-
mustLeave = this.type.isAnonymous;
|
|
1120
|
-
if (this.nextSibling())
|
|
1121
|
-
break;
|
|
1122
|
-
if (!depth)
|
|
1123
|
-
return;
|
|
1124
|
-
this.parent();
|
|
1125
|
-
depth--;
|
|
1126
|
-
mustLeave = true;
|
|
1127
|
-
}
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
/// Test whether the current node matches a given context—a sequence
|
|
1131
|
-
/// of direct parent node names. Empty strings in the context array
|
|
1132
|
-
/// are treated as wildcards.
|
|
1133
|
-
matchContext(context) {
|
|
1134
|
-
if (!this.buffer)
|
|
1135
|
-
return matchNodeContext(this.node, context);
|
|
1136
|
-
let { buffer } = this.buffer, { types } = buffer.set;
|
|
1137
|
-
for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {
|
|
1138
|
-
if (d < 0)
|
|
1139
|
-
return matchNodeContext(this.node, context, i);
|
|
1140
|
-
let type = types[buffer.buffer[this.stack[d]]];
|
|
1141
|
-
if (!type.isAnonymous) {
|
|
1142
|
-
if (context[i] && context[i] != type.name)
|
|
1143
|
-
return false;
|
|
1144
|
-
i--;
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1147
|
-
return true;
|
|
1148
|
-
}
|
|
1149
|
-
};
|
|
1150
|
-
function hasChild(tree) {
|
|
1151
|
-
return tree.children.some((ch) => ch instanceof TreeBuffer || !ch.type.isAnonymous || hasChild(ch));
|
|
1152
|
-
}
|
|
1153
|
-
function buildTree(data) {
|
|
1154
|
-
var _a;
|
|
1155
|
-
let { buffer, nodeSet, maxBufferLength = DefaultBufferLength, reused = [], minRepeatType = nodeSet.types.length } = data;
|
|
1156
|
-
let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;
|
|
1157
|
-
let types = nodeSet.types;
|
|
1158
|
-
let contextHash = 0, lookAhead = 0;
|
|
1159
|
-
function takeNode(parentStart, minPos, children2, positions2, inRepeat) {
|
|
1160
|
-
let { id, start, end, size } = cursor;
|
|
1161
|
-
let lookAheadAtStart = lookAhead;
|
|
1162
|
-
while (size < 0) {
|
|
1163
|
-
cursor.next();
|
|
1164
|
-
if (size == -1) {
|
|
1165
|
-
let node2 = reused[id];
|
|
1166
|
-
children2.push(node2);
|
|
1167
|
-
positions2.push(start - parentStart);
|
|
1168
|
-
return;
|
|
1169
|
-
} else if (size == -3) {
|
|
1170
|
-
contextHash = id;
|
|
1171
|
-
return;
|
|
1172
|
-
} else if (size == -4) {
|
|
1173
|
-
lookAhead = id;
|
|
1174
|
-
return;
|
|
1175
|
-
} else {
|
|
1176
|
-
throw new RangeError(`Unrecognized record size: ${size}`);
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
let type = types[id], node, buffer2;
|
|
1180
|
-
let startPos = start - parentStart;
|
|
1181
|
-
if (end - start <= maxBufferLength && (buffer2 = findBufferSize(cursor.pos - minPos, inRepeat))) {
|
|
1182
|
-
let data2 = new Uint16Array(buffer2.size - buffer2.skip);
|
|
1183
|
-
let endPos = cursor.pos - buffer2.size, index = data2.length;
|
|
1184
|
-
while (cursor.pos > endPos)
|
|
1185
|
-
index = copyToBuffer(buffer2.start, data2, index);
|
|
1186
|
-
node = new TreeBuffer(data2, end - buffer2.start, nodeSet);
|
|
1187
|
-
startPos = buffer2.start - parentStart;
|
|
1188
|
-
} else {
|
|
1189
|
-
let endPos = cursor.pos - size;
|
|
1190
|
-
cursor.next();
|
|
1191
|
-
let localChildren = [], localPositions = [];
|
|
1192
|
-
let localInRepeat = id >= minRepeatType ? id : -1;
|
|
1193
|
-
let lastGroup = 0, lastEnd = end;
|
|
1194
|
-
while (cursor.pos > endPos) {
|
|
1195
|
-
if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
|
|
1196
|
-
if (cursor.end <= lastEnd - maxBufferLength) {
|
|
1197
|
-
makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart);
|
|
1198
|
-
lastGroup = localChildren.length;
|
|
1199
|
-
lastEnd = cursor.end;
|
|
1200
|
-
}
|
|
1201
|
-
cursor.next();
|
|
1202
|
-
} else {
|
|
1203
|
-
takeNode(start, endPos, localChildren, localPositions, localInRepeat);
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
|
-
if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)
|
|
1207
|
-
makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart);
|
|
1208
|
-
localChildren.reverse();
|
|
1209
|
-
localPositions.reverse();
|
|
1210
|
-
if (localInRepeat > -1 && lastGroup > 0) {
|
|
1211
|
-
let make = makeBalanced(type);
|
|
1212
|
-
node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
|
|
1213
|
-
} else {
|
|
1214
|
-
node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end);
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
children2.push(node);
|
|
1218
|
-
positions2.push(startPos);
|
|
1219
|
-
}
|
|
1220
|
-
function makeBalanced(type) {
|
|
1221
|
-
return (children2, positions2, length2) => {
|
|
1222
|
-
let lookAhead2 = 0, lastI = children2.length - 1, last, lookAheadProp;
|
|
1223
|
-
if (lastI >= 0 && (last = children2[lastI]) instanceof Tree) {
|
|
1224
|
-
if (!lastI && last.type == type && last.length == length2)
|
|
1225
|
-
return last;
|
|
1226
|
-
if (lookAheadProp = last.prop(NodeProp.lookAhead))
|
|
1227
|
-
lookAhead2 = positions2[lastI] + last.length + lookAheadProp;
|
|
1228
|
-
}
|
|
1229
|
-
return makeTree(type, children2, positions2, length2, lookAhead2);
|
|
1230
|
-
};
|
|
1231
|
-
}
|
|
1232
|
-
function makeRepeatLeaf(children2, positions2, base, i, from, to, type, lookAhead2) {
|
|
1233
|
-
let localChildren = [], localPositions = [];
|
|
1234
|
-
while (children2.length > i) {
|
|
1235
|
-
localChildren.push(children2.pop());
|
|
1236
|
-
localPositions.push(positions2.pop() + base - from);
|
|
1237
|
-
}
|
|
1238
|
-
children2.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead2 - to));
|
|
1239
|
-
positions2.push(from - base);
|
|
1240
|
-
}
|
|
1241
|
-
function makeTree(type, children2, positions2, length2, lookAhead2 = 0, props) {
|
|
1242
|
-
if (contextHash) {
|
|
1243
|
-
let pair2 = [NodeProp.contextHash, contextHash];
|
|
1244
|
-
props = props ? [pair2].concat(props) : [pair2];
|
|
1245
|
-
}
|
|
1246
|
-
if (lookAhead2 > 25) {
|
|
1247
|
-
let pair2 = [NodeProp.lookAhead, lookAhead2];
|
|
1248
|
-
props = props ? [pair2].concat(props) : [pair2];
|
|
1249
|
-
}
|
|
1250
|
-
return new Tree(type, children2, positions2, length2, props);
|
|
1251
|
-
}
|
|
1252
|
-
function findBufferSize(maxSize, inRepeat) {
|
|
1253
|
-
let fork = cursor.fork();
|
|
1254
|
-
let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;
|
|
1255
|
-
let result = { size: 0, start: 0, skip: 0 };
|
|
1256
|
-
scan:
|
|
1257
|
-
for (let minPos = fork.pos - maxSize; fork.pos > minPos; ) {
|
|
1258
|
-
let nodeSize2 = fork.size;
|
|
1259
|
-
if (fork.id == inRepeat && nodeSize2 >= 0) {
|
|
1260
|
-
result.size = size;
|
|
1261
|
-
result.start = start;
|
|
1262
|
-
result.skip = skip;
|
|
1263
|
-
skip += 4;
|
|
1264
|
-
size += 4;
|
|
1265
|
-
fork.next();
|
|
1266
|
-
continue;
|
|
1267
|
-
}
|
|
1268
|
-
let startPos = fork.pos - nodeSize2;
|
|
1269
|
-
if (nodeSize2 < 0 || startPos < minPos || fork.start < minStart)
|
|
1270
|
-
break;
|
|
1271
|
-
let localSkipped = fork.id >= minRepeatType ? 4 : 0;
|
|
1272
|
-
let nodeStart = fork.start;
|
|
1273
|
-
fork.next();
|
|
1274
|
-
while (fork.pos > startPos) {
|
|
1275
|
-
if (fork.size < 0) {
|
|
1276
|
-
if (fork.size == -3)
|
|
1277
|
-
localSkipped += 4;
|
|
1278
|
-
else
|
|
1279
|
-
break scan;
|
|
1280
|
-
} else if (fork.id >= minRepeatType) {
|
|
1281
|
-
localSkipped += 4;
|
|
1282
|
-
}
|
|
1283
|
-
fork.next();
|
|
1284
|
-
}
|
|
1285
|
-
start = nodeStart;
|
|
1286
|
-
size += nodeSize2;
|
|
1287
|
-
skip += localSkipped;
|
|
1288
|
-
}
|
|
1289
|
-
if (inRepeat < 0 || size == maxSize) {
|
|
1290
|
-
result.size = size;
|
|
1291
|
-
result.start = start;
|
|
1292
|
-
result.skip = skip;
|
|
1293
|
-
}
|
|
1294
|
-
return result.size > 4 ? result : void 0;
|
|
1295
|
-
}
|
|
1296
|
-
function copyToBuffer(bufferStart, buffer2, index) {
|
|
1297
|
-
let { id, start, end, size } = cursor;
|
|
1298
|
-
cursor.next();
|
|
1299
|
-
if (size >= 0 && id < minRepeatType) {
|
|
1300
|
-
let startIndex = index;
|
|
1301
|
-
if (size > 4) {
|
|
1302
|
-
let endPos = cursor.pos - (size - 4);
|
|
1303
|
-
while (cursor.pos > endPos)
|
|
1304
|
-
index = copyToBuffer(bufferStart, buffer2, index);
|
|
1305
|
-
}
|
|
1306
|
-
buffer2[--index] = startIndex;
|
|
1307
|
-
buffer2[--index] = end - bufferStart;
|
|
1308
|
-
buffer2[--index] = start - bufferStart;
|
|
1309
|
-
buffer2[--index] = id;
|
|
1310
|
-
} else if (size == -3) {
|
|
1311
|
-
contextHash = id;
|
|
1312
|
-
} else if (size == -4) {
|
|
1313
|
-
lookAhead = id;
|
|
1314
|
-
}
|
|
1315
|
-
return index;
|
|
1316
|
-
}
|
|
1317
|
-
let children = [], positions = [];
|
|
1318
|
-
while (cursor.pos > 0)
|
|
1319
|
-
takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1);
|
|
1320
|
-
let length = (_a = data.length) !== null && _a !== void 0 ? _a : children.length ? positions[0] + children[0].length : 0;
|
|
1321
|
-
return new Tree(types[data.topID], children.reverse(), positions.reverse(), length);
|
|
1322
|
-
}
|
|
1323
|
-
var nodeSizeCache = /* @__PURE__ */ new WeakMap();
|
|
1324
|
-
function nodeSize(balanceType, node) {
|
|
1325
|
-
if (!balanceType.isAnonymous || node instanceof TreeBuffer || node.type != balanceType)
|
|
1326
|
-
return 1;
|
|
1327
|
-
let size = nodeSizeCache.get(node);
|
|
1328
|
-
if (size == null) {
|
|
1329
|
-
size = 1;
|
|
1330
|
-
for (let child of node.children) {
|
|
1331
|
-
if (child.type != balanceType || !(child instanceof Tree)) {
|
|
1332
|
-
size = 1;
|
|
1333
|
-
break;
|
|
1334
|
-
}
|
|
1335
|
-
size += nodeSize(balanceType, child);
|
|
1336
|
-
}
|
|
1337
|
-
nodeSizeCache.set(node, size);
|
|
1338
|
-
}
|
|
1339
|
-
return size;
|
|
1340
|
-
}
|
|
1341
|
-
function balanceRange(balanceType, children, positions, from, to, start, length, mkTop, mkTree) {
|
|
1342
|
-
let total = 0;
|
|
1343
|
-
for (let i = from; i < to; i++)
|
|
1344
|
-
total += nodeSize(balanceType, children[i]);
|
|
1345
|
-
let maxChild = Math.ceil(
|
|
1346
|
-
total * 1.5 / 8
|
|
1347
|
-
/* Balance.BranchFactor */
|
|
1348
|
-
);
|
|
1349
|
-
let localChildren = [], localPositions = [];
|
|
1350
|
-
function divide(children2, positions2, from2, to2, offset) {
|
|
1351
|
-
for (let i = from2; i < to2; ) {
|
|
1352
|
-
let groupFrom = i, groupStart = positions2[i], groupSize = nodeSize(balanceType, children2[i]);
|
|
1353
|
-
i++;
|
|
1354
|
-
for (; i < to2; i++) {
|
|
1355
|
-
let nextSize = nodeSize(balanceType, children2[i]);
|
|
1356
|
-
if (groupSize + nextSize >= maxChild)
|
|
1357
|
-
break;
|
|
1358
|
-
groupSize += nextSize;
|
|
1359
|
-
}
|
|
1360
|
-
if (i == groupFrom + 1) {
|
|
1361
|
-
if (groupSize > maxChild) {
|
|
1362
|
-
let only = children2[groupFrom];
|
|
1363
|
-
divide(only.children, only.positions, 0, only.children.length, positions2[groupFrom] + offset);
|
|
1364
|
-
continue;
|
|
1365
|
-
}
|
|
1366
|
-
localChildren.push(children2[groupFrom]);
|
|
1367
|
-
} else {
|
|
1368
|
-
let length2 = positions2[i - 1] + children2[i - 1].length - groupStart;
|
|
1369
|
-
localChildren.push(balanceRange(balanceType, children2, positions2, groupFrom, i, groupStart, length2, null, mkTree));
|
|
1370
|
-
}
|
|
1371
|
-
localPositions.push(groupStart + offset - start);
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1374
|
-
divide(children, positions, from, to, 0);
|
|
1375
|
-
return (mkTop || mkTree)(localChildren, localPositions, length);
|
|
1376
|
-
}
|
|
1377
|
-
var Parser = class {
|
|
1378
|
-
/// Start a parse, returning a [partial parse](#common.PartialParse)
|
|
1379
|
-
/// object. [`fragments`](#common.TreeFragment) can be passed in to
|
|
1380
|
-
/// make the parse incremental.
|
|
1381
|
-
///
|
|
1382
|
-
/// By default, the entire input is parsed. You can pass `ranges`,
|
|
1383
|
-
/// which should be a sorted array of non-empty, non-overlapping
|
|
1384
|
-
/// ranges, to parse only those ranges. The tree returned in that
|
|
1385
|
-
/// case will start at `ranges[0].from`.
|
|
1386
|
-
startParse(input, fragments, ranges) {
|
|
1387
|
-
if (typeof input == "string")
|
|
1388
|
-
input = new StringInput(input);
|
|
1389
|
-
ranges = !ranges ? [new Range(0, input.length)] : ranges.length ? ranges.map((r) => new Range(r.from, r.to)) : [new Range(0, 0)];
|
|
1390
|
-
return this.createParse(input, fragments || [], ranges);
|
|
1391
|
-
}
|
|
1392
|
-
/// Run a full parse, returning the resulting tree.
|
|
1393
|
-
parse(input, fragments, ranges) {
|
|
1394
|
-
let parse = this.startParse(input, fragments, ranges);
|
|
1395
|
-
for (; ; ) {
|
|
1396
|
-
let done = parse.advance();
|
|
1397
|
-
if (done)
|
|
1398
|
-
return done;
|
|
1399
|
-
}
|
|
1400
|
-
}
|
|
1401
|
-
};
|
|
1402
|
-
var StringInput = class {
|
|
1403
|
-
constructor(string) {
|
|
1404
|
-
this.string = string;
|
|
1405
|
-
}
|
|
1406
|
-
get length() {
|
|
1407
|
-
return this.string.length;
|
|
1408
|
-
}
|
|
1409
|
-
chunk(from) {
|
|
1410
|
-
return this.string.slice(from);
|
|
1411
|
-
}
|
|
1412
|
-
get lineChunks() {
|
|
1413
|
-
return false;
|
|
1414
|
-
}
|
|
1415
|
-
read(from, to) {
|
|
1416
|
-
return this.string.slice(from, to);
|
|
1417
|
-
}
|
|
1418
|
-
};
|
|
1419
|
-
var stoppedInner = new NodeProp({ perNode: true });
|
|
1420
|
-
|
|
1421
|
-
// ../../node_modules/@lezer/lr/dist/index.js
|
|
1422
|
-
var Stack = class _Stack {
|
|
1423
|
-
/// @internal
|
|
1424
|
-
constructor(p, stack, state, reducePos, pos, score, buffer, bufferBase, curContext, lookAhead = 0, parent) {
|
|
1425
|
-
this.p = p;
|
|
1426
|
-
this.stack = stack;
|
|
1427
|
-
this.state = state;
|
|
1428
|
-
this.reducePos = reducePos;
|
|
1429
|
-
this.pos = pos;
|
|
1430
|
-
this.score = score;
|
|
1431
|
-
this.buffer = buffer;
|
|
1432
|
-
this.bufferBase = bufferBase;
|
|
1433
|
-
this.curContext = curContext;
|
|
1434
|
-
this.lookAhead = lookAhead;
|
|
1435
|
-
this.parent = parent;
|
|
1436
|
-
}
|
|
1437
|
-
/// @internal
|
|
1438
|
-
toString() {
|
|
1439
|
-
return `[${this.stack.filter((_, i) => i % 3 == 0).concat(this.state)}]@${this.pos}${this.score ? "!" + this.score : ""}`;
|
|
1440
|
-
}
|
|
1441
|
-
// Start an empty stack
|
|
1442
|
-
/// @internal
|
|
1443
|
-
static start(p, state, pos = 0) {
|
|
1444
|
-
let cx2 = p.parser.context;
|
|
1445
|
-
return new _Stack(p, [], state, pos, pos, 0, [], 0, cx2 ? new StackContext(cx2, cx2.start) : null, 0, null);
|
|
1446
|
-
}
|
|
1447
|
-
/// The stack's current [context](#lr.ContextTracker) value, if
|
|
1448
|
-
/// any. Its type will depend on the context tracker's type
|
|
1449
|
-
/// parameter, or it will be `null` if there is no context
|
|
1450
|
-
/// tracker.
|
|
1451
|
-
get context() {
|
|
1452
|
-
return this.curContext ? this.curContext.context : null;
|
|
1453
|
-
}
|
|
1454
|
-
// Push a state onto the stack, tracking its start position as well
|
|
1455
|
-
// as the buffer base at that point.
|
|
1456
|
-
/// @internal
|
|
1457
|
-
pushState(state, start) {
|
|
1458
|
-
this.stack.push(this.state, start, this.bufferBase + this.buffer.length);
|
|
1459
|
-
this.state = state;
|
|
1460
|
-
}
|
|
1461
|
-
// Apply a reduce action
|
|
1462
|
-
/// @internal
|
|
1463
|
-
reduce(action) {
|
|
1464
|
-
var _a;
|
|
1465
|
-
let depth = action >> 19, type = action & 65535;
|
|
1466
|
-
let { parser: parser2 } = this.p;
|
|
1467
|
-
let dPrec = parser2.dynamicPrecedence(type);
|
|
1468
|
-
if (dPrec)
|
|
1469
|
-
this.score += dPrec;
|
|
1470
|
-
if (depth == 0) {
|
|
1471
|
-
this.pushState(parser2.getGoto(this.state, type, true), this.reducePos);
|
|
1472
|
-
if (type < parser2.minRepeatTerm)
|
|
1473
|
-
this.storeNode(type, this.reducePos, this.reducePos, 4, true);
|
|
1474
|
-
this.reduceContext(type, this.reducePos);
|
|
1475
|
-
return;
|
|
1476
|
-
}
|
|
1477
|
-
let base = this.stack.length - (depth - 1) * 3 - (action & 262144 ? 6 : 0);
|
|
1478
|
-
let start = base ? this.stack[base - 2] : this.p.ranges[0].from, size = this.reducePos - start;
|
|
1479
|
-
if (size >= 2e3 && !((_a = this.p.parser.nodeSet.types[type]) === null || _a === void 0 ? void 0 : _a.isAnonymous)) {
|
|
1480
|
-
if (start == this.p.lastBigReductionStart) {
|
|
1481
|
-
this.p.bigReductionCount++;
|
|
1482
|
-
this.p.lastBigReductionSize = size;
|
|
1483
|
-
} else if (this.p.lastBigReductionSize < size) {
|
|
1484
|
-
this.p.bigReductionCount = 1;
|
|
1485
|
-
this.p.lastBigReductionStart = start;
|
|
1486
|
-
this.p.lastBigReductionSize = size;
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
let bufferBase = base ? this.stack[base - 1] : 0, count = this.bufferBase + this.buffer.length - bufferBase;
|
|
1490
|
-
if (type < parser2.minRepeatTerm || action & 131072) {
|
|
1491
|
-
let pos = parser2.stateFlag(
|
|
1492
|
-
this.state,
|
|
1493
|
-
1
|
|
1494
|
-
/* StateFlag.Skipped */
|
|
1495
|
-
) ? this.pos : this.reducePos;
|
|
1496
|
-
this.storeNode(type, start, pos, count + 4, true);
|
|
1497
|
-
}
|
|
1498
|
-
if (action & 262144) {
|
|
1499
|
-
this.state = this.stack[base];
|
|
1500
|
-
} else {
|
|
1501
|
-
let baseStateID = this.stack[base - 3];
|
|
1502
|
-
this.state = parser2.getGoto(baseStateID, type, true);
|
|
1503
|
-
}
|
|
1504
|
-
while (this.stack.length > base)
|
|
1505
|
-
this.stack.pop();
|
|
1506
|
-
this.reduceContext(type, start);
|
|
1507
|
-
}
|
|
1508
|
-
// Shift a value into the buffer
|
|
1509
|
-
/// @internal
|
|
1510
|
-
storeNode(term, start, end, size = 4, isReduce = false) {
|
|
1511
|
-
if (term == 0 && (!this.stack.length || this.stack[this.stack.length - 1] < this.buffer.length + this.bufferBase)) {
|
|
1512
|
-
let cur = this, top = this.buffer.length;
|
|
1513
|
-
if (top == 0 && cur.parent) {
|
|
1514
|
-
top = cur.bufferBase - cur.parent.bufferBase;
|
|
1515
|
-
cur = cur.parent;
|
|
1516
|
-
}
|
|
1517
|
-
if (top > 0 && cur.buffer[top - 4] == 0 && cur.buffer[top - 1] > -1) {
|
|
1518
|
-
if (start == end)
|
|
1519
|
-
return;
|
|
1520
|
-
if (cur.buffer[top - 2] >= start) {
|
|
1521
|
-
cur.buffer[top - 2] = end;
|
|
1522
|
-
return;
|
|
1523
|
-
}
|
|
1524
|
-
}
|
|
1525
|
-
}
|
|
1526
|
-
if (!isReduce || this.pos == end) {
|
|
1527
|
-
this.buffer.push(term, start, end, size);
|
|
1528
|
-
} else {
|
|
1529
|
-
let index = this.buffer.length;
|
|
1530
|
-
if (index > 0 && this.buffer[index - 4] != 0)
|
|
1531
|
-
while (index > 0 && this.buffer[index - 2] > end) {
|
|
1532
|
-
this.buffer[index] = this.buffer[index - 4];
|
|
1533
|
-
this.buffer[index + 1] = this.buffer[index - 3];
|
|
1534
|
-
this.buffer[index + 2] = this.buffer[index - 2];
|
|
1535
|
-
this.buffer[index + 3] = this.buffer[index - 1];
|
|
1536
|
-
index -= 4;
|
|
1537
|
-
if (size > 4)
|
|
1538
|
-
size -= 4;
|
|
1539
|
-
}
|
|
1540
|
-
this.buffer[index] = term;
|
|
1541
|
-
this.buffer[index + 1] = start;
|
|
1542
|
-
this.buffer[index + 2] = end;
|
|
1543
|
-
this.buffer[index + 3] = size;
|
|
1544
|
-
}
|
|
1545
|
-
}
|
|
1546
|
-
// Apply a shift action
|
|
1547
|
-
/// @internal
|
|
1548
|
-
shift(action, next, nextEnd) {
|
|
1549
|
-
let start = this.pos;
|
|
1550
|
-
if (action & 131072) {
|
|
1551
|
-
this.pushState(action & 65535, this.pos);
|
|
1552
|
-
} else if ((action & 262144) == 0) {
|
|
1553
|
-
let nextState = action, { parser: parser2 } = this.p;
|
|
1554
|
-
if (nextEnd > this.pos || next <= parser2.maxNode) {
|
|
1555
|
-
this.pos = nextEnd;
|
|
1556
|
-
if (!parser2.stateFlag(
|
|
1557
|
-
nextState,
|
|
1558
|
-
1
|
|
1559
|
-
/* StateFlag.Skipped */
|
|
1560
|
-
))
|
|
1561
|
-
this.reducePos = nextEnd;
|
|
1562
|
-
}
|
|
1563
|
-
this.pushState(nextState, start);
|
|
1564
|
-
this.shiftContext(next, start);
|
|
1565
|
-
if (next <= parser2.maxNode)
|
|
1566
|
-
this.buffer.push(next, start, nextEnd, 4);
|
|
1567
|
-
} else {
|
|
1568
|
-
this.pos = nextEnd;
|
|
1569
|
-
this.shiftContext(next, start);
|
|
1570
|
-
if (next <= this.p.parser.maxNode)
|
|
1571
|
-
this.buffer.push(next, start, nextEnd, 4);
|
|
1572
|
-
}
|
|
1573
|
-
}
|
|
1574
|
-
// Apply an action
|
|
1575
|
-
/// @internal
|
|
1576
|
-
apply(action, next, nextEnd) {
|
|
1577
|
-
if (action & 65536)
|
|
1578
|
-
this.reduce(action);
|
|
1579
|
-
else
|
|
1580
|
-
this.shift(action, next, nextEnd);
|
|
1581
|
-
}
|
|
1582
|
-
// Add a prebuilt (reused) node into the buffer.
|
|
1583
|
-
/// @internal
|
|
1584
|
-
useNode(value, next) {
|
|
1585
|
-
let index = this.p.reused.length - 1;
|
|
1586
|
-
if (index < 0 || this.p.reused[index] != value) {
|
|
1587
|
-
this.p.reused.push(value);
|
|
1588
|
-
index++;
|
|
1589
|
-
}
|
|
1590
|
-
let start = this.pos;
|
|
1591
|
-
this.reducePos = this.pos = start + value.length;
|
|
1592
|
-
this.pushState(next, start);
|
|
1593
|
-
this.buffer.push(
|
|
1594
|
-
index,
|
|
1595
|
-
start,
|
|
1596
|
-
this.reducePos,
|
|
1597
|
-
-1
|
|
1598
|
-
/* size == -1 means this is a reused value */
|
|
1599
|
-
);
|
|
1600
|
-
if (this.curContext)
|
|
1601
|
-
this.updateContext(this.curContext.tracker.reuse(this.curContext.context, value, this, this.p.stream.reset(this.pos - value.length)));
|
|
1602
|
-
}
|
|
1603
|
-
// Split the stack. Due to the buffer sharing and the fact
|
|
1604
|
-
// that `this.stack` tends to stay quite shallow, this isn't very
|
|
1605
|
-
// expensive.
|
|
1606
|
-
/// @internal
|
|
1607
|
-
split() {
|
|
1608
|
-
let parent = this;
|
|
1609
|
-
let off = parent.buffer.length;
|
|
1610
|
-
while (off > 0 && parent.buffer[off - 2] > parent.reducePos)
|
|
1611
|
-
off -= 4;
|
|
1612
|
-
let buffer = parent.buffer.slice(off), base = parent.bufferBase + off;
|
|
1613
|
-
while (parent && base == parent.bufferBase)
|
|
1614
|
-
parent = parent.parent;
|
|
1615
|
-
return new _Stack(this.p, this.stack.slice(), this.state, this.reducePos, this.pos, this.score, buffer, base, this.curContext, this.lookAhead, parent);
|
|
1616
|
-
}
|
|
1617
|
-
// Try to recover from an error by 'deleting' (ignoring) one token.
|
|
1618
|
-
/// @internal
|
|
1619
|
-
recoverByDelete(next, nextEnd) {
|
|
1620
|
-
let isNode = next <= this.p.parser.maxNode;
|
|
1621
|
-
if (isNode)
|
|
1622
|
-
this.storeNode(next, this.pos, nextEnd, 4);
|
|
1623
|
-
this.storeNode(0, this.pos, nextEnd, isNode ? 8 : 4);
|
|
1624
|
-
this.pos = this.reducePos = nextEnd;
|
|
1625
|
-
this.score -= 190;
|
|
1626
|
-
}
|
|
1627
|
-
/// Check if the given term would be able to be shifted (optionally
|
|
1628
|
-
/// after some reductions) on this stack. This can be useful for
|
|
1629
|
-
/// external tokenizers that want to make sure they only provide a
|
|
1630
|
-
/// given token when it applies.
|
|
1631
|
-
canShift(term) {
|
|
1632
|
-
for (let sim = new SimulatedStack(this); ; ) {
|
|
1633
|
-
let action = this.p.parser.stateSlot(
|
|
1634
|
-
sim.state,
|
|
1635
|
-
4
|
|
1636
|
-
/* ParseState.DefaultReduce */
|
|
1637
|
-
) || this.p.parser.hasAction(sim.state, term);
|
|
1638
|
-
if (action == 0)
|
|
1639
|
-
return false;
|
|
1640
|
-
if ((action & 65536) == 0)
|
|
1641
|
-
return true;
|
|
1642
|
-
sim.reduce(action);
|
|
1643
|
-
}
|
|
1644
|
-
}
|
|
1645
|
-
// Apply up to Recover.MaxNext recovery actions that conceptually
|
|
1646
|
-
// inserts some missing token or rule.
|
|
1647
|
-
/// @internal
|
|
1648
|
-
recoverByInsert(next) {
|
|
1649
|
-
if (this.stack.length >= 300)
|
|
1650
|
-
return [];
|
|
1651
|
-
let nextStates = this.p.parser.nextStates(this.state);
|
|
1652
|
-
if (nextStates.length > 4 << 1 || this.stack.length >= 120) {
|
|
1653
|
-
let best = [];
|
|
1654
|
-
for (let i = 0, s; i < nextStates.length; i += 2) {
|
|
1655
|
-
if ((s = nextStates[i + 1]) != this.state && this.p.parser.hasAction(s, next))
|
|
1656
|
-
best.push(nextStates[i], s);
|
|
1657
|
-
}
|
|
1658
|
-
if (this.stack.length < 120)
|
|
1659
|
-
for (let i = 0; best.length < 4 << 1 && i < nextStates.length; i += 2) {
|
|
1660
|
-
let s = nextStates[i + 1];
|
|
1661
|
-
if (!best.some((v, i2) => i2 & 1 && v == s))
|
|
1662
|
-
best.push(nextStates[i], s);
|
|
1663
|
-
}
|
|
1664
|
-
nextStates = best;
|
|
1665
|
-
}
|
|
1666
|
-
let result = [];
|
|
1667
|
-
for (let i = 0; i < nextStates.length && result.length < 4; i += 2) {
|
|
1668
|
-
let s = nextStates[i + 1];
|
|
1669
|
-
if (s == this.state)
|
|
1670
|
-
continue;
|
|
1671
|
-
let stack = this.split();
|
|
1672
|
-
stack.pushState(s, this.pos);
|
|
1673
|
-
stack.storeNode(0, stack.pos, stack.pos, 4, true);
|
|
1674
|
-
stack.shiftContext(nextStates[i], this.pos);
|
|
1675
|
-
stack.score -= 200;
|
|
1676
|
-
result.push(stack);
|
|
1677
|
-
}
|
|
1678
|
-
return result;
|
|
1679
|
-
}
|
|
1680
|
-
// Force a reduce, if possible. Return false if that can't
|
|
1681
|
-
// be done.
|
|
1682
|
-
/// @internal
|
|
1683
|
-
forceReduce() {
|
|
1684
|
-
let { parser: parser2 } = this.p;
|
|
1685
|
-
let reduce = parser2.stateSlot(
|
|
1686
|
-
this.state,
|
|
1687
|
-
5
|
|
1688
|
-
/* ParseState.ForcedReduce */
|
|
1689
|
-
);
|
|
1690
|
-
if ((reduce & 65536) == 0)
|
|
1691
|
-
return false;
|
|
1692
|
-
if (!parser2.validAction(this.state, reduce)) {
|
|
1693
|
-
let depth = reduce >> 19, term = reduce & 65535;
|
|
1694
|
-
let target = this.stack.length - depth * 3;
|
|
1695
|
-
if (target < 0 || parser2.getGoto(this.stack[target], term, false) < 0) {
|
|
1696
|
-
let backup = this.findForcedReduction();
|
|
1697
|
-
if (backup == null)
|
|
1698
|
-
return false;
|
|
1699
|
-
reduce = backup;
|
|
1700
|
-
}
|
|
1701
|
-
this.storeNode(0, this.pos, this.pos, 4, true);
|
|
1702
|
-
this.score -= 100;
|
|
1703
|
-
}
|
|
1704
|
-
this.reducePos = this.pos;
|
|
1705
|
-
this.reduce(reduce);
|
|
1706
|
-
return true;
|
|
1707
|
-
}
|
|
1708
|
-
/// Try to scan through the automaton to find some kind of reduction
|
|
1709
|
-
/// that can be applied. Used when the regular ForcedReduce field
|
|
1710
|
-
/// isn't a valid action. @internal
|
|
1711
|
-
findForcedReduction() {
|
|
1712
|
-
let { parser: parser2 } = this.p, seen = [];
|
|
1713
|
-
let explore = (state, depth) => {
|
|
1714
|
-
if (seen.includes(state))
|
|
1715
|
-
return;
|
|
1716
|
-
seen.push(state);
|
|
1717
|
-
return parser2.allActions(state, (action) => {
|
|
1718
|
-
if (action & (262144 | 131072))
|
|
1719
|
-
;
|
|
1720
|
-
else if (action & 65536) {
|
|
1721
|
-
let rDepth = (action >> 19) - depth;
|
|
1722
|
-
if (rDepth > 1) {
|
|
1723
|
-
let term = action & 65535, target = this.stack.length - rDepth * 3;
|
|
1724
|
-
if (target >= 0 && parser2.getGoto(this.stack[target], term, false) >= 0)
|
|
1725
|
-
return rDepth << 19 | 65536 | term;
|
|
1726
|
-
}
|
|
1727
|
-
} else {
|
|
1728
|
-
let found = explore(action, depth + 1);
|
|
1729
|
-
if (found != null)
|
|
1730
|
-
return found;
|
|
1731
|
-
}
|
|
1732
|
-
});
|
|
1733
|
-
};
|
|
1734
|
-
return explore(this.state, 0);
|
|
1735
|
-
}
|
|
1736
|
-
/// @internal
|
|
1737
|
-
forceAll() {
|
|
1738
|
-
while (!this.p.parser.stateFlag(
|
|
1739
|
-
this.state,
|
|
1740
|
-
2
|
|
1741
|
-
/* StateFlag.Accepting */
|
|
1742
|
-
)) {
|
|
1743
|
-
if (!this.forceReduce()) {
|
|
1744
|
-
this.storeNode(0, this.pos, this.pos, 4, true);
|
|
1745
|
-
break;
|
|
1746
|
-
}
|
|
1747
|
-
}
|
|
1748
|
-
return this;
|
|
1749
|
-
}
|
|
1750
|
-
/// Check whether this state has no further actions (assumed to be a direct descendant of the
|
|
1751
|
-
/// top state, since any other states must be able to continue
|
|
1752
|
-
/// somehow). @internal
|
|
1753
|
-
get deadEnd() {
|
|
1754
|
-
if (this.stack.length != 3)
|
|
1755
|
-
return false;
|
|
1756
|
-
let { parser: parser2 } = this.p;
|
|
1757
|
-
return parser2.data[parser2.stateSlot(
|
|
1758
|
-
this.state,
|
|
1759
|
-
1
|
|
1760
|
-
/* ParseState.Actions */
|
|
1761
|
-
)] == 65535 && !parser2.stateSlot(
|
|
1762
|
-
this.state,
|
|
1763
|
-
4
|
|
1764
|
-
/* ParseState.DefaultReduce */
|
|
1765
|
-
);
|
|
1766
|
-
}
|
|
1767
|
-
/// Restart the stack (put it back in its start state). Only safe
|
|
1768
|
-
/// when this.stack.length == 3 (state is directly below the top
|
|
1769
|
-
/// state). @internal
|
|
1770
|
-
restart() {
|
|
1771
|
-
this.state = this.stack[0];
|
|
1772
|
-
this.stack.length = 0;
|
|
1773
|
-
}
|
|
1774
|
-
/// @internal
|
|
1775
|
-
sameState(other) {
|
|
1776
|
-
if (this.state != other.state || this.stack.length != other.stack.length)
|
|
1777
|
-
return false;
|
|
1778
|
-
for (let i = 0; i < this.stack.length; i += 3)
|
|
1779
|
-
if (this.stack[i] != other.stack[i])
|
|
1780
|
-
return false;
|
|
1781
|
-
return true;
|
|
1782
|
-
}
|
|
1783
|
-
/// Get the parser used by this stack.
|
|
1784
|
-
get parser() {
|
|
1785
|
-
return this.p.parser;
|
|
1786
|
-
}
|
|
1787
|
-
/// Test whether a given dialect (by numeric ID, as exported from
|
|
1788
|
-
/// the terms file) is enabled.
|
|
1789
|
-
dialectEnabled(dialectID) {
|
|
1790
|
-
return this.p.parser.dialect.flags[dialectID];
|
|
1791
|
-
}
|
|
1792
|
-
shiftContext(term, start) {
|
|
1793
|
-
if (this.curContext)
|
|
1794
|
-
this.updateContext(this.curContext.tracker.shift(this.curContext.context, term, this, this.p.stream.reset(start)));
|
|
1795
|
-
}
|
|
1796
|
-
reduceContext(term, start) {
|
|
1797
|
-
if (this.curContext)
|
|
1798
|
-
this.updateContext(this.curContext.tracker.reduce(this.curContext.context, term, this, this.p.stream.reset(start)));
|
|
1799
|
-
}
|
|
1800
|
-
/// @internal
|
|
1801
|
-
emitContext() {
|
|
1802
|
-
let last = this.buffer.length - 1;
|
|
1803
|
-
if (last < 0 || this.buffer[last] != -3)
|
|
1804
|
-
this.buffer.push(this.curContext.hash, this.pos, this.pos, -3);
|
|
1805
|
-
}
|
|
1806
|
-
/// @internal
|
|
1807
|
-
emitLookAhead() {
|
|
1808
|
-
let last = this.buffer.length - 1;
|
|
1809
|
-
if (last < 0 || this.buffer[last] != -4)
|
|
1810
|
-
this.buffer.push(this.lookAhead, this.pos, this.pos, -4);
|
|
1811
|
-
}
|
|
1812
|
-
updateContext(context) {
|
|
1813
|
-
if (context != this.curContext.context) {
|
|
1814
|
-
let newCx = new StackContext(this.curContext.tracker, context);
|
|
1815
|
-
if (newCx.hash != this.curContext.hash)
|
|
1816
|
-
this.emitContext();
|
|
1817
|
-
this.curContext = newCx;
|
|
1818
|
-
}
|
|
1819
|
-
}
|
|
1820
|
-
/// @internal
|
|
1821
|
-
setLookAhead(lookAhead) {
|
|
1822
|
-
if (lookAhead > this.lookAhead) {
|
|
1823
|
-
this.emitLookAhead();
|
|
1824
|
-
this.lookAhead = lookAhead;
|
|
1825
|
-
}
|
|
1826
|
-
}
|
|
1827
|
-
/// @internal
|
|
1828
|
-
close() {
|
|
1829
|
-
if (this.curContext && this.curContext.tracker.strict)
|
|
1830
|
-
this.emitContext();
|
|
1831
|
-
if (this.lookAhead > 0)
|
|
1832
|
-
this.emitLookAhead();
|
|
1833
|
-
}
|
|
1834
|
-
};
|
|
1835
|
-
var StackContext = class {
|
|
1836
|
-
constructor(tracker, context) {
|
|
1837
|
-
this.tracker = tracker;
|
|
1838
|
-
this.context = context;
|
|
1839
|
-
this.hash = tracker.strict ? tracker.hash(context) : 0;
|
|
1840
|
-
}
|
|
1841
|
-
};
|
|
1842
|
-
var Recover;
|
|
1843
|
-
(function(Recover2) {
|
|
1844
|
-
Recover2[Recover2["Insert"] = 200] = "Insert";
|
|
1845
|
-
Recover2[Recover2["Delete"] = 190] = "Delete";
|
|
1846
|
-
Recover2[Recover2["Reduce"] = 100] = "Reduce";
|
|
1847
|
-
Recover2[Recover2["MaxNext"] = 4] = "MaxNext";
|
|
1848
|
-
Recover2[Recover2["MaxInsertStackDepth"] = 300] = "MaxInsertStackDepth";
|
|
1849
|
-
Recover2[Recover2["DampenInsertStackDepth"] = 120] = "DampenInsertStackDepth";
|
|
1850
|
-
Recover2[Recover2["MinBigReduction"] = 2e3] = "MinBigReduction";
|
|
1851
|
-
})(Recover || (Recover = {}));
|
|
1852
|
-
var SimulatedStack = class {
|
|
1853
|
-
constructor(start) {
|
|
1854
|
-
this.start = start;
|
|
1855
|
-
this.state = start.state;
|
|
1856
|
-
this.stack = start.stack;
|
|
1857
|
-
this.base = this.stack.length;
|
|
1858
|
-
}
|
|
1859
|
-
reduce(action) {
|
|
1860
|
-
let term = action & 65535, depth = action >> 19;
|
|
1861
|
-
if (depth == 0) {
|
|
1862
|
-
if (this.stack == this.start.stack)
|
|
1863
|
-
this.stack = this.stack.slice();
|
|
1864
|
-
this.stack.push(this.state, 0, 0);
|
|
1865
|
-
this.base += 3;
|
|
1866
|
-
} else {
|
|
1867
|
-
this.base -= (depth - 1) * 3;
|
|
1868
|
-
}
|
|
1869
|
-
let goto = this.start.p.parser.getGoto(this.stack[this.base - 3], term, true);
|
|
1870
|
-
this.state = goto;
|
|
1871
|
-
}
|
|
1872
|
-
};
|
|
1873
|
-
var StackBufferCursor = class _StackBufferCursor {
|
|
1874
|
-
constructor(stack, pos, index) {
|
|
1875
|
-
this.stack = stack;
|
|
1876
|
-
this.pos = pos;
|
|
1877
|
-
this.index = index;
|
|
1878
|
-
this.buffer = stack.buffer;
|
|
1879
|
-
if (this.index == 0)
|
|
1880
|
-
this.maybeNext();
|
|
1881
|
-
}
|
|
1882
|
-
static create(stack, pos = stack.bufferBase + stack.buffer.length) {
|
|
1883
|
-
return new _StackBufferCursor(stack, pos, pos - stack.bufferBase);
|
|
1884
|
-
}
|
|
1885
|
-
maybeNext() {
|
|
1886
|
-
let next = this.stack.parent;
|
|
1887
|
-
if (next != null) {
|
|
1888
|
-
this.index = this.stack.bufferBase - next.bufferBase;
|
|
1889
|
-
this.stack = next;
|
|
1890
|
-
this.buffer = next.buffer;
|
|
1891
|
-
}
|
|
1892
|
-
}
|
|
1893
|
-
get id() {
|
|
1894
|
-
return this.buffer[this.index - 4];
|
|
1895
|
-
}
|
|
1896
|
-
get start() {
|
|
1897
|
-
return this.buffer[this.index - 3];
|
|
1898
|
-
}
|
|
1899
|
-
get end() {
|
|
1900
|
-
return this.buffer[this.index - 2];
|
|
1901
|
-
}
|
|
1902
|
-
get size() {
|
|
1903
|
-
return this.buffer[this.index - 1];
|
|
1904
|
-
}
|
|
1905
|
-
next() {
|
|
1906
|
-
this.index -= 4;
|
|
1907
|
-
this.pos -= 4;
|
|
1908
|
-
if (this.index == 0)
|
|
1909
|
-
this.maybeNext();
|
|
1910
|
-
}
|
|
1911
|
-
fork() {
|
|
1912
|
-
return new _StackBufferCursor(this.stack, this.pos, this.index);
|
|
1913
|
-
}
|
|
1914
|
-
};
|
|
1915
|
-
function decodeArray(input, Type = Uint16Array) {
|
|
1916
|
-
if (typeof input != "string")
|
|
1917
|
-
return input;
|
|
1918
|
-
let array = null;
|
|
1919
|
-
for (let pos = 0, out = 0; pos < input.length; ) {
|
|
1920
|
-
let value = 0;
|
|
1921
|
-
for (; ; ) {
|
|
1922
|
-
let next = input.charCodeAt(pos++), stop = false;
|
|
1923
|
-
if (next == 126) {
|
|
1924
|
-
value = 65535;
|
|
1925
|
-
break;
|
|
1926
|
-
}
|
|
1927
|
-
if (next >= 92)
|
|
1928
|
-
next--;
|
|
1929
|
-
if (next >= 34)
|
|
1930
|
-
next--;
|
|
1931
|
-
let digit = next - 32;
|
|
1932
|
-
if (digit >= 46) {
|
|
1933
|
-
digit -= 46;
|
|
1934
|
-
stop = true;
|
|
1935
|
-
}
|
|
1936
|
-
value += digit;
|
|
1937
|
-
if (stop)
|
|
1938
|
-
break;
|
|
1939
|
-
value *= 46;
|
|
1940
|
-
}
|
|
1941
|
-
if (array)
|
|
1942
|
-
array[out++] = value;
|
|
1943
|
-
else
|
|
1944
|
-
array = new Type(value);
|
|
1945
|
-
}
|
|
1946
|
-
return array;
|
|
1947
|
-
}
|
|
1948
|
-
var CachedToken = class {
|
|
1949
|
-
constructor() {
|
|
1950
|
-
this.start = -1;
|
|
1951
|
-
this.value = -1;
|
|
1952
|
-
this.end = -1;
|
|
1953
|
-
this.extended = -1;
|
|
1954
|
-
this.lookAhead = 0;
|
|
1955
|
-
this.mask = 0;
|
|
1956
|
-
this.context = 0;
|
|
1957
|
-
}
|
|
1958
|
-
};
|
|
1959
|
-
var nullToken = new CachedToken();
|
|
1960
|
-
var InputStream = class {
|
|
1961
|
-
/// @internal
|
|
1962
|
-
constructor(input, ranges) {
|
|
1963
|
-
this.input = input;
|
|
1964
|
-
this.ranges = ranges;
|
|
1965
|
-
this.chunk = "";
|
|
1966
|
-
this.chunkOff = 0;
|
|
1967
|
-
this.chunk2 = "";
|
|
1968
|
-
this.chunk2Pos = 0;
|
|
1969
|
-
this.next = -1;
|
|
1970
|
-
this.token = nullToken;
|
|
1971
|
-
this.rangeIndex = 0;
|
|
1972
|
-
this.pos = this.chunkPos = ranges[0].from;
|
|
1973
|
-
this.range = ranges[0];
|
|
1974
|
-
this.end = ranges[ranges.length - 1].to;
|
|
1975
|
-
this.readNext();
|
|
1976
|
-
}
|
|
1977
|
-
/// @internal
|
|
1978
|
-
resolveOffset(offset, assoc) {
|
|
1979
|
-
let range = this.range, index = this.rangeIndex;
|
|
1980
|
-
let pos = this.pos + offset;
|
|
1981
|
-
while (pos < range.from) {
|
|
1982
|
-
if (!index)
|
|
1983
|
-
return null;
|
|
1984
|
-
let next = this.ranges[--index];
|
|
1985
|
-
pos -= range.from - next.to;
|
|
1986
|
-
range = next;
|
|
1987
|
-
}
|
|
1988
|
-
while (assoc < 0 ? pos > range.to : pos >= range.to) {
|
|
1989
|
-
if (index == this.ranges.length - 1)
|
|
1990
|
-
return null;
|
|
1991
|
-
let next = this.ranges[++index];
|
|
1992
|
-
pos += next.from - range.to;
|
|
1993
|
-
range = next;
|
|
1994
|
-
}
|
|
1995
|
-
return pos;
|
|
1996
|
-
}
|
|
1997
|
-
/// @internal
|
|
1998
|
-
clipPos(pos) {
|
|
1999
|
-
if (pos >= this.range.from && pos < this.range.to)
|
|
2000
|
-
return pos;
|
|
2001
|
-
for (let range of this.ranges)
|
|
2002
|
-
if (range.to > pos)
|
|
2003
|
-
return Math.max(pos, range.from);
|
|
2004
|
-
return this.end;
|
|
2005
|
-
}
|
|
2006
|
-
/// Look at a code unit near the stream position. `.peek(0)` equals
|
|
2007
|
-
/// `.next`, `.peek(-1)` gives you the previous character, and so
|
|
2008
|
-
/// on.
|
|
2009
|
-
///
|
|
2010
|
-
/// Note that looking around during tokenizing creates dependencies
|
|
2011
|
-
/// on potentially far-away content, which may reduce the
|
|
2012
|
-
/// effectiveness incremental parsing—when looking forward—or even
|
|
2013
|
-
/// cause invalid reparses when looking backward more than 25 code
|
|
2014
|
-
/// units, since the library does not track lookbehind.
|
|
2015
|
-
peek(offset) {
|
|
2016
|
-
let idx = this.chunkOff + offset, pos, result;
|
|
2017
|
-
if (idx >= 0 && idx < this.chunk.length) {
|
|
2018
|
-
pos = this.pos + offset;
|
|
2019
|
-
result = this.chunk.charCodeAt(idx);
|
|
2020
|
-
} else {
|
|
2021
|
-
let resolved = this.resolveOffset(offset, 1);
|
|
2022
|
-
if (resolved == null)
|
|
2023
|
-
return -1;
|
|
2024
|
-
pos = resolved;
|
|
2025
|
-
if (pos >= this.chunk2Pos && pos < this.chunk2Pos + this.chunk2.length) {
|
|
2026
|
-
result = this.chunk2.charCodeAt(pos - this.chunk2Pos);
|
|
2027
|
-
} else {
|
|
2028
|
-
let i = this.rangeIndex, range = this.range;
|
|
2029
|
-
while (range.to <= pos)
|
|
2030
|
-
range = this.ranges[++i];
|
|
2031
|
-
this.chunk2 = this.input.chunk(this.chunk2Pos = pos);
|
|
2032
|
-
if (pos + this.chunk2.length > range.to)
|
|
2033
|
-
this.chunk2 = this.chunk2.slice(0, range.to - pos);
|
|
2034
|
-
result = this.chunk2.charCodeAt(0);
|
|
2035
|
-
}
|
|
2036
|
-
}
|
|
2037
|
-
if (pos >= this.token.lookAhead)
|
|
2038
|
-
this.token.lookAhead = pos + 1;
|
|
2039
|
-
return result;
|
|
2040
|
-
}
|
|
2041
|
-
/// Accept a token. By default, the end of the token is set to the
|
|
2042
|
-
/// current stream position, but you can pass an offset (relative to
|
|
2043
|
-
/// the stream position) to change that.
|
|
2044
|
-
acceptToken(token, endOffset = 0) {
|
|
2045
|
-
let end = endOffset ? this.resolveOffset(endOffset, -1) : this.pos;
|
|
2046
|
-
if (end == null || end < this.token.start)
|
|
2047
|
-
throw new RangeError("Token end out of bounds");
|
|
2048
|
-
this.token.value = token;
|
|
2049
|
-
this.token.end = end;
|
|
2050
|
-
}
|
|
2051
|
-
getChunk() {
|
|
2052
|
-
if (this.pos >= this.chunk2Pos && this.pos < this.chunk2Pos + this.chunk2.length) {
|
|
2053
|
-
let { chunk, chunkPos } = this;
|
|
2054
|
-
this.chunk = this.chunk2;
|
|
2055
|
-
this.chunkPos = this.chunk2Pos;
|
|
2056
|
-
this.chunk2 = chunk;
|
|
2057
|
-
this.chunk2Pos = chunkPos;
|
|
2058
|
-
this.chunkOff = this.pos - this.chunkPos;
|
|
2059
|
-
} else {
|
|
2060
|
-
this.chunk2 = this.chunk;
|
|
2061
|
-
this.chunk2Pos = this.chunkPos;
|
|
2062
|
-
let nextChunk = this.input.chunk(this.pos);
|
|
2063
|
-
let end = this.pos + nextChunk.length;
|
|
2064
|
-
this.chunk = end > this.range.to ? nextChunk.slice(0, this.range.to - this.pos) : nextChunk;
|
|
2065
|
-
this.chunkPos = this.pos;
|
|
2066
|
-
this.chunkOff = 0;
|
|
2067
|
-
}
|
|
2068
|
-
}
|
|
2069
|
-
readNext() {
|
|
2070
|
-
if (this.chunkOff >= this.chunk.length) {
|
|
2071
|
-
this.getChunk();
|
|
2072
|
-
if (this.chunkOff == this.chunk.length)
|
|
2073
|
-
return this.next = -1;
|
|
2074
|
-
}
|
|
2075
|
-
return this.next = this.chunk.charCodeAt(this.chunkOff);
|
|
2076
|
-
}
|
|
2077
|
-
/// Move the stream forward N (defaults to 1) code units. Returns
|
|
2078
|
-
/// the new value of [`next`](#lr.InputStream.next).
|
|
2079
|
-
advance(n = 1) {
|
|
2080
|
-
this.chunkOff += n;
|
|
2081
|
-
while (this.pos + n >= this.range.to) {
|
|
2082
|
-
if (this.rangeIndex == this.ranges.length - 1)
|
|
2083
|
-
return this.setDone();
|
|
2084
|
-
n -= this.range.to - this.pos;
|
|
2085
|
-
this.range = this.ranges[++this.rangeIndex];
|
|
2086
|
-
this.pos = this.range.from;
|
|
2087
|
-
}
|
|
2088
|
-
this.pos += n;
|
|
2089
|
-
if (this.pos >= this.token.lookAhead)
|
|
2090
|
-
this.token.lookAhead = this.pos + 1;
|
|
2091
|
-
return this.readNext();
|
|
2092
|
-
}
|
|
2093
|
-
setDone() {
|
|
2094
|
-
this.pos = this.chunkPos = this.end;
|
|
2095
|
-
this.range = this.ranges[this.rangeIndex = this.ranges.length - 1];
|
|
2096
|
-
this.chunk = "";
|
|
2097
|
-
return this.next = -1;
|
|
2098
|
-
}
|
|
2099
|
-
/// @internal
|
|
2100
|
-
reset(pos, token) {
|
|
2101
|
-
if (token) {
|
|
2102
|
-
this.token = token;
|
|
2103
|
-
token.start = pos;
|
|
2104
|
-
token.lookAhead = pos + 1;
|
|
2105
|
-
token.value = token.extended = -1;
|
|
2106
|
-
} else {
|
|
2107
|
-
this.token = nullToken;
|
|
2108
|
-
}
|
|
2109
|
-
if (this.pos != pos) {
|
|
2110
|
-
this.pos = pos;
|
|
2111
|
-
if (pos == this.end) {
|
|
2112
|
-
this.setDone();
|
|
2113
|
-
return this;
|
|
2114
|
-
}
|
|
2115
|
-
while (pos < this.range.from)
|
|
2116
|
-
this.range = this.ranges[--this.rangeIndex];
|
|
2117
|
-
while (pos >= this.range.to)
|
|
2118
|
-
this.range = this.ranges[++this.rangeIndex];
|
|
2119
|
-
if (pos >= this.chunkPos && pos < this.chunkPos + this.chunk.length) {
|
|
2120
|
-
this.chunkOff = pos - this.chunkPos;
|
|
2121
|
-
} else {
|
|
2122
|
-
this.chunk = "";
|
|
2123
|
-
this.chunkOff = 0;
|
|
2124
|
-
}
|
|
2125
|
-
this.readNext();
|
|
2126
|
-
}
|
|
2127
|
-
return this;
|
|
2128
|
-
}
|
|
2129
|
-
/// @internal
|
|
2130
|
-
read(from, to) {
|
|
2131
|
-
if (from >= this.chunkPos && to <= this.chunkPos + this.chunk.length)
|
|
2132
|
-
return this.chunk.slice(from - this.chunkPos, to - this.chunkPos);
|
|
2133
|
-
if (from >= this.chunk2Pos && to <= this.chunk2Pos + this.chunk2.length)
|
|
2134
|
-
return this.chunk2.slice(from - this.chunk2Pos, to - this.chunk2Pos);
|
|
2135
|
-
if (from >= this.range.from && to <= this.range.to)
|
|
2136
|
-
return this.input.read(from, to);
|
|
2137
|
-
let result = "";
|
|
2138
|
-
for (let r of this.ranges) {
|
|
2139
|
-
if (r.from >= to)
|
|
2140
|
-
break;
|
|
2141
|
-
if (r.to > from)
|
|
2142
|
-
result += this.input.read(Math.max(r.from, from), Math.min(r.to, to));
|
|
2143
|
-
}
|
|
2144
|
-
return result;
|
|
2145
|
-
}
|
|
2146
|
-
};
|
|
2147
|
-
var TokenGroup = class {
|
|
2148
|
-
constructor(data, id) {
|
|
2149
|
-
this.data = data;
|
|
2150
|
-
this.id = id;
|
|
2151
|
-
}
|
|
2152
|
-
token(input, stack) {
|
|
2153
|
-
let { parser: parser2 } = stack.p;
|
|
2154
|
-
readToken(this.data, input, stack, this.id, parser2.data, parser2.tokenPrecTable);
|
|
2155
|
-
}
|
|
2156
|
-
};
|
|
2157
|
-
TokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
|
|
2158
|
-
var LocalTokenGroup = class {
|
|
2159
|
-
constructor(data, precTable, elseToken) {
|
|
2160
|
-
this.precTable = precTable;
|
|
2161
|
-
this.elseToken = elseToken;
|
|
2162
|
-
this.data = typeof data == "string" ? decodeArray(data) : data;
|
|
2163
|
-
}
|
|
2164
|
-
token(input, stack) {
|
|
2165
|
-
let start = input.pos, skipped = 0;
|
|
2166
|
-
for (; ; ) {
|
|
2167
|
-
let atEof = input.next < 0, nextPos = input.resolveOffset(1, 1);
|
|
2168
|
-
readToken(this.data, input, stack, 0, this.data, this.precTable);
|
|
2169
|
-
if (input.token.value > -1)
|
|
2170
|
-
break;
|
|
2171
|
-
if (this.elseToken == null)
|
|
2172
|
-
return;
|
|
2173
|
-
if (!atEof)
|
|
2174
|
-
skipped++;
|
|
2175
|
-
if (nextPos == null)
|
|
2176
|
-
break;
|
|
2177
|
-
input.reset(nextPos, input.token);
|
|
2178
|
-
}
|
|
2179
|
-
if (skipped) {
|
|
2180
|
-
input.reset(start, input.token);
|
|
2181
|
-
input.acceptToken(this.elseToken, skipped);
|
|
2182
|
-
}
|
|
2183
|
-
}
|
|
2184
|
-
};
|
|
2185
|
-
LocalTokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
|
|
2186
|
-
function readToken(data, input, stack, group, precTable, precOffset) {
|
|
2187
|
-
let state = 0, groupMask = 1 << group, { dialect } = stack.p.parser;
|
|
2188
|
-
scan:
|
|
2189
|
-
for (; ; ) {
|
|
2190
|
-
if ((groupMask & data[state]) == 0)
|
|
2191
|
-
break;
|
|
2192
|
-
let accEnd = data[state + 1];
|
|
2193
|
-
for (let i = state + 3; i < accEnd; i += 2)
|
|
2194
|
-
if ((data[i + 1] & groupMask) > 0) {
|
|
2195
|
-
let term = data[i];
|
|
2196
|
-
if (dialect.allows(term) && (input.token.value == -1 || input.token.value == term || overrides(term, input.token.value, precTable, precOffset))) {
|
|
2197
|
-
input.acceptToken(term);
|
|
2198
|
-
break;
|
|
2199
|
-
}
|
|
2200
|
-
}
|
|
2201
|
-
let next = input.next, low = 0, high = data[state + 2];
|
|
2202
|
-
if (input.next < 0 && high > low && data[accEnd + high * 3 - 3] == 65535 && data[accEnd + high * 3 - 3] == 65535) {
|
|
2203
|
-
state = data[accEnd + high * 3 - 1];
|
|
2204
|
-
continue scan;
|
|
2205
|
-
}
|
|
2206
|
-
for (; low < high; ) {
|
|
2207
|
-
let mid = low + high >> 1;
|
|
2208
|
-
let index = accEnd + mid + (mid << 1);
|
|
2209
|
-
let from = data[index], to = data[index + 1] || 65536;
|
|
2210
|
-
if (next < from)
|
|
2211
|
-
high = mid;
|
|
2212
|
-
else if (next >= to)
|
|
2213
|
-
low = mid + 1;
|
|
2214
|
-
else {
|
|
2215
|
-
state = data[index + 2];
|
|
2216
|
-
input.advance();
|
|
2217
|
-
continue scan;
|
|
2218
|
-
}
|
|
2219
|
-
}
|
|
2220
|
-
break;
|
|
2221
|
-
}
|
|
2222
|
-
}
|
|
2223
|
-
function findOffset(data, start, term) {
|
|
2224
|
-
for (let i = start, next; (next = data[i]) != 65535; i++)
|
|
2225
|
-
if (next == term)
|
|
2226
|
-
return i - start;
|
|
2227
|
-
return -1;
|
|
2228
|
-
}
|
|
2229
|
-
function overrides(token, prev, tableData, tableOffset) {
|
|
2230
|
-
let iPrev = findOffset(tableData, tableOffset, prev);
|
|
2231
|
-
return iPrev < 0 || findOffset(tableData, tableOffset, token) < iPrev;
|
|
2232
|
-
}
|
|
2233
|
-
var verbose = typeof process != "undefined" && process.env && /\bparse\b/.test(process.env.LOG);
|
|
2234
|
-
var stackIDs = null;
|
|
2235
|
-
var Safety;
|
|
2236
|
-
(function(Safety2) {
|
|
2237
|
-
Safety2[Safety2["Margin"] = 25] = "Margin";
|
|
2238
|
-
})(Safety || (Safety = {}));
|
|
2239
|
-
function cutAt(tree, pos, side) {
|
|
2240
|
-
let cursor = tree.cursor(IterMode.IncludeAnonymous);
|
|
2241
|
-
cursor.moveTo(pos);
|
|
2242
|
-
for (; ; ) {
|
|
2243
|
-
if (!(side < 0 ? cursor.childBefore(pos) : cursor.childAfter(pos)))
|
|
2244
|
-
for (; ; ) {
|
|
2245
|
-
if ((side < 0 ? cursor.to < pos : cursor.from > pos) && !cursor.type.isError)
|
|
2246
|
-
return side < 0 ? Math.max(0, Math.min(
|
|
2247
|
-
cursor.to - 1,
|
|
2248
|
-
pos - 25
|
|
2249
|
-
/* Safety.Margin */
|
|
2250
|
-
)) : Math.min(tree.length, Math.max(
|
|
2251
|
-
cursor.from + 1,
|
|
2252
|
-
pos + 25
|
|
2253
|
-
/* Safety.Margin */
|
|
2254
|
-
));
|
|
2255
|
-
if (side < 0 ? cursor.prevSibling() : cursor.nextSibling())
|
|
2256
|
-
break;
|
|
2257
|
-
if (!cursor.parent())
|
|
2258
|
-
return side < 0 ? 0 : tree.length;
|
|
2259
|
-
}
|
|
2260
|
-
}
|
|
2261
|
-
}
|
|
2262
|
-
var FragmentCursor = class {
|
|
2263
|
-
constructor(fragments, nodeSet) {
|
|
2264
|
-
this.fragments = fragments;
|
|
2265
|
-
this.nodeSet = nodeSet;
|
|
2266
|
-
this.i = 0;
|
|
2267
|
-
this.fragment = null;
|
|
2268
|
-
this.safeFrom = -1;
|
|
2269
|
-
this.safeTo = -1;
|
|
2270
|
-
this.trees = [];
|
|
2271
|
-
this.start = [];
|
|
2272
|
-
this.index = [];
|
|
2273
|
-
this.nextFragment();
|
|
2274
|
-
}
|
|
2275
|
-
nextFragment() {
|
|
2276
|
-
let fr = this.fragment = this.i == this.fragments.length ? null : this.fragments[this.i++];
|
|
2277
|
-
if (fr) {
|
|
2278
|
-
this.safeFrom = fr.openStart ? cutAt(fr.tree, fr.from + fr.offset, 1) - fr.offset : fr.from;
|
|
2279
|
-
this.safeTo = fr.openEnd ? cutAt(fr.tree, fr.to + fr.offset, -1) - fr.offset : fr.to;
|
|
2280
|
-
while (this.trees.length) {
|
|
2281
|
-
this.trees.pop();
|
|
2282
|
-
this.start.pop();
|
|
2283
|
-
this.index.pop();
|
|
2284
|
-
}
|
|
2285
|
-
this.trees.push(fr.tree);
|
|
2286
|
-
this.start.push(-fr.offset);
|
|
2287
|
-
this.index.push(0);
|
|
2288
|
-
this.nextStart = this.safeFrom;
|
|
2289
|
-
} else {
|
|
2290
|
-
this.nextStart = 1e9;
|
|
2291
|
-
}
|
|
2292
|
-
}
|
|
2293
|
-
// `pos` must be >= any previously given `pos` for this cursor
|
|
2294
|
-
nodeAt(pos) {
|
|
2295
|
-
if (pos < this.nextStart)
|
|
2296
|
-
return null;
|
|
2297
|
-
while (this.fragment && this.safeTo <= pos)
|
|
2298
|
-
this.nextFragment();
|
|
2299
|
-
if (!this.fragment)
|
|
2300
|
-
return null;
|
|
2301
|
-
for (; ; ) {
|
|
2302
|
-
let last = this.trees.length - 1;
|
|
2303
|
-
if (last < 0) {
|
|
2304
|
-
this.nextFragment();
|
|
2305
|
-
return null;
|
|
2306
|
-
}
|
|
2307
|
-
let top = this.trees[last], index = this.index[last];
|
|
2308
|
-
if (index == top.children.length) {
|
|
2309
|
-
this.trees.pop();
|
|
2310
|
-
this.start.pop();
|
|
2311
|
-
this.index.pop();
|
|
2312
|
-
continue;
|
|
2313
|
-
}
|
|
2314
|
-
let next = top.children[index];
|
|
2315
|
-
let start = this.start[last] + top.positions[index];
|
|
2316
|
-
if (start > pos) {
|
|
2317
|
-
this.nextStart = start;
|
|
2318
|
-
return null;
|
|
2319
|
-
}
|
|
2320
|
-
if (next instanceof Tree) {
|
|
2321
|
-
if (start == pos) {
|
|
2322
|
-
if (start < this.safeFrom)
|
|
2323
|
-
return null;
|
|
2324
|
-
let end = start + next.length;
|
|
2325
|
-
if (end <= this.safeTo) {
|
|
2326
|
-
let lookAhead = next.prop(NodeProp.lookAhead);
|
|
2327
|
-
if (!lookAhead || end + lookAhead < this.fragment.to)
|
|
2328
|
-
return next;
|
|
2329
|
-
}
|
|
2330
|
-
}
|
|
2331
|
-
this.index[last]++;
|
|
2332
|
-
if (start + next.length >= Math.max(this.safeFrom, pos)) {
|
|
2333
|
-
this.trees.push(next);
|
|
2334
|
-
this.start.push(start);
|
|
2335
|
-
this.index.push(0);
|
|
2336
|
-
}
|
|
2337
|
-
} else {
|
|
2338
|
-
this.index[last]++;
|
|
2339
|
-
this.nextStart = start + next.length;
|
|
2340
|
-
}
|
|
2341
|
-
}
|
|
2342
|
-
}
|
|
2343
|
-
};
|
|
2344
|
-
var TokenCache = class {
|
|
2345
|
-
constructor(parser2, stream) {
|
|
2346
|
-
this.stream = stream;
|
|
2347
|
-
this.tokens = [];
|
|
2348
|
-
this.mainToken = null;
|
|
2349
|
-
this.actions = [];
|
|
2350
|
-
this.tokens = parser2.tokenizers.map((_) => new CachedToken());
|
|
2351
|
-
}
|
|
2352
|
-
getActions(stack) {
|
|
2353
|
-
let actionIndex = 0;
|
|
2354
|
-
let main = null;
|
|
2355
|
-
let { parser: parser2 } = stack.p, { tokenizers } = parser2;
|
|
2356
|
-
let mask = parser2.stateSlot(
|
|
2357
|
-
stack.state,
|
|
2358
|
-
3
|
|
2359
|
-
/* ParseState.TokenizerMask */
|
|
2360
|
-
);
|
|
2361
|
-
let context = stack.curContext ? stack.curContext.hash : 0;
|
|
2362
|
-
let lookAhead = 0;
|
|
2363
|
-
for (let i = 0; i < tokenizers.length; i++) {
|
|
2364
|
-
if ((1 << i & mask) == 0)
|
|
2365
|
-
continue;
|
|
2366
|
-
let tokenizer = tokenizers[i], token = this.tokens[i];
|
|
2367
|
-
if (main && !tokenizer.fallback)
|
|
2368
|
-
continue;
|
|
2369
|
-
if (tokenizer.contextual || token.start != stack.pos || token.mask != mask || token.context != context) {
|
|
2370
|
-
this.updateCachedToken(token, tokenizer, stack);
|
|
2371
|
-
token.mask = mask;
|
|
2372
|
-
token.context = context;
|
|
2373
|
-
}
|
|
2374
|
-
if (token.lookAhead > token.end + 25)
|
|
2375
|
-
lookAhead = Math.max(token.lookAhead, lookAhead);
|
|
2376
|
-
if (token.value != 0) {
|
|
2377
|
-
let startIndex = actionIndex;
|
|
2378
|
-
if (token.extended > -1)
|
|
2379
|
-
actionIndex = this.addActions(stack, token.extended, token.end, actionIndex);
|
|
2380
|
-
actionIndex = this.addActions(stack, token.value, token.end, actionIndex);
|
|
2381
|
-
if (!tokenizer.extend) {
|
|
2382
|
-
main = token;
|
|
2383
|
-
if (actionIndex > startIndex)
|
|
2384
|
-
break;
|
|
2385
|
-
}
|
|
2386
|
-
}
|
|
2387
|
-
}
|
|
2388
|
-
while (this.actions.length > actionIndex)
|
|
2389
|
-
this.actions.pop();
|
|
2390
|
-
if (lookAhead)
|
|
2391
|
-
stack.setLookAhead(lookAhead);
|
|
2392
|
-
if (!main && stack.pos == this.stream.end) {
|
|
2393
|
-
main = new CachedToken();
|
|
2394
|
-
main.value = stack.p.parser.eofTerm;
|
|
2395
|
-
main.start = main.end = stack.pos;
|
|
2396
|
-
actionIndex = this.addActions(stack, main.value, main.end, actionIndex);
|
|
2397
|
-
}
|
|
2398
|
-
this.mainToken = main;
|
|
2399
|
-
return this.actions;
|
|
2400
|
-
}
|
|
2401
|
-
getMainToken(stack) {
|
|
2402
|
-
if (this.mainToken)
|
|
2403
|
-
return this.mainToken;
|
|
2404
|
-
let main = new CachedToken(), { pos, p } = stack;
|
|
2405
|
-
main.start = pos;
|
|
2406
|
-
main.end = Math.min(pos + 1, p.stream.end);
|
|
2407
|
-
main.value = pos == p.stream.end ? p.parser.eofTerm : 0;
|
|
2408
|
-
return main;
|
|
2409
|
-
}
|
|
2410
|
-
updateCachedToken(token, tokenizer, stack) {
|
|
2411
|
-
let start = this.stream.clipPos(stack.pos);
|
|
2412
|
-
tokenizer.token(this.stream.reset(start, token), stack);
|
|
2413
|
-
if (token.value > -1) {
|
|
2414
|
-
let { parser: parser2 } = stack.p;
|
|
2415
|
-
for (let i = 0; i < parser2.specialized.length; i++)
|
|
2416
|
-
if (parser2.specialized[i] == token.value) {
|
|
2417
|
-
let result = parser2.specializers[i](this.stream.read(token.start, token.end), stack);
|
|
2418
|
-
if (result >= 0 && stack.p.parser.dialect.allows(result >> 1)) {
|
|
2419
|
-
if ((result & 1) == 0)
|
|
2420
|
-
token.value = result >> 1;
|
|
2421
|
-
else
|
|
2422
|
-
token.extended = result >> 1;
|
|
2423
|
-
break;
|
|
2424
|
-
}
|
|
2425
|
-
}
|
|
2426
|
-
} else {
|
|
2427
|
-
token.value = 0;
|
|
2428
|
-
token.end = this.stream.clipPos(start + 1);
|
|
2429
|
-
}
|
|
2430
|
-
}
|
|
2431
|
-
putAction(action, token, end, index) {
|
|
2432
|
-
for (let i = 0; i < index; i += 3)
|
|
2433
|
-
if (this.actions[i] == action)
|
|
2434
|
-
return index;
|
|
2435
|
-
this.actions[index++] = action;
|
|
2436
|
-
this.actions[index++] = token;
|
|
2437
|
-
this.actions[index++] = end;
|
|
2438
|
-
return index;
|
|
2439
|
-
}
|
|
2440
|
-
addActions(stack, token, end, index) {
|
|
2441
|
-
let { state } = stack, { parser: parser2 } = stack.p, { data } = parser2;
|
|
2442
|
-
for (let set = 0; set < 2; set++) {
|
|
2443
|
-
for (let i = parser2.stateSlot(
|
|
2444
|
-
state,
|
|
2445
|
-
set ? 2 : 1
|
|
2446
|
-
/* ParseState.Actions */
|
|
2447
|
-
); ; i += 3) {
|
|
2448
|
-
if (data[i] == 65535) {
|
|
2449
|
-
if (data[i + 1] == 1) {
|
|
2450
|
-
i = pair(data, i + 2);
|
|
2451
|
-
} else {
|
|
2452
|
-
if (index == 0 && data[i + 1] == 2)
|
|
2453
|
-
index = this.putAction(pair(data, i + 2), token, end, index);
|
|
2454
|
-
break;
|
|
2455
|
-
}
|
|
2456
|
-
}
|
|
2457
|
-
if (data[i] == token)
|
|
2458
|
-
index = this.putAction(pair(data, i + 1), token, end, index);
|
|
2459
|
-
}
|
|
2460
|
-
}
|
|
2461
|
-
return index;
|
|
2462
|
-
}
|
|
2463
|
-
};
|
|
2464
|
-
var Rec;
|
|
2465
|
-
(function(Rec2) {
|
|
2466
|
-
Rec2[Rec2["Distance"] = 5] = "Distance";
|
|
2467
|
-
Rec2[Rec2["MaxRemainingPerStep"] = 3] = "MaxRemainingPerStep";
|
|
2468
|
-
Rec2[Rec2["MinBufferLengthPrune"] = 500] = "MinBufferLengthPrune";
|
|
2469
|
-
Rec2[Rec2["ForceReduceLimit"] = 10] = "ForceReduceLimit";
|
|
2470
|
-
Rec2[Rec2["CutDepth"] = 15e3] = "CutDepth";
|
|
2471
|
-
Rec2[Rec2["CutTo"] = 9e3] = "CutTo";
|
|
2472
|
-
Rec2[Rec2["MaxLeftAssociativeReductionCount"] = 300] = "MaxLeftAssociativeReductionCount";
|
|
2473
|
-
Rec2[Rec2["MaxStackCount"] = 12] = "MaxStackCount";
|
|
2474
|
-
})(Rec || (Rec = {}));
|
|
2475
|
-
var Parse = class {
|
|
2476
|
-
constructor(parser2, input, fragments, ranges) {
|
|
2477
|
-
this.parser = parser2;
|
|
2478
|
-
this.input = input;
|
|
2479
|
-
this.ranges = ranges;
|
|
2480
|
-
this.recovering = 0;
|
|
2481
|
-
this.nextStackID = 9812;
|
|
2482
|
-
this.minStackPos = 0;
|
|
2483
|
-
this.reused = [];
|
|
2484
|
-
this.stoppedAt = null;
|
|
2485
|
-
this.lastBigReductionStart = -1;
|
|
2486
|
-
this.lastBigReductionSize = 0;
|
|
2487
|
-
this.bigReductionCount = 0;
|
|
2488
|
-
this.stream = new InputStream(input, ranges);
|
|
2489
|
-
this.tokens = new TokenCache(parser2, this.stream);
|
|
2490
|
-
this.topTerm = parser2.top[1];
|
|
2491
|
-
let { from } = ranges[0];
|
|
2492
|
-
this.stacks = [Stack.start(this, parser2.top[0], from)];
|
|
2493
|
-
this.fragments = fragments.length && this.stream.end - from > parser2.bufferLength * 4 ? new FragmentCursor(fragments, parser2.nodeSet) : null;
|
|
2494
|
-
}
|
|
2495
|
-
get parsedPos() {
|
|
2496
|
-
return this.minStackPos;
|
|
2497
|
-
}
|
|
2498
|
-
// Move the parser forward. This will process all parse stacks at
|
|
2499
|
-
// `this.pos` and try to advance them to a further position. If no
|
|
2500
|
-
// stack for such a position is found, it'll start error-recovery.
|
|
2501
|
-
//
|
|
2502
|
-
// When the parse is finished, this will return a syntax tree. When
|
|
2503
|
-
// not, it returns `null`.
|
|
2504
|
-
advance() {
|
|
2505
|
-
let stacks = this.stacks, pos = this.minStackPos;
|
|
2506
|
-
let newStacks = this.stacks = [];
|
|
2507
|
-
let stopped, stoppedTokens;
|
|
2508
|
-
if (this.bigReductionCount > 300 && stacks.length == 1) {
|
|
2509
|
-
let [s] = stacks;
|
|
2510
|
-
while (s.forceReduce() && s.stack.length && s.stack[s.stack.length - 2] >= this.lastBigReductionStart) {
|
|
2511
|
-
}
|
|
2512
|
-
this.bigReductionCount = this.lastBigReductionSize = 0;
|
|
2513
|
-
}
|
|
2514
|
-
for (let i = 0; i < stacks.length; i++) {
|
|
2515
|
-
let stack = stacks[i];
|
|
2516
|
-
for (; ; ) {
|
|
2517
|
-
this.tokens.mainToken = null;
|
|
2518
|
-
if (stack.pos > pos) {
|
|
2519
|
-
newStacks.push(stack);
|
|
2520
|
-
} else if (this.advanceStack(stack, newStacks, stacks)) {
|
|
2521
|
-
continue;
|
|
2522
|
-
} else {
|
|
2523
|
-
if (!stopped) {
|
|
2524
|
-
stopped = [];
|
|
2525
|
-
stoppedTokens = [];
|
|
2526
|
-
}
|
|
2527
|
-
stopped.push(stack);
|
|
2528
|
-
let tok = this.tokens.getMainToken(stack);
|
|
2529
|
-
stoppedTokens.push(tok.value, tok.end);
|
|
2530
|
-
}
|
|
2531
|
-
break;
|
|
2532
|
-
}
|
|
2533
|
-
}
|
|
2534
|
-
if (!newStacks.length) {
|
|
2535
|
-
let finished = stopped && findFinished(stopped);
|
|
2536
|
-
if (finished)
|
|
2537
|
-
return this.stackToTree(finished);
|
|
2538
|
-
if (this.parser.strict) {
|
|
2539
|
-
if (verbose && stopped)
|
|
2540
|
-
console.log("Stuck with token " + (this.tokens.mainToken ? this.parser.getName(this.tokens.mainToken.value) : "none"));
|
|
2541
|
-
throw new SyntaxError("No parse at " + pos);
|
|
2542
|
-
}
|
|
2543
|
-
if (!this.recovering)
|
|
2544
|
-
this.recovering = 5;
|
|
2545
|
-
}
|
|
2546
|
-
if (this.recovering && stopped) {
|
|
2547
|
-
let finished = this.stoppedAt != null && stopped[0].pos > this.stoppedAt ? stopped[0] : this.runRecovery(stopped, stoppedTokens, newStacks);
|
|
2548
|
-
if (finished)
|
|
2549
|
-
return this.stackToTree(finished.forceAll());
|
|
2550
|
-
}
|
|
2551
|
-
if (this.recovering) {
|
|
2552
|
-
let maxRemaining = this.recovering == 1 ? 1 : this.recovering * 3;
|
|
2553
|
-
if (newStacks.length > maxRemaining) {
|
|
2554
|
-
newStacks.sort((a, b) => b.score - a.score);
|
|
2555
|
-
while (newStacks.length > maxRemaining)
|
|
2556
|
-
newStacks.pop();
|
|
2557
|
-
}
|
|
2558
|
-
if (newStacks.some((s) => s.reducePos > pos))
|
|
2559
|
-
this.recovering--;
|
|
2560
|
-
} else if (newStacks.length > 1) {
|
|
2561
|
-
outer:
|
|
2562
|
-
for (let i = 0; i < newStacks.length - 1; i++) {
|
|
2563
|
-
let stack = newStacks[i];
|
|
2564
|
-
for (let j = i + 1; j < newStacks.length; j++) {
|
|
2565
|
-
let other = newStacks[j];
|
|
2566
|
-
if (stack.sameState(other) || stack.buffer.length > 500 && other.buffer.length > 500) {
|
|
2567
|
-
if ((stack.score - other.score || stack.buffer.length - other.buffer.length) > 0) {
|
|
2568
|
-
newStacks.splice(j--, 1);
|
|
2569
|
-
} else {
|
|
2570
|
-
newStacks.splice(i--, 1);
|
|
2571
|
-
continue outer;
|
|
2572
|
-
}
|
|
2573
|
-
}
|
|
2574
|
-
}
|
|
2575
|
-
}
|
|
2576
|
-
if (newStacks.length > 12)
|
|
2577
|
-
newStacks.splice(
|
|
2578
|
-
12,
|
|
2579
|
-
newStacks.length - 12
|
|
2580
|
-
/* Rec.MaxStackCount */
|
|
2581
|
-
);
|
|
2582
|
-
}
|
|
2583
|
-
this.minStackPos = newStacks[0].pos;
|
|
2584
|
-
for (let i = 1; i < newStacks.length; i++)
|
|
2585
|
-
if (newStacks[i].pos < this.minStackPos)
|
|
2586
|
-
this.minStackPos = newStacks[i].pos;
|
|
2587
|
-
return null;
|
|
2588
|
-
}
|
|
2589
|
-
stopAt(pos) {
|
|
2590
|
-
if (this.stoppedAt != null && this.stoppedAt < pos)
|
|
2591
|
-
throw new RangeError("Can't move stoppedAt forward");
|
|
2592
|
-
this.stoppedAt = pos;
|
|
2593
|
-
}
|
|
2594
|
-
// Returns an updated version of the given stack, or null if the
|
|
2595
|
-
// stack can't advance normally. When `split` and `stacks` are
|
|
2596
|
-
// given, stacks split off by ambiguous operations will be pushed to
|
|
2597
|
-
// `split`, or added to `stacks` if they move `pos` forward.
|
|
2598
|
-
advanceStack(stack, stacks, split) {
|
|
2599
|
-
let start = stack.pos, { parser: parser2 } = this;
|
|
2600
|
-
let base = verbose ? this.stackID(stack) + " -> " : "";
|
|
2601
|
-
if (this.stoppedAt != null && start > this.stoppedAt)
|
|
2602
|
-
return stack.forceReduce() ? stack : null;
|
|
2603
|
-
if (this.fragments) {
|
|
2604
|
-
let strictCx = stack.curContext && stack.curContext.tracker.strict, cxHash = strictCx ? stack.curContext.hash : 0;
|
|
2605
|
-
for (let cached = this.fragments.nodeAt(start); cached; ) {
|
|
2606
|
-
let match = this.parser.nodeSet.types[cached.type.id] == cached.type ? parser2.getGoto(stack.state, cached.type.id) : -1;
|
|
2607
|
-
if (match > -1 && cached.length && (!strictCx || (cached.prop(NodeProp.contextHash) || 0) == cxHash)) {
|
|
2608
|
-
stack.useNode(cached, match);
|
|
2609
|
-
if (verbose)
|
|
2610
|
-
console.log(base + this.stackID(stack) + ` (via reuse of ${parser2.getName(cached.type.id)})`);
|
|
2611
|
-
return true;
|
|
2612
|
-
}
|
|
2613
|
-
if (!(cached instanceof Tree) || cached.children.length == 0 || cached.positions[0] > 0)
|
|
2614
|
-
break;
|
|
2615
|
-
let inner = cached.children[0];
|
|
2616
|
-
if (inner instanceof Tree && cached.positions[0] == 0)
|
|
2617
|
-
cached = inner;
|
|
2618
|
-
else
|
|
2619
|
-
break;
|
|
2620
|
-
}
|
|
2621
|
-
}
|
|
2622
|
-
let defaultReduce = parser2.stateSlot(
|
|
2623
|
-
stack.state,
|
|
2624
|
-
4
|
|
2625
|
-
/* ParseState.DefaultReduce */
|
|
2626
|
-
);
|
|
2627
|
-
if (defaultReduce > 0) {
|
|
2628
|
-
stack.reduce(defaultReduce);
|
|
2629
|
-
if (verbose)
|
|
2630
|
-
console.log(base + this.stackID(stack) + ` (via always-reduce ${parser2.getName(
|
|
2631
|
-
defaultReduce & 65535
|
|
2632
|
-
/* Action.ValueMask */
|
|
2633
|
-
)})`);
|
|
2634
|
-
return true;
|
|
2635
|
-
}
|
|
2636
|
-
if (stack.stack.length >= 15e3) {
|
|
2637
|
-
while (stack.stack.length > 9e3 && stack.forceReduce()) {
|
|
2638
|
-
}
|
|
2639
|
-
}
|
|
2640
|
-
let actions = this.tokens.getActions(stack);
|
|
2641
|
-
for (let i = 0; i < actions.length; ) {
|
|
2642
|
-
let action = actions[i++], term = actions[i++], end = actions[i++];
|
|
2643
|
-
let last = i == actions.length || !split;
|
|
2644
|
-
let localStack = last ? stack : stack.split();
|
|
2645
|
-
localStack.apply(action, term, end);
|
|
2646
|
-
if (verbose)
|
|
2647
|
-
console.log(base + this.stackID(localStack) + ` (via ${(action & 65536) == 0 ? "shift" : `reduce of ${parser2.getName(
|
|
2648
|
-
action & 65535
|
|
2649
|
-
/* Action.ValueMask */
|
|
2650
|
-
)}`} for ${parser2.getName(term)} @ ${start}${localStack == stack ? "" : ", split"})`);
|
|
2651
|
-
if (last)
|
|
2652
|
-
return true;
|
|
2653
|
-
else if (localStack.pos > start)
|
|
2654
|
-
stacks.push(localStack);
|
|
2655
|
-
else
|
|
2656
|
-
split.push(localStack);
|
|
2657
|
-
}
|
|
2658
|
-
return false;
|
|
2659
|
-
}
|
|
2660
|
-
// Advance a given stack forward as far as it will go. Returns the
|
|
2661
|
-
// (possibly updated) stack if it got stuck, or null if it moved
|
|
2662
|
-
// forward and was given to `pushStackDedup`.
|
|
2663
|
-
advanceFully(stack, newStacks) {
|
|
2664
|
-
let pos = stack.pos;
|
|
2665
|
-
for (; ; ) {
|
|
2666
|
-
if (!this.advanceStack(stack, null, null))
|
|
2667
|
-
return false;
|
|
2668
|
-
if (stack.pos > pos) {
|
|
2669
|
-
pushStackDedup(stack, newStacks);
|
|
2670
|
-
return true;
|
|
2671
|
-
}
|
|
2672
|
-
}
|
|
2673
|
-
}
|
|
2674
|
-
runRecovery(stacks, tokens, newStacks) {
|
|
2675
|
-
let finished = null, restarted = false;
|
|
2676
|
-
for (let i = 0; i < stacks.length; i++) {
|
|
2677
|
-
let stack = stacks[i], token = tokens[i << 1], tokenEnd = tokens[(i << 1) + 1];
|
|
2678
|
-
let base = verbose ? this.stackID(stack) + " -> " : "";
|
|
2679
|
-
if (stack.deadEnd) {
|
|
2680
|
-
if (restarted)
|
|
2681
|
-
continue;
|
|
2682
|
-
restarted = true;
|
|
2683
|
-
stack.restart();
|
|
2684
|
-
if (verbose)
|
|
2685
|
-
console.log(base + this.stackID(stack) + " (restarted)");
|
|
2686
|
-
let done = this.advanceFully(stack, newStacks);
|
|
2687
|
-
if (done)
|
|
2688
|
-
continue;
|
|
2689
|
-
}
|
|
2690
|
-
let force = stack.split(), forceBase = base;
|
|
2691
|
-
for (let j = 0; force.forceReduce() && j < 10; j++) {
|
|
2692
|
-
if (verbose)
|
|
2693
|
-
console.log(forceBase + this.stackID(force) + " (via force-reduce)");
|
|
2694
|
-
let done = this.advanceFully(force, newStacks);
|
|
2695
|
-
if (done)
|
|
2696
|
-
break;
|
|
2697
|
-
if (verbose)
|
|
2698
|
-
forceBase = this.stackID(force) + " -> ";
|
|
2699
|
-
}
|
|
2700
|
-
for (let insert of stack.recoverByInsert(token)) {
|
|
2701
|
-
if (verbose)
|
|
2702
|
-
console.log(base + this.stackID(insert) + " (via recover-insert)");
|
|
2703
|
-
this.advanceFully(insert, newStacks);
|
|
2704
|
-
}
|
|
2705
|
-
if (this.stream.end > stack.pos) {
|
|
2706
|
-
if (tokenEnd == stack.pos) {
|
|
2707
|
-
tokenEnd++;
|
|
2708
|
-
token = 0;
|
|
2709
|
-
}
|
|
2710
|
-
stack.recoverByDelete(token, tokenEnd);
|
|
2711
|
-
if (verbose)
|
|
2712
|
-
console.log(base + this.stackID(stack) + ` (via recover-delete ${this.parser.getName(token)})`);
|
|
2713
|
-
pushStackDedup(stack, newStacks);
|
|
2714
|
-
} else if (!finished || finished.score < stack.score) {
|
|
2715
|
-
finished = stack;
|
|
2716
|
-
}
|
|
2717
|
-
}
|
|
2718
|
-
return finished;
|
|
2719
|
-
}
|
|
2720
|
-
// Convert the stack's buffer to a syntax tree.
|
|
2721
|
-
stackToTree(stack) {
|
|
2722
|
-
stack.close();
|
|
2723
|
-
return Tree.build({
|
|
2724
|
-
buffer: StackBufferCursor.create(stack),
|
|
2725
|
-
nodeSet: this.parser.nodeSet,
|
|
2726
|
-
topID: this.topTerm,
|
|
2727
|
-
maxBufferLength: this.parser.bufferLength,
|
|
2728
|
-
reused: this.reused,
|
|
2729
|
-
start: this.ranges[0].from,
|
|
2730
|
-
length: stack.pos - this.ranges[0].from,
|
|
2731
|
-
minRepeatType: this.parser.minRepeatTerm
|
|
2732
|
-
});
|
|
2733
|
-
}
|
|
2734
|
-
stackID(stack) {
|
|
2735
|
-
let id = (stackIDs || (stackIDs = /* @__PURE__ */ new WeakMap())).get(stack);
|
|
2736
|
-
if (!id)
|
|
2737
|
-
stackIDs.set(stack, id = String.fromCodePoint(this.nextStackID++));
|
|
2738
|
-
return id + stack;
|
|
2739
|
-
}
|
|
2740
|
-
};
|
|
2741
|
-
function pushStackDedup(stack, newStacks) {
|
|
2742
|
-
for (let i = 0; i < newStacks.length; i++) {
|
|
2743
|
-
let other = newStacks[i];
|
|
2744
|
-
if (other.pos == stack.pos && other.sameState(stack)) {
|
|
2745
|
-
if (newStacks[i].score < stack.score)
|
|
2746
|
-
newStacks[i] = stack;
|
|
2747
|
-
return;
|
|
2748
|
-
}
|
|
2749
|
-
}
|
|
2750
|
-
newStacks.push(stack);
|
|
2751
|
-
}
|
|
2752
|
-
var Dialect = class {
|
|
2753
|
-
constructor(source, flags, disabled) {
|
|
2754
|
-
this.source = source;
|
|
2755
|
-
this.flags = flags;
|
|
2756
|
-
this.disabled = disabled;
|
|
2757
|
-
}
|
|
2758
|
-
allows(term) {
|
|
2759
|
-
return !this.disabled || this.disabled[term] == 0;
|
|
2760
|
-
}
|
|
2761
|
-
};
|
|
2762
|
-
var LRParser = class _LRParser extends Parser {
|
|
2763
|
-
/// @internal
|
|
2764
|
-
constructor(spec) {
|
|
2765
|
-
super();
|
|
2766
|
-
this.wrappers = [];
|
|
2767
|
-
if (spec.version != 14)
|
|
2768
|
-
throw new RangeError(`Parser version (${spec.version}) doesn't match runtime version (${14})`);
|
|
2769
|
-
let nodeNames = spec.nodeNames.split(" ");
|
|
2770
|
-
this.minRepeatTerm = nodeNames.length;
|
|
2771
|
-
for (let i = 0; i < spec.repeatNodeCount; i++)
|
|
2772
|
-
nodeNames.push("");
|
|
2773
|
-
let topTerms = Object.keys(spec.topRules).map((r) => spec.topRules[r][1]);
|
|
2774
|
-
let nodeProps = [];
|
|
2775
|
-
for (let i = 0; i < nodeNames.length; i++)
|
|
2776
|
-
nodeProps.push([]);
|
|
2777
|
-
function setProp(nodeID, prop, value) {
|
|
2778
|
-
nodeProps[nodeID].push([prop, prop.deserialize(String(value))]);
|
|
2779
|
-
}
|
|
2780
|
-
if (spec.nodeProps)
|
|
2781
|
-
for (let propSpec of spec.nodeProps) {
|
|
2782
|
-
let prop = propSpec[0];
|
|
2783
|
-
if (typeof prop == "string")
|
|
2784
|
-
prop = NodeProp[prop];
|
|
2785
|
-
for (let i = 1; i < propSpec.length; ) {
|
|
2786
|
-
let next = propSpec[i++];
|
|
2787
|
-
if (next >= 0) {
|
|
2788
|
-
setProp(next, prop, propSpec[i++]);
|
|
2789
|
-
} else {
|
|
2790
|
-
let value = propSpec[i + -next];
|
|
2791
|
-
for (let j = -next; j > 0; j--)
|
|
2792
|
-
setProp(propSpec[i++], prop, value);
|
|
2793
|
-
i++;
|
|
2794
|
-
}
|
|
2795
|
-
}
|
|
2796
|
-
}
|
|
2797
|
-
this.nodeSet = new NodeSet(nodeNames.map((name, i) => NodeType.define({
|
|
2798
|
-
name: i >= this.minRepeatTerm ? void 0 : name,
|
|
2799
|
-
id: i,
|
|
2800
|
-
props: nodeProps[i],
|
|
2801
|
-
top: topTerms.indexOf(i) > -1,
|
|
2802
|
-
error: i == 0,
|
|
2803
|
-
skipped: spec.skippedNodes && spec.skippedNodes.indexOf(i) > -1
|
|
2804
|
-
})));
|
|
2805
|
-
if (spec.propSources)
|
|
2806
|
-
this.nodeSet = this.nodeSet.extend(...spec.propSources);
|
|
2807
|
-
this.strict = false;
|
|
2808
|
-
this.bufferLength = DefaultBufferLength;
|
|
2809
|
-
let tokenArray = decodeArray(spec.tokenData);
|
|
2810
|
-
this.context = spec.context;
|
|
2811
|
-
this.specializerSpecs = spec.specialized || [];
|
|
2812
|
-
this.specialized = new Uint16Array(this.specializerSpecs.length);
|
|
2813
|
-
for (let i = 0; i < this.specializerSpecs.length; i++)
|
|
2814
|
-
this.specialized[i] = this.specializerSpecs[i].term;
|
|
2815
|
-
this.specializers = this.specializerSpecs.map(getSpecializer);
|
|
2816
|
-
this.states = decodeArray(spec.states, Uint32Array);
|
|
2817
|
-
this.data = decodeArray(spec.stateData);
|
|
2818
|
-
this.goto = decodeArray(spec.goto);
|
|
2819
|
-
this.maxTerm = spec.maxTerm;
|
|
2820
|
-
this.tokenizers = spec.tokenizers.map((value) => typeof value == "number" ? new TokenGroup(tokenArray, value) : value);
|
|
2821
|
-
this.topRules = spec.topRules;
|
|
2822
|
-
this.dialects = spec.dialects || {};
|
|
2823
|
-
this.dynamicPrecedences = spec.dynamicPrecedences || null;
|
|
2824
|
-
this.tokenPrecTable = spec.tokenPrec;
|
|
2825
|
-
this.termNames = spec.termNames || null;
|
|
2826
|
-
this.maxNode = this.nodeSet.types.length - 1;
|
|
2827
|
-
this.dialect = this.parseDialect();
|
|
2828
|
-
this.top = this.topRules[Object.keys(this.topRules)[0]];
|
|
2829
|
-
}
|
|
2830
|
-
createParse(input, fragments, ranges) {
|
|
2831
|
-
let parse = new Parse(this, input, fragments, ranges);
|
|
2832
|
-
for (let w of this.wrappers)
|
|
2833
|
-
parse = w(parse, input, fragments, ranges);
|
|
2834
|
-
return parse;
|
|
2835
|
-
}
|
|
2836
|
-
/// Get a goto table entry @internal
|
|
2837
|
-
getGoto(state, term, loose = false) {
|
|
2838
|
-
let table = this.goto;
|
|
2839
|
-
if (term >= table[0])
|
|
2840
|
-
return -1;
|
|
2841
|
-
for (let pos = table[term + 1]; ; ) {
|
|
2842
|
-
let groupTag = table[pos++], last = groupTag & 1;
|
|
2843
|
-
let target = table[pos++];
|
|
2844
|
-
if (last && loose)
|
|
2845
|
-
return target;
|
|
2846
|
-
for (let end = pos + (groupTag >> 1); pos < end; pos++)
|
|
2847
|
-
if (table[pos] == state)
|
|
2848
|
-
return target;
|
|
2849
|
-
if (last)
|
|
2850
|
-
return -1;
|
|
2851
|
-
}
|
|
2852
|
-
}
|
|
2853
|
-
/// Check if this state has an action for a given terminal @internal
|
|
2854
|
-
hasAction(state, terminal) {
|
|
2855
|
-
let data = this.data;
|
|
2856
|
-
for (let set = 0; set < 2; set++) {
|
|
2857
|
-
for (let i = this.stateSlot(
|
|
2858
|
-
state,
|
|
2859
|
-
set ? 2 : 1
|
|
2860
|
-
/* ParseState.Actions */
|
|
2861
|
-
), next; ; i += 3) {
|
|
2862
|
-
if ((next = data[i]) == 65535) {
|
|
2863
|
-
if (data[i + 1] == 1)
|
|
2864
|
-
next = data[i = pair(data, i + 2)];
|
|
2865
|
-
else if (data[i + 1] == 2)
|
|
2866
|
-
return pair(data, i + 2);
|
|
2867
|
-
else
|
|
2868
|
-
break;
|
|
2869
|
-
}
|
|
2870
|
-
if (next == terminal || next == 0)
|
|
2871
|
-
return pair(data, i + 1);
|
|
2872
|
-
}
|
|
2873
|
-
}
|
|
2874
|
-
return 0;
|
|
2875
|
-
}
|
|
2876
|
-
/// @internal
|
|
2877
|
-
stateSlot(state, slot) {
|
|
2878
|
-
return this.states[state * 6 + slot];
|
|
2879
|
-
}
|
|
2880
|
-
/// @internal
|
|
2881
|
-
stateFlag(state, flag) {
|
|
2882
|
-
return (this.stateSlot(
|
|
2883
|
-
state,
|
|
2884
|
-
0
|
|
2885
|
-
/* ParseState.Flags */
|
|
2886
|
-
) & flag) > 0;
|
|
2887
|
-
}
|
|
2888
|
-
/// @internal
|
|
2889
|
-
validAction(state, action) {
|
|
2890
|
-
return !!this.allActions(state, (a) => a == action ? true : null);
|
|
2891
|
-
}
|
|
2892
|
-
/// @internal
|
|
2893
|
-
allActions(state, action) {
|
|
2894
|
-
let deflt = this.stateSlot(
|
|
2895
|
-
state,
|
|
2896
|
-
4
|
|
2897
|
-
/* ParseState.DefaultReduce */
|
|
2898
|
-
);
|
|
2899
|
-
let result = deflt ? action(deflt) : void 0;
|
|
2900
|
-
for (let i = this.stateSlot(
|
|
2901
|
-
state,
|
|
2902
|
-
1
|
|
2903
|
-
/* ParseState.Actions */
|
|
2904
|
-
); result == null; i += 3) {
|
|
2905
|
-
if (this.data[i] == 65535) {
|
|
2906
|
-
if (this.data[i + 1] == 1)
|
|
2907
|
-
i = pair(this.data, i + 2);
|
|
2908
|
-
else
|
|
2909
|
-
break;
|
|
2910
|
-
}
|
|
2911
|
-
result = action(pair(this.data, i + 1));
|
|
2912
|
-
}
|
|
2913
|
-
return result;
|
|
2914
|
-
}
|
|
2915
|
-
/// Get the states that can follow this one through shift actions or
|
|
2916
|
-
/// goto jumps. @internal
|
|
2917
|
-
nextStates(state) {
|
|
2918
|
-
let result = [];
|
|
2919
|
-
for (let i = this.stateSlot(
|
|
2920
|
-
state,
|
|
2921
|
-
1
|
|
2922
|
-
/* ParseState.Actions */
|
|
2923
|
-
); ; i += 3) {
|
|
2924
|
-
if (this.data[i] == 65535) {
|
|
2925
|
-
if (this.data[i + 1] == 1)
|
|
2926
|
-
i = pair(this.data, i + 2);
|
|
2927
|
-
else
|
|
2928
|
-
break;
|
|
2929
|
-
}
|
|
2930
|
-
if ((this.data[i + 2] & 65536 >> 16) == 0) {
|
|
2931
|
-
let value = this.data[i + 1];
|
|
2932
|
-
if (!result.some((v, i2) => i2 & 1 && v == value))
|
|
2933
|
-
result.push(this.data[i], value);
|
|
2934
|
-
}
|
|
2935
|
-
}
|
|
2936
|
-
return result;
|
|
2937
|
-
}
|
|
2938
|
-
/// Configure the parser. Returns a new parser instance that has the
|
|
2939
|
-
/// given settings modified. Settings not provided in `config` are
|
|
2940
|
-
/// kept from the original parser.
|
|
2941
|
-
configure(config) {
|
|
2942
|
-
let copy = Object.assign(Object.create(_LRParser.prototype), this);
|
|
2943
|
-
if (config.props)
|
|
2944
|
-
copy.nodeSet = this.nodeSet.extend(...config.props);
|
|
2945
|
-
if (config.top) {
|
|
2946
|
-
let info = this.topRules[config.top];
|
|
2947
|
-
if (!info)
|
|
2948
|
-
throw new RangeError(`Invalid top rule name ${config.top}`);
|
|
2949
|
-
copy.top = info;
|
|
2950
|
-
}
|
|
2951
|
-
if (config.tokenizers)
|
|
2952
|
-
copy.tokenizers = this.tokenizers.map((t) => {
|
|
2953
|
-
let found = config.tokenizers.find((r) => r.from == t);
|
|
2954
|
-
return found ? found.to : t;
|
|
2955
|
-
});
|
|
2956
|
-
if (config.specializers) {
|
|
2957
|
-
copy.specializers = this.specializers.slice();
|
|
2958
|
-
copy.specializerSpecs = this.specializerSpecs.map((s, i) => {
|
|
2959
|
-
let found = config.specializers.find((r) => r.from == s.external);
|
|
2960
|
-
if (!found)
|
|
2961
|
-
return s;
|
|
2962
|
-
let spec = Object.assign(Object.assign({}, s), { external: found.to });
|
|
2963
|
-
copy.specializers[i] = getSpecializer(spec);
|
|
2964
|
-
return spec;
|
|
2965
|
-
});
|
|
2966
|
-
}
|
|
2967
|
-
if (config.contextTracker)
|
|
2968
|
-
copy.context = config.contextTracker;
|
|
2969
|
-
if (config.dialect)
|
|
2970
|
-
copy.dialect = this.parseDialect(config.dialect);
|
|
2971
|
-
if (config.strict != null)
|
|
2972
|
-
copy.strict = config.strict;
|
|
2973
|
-
if (config.wrap)
|
|
2974
|
-
copy.wrappers = copy.wrappers.concat(config.wrap);
|
|
2975
|
-
if (config.bufferLength != null)
|
|
2976
|
-
copy.bufferLength = config.bufferLength;
|
|
2977
|
-
return copy;
|
|
2978
|
-
}
|
|
2979
|
-
/// Tells you whether any [parse wrappers](#lr.ParserConfig.wrap)
|
|
2980
|
-
/// are registered for this parser.
|
|
2981
|
-
hasWrappers() {
|
|
2982
|
-
return this.wrappers.length > 0;
|
|
2983
|
-
}
|
|
2984
|
-
/// Returns the name associated with a given term. This will only
|
|
2985
|
-
/// work for all terms when the parser was generated with the
|
|
2986
|
-
/// `--names` option. By default, only the names of tagged terms are
|
|
2987
|
-
/// stored.
|
|
2988
|
-
getName(term) {
|
|
2989
|
-
return this.termNames ? this.termNames[term] : String(term <= this.maxNode && this.nodeSet.types[term].name || term);
|
|
2990
|
-
}
|
|
2991
|
-
/// The eof term id is always allocated directly after the node
|
|
2992
|
-
/// types. @internal
|
|
2993
|
-
get eofTerm() {
|
|
2994
|
-
return this.maxNode + 1;
|
|
2995
|
-
}
|
|
2996
|
-
/// The type of top node produced by the parser.
|
|
2997
|
-
get topNode() {
|
|
2998
|
-
return this.nodeSet.types[this.top[1]];
|
|
2999
|
-
}
|
|
3000
|
-
/// @internal
|
|
3001
|
-
dynamicPrecedence(term) {
|
|
3002
|
-
let prec = this.dynamicPrecedences;
|
|
3003
|
-
return prec == null ? 0 : prec[term] || 0;
|
|
3004
|
-
}
|
|
3005
|
-
/// @internal
|
|
3006
|
-
parseDialect(dialect) {
|
|
3007
|
-
let values = Object.keys(this.dialects), flags = values.map(() => false);
|
|
3008
|
-
if (dialect)
|
|
3009
|
-
for (let part of dialect.split(" ")) {
|
|
3010
|
-
let id = values.indexOf(part);
|
|
3011
|
-
if (id >= 0)
|
|
3012
|
-
flags[id] = true;
|
|
3013
|
-
}
|
|
3014
|
-
let disabled = null;
|
|
3015
|
-
for (let i = 0; i < values.length; i++)
|
|
3016
|
-
if (!flags[i]) {
|
|
3017
|
-
for (let j = this.dialects[values[i]], id; (id = this.data[j++]) != 65535; )
|
|
3018
|
-
(disabled || (disabled = new Uint8Array(this.maxTerm + 1)))[id] = 1;
|
|
3019
|
-
}
|
|
3020
|
-
return new Dialect(dialect, flags, disabled);
|
|
3021
|
-
}
|
|
3022
|
-
/// Used by the output of the parser generator. Not available to
|
|
3023
|
-
/// user code. @hide
|
|
3024
|
-
static deserialize(spec) {
|
|
3025
|
-
return new _LRParser(spec);
|
|
3026
|
-
}
|
|
3027
|
-
};
|
|
3028
|
-
function pair(data, off) {
|
|
3029
|
-
return data[off] | data[off + 1] << 16;
|
|
3030
|
-
}
|
|
3031
|
-
function findFinished(stacks) {
|
|
3032
|
-
let best = null;
|
|
3033
|
-
for (let stack of stacks) {
|
|
3034
|
-
let stopped = stack.p.stoppedAt;
|
|
3035
|
-
if ((stack.pos == stack.p.stream.end || stopped != null && stack.pos > stopped) && stack.p.parser.stateFlag(
|
|
3036
|
-
stack.state,
|
|
3037
|
-
2
|
|
3038
|
-
/* StateFlag.Accepting */
|
|
3039
|
-
) && (!best || best.score < stack.score))
|
|
3040
|
-
best = stack;
|
|
3041
|
-
}
|
|
3042
|
-
return best;
|
|
3043
|
-
}
|
|
3044
|
-
function getSpecializer(spec) {
|
|
3045
|
-
if (spec.external) {
|
|
3046
|
-
let mask = spec.extend ? 1 : 0;
|
|
3047
|
-
return (value, stack) => spec.external(value, stack) << 1 | mask;
|
|
3048
|
-
}
|
|
3049
|
-
return spec.get;
|
|
3050
|
-
}
|
|
3051
|
-
|
|
3052
|
-
// ../vuu-filter-parser/src/generated/filter-parser.js
|
|
3053
|
-
var parser = LRParser.deserialize({
|
|
3054
|
-
version: 14,
|
|
3055
|
-
states: "%QOVQPOOOOQO'#C_'#C_O_QQO'#C^OOQO'#DO'#DOOvQQO'#C|OOQO'#DR'#DROVQPO'#CuOOQO'#C}'#C}QOQPOOOOQO'#C`'#C`O!UQQO,58xO!dQPO,59VOVQPO,59]OVQPO,59_O!iQPO,59hO!nQQO,59aOOQO'#DQ'#DQOOQO1G.d1G.dO!UQQO1G.qO!yQQO1G.wOOQO1G.y1G.yOOQO'#Cw'#CwOOQO1G/S1G/SOOQO1G.{1G.{O#[QPO'#CnO#dQPO7+$]O!UQQO'#CxO#iQPO,59YOOQO<<Gw<<GwOOQO,59d,59dOOQO-E6v-E6v",
|
|
3056
|
-
stateData: "#q~OoOS~OsPOvUO~OTXOUXOVXOWXOXXOYXO`ZO~Of[Oh]Oj^OmpX~OZ`O[`O]`O^`O~OabO~OseO~Of[Oh]OwgO~Oh]Ofeijeimeiwei~OcjOdbX~OdlO~OcjOdba~O",
|
|
3057
|
-
goto: "#YvPPw}!TPPPPPPPPPPwPP!WPP!ZP!ZP!aP!g!jPPP!p!s!aP#P!aXROU[]XQOU[]RYQRibXTOU[]XVOU[]Rf^QkhRnkRWOQSOQ_UQc[Rd]QaYQhbRmj",
|
|
3058
|
-
nodeNames: "\u26A0 Filter ColumnValueExpression Column Operator Eq NotEq Gt Lt Starts Ends Number String True False ColumnSetExpression In LBrack Values Comma RBrack AndExpression And OrExpression Or ParenthesizedExpression As FilterName",
|
|
3059
|
-
maxTerm: 39,
|
|
3060
|
-
skippedNodes: [0],
|
|
3061
|
-
repeatNodeCount: 1,
|
|
3062
|
-
tokenData: "6p~RnXY#PYZ#P]^#Ppq#Pqr#brs#mxy$eyz$j|}$o!O!P$t!Q![%S!^!_%_!_!`%d!`!a%i!c!}%n!}#O&V#P#Q&[#R#S%n#T#U&a#U#X%n#X#Y(w#Y#Z+]#Z#]%n#]#^.]#^#c%n#c#d/e#d#g%n#g#h0m#h#i4[#i#o%n~#USo~XY#PYZ#P]^#Ppq#P~#eP!_!`#h~#mOU~~#pWOX#mZ]#m^r#mrs$Ys#O#m#P;'S#m;'S;=`$_<%lO#m~$_O[~~$bP;=`<%l#m~$jOv~~$oOw~~$tOc~~$wP!Q![$z~%PPZ~!Q![$z~%XQZ~!O!P$t!Q![%S~%dOW~~%iOT~~%nOV~P%sUsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n~&[Oa~~&aOd~R&fYsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c'U#c#g%n#g#h(^#h#o%nR'ZWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X's#X#o%nR'zUfQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(eUjQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c)f#c#o%nR)kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X*T#X#o%nR*YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h*r#h#o%nR*yUYQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR+bVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U+w#U#o%nR+|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#`%n#`#a,f#a#o%nR,kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h-T#h#o%nR-YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y-r#Y#o%nR-yU^QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR.bWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c.z#c#o%nR/RU`QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR/jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g0S#g#o%nR0ZUhQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR0rWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i1[#i#o%nR1aVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U1v#U#o%nR1{WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g2e#g#o%nR2jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i3S#i#o%nR3XWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h3q#h#o%nR3xUXQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR4aWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g4y#g#o%nR5OWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#i%n#i#j5h#j#o%nR5mWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y6V#Y#o%nR6^U]QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n",
|
|
3063
|
-
tokenizers: [0, 1],
|
|
3064
|
-
topRules: { "Filter": [0, 1] },
|
|
3065
|
-
tokenPrec: 0
|
|
3066
|
-
});
|
|
3067
|
-
|
|
3068
|
-
// ../vuu-filter-parser/src/FilterTreeWalker.ts
|
|
3069
|
-
var import_vuu_utils = require("@vuu-ui/vuu-utils");
|
|
3070
|
-
|
|
3071
|
-
// ../vuu-filter-parser/src/FilterParser.ts
|
|
3072
|
-
var strictParser = parser.configure({ strict: true });
|
|
3073
|
-
|
|
3074
|
-
// ../vuu-data-local/src/array-data-source/array-data-source.ts
|
|
3075
|
-
var import_vuu_utils4 = require("@vuu-ui/vuu-utils");
|
|
3076
|
-
|
|
3077
|
-
// ../vuu-data-local/src/array-data-source/array-data-utils.ts
|
|
3078
|
-
var import_vuu_utils2 = require("@vuu-ui/vuu-utils");
|
|
3079
|
-
var { RENDER_IDX, SELECTED } = import_vuu_utils2.metadataKeys;
|
|
3080
|
-
|
|
3081
|
-
// ../vuu-data-local/src/array-data-source/group-utils.ts
|
|
3082
|
-
var import_vuu_utils3 = require("@vuu-ui/vuu-utils");
|
|
3083
|
-
var { DEPTH, IS_EXPANDED, KEY } = import_vuu_utils3.metadataKeys;
|
|
3084
|
-
|
|
3085
|
-
// ../vuu-data-local/src/array-data-source/array-data-source.ts
|
|
3086
|
-
var { KEY: KEY2 } = import_vuu_utils4.metadataKeys;
|
|
3087
|
-
var { debug } = (0, import_vuu_utils4.logger)("ArrayDataSource");
|
|
3088
|
-
|
|
3089
|
-
// ../vuu-data-local/src/json-data-source/json-data-source.ts
|
|
3090
|
-
var import_vuu_utils5 = require("@vuu-ui/vuu-utils");
|
|
3091
|
-
var NULL_SCHEMA = { columns: [], key: "", table: { module: "", table: "" } };
|
|
3092
|
-
var { DEPTH: DEPTH2, IDX, IS_EXPANDED: IS_EXPANDED2, IS_LEAF, KEY: KEY3, SELECTED: SELECTED2 } = import_vuu_utils5.metadataKeys;
|
|
3093
|
-
var toClientRow2 = (row, keys) => {
|
|
3094
|
-
const [rowIndex] = row;
|
|
3095
|
-
const clientRow = row.slice();
|
|
3096
|
-
clientRow[1] = keys.keyFor(rowIndex);
|
|
3097
|
-
return clientRow;
|
|
3098
|
-
};
|
|
3099
|
-
var _aggregations, _config, _data, _filter, _groupBy, _range, _selectedRowsCount, _size, _sort, _status, _title;
|
|
3100
|
-
var JsonDataSource = class extends import_vuu_utils5.EventEmitter {
|
|
3101
|
-
constructor({
|
|
3102
|
-
aggregations,
|
|
3103
|
-
data,
|
|
3104
|
-
filter,
|
|
3105
|
-
groupBy,
|
|
3106
|
-
sort,
|
|
3107
|
-
title,
|
|
3108
|
-
viewport
|
|
3109
|
-
}) {
|
|
3110
|
-
super();
|
|
3111
|
-
this.expandedRows = /* @__PURE__ */ new Set();
|
|
3112
|
-
this.visibleRows = [];
|
|
3113
|
-
__privateAdd(this, _aggregations, []);
|
|
3114
|
-
__privateAdd(this, _config, import_vuu_utils5.vanillaConfig);
|
|
3115
|
-
__privateAdd(this, _data, void 0);
|
|
3116
|
-
__privateAdd(this, _filter, { filter: "" });
|
|
3117
|
-
__privateAdd(this, _groupBy, []);
|
|
3118
|
-
__privateAdd(this, _range, { from: 0, to: 0 });
|
|
3119
|
-
__privateAdd(this, _selectedRowsCount, 0);
|
|
3120
|
-
__privateAdd(this, _size, 0);
|
|
3121
|
-
__privateAdd(this, _sort, { sortDefs: [] });
|
|
3122
|
-
__privateAdd(this, _status, "initialising");
|
|
3123
|
-
__privateAdd(this, _title, void 0);
|
|
3124
|
-
this.keys = new import_vuu_utils5.KeySet(__privateGet(this, _range));
|
|
3125
|
-
if (!data) {
|
|
3126
|
-
throw Error("JsonDataSource constructor called without data");
|
|
3127
|
-
}
|
|
3128
|
-
[this.columnDescriptors, __privateWrapper(this, _data)._] = (0, import_vuu_utils5.jsonToDataSourceRows)(data);
|
|
3129
|
-
this.visibleRows = __privateGet(this, _data).filter((row) => row[DEPTH2] === 0).map(
|
|
3130
|
-
(row, index) => [index, index].concat(row.slice(2))
|
|
3131
|
-
);
|
|
3132
|
-
this.viewport = viewport || (0, import_vuu_utils5.uuid)();
|
|
3133
|
-
if (aggregations) {
|
|
3134
|
-
__privateSet(this, _aggregations, aggregations);
|
|
3135
|
-
}
|
|
3136
|
-
if (this.columnDescriptors) {
|
|
3137
|
-
__privateSet(this, _config, {
|
|
3138
|
-
...__privateGet(this, _config),
|
|
3139
|
-
columns: this.columnDescriptors.map((c) => c.name)
|
|
3140
|
-
});
|
|
3141
|
-
}
|
|
3142
|
-
if (filter) {
|
|
3143
|
-
__privateSet(this, _filter, filter);
|
|
3144
|
-
}
|
|
3145
|
-
if (groupBy) {
|
|
3146
|
-
__privateSet(this, _groupBy, groupBy);
|
|
3147
|
-
}
|
|
3148
|
-
if (sort) {
|
|
3149
|
-
__privateSet(this, _sort, sort);
|
|
3150
|
-
}
|
|
3151
|
-
__privateSet(this, _title, title);
|
|
3152
|
-
}
|
|
3153
|
-
async subscribe({
|
|
3154
|
-
viewport = ((_a) => (_a = this.viewport) != null ? _a : (0, import_vuu_utils5.uuid)())(),
|
|
3155
|
-
columns,
|
|
3156
|
-
aggregations,
|
|
3157
|
-
range,
|
|
3158
|
-
sort,
|
|
3159
|
-
groupBy,
|
|
3160
|
-
filter
|
|
3161
|
-
}, callback) {
|
|
3162
|
-
var _a2;
|
|
3163
|
-
this.clientCallback = callback;
|
|
3164
|
-
if (aggregations) {
|
|
3165
|
-
__privateSet(this, _aggregations, aggregations);
|
|
3166
|
-
}
|
|
3167
|
-
if (columns) {
|
|
3168
|
-
__privateSet(this, _config, {
|
|
3169
|
-
...__privateGet(this, _config),
|
|
3170
|
-
columns
|
|
3171
|
-
});
|
|
3172
|
-
}
|
|
3173
|
-
if (filter) {
|
|
3174
|
-
__privateSet(this, _filter, filter);
|
|
3175
|
-
}
|
|
3176
|
-
if (groupBy) {
|
|
3177
|
-
__privateSet(this, _groupBy, groupBy);
|
|
3178
|
-
}
|
|
3179
|
-
if (range) {
|
|
3180
|
-
__privateSet(this, _range, range);
|
|
3181
|
-
}
|
|
3182
|
-
if (sort) {
|
|
3183
|
-
__privateSet(this, _sort, sort);
|
|
3184
|
-
}
|
|
3185
|
-
if (__privateGet(this, _status) !== "initialising") {
|
|
3186
|
-
return;
|
|
3187
|
-
}
|
|
3188
|
-
this.viewport = viewport;
|
|
3189
|
-
__privateSet(this, _status, "subscribed");
|
|
3190
|
-
(_a2 = this.clientCallback) == null ? void 0 : _a2.call(this, {
|
|
3191
|
-
aggregations: __privateGet(this, _aggregations),
|
|
3192
|
-
type: "subscribed",
|
|
3193
|
-
clientViewportId: this.viewport,
|
|
3194
|
-
columns: __privateGet(this, _config).columns,
|
|
3195
|
-
filter: __privateGet(this, _filter),
|
|
3196
|
-
groupBy: __privateGet(this, _groupBy),
|
|
3197
|
-
range: __privateGet(this, _range),
|
|
3198
|
-
sort: __privateGet(this, _sort),
|
|
3199
|
-
tableSchema: NULL_SCHEMA
|
|
3200
|
-
});
|
|
3201
|
-
this.clientCallback({
|
|
3202
|
-
clientViewportId: this.viewport,
|
|
3203
|
-
mode: "size-only",
|
|
3204
|
-
type: "viewport-update",
|
|
3205
|
-
size: this.visibleRows.length
|
|
3206
|
-
});
|
|
3207
|
-
}
|
|
3208
|
-
unsubscribe() {
|
|
3209
|
-
console.log("noop");
|
|
3210
|
-
}
|
|
3211
|
-
suspend() {
|
|
3212
|
-
console.log("noop");
|
|
3213
|
-
return this;
|
|
3214
|
-
}
|
|
3215
|
-
resume() {
|
|
3216
|
-
console.log("noop");
|
|
3217
|
-
return this;
|
|
3218
|
-
}
|
|
3219
|
-
disable() {
|
|
3220
|
-
console.log("noop");
|
|
3221
|
-
return this;
|
|
3222
|
-
}
|
|
3223
|
-
enable() {
|
|
3224
|
-
console.log("noop");
|
|
3225
|
-
return this;
|
|
3226
|
-
}
|
|
3227
|
-
set data(data) {
|
|
3228
|
-
console.log(`set JsonDataSource data`);
|
|
3229
|
-
[this.columnDescriptors, __privateWrapper(this, _data)._] = (0, import_vuu_utils5.jsonToDataSourceRows)(data);
|
|
3230
|
-
this.visibleRows = __privateGet(this, _data).filter((row) => row[DEPTH2] === 0).map(
|
|
3231
|
-
(row, index) => [index, index].concat(row.slice(2))
|
|
3232
|
-
);
|
|
3233
|
-
requestAnimationFrame(() => {
|
|
3234
|
-
this.sendRowsToClient();
|
|
3235
|
-
});
|
|
3236
|
-
}
|
|
3237
|
-
select(selected) {
|
|
3238
|
-
var _a;
|
|
3239
|
-
const updatedRows = [];
|
|
3240
|
-
for (const row of __privateGet(this, _data)) {
|
|
3241
|
-
const { [IDX]: rowIndex, [SELECTED2]: sel } = row;
|
|
3242
|
-
const wasSelected = sel === 1;
|
|
3243
|
-
const nowSelected = (0, import_vuu_utils5.isSelected)(selected, rowIndex);
|
|
3244
|
-
if (nowSelected !== wasSelected) {
|
|
3245
|
-
const selectedRow = row.slice();
|
|
3246
|
-
selectedRow[SELECTED2] = nowSelected ? 1 : 0;
|
|
3247
|
-
__privateGet(this, _data)[rowIndex] = selectedRow;
|
|
3248
|
-
updatedRows.push(selectedRow);
|
|
3249
|
-
}
|
|
3250
|
-
}
|
|
3251
|
-
if (updatedRows.length > 0) {
|
|
3252
|
-
(_a = this.clientCallback) == null ? void 0 : _a.call(this, {
|
|
3253
|
-
clientViewportId: this.viewport,
|
|
3254
|
-
mode: "update",
|
|
3255
|
-
type: "viewport-update",
|
|
3256
|
-
rows: updatedRows
|
|
3257
|
-
});
|
|
3258
|
-
}
|
|
3259
|
-
}
|
|
3260
|
-
openTreeNode(key) {
|
|
3261
|
-
var _a;
|
|
3262
|
-
this.expandedRows.add(key);
|
|
3263
|
-
this.visibleRows = getVisibleRows(__privateGet(this, _data), this.expandedRows);
|
|
3264
|
-
const { from, to } = __privateGet(this, _range);
|
|
3265
|
-
(_a = this.clientCallback) == null ? void 0 : _a.call(this, {
|
|
3266
|
-
clientViewportId: this.viewport,
|
|
3267
|
-
mode: "batch",
|
|
3268
|
-
rows: this.visibleRows.slice(from, to).map((row) => toClientRow2(row, this.keys)),
|
|
3269
|
-
size: this.visibleRows.length,
|
|
3270
|
-
type: "viewport-update"
|
|
3271
|
-
});
|
|
3272
|
-
}
|
|
3273
|
-
closeTreeNode(key, cascade = false) {
|
|
3274
|
-
this.expandedRows.delete(key);
|
|
3275
|
-
if (cascade) {
|
|
3276
|
-
for (const rowKey of this.expandedRows.keys()) {
|
|
3277
|
-
if (rowKey.startsWith(key)) {
|
|
3278
|
-
this.expandedRows.delete(rowKey);
|
|
3279
|
-
}
|
|
3280
|
-
}
|
|
3281
|
-
}
|
|
3282
|
-
this.visibleRows = getVisibleRows(__privateGet(this, _data), this.expandedRows);
|
|
3283
|
-
this.sendRowsToClient();
|
|
3284
|
-
}
|
|
3285
|
-
get status() {
|
|
3286
|
-
return __privateGet(this, _status);
|
|
3287
|
-
}
|
|
3288
|
-
get config() {
|
|
3289
|
-
return __privateGet(this, _config);
|
|
3290
|
-
}
|
|
3291
|
-
applyConfig() {
|
|
3292
|
-
return true;
|
|
3293
|
-
}
|
|
3294
|
-
get selectedRowsCount() {
|
|
3295
|
-
return __privateGet(this, _selectedRowsCount);
|
|
3296
|
-
}
|
|
3297
|
-
get size() {
|
|
3298
|
-
return __privateGet(this, _size);
|
|
3299
|
-
}
|
|
3300
|
-
get range() {
|
|
3301
|
-
return __privateGet(this, _range);
|
|
3302
|
-
}
|
|
3303
|
-
set range(range) {
|
|
3304
|
-
__privateSet(this, _range, range);
|
|
3305
|
-
this.keys.reset(range);
|
|
3306
|
-
requestAnimationFrame(() => {
|
|
3307
|
-
this.sendRowsToClient();
|
|
3308
|
-
});
|
|
3309
|
-
}
|
|
3310
|
-
sendRowsToClient() {
|
|
3311
|
-
var _a;
|
|
3312
|
-
const { from, to } = __privateGet(this, _range);
|
|
3313
|
-
(_a = this.clientCallback) == null ? void 0 : _a.call(this, {
|
|
3314
|
-
clientViewportId: this.viewport,
|
|
3315
|
-
mode: "batch",
|
|
3316
|
-
rows: this.visibleRows.slice(from, to).map((row) => toClientRow2(row, this.keys)),
|
|
3317
|
-
size: this.visibleRows.length,
|
|
3318
|
-
type: "viewport-update"
|
|
3319
|
-
});
|
|
3320
|
-
}
|
|
3321
|
-
get columns() {
|
|
3322
|
-
return __privateGet(this, _config).columns;
|
|
3323
|
-
}
|
|
3324
|
-
set columns(columns) {
|
|
3325
|
-
__privateSet(this, _config, {
|
|
3326
|
-
...__privateGet(this, _config),
|
|
3327
|
-
columns
|
|
3328
|
-
});
|
|
3329
|
-
}
|
|
3330
|
-
get aggregations() {
|
|
3331
|
-
return __privateGet(this, _aggregations);
|
|
3332
|
-
}
|
|
3333
|
-
set aggregations(aggregations) {
|
|
3334
|
-
__privateSet(this, _aggregations, aggregations);
|
|
3335
|
-
}
|
|
3336
|
-
get sort() {
|
|
3337
|
-
return __privateGet(this, _sort);
|
|
3338
|
-
}
|
|
3339
|
-
set sort(sort) {
|
|
3340
|
-
__privateSet(this, _sort, sort);
|
|
3341
|
-
}
|
|
3342
|
-
get filter() {
|
|
3343
|
-
return __privateGet(this, _filter);
|
|
3344
|
-
}
|
|
3345
|
-
set filter(filter) {
|
|
3346
|
-
__privateSet(this, _filter, filter);
|
|
3347
|
-
}
|
|
3348
|
-
get groupBy() {
|
|
3349
|
-
return __privateGet(this, _groupBy);
|
|
3350
|
-
}
|
|
3351
|
-
set groupBy(groupBy) {
|
|
3352
|
-
__privateSet(this, _groupBy, groupBy);
|
|
3353
|
-
}
|
|
3354
|
-
get title() {
|
|
3355
|
-
return __privateGet(this, _title);
|
|
3356
|
-
}
|
|
3357
|
-
set title(title) {
|
|
3358
|
-
__privateSet(this, _title, title);
|
|
3359
|
-
}
|
|
3360
|
-
createLink({
|
|
3361
|
-
parentVpId,
|
|
3362
|
-
link: { fromColumn, toColumn }
|
|
3363
|
-
}) {
|
|
3364
|
-
console.log("create link", {
|
|
3365
|
-
parentVpId,
|
|
3366
|
-
fromColumn,
|
|
3367
|
-
toColumn
|
|
3368
|
-
});
|
|
3369
|
-
}
|
|
3370
|
-
removeLink() {
|
|
3371
|
-
console.log("remove link");
|
|
3372
|
-
}
|
|
3373
|
-
async menuRpcCall(rpcRequest) {
|
|
3374
|
-
console.log("rmenuRpcCall", {
|
|
3375
|
-
rpcRequest
|
|
3376
|
-
});
|
|
3377
|
-
return void 0;
|
|
3378
|
-
}
|
|
3379
|
-
applyEdit(row, columnName, value) {
|
|
3380
|
-
console.log(
|
|
3381
|
-
`ArrayDataSource applyEdit ${row.join(",")} ${columnName} ${value}`
|
|
3382
|
-
);
|
|
3383
|
-
return Promise.resolve(true);
|
|
3384
|
-
}
|
|
3385
|
-
getChildRows(rowKey) {
|
|
3386
|
-
const parentRow = __privateGet(this, _data).find((row) => row[KEY3] === rowKey);
|
|
3387
|
-
if (parentRow) {
|
|
3388
|
-
const { [IDX]: parentIdx, [DEPTH2]: parentDepth } = parentRow;
|
|
3389
|
-
let rowIdx = parentIdx + 1;
|
|
3390
|
-
const childRows = [];
|
|
3391
|
-
do {
|
|
3392
|
-
const { [DEPTH2]: depth } = __privateGet(this, _data)[rowIdx];
|
|
3393
|
-
if (depth === parentDepth + 1) {
|
|
3394
|
-
childRows.push(__privateGet(this, _data)[rowIdx]);
|
|
3395
|
-
} else if (depth <= parentDepth) {
|
|
3396
|
-
break;
|
|
3397
|
-
}
|
|
3398
|
-
rowIdx += 1;
|
|
3399
|
-
} while (rowIdx < __privateGet(this, _data).length);
|
|
3400
|
-
return childRows;
|
|
3401
|
-
} else {
|
|
3402
|
-
console.warn(
|
|
3403
|
-
`JsonDataSource getChildRows row not found for key ${rowKey}`
|
|
3404
|
-
);
|
|
3405
|
-
}
|
|
3406
|
-
return [];
|
|
3407
|
-
}
|
|
3408
|
-
getRowsAtDepth(depth, visibleOnly = true) {
|
|
3409
|
-
const rows = visibleOnly ? this.visibleRows : __privateGet(this, _data);
|
|
3410
|
-
return rows.filter((row) => row[DEPTH2] === depth);
|
|
3411
|
-
}
|
|
3412
|
-
};
|
|
3413
|
-
_aggregations = new WeakMap();
|
|
3414
|
-
_config = new WeakMap();
|
|
3415
|
-
_data = new WeakMap();
|
|
3416
|
-
_filter = new WeakMap();
|
|
3417
|
-
_groupBy = new WeakMap();
|
|
3418
|
-
_range = new WeakMap();
|
|
3419
|
-
_selectedRowsCount = new WeakMap();
|
|
3420
|
-
_size = new WeakMap();
|
|
3421
|
-
_sort = new WeakMap();
|
|
3422
|
-
_status = new WeakMap();
|
|
3423
|
-
_title = new WeakMap();
|
|
3424
|
-
function getVisibleRows(rows, expandedKeys) {
|
|
3425
|
-
const visibleRows = [];
|
|
3426
|
-
const index = { value: 0 };
|
|
3427
|
-
for (let i = 0; i < rows.length; i++) {
|
|
3428
|
-
const row = rows[i];
|
|
3429
|
-
const { [DEPTH2]: depth, [KEY3]: key, [IS_LEAF]: isLeaf } = row;
|
|
3430
|
-
const isExpanded = expandedKeys.has(key);
|
|
3431
|
-
visibleRows.push(cloneRow(row, index, isExpanded));
|
|
3432
|
-
if (!isLeaf && !isExpanded) {
|
|
3433
|
-
do {
|
|
3434
|
-
i += 1;
|
|
3435
|
-
} while (i < rows.length - 1 && rows[i + 1][DEPTH2] > depth);
|
|
3436
|
-
}
|
|
3437
|
-
}
|
|
3438
|
-
return visibleRows;
|
|
3439
|
-
}
|
|
3440
|
-
var cloneRow = (row, index, isExpanded) => {
|
|
3441
|
-
const dolly = row.slice();
|
|
3442
|
-
dolly[0] = index.value;
|
|
3443
|
-
dolly[1] = index.value;
|
|
3444
|
-
if (isExpanded) {
|
|
3445
|
-
dolly[IS_EXPANDED2] = true;
|
|
3446
|
-
}
|
|
3447
|
-
index.value += 1;
|
|
3448
|
-
return dolly;
|
|
3449
|
-
};
|
|
3450
|
-
|
|
3451
|
-
// src/json-table/JsonTable.tsx
|
|
57
|
+
var import_vuu_data_local = require("@vuu-ui/vuu-data-local");
|
|
3452
58
|
var import_react = require("react");
|
|
3453
59
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
3454
60
|
var JsonTable = ({
|
|
@@ -3459,7 +65,7 @@ var JsonTable = ({
|
|
|
3459
65
|
const sourceRef = (0, import_react.useRef)(sourceProp);
|
|
3460
66
|
const dataSourceRef = (0, import_react.useRef)();
|
|
3461
67
|
(0, import_react.useMemo)(() => {
|
|
3462
|
-
dataSourceRef.current = new JsonDataSource({
|
|
68
|
+
dataSourceRef.current = new import_vuu_data_local.JsonDataSource({
|
|
3463
69
|
data: sourceRef.current
|
|
3464
70
|
});
|
|
3465
71
|
}, []);
|