@voicenter-team/voicenter-ui-plus 1.1.13 → 1.1.14
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/library/{VcExcelFileUploader-ctMBaT_F.mjs → VcExcelFileUploader-BGWQNFwu.mjs} +2 -2
- package/library/VcExcelFileUploader-BGWQNFwu.mjs.br +0 -0
- package/library/VcExcelFileUploader-BGWQNFwu.mjs.gz +0 -0
- package/library/{VcHtmlEditor-C6fqY5jG.mjs → VcHtmlEditor-BLBtXzie.mjs} +15 -14
- package/library/VcHtmlEditor-BLBtXzie.mjs.br +0 -0
- package/library/VcHtmlEditor-BLBtXzie.mjs.gz +0 -0
- package/library/{VcImageUploader-CyF8PyGr.mjs → VcImageUploader-Dx4Kdlnt.mjs} +1 -1
- package/library/VcImageUploader-Dx4Kdlnt.mjs.br +0 -0
- package/library/VcImageUploader-Dx4Kdlnt.mjs.gz +0 -0
- package/library/{VcJsonSchema-B6t6wo0H.mjs → VcJsonSchema-DkXo7zke.mjs} +4 -4
- package/library/VcJsonSchema-DkXo7zke.mjs.br +0 -0
- package/library/VcJsonSchema-DkXo7zke.mjs.gz +0 -0
- package/library/{VcMdEditor-BSL6fJlG.mjs → VcMdEditor-BCLnDMVI.mjs} +1 -1
- package/library/{VcMdEditor.vue_vue_type_script_setup_true_lang-vKHE5Tli.mjs → VcMdEditor.vue_vue_type_script_setup_true_lang-_n1Xfo53.mjs} +126 -2801
- package/library/VcMdEditor.vue_vue_type_script_setup_true_lang-_n1Xfo53.mjs.br +0 -0
- package/library/VcMdEditor.vue_vue_type_script_setup_true_lang-_n1Xfo53.mjs.gz +0 -0
- package/library/{VcPdfDocument-TK-FeJ6-.mjs → VcPdfDocument-B5SRvrmF.mjs} +1 -1
- package/library/VcPdfDocument-B5SRvrmF.mjs.br +0 -0
- package/library/VcPdfDocument-B5SRvrmF.mjs.gz +0 -0
- package/library/{VcSoundPlayer-CkHANDuX.mjs → VcSoundPlayer-wL4ojS_O.mjs} +1 -1
- package/library/VcSoundPlayer-wL4ojS_O.mjs.br +0 -0
- package/library/VcSoundPlayer-wL4ojS_O.mjs.gz +0 -0
- package/library/{VcSparkline-C7GRQ4Iy.mjs → VcSparkline-q9AhIwYB.mjs} +1 -1
- package/library/VcSparkline-q9AhIwYB.mjs.br +0 -0
- package/library/VcSparkline-q9AhIwYB.mjs.gz +0 -0
- package/library/{VcSystemUserPrompt-BOmOGkxG.mjs → VcSystemUserPrompt-DV2q021X.mjs} +2 -2
- package/library/VcSystemUserPrompt-DV2q021X.mjs.br +0 -0
- package/library/VcSystemUserPrompt-DV2q021X.mjs.gz +0 -0
- package/library/{VcTour-CcNFTLny.mjs → VcTour-CYC9VauJ.mjs} +2 -2
- package/library/VcTour-CYC9VauJ.mjs.br +0 -0
- package/library/VcTour-CYC9VauJ.mjs.gz +0 -0
- package/library/{VcTransfer-Cli1Oq2A.mjs → VcTransfer-c3JKCl4h.mjs} +1 -1
- package/library/VcTransfer-c3JKCl4h.mjs.br +0 -0
- package/library/VcTransfer-c3JKCl4h.mjs.gz +0 -0
- package/library/{VcTree-CfZqYrEh.mjs → VcTree-BMKqNgg0.mjs} +1 -1
- package/library/{VcTree.vue_vue_type_style_index_0_lang-CCxm5H59.mjs → VcTree.vue_vue_type_style_index_0_lang-D4K9G2kS.mjs} +1 -1
- package/library/VcTree.vue_vue_type_style_index_0_lang-D4K9G2kS.mjs.br +0 -0
- package/library/VcTree.vue_vue_type_style_index_0_lang-D4K9G2kS.mjs.gz +0 -0
- package/library/{VcTreeSelect-BlHYiWN6.mjs → VcTreeSelect-dM9OAfje.mjs} +2 -2
- package/library/VcTreeSelect-dM9OAfje.mjs.br +0 -0
- package/library/VcTreeSelect-dM9OAfje.mjs.gz +0 -0
- package/library/{_isIterateeCall-Bf-FzL6I.mjs → _isIterateeCall-DwU3ijt0.mjs} +1 -1
- package/library/{entry-DF9hJfXh.mjs → entry-B5Xh8_lC.mjs} +13 -13
- package/library/entry-B5Xh8_lC.mjs.br +0 -0
- package/library/{entry-DF9hJfXh.mjs.gz → entry-B5Xh8_lC.mjs.gz} +0 -0
- package/library/{floating-ui.dom-BxWZQh-a.mjs → floating-ui.dom-xZpJRvSJ.mjs} +1 -1
- package/library/floating-ui.dom-xZpJRvSJ.mjs.br +0 -0
- package/library/floating-ui.dom-xZpJRvSJ.mjs.gz +0 -0
- package/library/{index-C_21_01J.mjs → index-B3YH1Rp8.mjs} +2 -3
- package/library/index-B3YH1Rp8.mjs.br +0 -0
- package/library/index-B3YH1Rp8.mjs.gz +0 -0
- package/library/{index-D01sOJgv.mjs → index-BAAqkdMI.mjs} +1 -2
- package/library/index-BAAqkdMI.mjs.br +0 -0
- package/library/index-BAAqkdMI.mjs.gz +0 -0
- package/library/{index-CmAHKlzX.mjs → index-Bs6_pkvd.mjs} +1 -2
- package/library/index-Bs6_pkvd.mjs.br +0 -0
- package/library/index-Bs6_pkvd.mjs.gz +0 -0
- package/library/{index-CikdSQHP.mjs → index-CWRhvk2r.mjs} +1 -2
- package/library/index-CWRhvk2r.mjs.br +0 -0
- package/library/index-CWRhvk2r.mjs.gz +0 -0
- package/library/{index-BbGnYK6O.mjs → index-CkrjnzoC.mjs} +1 -2
- package/library/index-CkrjnzoC.mjs.br +0 -0
- package/library/index-CkrjnzoC.mjs.gz +0 -0
- package/library/{index-CAKh3JGH.mjs → index-DGsahj0V.mjs} +2 -3
- package/library/index-DGsahj0V.mjs.br +0 -0
- package/library/index-DGsahj0V.mjs.gz +0 -0
- package/library/{index-zlit9fPu.mjs → index-DZkxoGn3.mjs} +1 -2
- package/library/index-DZkxoGn3.mjs.br +0 -0
- package/library/index-DZkxoGn3.mjs.gz +0 -0
- package/library/{index-BnbDskby.mjs → index-DlA-_JNN.mjs} +2 -3
- package/library/index-DlA-_JNN.mjs.br +0 -0
- package/library/index-DlA-_JNN.mjs.gz +0 -0
- package/library/{index-zC09MyRz.mjs → index-Dq7WhUJu.mjs} +2 -3
- package/library/index-Dq7WhUJu.mjs.br +0 -0
- package/library/index-Dq7WhUJu.mjs.gz +0 -0
- package/library/{index-DeSueTib.mjs → index-EVu8jdcY.mjs} +1 -2
- package/library/index-EVu8jdcY.mjs.br +0 -0
- package/library/index-EVu8jdcY.mjs.gz +0 -0
- package/library/{index-B2ZP5CVm.mjs → index-Ftvywh65.mjs} +1 -2
- package/library/index-Ftvywh65.mjs.br +0 -0
- package/library/index-Ftvywh65.mjs.gz +0 -0
- package/library/{mdEditor.config-CKrm_xtK.mjs → index-Meq0EvXk.mjs} +2883 -205
- package/library/index-Meq0EvXk.mjs.br +0 -0
- package/library/index-Meq0EvXk.mjs.gz +0 -0
- package/library/{index-sgXxTXif.mjs → index-PFn9GZaw.mjs} +1 -2
- package/library/index-PFn9GZaw.mjs.br +0 -0
- package/library/index-PFn9GZaw.mjs.gz +0 -0
- package/library/{index-C4R0KFt1.mjs → index-RdTEsCmZ.mjs} +2 -3
- package/library/index-RdTEsCmZ.mjs.br +0 -0
- package/library/index-RdTEsCmZ.mjs.gz +0 -0
- package/library/{index-4q-4gucE.mjs → index-ef4WGzk3.mjs} +1 -2
- package/library/index-ef4WGzk3.mjs.br +0 -0
- package/library/index-ef4WGzk3.mjs.gz +0 -0
- package/library/{index-Be7eTO9p.mjs → index-kYmjso4n.mjs} +1 -2
- package/library/index-kYmjso4n.mjs.br +0 -0
- package/library/index-kYmjso4n.mjs.gz +0 -0
- package/library/{index-BUp6-OGo.mjs → index-mWEsOn1Y.mjs} +2 -3
- package/library/index-mWEsOn1Y.mjs.br +0 -0
- package/library/index-mWEsOn1Y.mjs.gz +0 -0
- package/library/{index.es-By1dbMUl.mjs → index.es-DQ0tvEe9.mjs} +1846 -92
- package/library/index.es-DQ0tvEe9.mjs.br +0 -0
- package/library/index.es-DQ0tvEe9.mjs.gz +0 -0
- package/library/style.css +1 -1
- package/library/style.css.br +0 -0
- package/library/style.css.gz +0 -0
- package/library/super.mjs +1 -1
- package/library/super.mjs.br +0 -0
- package/library/super.mjs.gz +0 -0
- package/library/super.umd.js +1 -1
- package/library/super.umd.js.br +0 -0
- package/library/super.umd.js.gz +0 -0
- package/package.json +1 -1
- package/library/VcExcelFileUploader-ctMBaT_F.mjs.br +0 -0
- package/library/VcExcelFileUploader-ctMBaT_F.mjs.gz +0 -0
- package/library/VcHtmlEditor-C6fqY5jG.mjs.br +0 -0
- package/library/VcHtmlEditor-C6fqY5jG.mjs.gz +0 -0
- package/library/VcImageUploader-CyF8PyGr.mjs.br +0 -0
- package/library/VcImageUploader-CyF8PyGr.mjs.gz +0 -0
- package/library/VcJsonSchema-B6t6wo0H.mjs.br +0 -0
- package/library/VcJsonSchema-B6t6wo0H.mjs.gz +0 -0
- package/library/VcMdEditor.vue_vue_type_script_setup_true_lang-vKHE5Tli.mjs.br +0 -0
- package/library/VcMdEditor.vue_vue_type_script_setup_true_lang-vKHE5Tli.mjs.gz +0 -0
- package/library/VcPdfDocument-TK-FeJ6-.mjs.br +0 -0
- package/library/VcPdfDocument-TK-FeJ6-.mjs.gz +0 -0
- package/library/VcSoundPlayer-CkHANDuX.mjs.br +0 -0
- package/library/VcSoundPlayer-CkHANDuX.mjs.gz +0 -0
- package/library/VcSparkline-C7GRQ4Iy.mjs.br +0 -0
- package/library/VcSparkline-C7GRQ4Iy.mjs.gz +0 -0
- package/library/VcSystemUserPrompt-BOmOGkxG.mjs.br +0 -0
- package/library/VcSystemUserPrompt-BOmOGkxG.mjs.gz +0 -0
- package/library/VcTour-CcNFTLny.mjs.br +0 -0
- package/library/VcTour-CcNFTLny.mjs.gz +0 -0
- package/library/VcTransfer-Cli1Oq2A.mjs.br +0 -0
- package/library/VcTransfer-Cli1Oq2A.mjs.gz +0 -0
- package/library/VcTree.vue_vue_type_style_index_0_lang-CCxm5H59.mjs.br +0 -0
- package/library/VcTree.vue_vue_type_style_index_0_lang-CCxm5H59.mjs.gz +0 -0
- package/library/VcTreeSelect-BlHYiWN6.mjs.br +0 -0
- package/library/VcTreeSelect-BlHYiWN6.mjs.gz +0 -0
- package/library/entry-DF9hJfXh.mjs.br +0 -0
- package/library/floating-ui.dom-BxWZQh-a.mjs.br +0 -0
- package/library/floating-ui.dom-BxWZQh-a.mjs.gz +0 -0
- package/library/index-4q-4gucE.mjs.br +0 -0
- package/library/index-4q-4gucE.mjs.gz +0 -0
- package/library/index-B2ZP5CVm.mjs.br +0 -0
- package/library/index-B2ZP5CVm.mjs.gz +0 -0
- package/library/index-BUp6-OGo.mjs.br +0 -0
- package/library/index-BUp6-OGo.mjs.gz +0 -0
- package/library/index-BYoXZebg.mjs +0 -1758
- package/library/index-BYoXZebg.mjs.br +0 -0
- package/library/index-BYoXZebg.mjs.gz +0 -0
- package/library/index-BbGnYK6O.mjs.br +0 -0
- package/library/index-BbGnYK6O.mjs.gz +0 -0
- package/library/index-Be7eTO9p.mjs.br +0 -0
- package/library/index-Be7eTO9p.mjs.gz +0 -0
- package/library/index-BnbDskby.mjs.br +0 -0
- package/library/index-BnbDskby.mjs.gz +0 -0
- package/library/index-C4R0KFt1.mjs.br +0 -0
- package/library/index-C4R0KFt1.mjs.gz +0 -0
- package/library/index-CAKh3JGH.mjs.br +0 -0
- package/library/index-CAKh3JGH.mjs.gz +0 -0
- package/library/index-C_21_01J.mjs.br +0 -0
- package/library/index-C_21_01J.mjs.gz +0 -0
- package/library/index-CikdSQHP.mjs.br +0 -0
- package/library/index-CikdSQHP.mjs.gz +0 -0
- package/library/index-CmAHKlzX.mjs.br +0 -0
- package/library/index-CmAHKlzX.mjs.gz +0 -0
- package/library/index-D01sOJgv.mjs.br +0 -0
- package/library/index-D01sOJgv.mjs.gz +0 -0
- package/library/index-DeSueTib.mjs.br +0 -0
- package/library/index-DeSueTib.mjs.gz +0 -0
- package/library/index-sgXxTXif.mjs.br +0 -0
- package/library/index-sgXxTXif.mjs.gz +0 -0
- package/library/index-zC09MyRz.mjs.br +0 -0
- package/library/index-zC09MyRz.mjs.gz +0 -0
- package/library/index-zlit9fPu.mjs.br +0 -0
- package/library/index-zlit9fPu.mjs.gz +0 -0
- package/library/index.es-By1dbMUl.mjs.br +0 -0
- package/library/index.es-By1dbMUl.mjs.gz +0 -0
- package/library/mdEditor.config-CKrm_xtK.mjs.br +0 -0
- package/library/mdEditor.config-CKrm_xtK.mjs.gz +0 -0
|
@@ -67,10 +67,10 @@ class NodeType {
|
|
|
67
67
|
/**
|
|
68
68
|
@internal
|
|
69
69
|
*/
|
|
70
|
-
constructor(name2, props,
|
|
70
|
+
constructor(name2, props, id2, flags = 0) {
|
|
71
71
|
this.name = name2;
|
|
72
72
|
this.props = props;
|
|
73
|
-
this.id =
|
|
73
|
+
this.id = id2;
|
|
74
74
|
this.flags = flags;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
@@ -349,8 +349,8 @@ class Tree {
|
|
|
349
349
|
get propValues() {
|
|
350
350
|
let result = [];
|
|
351
351
|
if (this.props)
|
|
352
|
-
for (let
|
|
353
|
-
result.push([+
|
|
352
|
+
for (let id2 in this.props)
|
|
353
|
+
result.push([+id2, this.props[id2]]);
|
|
354
354
|
return result;
|
|
355
355
|
}
|
|
356
356
|
/**
|
|
@@ -427,8 +427,8 @@ class TreeBuffer {
|
|
|
427
427
|
@internal
|
|
428
428
|
*/
|
|
429
429
|
childString(index) {
|
|
430
|
-
let
|
|
431
|
-
let type = this.set.types[
|
|
430
|
+
let id2 = this.buffer[index], endIndex = this.buffer[index + 3];
|
|
431
|
+
let type = this.set.types[id2], result = type.name;
|
|
432
432
|
if (/\W/.test(result) && !type.isError)
|
|
433
433
|
result = JSON.stringify(result);
|
|
434
434
|
index += 4;
|
|
@@ -1234,26 +1234,26 @@ function buildTree(data) {
|
|
|
1234
1234
|
let types2 = nodeSet2.types;
|
|
1235
1235
|
let contextHash = 0, lookAhead = 0;
|
|
1236
1236
|
function takeNode(parentStart, minPos, children2, positions2, inRepeat, depth) {
|
|
1237
|
-
let { id, start, end, size } = cursor;
|
|
1237
|
+
let { id: id2, start, end, size } = cursor;
|
|
1238
1238
|
let lookAheadAtStart = lookAhead, contextAtStart = contextHash;
|
|
1239
1239
|
while (size < 0) {
|
|
1240
1240
|
cursor.next();
|
|
1241
1241
|
if (size == -1) {
|
|
1242
|
-
let node2 = reused[
|
|
1242
|
+
let node2 = reused[id2];
|
|
1243
1243
|
children2.push(node2);
|
|
1244
1244
|
positions2.push(start - parentStart);
|
|
1245
1245
|
return;
|
|
1246
1246
|
} else if (size == -3) {
|
|
1247
|
-
contextHash =
|
|
1247
|
+
contextHash = id2;
|
|
1248
1248
|
return;
|
|
1249
1249
|
} else if (size == -4) {
|
|
1250
|
-
lookAhead =
|
|
1250
|
+
lookAhead = id2;
|
|
1251
1251
|
return;
|
|
1252
1252
|
} else {
|
|
1253
1253
|
throw new RangeError(`Unrecognized record size: ${size}`);
|
|
1254
1254
|
}
|
|
1255
1255
|
}
|
|
1256
|
-
let type = types2[
|
|
1256
|
+
let type = types2[id2], node, buffer2;
|
|
1257
1257
|
let startPos = start - parentStart;
|
|
1258
1258
|
if (end - start <= maxBufferLength && (buffer2 = findBufferSize(cursor.pos - minPos, inRepeat))) {
|
|
1259
1259
|
let data2 = new Uint16Array(buffer2.size - buffer2.skip);
|
|
@@ -1266,7 +1266,7 @@ function buildTree(data) {
|
|
|
1266
1266
|
let endPos = cursor.pos - size;
|
|
1267
1267
|
cursor.next();
|
|
1268
1268
|
let localChildren = [], localPositions = [];
|
|
1269
|
-
let localInRepeat =
|
|
1269
|
+
let localInRepeat = id2 >= minRepeatType ? id2 : -1;
|
|
1270
1270
|
let lastGroup = 0, lastEnd = end;
|
|
1271
1271
|
while (cursor.pos > endPos) {
|
|
1272
1272
|
if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
|
|
@@ -1300,7 +1300,7 @@ function buildTree(data) {
|
|
|
1300
1300
|
let nodes = [];
|
|
1301
1301
|
let nodeCount = 0, stopAt = -1;
|
|
1302
1302
|
while (cursor.pos > minPos) {
|
|
1303
|
-
let { id, start, end, size } = cursor;
|
|
1303
|
+
let { id: id2, start, end, size } = cursor;
|
|
1304
1304
|
if (size > 4) {
|
|
1305
1305
|
cursor.next();
|
|
1306
1306
|
} else if (stopAt > -1 && start < stopAt) {
|
|
@@ -1308,7 +1308,7 @@ function buildTree(data) {
|
|
|
1308
1308
|
} else {
|
|
1309
1309
|
if (stopAt < 0)
|
|
1310
1310
|
stopAt = end - maxBufferLength;
|
|
1311
|
-
nodes.push(
|
|
1311
|
+
nodes.push(id2, start, end);
|
|
1312
1312
|
nodeCount++;
|
|
1313
1313
|
cursor.next();
|
|
1314
1314
|
}
|
|
@@ -1349,12 +1349,12 @@ function buildTree(data) {
|
|
|
1349
1349
|
}
|
|
1350
1350
|
function makeTree(type, children2, positions2, length2, lookAhead2, contextHash2, props) {
|
|
1351
1351
|
if (contextHash2) {
|
|
1352
|
-
let
|
|
1353
|
-
props = props ? [
|
|
1352
|
+
let pair2 = [NodeProp.contextHash, contextHash2];
|
|
1353
|
+
props = props ? [pair2].concat(props) : [pair2];
|
|
1354
1354
|
}
|
|
1355
1355
|
if (lookAhead2 > 25) {
|
|
1356
|
-
let
|
|
1357
|
-
props = props ? [
|
|
1356
|
+
let pair2 = [NodeProp.lookAhead, lookAhead2];
|
|
1357
|
+
props = props ? [pair2].concat(props) : [pair2];
|
|
1358
1358
|
}
|
|
1359
1359
|
return new Tree(type, children2, positions2, length2, props);
|
|
1360
1360
|
}
|
|
@@ -1402,9 +1402,9 @@ function buildTree(data) {
|
|
|
1402
1402
|
return result.size > 4 ? result : void 0;
|
|
1403
1403
|
}
|
|
1404
1404
|
function copyToBuffer(bufferStart, buffer2, index) {
|
|
1405
|
-
let { id, start, end, size } = cursor;
|
|
1405
|
+
let { id: id2, start, end, size } = cursor;
|
|
1406
1406
|
cursor.next();
|
|
1407
|
-
if (size >= 0 &&
|
|
1407
|
+
if (size >= 0 && id2 < minRepeatType) {
|
|
1408
1408
|
let startIndex = index;
|
|
1409
1409
|
if (size > 4) {
|
|
1410
1410
|
let endPos = cursor.pos - (size - 4);
|
|
@@ -1414,11 +1414,11 @@ function buildTree(data) {
|
|
|
1414
1414
|
buffer2[--index] = startIndex;
|
|
1415
1415
|
buffer2[--index] = end - bufferStart;
|
|
1416
1416
|
buffer2[--index] = start - bufferStart;
|
|
1417
|
-
buffer2[--index] =
|
|
1417
|
+
buffer2[--index] = id2;
|
|
1418
1418
|
} else if (size == -3) {
|
|
1419
|
-
contextHash =
|
|
1419
|
+
contextHash = id2;
|
|
1420
1420
|
} else if (size == -4) {
|
|
1421
|
-
lookAhead =
|
|
1421
|
+
lookAhead = id2;
|
|
1422
1422
|
}
|
|
1423
1423
|
return index;
|
|
1424
1424
|
}
|
|
@@ -1741,7 +1741,7 @@ class MixedParse {
|
|
|
1741
1741
|
this.inner[i].parse.stopAt(pos);
|
|
1742
1742
|
}
|
|
1743
1743
|
startInner() {
|
|
1744
|
-
let fragmentCursor = new FragmentCursor(this.fragments);
|
|
1744
|
+
let fragmentCursor = new FragmentCursor$1(this.fragments);
|
|
1745
1745
|
let overlay = null;
|
|
1746
1746
|
let covered = null;
|
|
1747
1747
|
let cursor = new TreeCursor(new TreeNode(this.baseTree, this.ranges[0].from, 0, null), IterMode.IncludeAnonymous | IterMode.IgnoreMounts);
|
|
@@ -1889,7 +1889,7 @@ class StructureCursor {
|
|
|
1889
1889
|
return false;
|
|
1890
1890
|
}
|
|
1891
1891
|
}
|
|
1892
|
-
class FragmentCursor {
|
|
1892
|
+
let FragmentCursor$1 = class FragmentCursor {
|
|
1893
1893
|
constructor(fragments) {
|
|
1894
1894
|
var _a2;
|
|
1895
1895
|
this.fragments = fragments;
|
|
@@ -1943,7 +1943,7 @@ class FragmentCursor {
|
|
|
1943
1943
|
}
|
|
1944
1944
|
return result;
|
|
1945
1945
|
}
|
|
1946
|
-
}
|
|
1946
|
+
};
|
|
1947
1947
|
function punchRanges(outer, ranges) {
|
|
1948
1948
|
let copy = null, current = ranges;
|
|
1949
1949
|
for (let i = 1, j = 0; i < outer.length; i++) {
|
|
@@ -3003,10 +3003,10 @@ class ChangeSet extends ChangeDesc {
|
|
|
3003
3003
|
inserted = [];
|
|
3004
3004
|
pos = 0;
|
|
3005
3005
|
}
|
|
3006
|
-
function
|
|
3006
|
+
function process2(spec) {
|
|
3007
3007
|
if (Array.isArray(spec)) {
|
|
3008
3008
|
for (let sub of spec)
|
|
3009
|
-
|
|
3009
|
+
process2(sub);
|
|
3010
3010
|
} else if (spec instanceof ChangeSet) {
|
|
3011
3011
|
if (spec.length != length)
|
|
3012
3012
|
throw new RangeError(`Mismatched change set length (got ${spec.length}, expected ${length})`);
|
|
@@ -3029,7 +3029,7 @@ class ChangeSet extends ChangeDesc {
|
|
|
3029
3029
|
pos = to;
|
|
3030
3030
|
}
|
|
3031
3031
|
}
|
|
3032
|
-
|
|
3032
|
+
process2(changes);
|
|
3033
3033
|
flush(!total);
|
|
3034
3034
|
return total;
|
|
3035
3035
|
}
|
|
@@ -3574,7 +3574,7 @@ class FacetProvider {
|
|
|
3574
3574
|
var _a2;
|
|
3575
3575
|
let getter = this.value;
|
|
3576
3576
|
let compare2 = this.facet.compareInput;
|
|
3577
|
-
let
|
|
3577
|
+
let id2 = this.id, idx = addresses[id2] >> 1, multi = this.type == 2;
|
|
3578
3578
|
let depDoc = false, depSel = false, depAddrs = [];
|
|
3579
3579
|
for (let dep of this.dependencies) {
|
|
3580
3580
|
if (dep == "doc")
|
|
@@ -3600,7 +3600,7 @@ class FacetProvider {
|
|
|
3600
3600
|
return 0;
|
|
3601
3601
|
},
|
|
3602
3602
|
reconfigure: (state, oldState) => {
|
|
3603
|
-
let newVal, oldAddr = oldState.config.address[
|
|
3603
|
+
let newVal, oldAddr = oldState.config.address[id2];
|
|
3604
3604
|
if (oldAddr != null) {
|
|
3605
3605
|
let oldVal = getAddr(oldState, oldAddr);
|
|
3606
3606
|
if (this.dependencies.every((dep) => {
|
|
@@ -3685,8 +3685,8 @@ function dynamicFacetSlot(addresses, facet, providers) {
|
|
|
3685
3685
|
}
|
|
3686
3686
|
const initField = /* @__PURE__ */ Facet.define({ static: true });
|
|
3687
3687
|
class StateField {
|
|
3688
|
-
constructor(
|
|
3689
|
-
this.id =
|
|
3688
|
+
constructor(id2, createF, updateF, compareF, spec) {
|
|
3689
|
+
this.id = id2;
|
|
3690
3690
|
this.createF = createF;
|
|
3691
3691
|
this.updateF = updateF;
|
|
3692
3692
|
this.compareF = compareF;
|
|
@@ -3858,9 +3858,9 @@ class Configuration {
|
|
|
3858
3858
|
dynamicSlots.push((a) => field.slot(a));
|
|
3859
3859
|
}
|
|
3860
3860
|
let oldFacets = oldState === null || oldState === void 0 ? void 0 : oldState.config.facets;
|
|
3861
|
-
for (let
|
|
3862
|
-
let providers = facets[
|
|
3863
|
-
let oldProviders = oldFacets && oldFacets[
|
|
3861
|
+
for (let id2 in facets) {
|
|
3862
|
+
let providers = facets[id2], facet = providers[0].facet;
|
|
3863
|
+
let oldProviders = oldFacets && oldFacets[id2] || [];
|
|
3864
3864
|
if (providers.every(
|
|
3865
3865
|
(p) => p.type == 0
|
|
3866
3866
|
/* Provider.Static */
|
|
@@ -5483,9 +5483,9 @@ class StyleModule {
|
|
|
5483
5483
|
// :: () → string
|
|
5484
5484
|
// Generate a new unique CSS class name.
|
|
5485
5485
|
static newName() {
|
|
5486
|
-
let
|
|
5487
|
-
top[COUNT] =
|
|
5488
|
-
return C +
|
|
5486
|
+
let id2 = top[COUNT] || 1;
|
|
5487
|
+
top[COUNT] = id2 + 1;
|
|
5488
|
+
return C + id2.toString(36);
|
|
5489
5489
|
}
|
|
5490
5490
|
// :: (union<Document, ShadowRoot>, union<[StyleModule], StyleModule>, ?{nonce: ?string})
|
|
5491
5491
|
//
|
|
@@ -7906,8 +7906,8 @@ const editable = /* @__PURE__ */ Facet.define({ combine: (values) => values.leng
|
|
|
7906
7906
|
let nextPluginID = 0;
|
|
7907
7907
|
const viewPlugin = /* @__PURE__ */ Facet.define();
|
|
7908
7908
|
class ViewPlugin {
|
|
7909
|
-
constructor(
|
|
7910
|
-
this.id =
|
|
7909
|
+
constructor(id2, create, domEventHandlers, domEventObservers, buildExtensions) {
|
|
7910
|
+
this.id = id2;
|
|
7911
7911
|
this.create = create;
|
|
7912
7912
|
this.domEventHandlers = domEventHandlers;
|
|
7913
7913
|
this.domEventObservers = domEventObservers;
|
|
@@ -18099,7 +18099,7 @@ class StreamLanguage extends Language {
|
|
|
18099
18099
|
let p = fullParser(parser), self;
|
|
18100
18100
|
let impl = new class extends Parser {
|
|
18101
18101
|
createParse(input, fragments, ranges) {
|
|
18102
|
-
return new Parse(self, input, fragments, ranges);
|
|
18102
|
+
return new Parse$1(self, input, fragments, ranges);
|
|
18103
18103
|
}
|
|
18104
18104
|
}();
|
|
18105
18105
|
super(data, impl, [], parser.name);
|
|
@@ -18142,7 +18142,7 @@ class StreamLanguage extends Language {
|
|
|
18142
18142
|
let indentation = overrideIndentation ? overrideIndentation(line2.from) : -1;
|
|
18143
18143
|
let stream = new StringStream(line2.text, cx.state.tabSize, cx.unit, indentation < 0 ? void 0 : indentation);
|
|
18144
18144
|
while (stream.pos < end - line2.from)
|
|
18145
|
-
readToken(this.streamParser.token, stream, state);
|
|
18145
|
+
readToken$1(this.streamParser.token, stream, state);
|
|
18146
18146
|
} else {
|
|
18147
18147
|
this.streamParser.blankLine(state, cx.unit);
|
|
18148
18148
|
}
|
|
@@ -18195,7 +18195,7 @@ function findStartInFragments(lang, fragments, startPos, endPos, editorState) {
|
|
|
18195
18195
|
}
|
|
18196
18196
|
return { state: lang.streamParser.startState(editorState ? getIndentUnit(editorState) : 4), tree: Tree.empty };
|
|
18197
18197
|
}
|
|
18198
|
-
class Parse {
|
|
18198
|
+
let Parse$1 = class Parse {
|
|
18199
18199
|
constructor(lang, input, fragments, ranges) {
|
|
18200
18200
|
this.lang = lang;
|
|
18201
18201
|
this.input = input;
|
|
@@ -18290,7 +18290,7 @@ class Parse {
|
|
|
18290
18290
|
while (this.ranges[this.rangeIndex].to < this.parsedPos)
|
|
18291
18291
|
this.rangeIndex++;
|
|
18292
18292
|
}
|
|
18293
|
-
emitToken(
|
|
18293
|
+
emitToken(id2, from, to, offset) {
|
|
18294
18294
|
let size = 4;
|
|
18295
18295
|
if (this.ranges.length > 1) {
|
|
18296
18296
|
offset = this.skipGapsTo(from, offset, 1);
|
|
@@ -18301,10 +18301,10 @@ class Parse {
|
|
|
18301
18301
|
size += this.chunk.length - len0;
|
|
18302
18302
|
}
|
|
18303
18303
|
let last = this.chunk.length - 4;
|
|
18304
|
-
if (this.lang.streamParser.mergeTokens && size == 4 && last >= 0 && this.chunk[last] ==
|
|
18304
|
+
if (this.lang.streamParser.mergeTokens && size == 4 && last >= 0 && this.chunk[last] == id2 && this.chunk[last + 2] == from)
|
|
18305
18305
|
this.chunk[last + 2] = to;
|
|
18306
18306
|
else
|
|
18307
|
-
this.chunk.push(
|
|
18307
|
+
this.chunk.push(id2, from, to, size);
|
|
18308
18308
|
return offset;
|
|
18309
18309
|
}
|
|
18310
18310
|
parseLine(context) {
|
|
@@ -18314,7 +18314,7 @@ class Parse {
|
|
|
18314
18314
|
streamParser.blankLine(this.state, stream.indentUnit);
|
|
18315
18315
|
} else {
|
|
18316
18316
|
while (!stream.eol()) {
|
|
18317
|
-
let token = readToken(streamParser.token, stream, this.state);
|
|
18317
|
+
let token = readToken$1(streamParser.token, stream, this.state);
|
|
18318
18318
|
if (token)
|
|
18319
18319
|
offset = this.emitToken(this.lang.tokenTable.resolve(token), this.parsedPos + stream.start, this.parsedPos + stream.pos, offset);
|
|
18320
18320
|
if (stream.start > 1e4)
|
|
@@ -18346,8 +18346,8 @@ class Parse {
|
|
|
18346
18346
|
finish() {
|
|
18347
18347
|
return new Tree(this.lang.topNode, this.chunks, this.chunkPos, this.parsedPos - this.ranges[0].from).balance();
|
|
18348
18348
|
}
|
|
18349
|
-
}
|
|
18350
|
-
function readToken(token, stream, state) {
|
|
18349
|
+
};
|
|
18350
|
+
function readToken$1(token, stream, state) {
|
|
18351
18351
|
stream.start = stream.pos;
|
|
18352
18352
|
for (let i = 0; i < 10; i++) {
|
|
18353
18353
|
let result = token(stream, state);
|
|
@@ -21077,10 +21077,10 @@ class CompletionTooltip {
|
|
|
21077
21077
|
mount() {
|
|
21078
21078
|
this.updateSel();
|
|
21079
21079
|
}
|
|
21080
|
-
showOptions(options,
|
|
21080
|
+
showOptions(options, id2) {
|
|
21081
21081
|
if (this.list)
|
|
21082
21082
|
this.list.remove();
|
|
21083
|
-
this.list = this.dom.appendChild(this.createListBox(options,
|
|
21083
|
+
this.list = this.dom.appendChild(this.createListBox(options, id2, this.range));
|
|
21084
21084
|
this.list.addEventListener("scroll", () => {
|
|
21085
21085
|
if (this.info)
|
|
21086
21086
|
this.view.requestMeasure(this.placeInfoReq);
|
|
@@ -21205,9 +21205,9 @@ class CompletionTooltip {
|
|
|
21205
21205
|
}
|
|
21206
21206
|
}
|
|
21207
21207
|
}
|
|
21208
|
-
createListBox(options,
|
|
21208
|
+
createListBox(options, id2, range) {
|
|
21209
21209
|
const ul = document.createElement("ul");
|
|
21210
|
-
ul.id =
|
|
21210
|
+
ul.id = id2;
|
|
21211
21211
|
ul.setAttribute("role", "listbox");
|
|
21212
21212
|
ul.setAttribute("aria-expanded", "true");
|
|
21213
21213
|
ul.setAttribute("aria-label", this.view.state.phrase("Completions"));
|
|
@@ -21231,7 +21231,7 @@ class CompletionTooltip {
|
|
|
21231
21231
|
}
|
|
21232
21232
|
}
|
|
21233
21233
|
const li = ul.appendChild(document.createElement("li"));
|
|
21234
|
-
li.id =
|
|
21234
|
+
li.id = id2 + "-" + i;
|
|
21235
21235
|
li.setAttribute("role", "option");
|
|
21236
21236
|
let cls = this.optionClass(completion);
|
|
21237
21237
|
if (cls)
|
|
@@ -21344,10 +21344,10 @@ class CompletionDialog {
|
|
|
21344
21344
|
this.selected = selected;
|
|
21345
21345
|
this.disabled = disabled;
|
|
21346
21346
|
}
|
|
21347
|
-
setSelected(selected,
|
|
21348
|
-
return selected == this.selected || selected >= this.options.length ? this : new CompletionDialog(this.options, makeAttrs(
|
|
21347
|
+
setSelected(selected, id2) {
|
|
21348
|
+
return selected == this.selected || selected >= this.options.length ? this : new CompletionDialog(this.options, makeAttrs(id2, selected), this.tooltip, this.timestamp, selected, this.disabled);
|
|
21349
21349
|
}
|
|
21350
|
-
static build(active, state,
|
|
21350
|
+
static build(active, state, id2, prev, conf, didSetActive) {
|
|
21351
21351
|
if (prev && !didSetActive && active.some((s) => s.isPending))
|
|
21352
21352
|
return prev.setDisabled();
|
|
21353
21353
|
let options = sortOptions(active, state);
|
|
@@ -21362,7 +21362,7 @@ class CompletionDialog {
|
|
|
21362
21362
|
break;
|
|
21363
21363
|
}
|
|
21364
21364
|
}
|
|
21365
|
-
return new CompletionDialog(options, makeAttrs(
|
|
21365
|
+
return new CompletionDialog(options, makeAttrs(id2, selected), {
|
|
21366
21366
|
pos: active.reduce((a, b) => b.hasResult() ? Math.min(a, b.from) : a, 1e8),
|
|
21367
21367
|
create: createTooltip,
|
|
21368
21368
|
above: conf.aboveCursor
|
|
@@ -21376,9 +21376,9 @@ class CompletionDialog {
|
|
|
21376
21376
|
}
|
|
21377
21377
|
}
|
|
21378
21378
|
class CompletionState {
|
|
21379
|
-
constructor(active,
|
|
21379
|
+
constructor(active, id2, open) {
|
|
21380
21380
|
this.active = active;
|
|
21381
|
-
this.id =
|
|
21381
|
+
this.id = id2;
|
|
21382
21382
|
this.open = open;
|
|
21383
21383
|
}
|
|
21384
21384
|
static start() {
|
|
@@ -21444,14 +21444,14 @@ const baseAttrs = {
|
|
|
21444
21444
|
"aria-autocomplete": "list"
|
|
21445
21445
|
};
|
|
21446
21446
|
const noAttrs = {};
|
|
21447
|
-
function makeAttrs(
|
|
21447
|
+
function makeAttrs(id2, selected) {
|
|
21448
21448
|
let result = {
|
|
21449
21449
|
"aria-autocomplete": "list",
|
|
21450
21450
|
"aria-haspopup": "listbox",
|
|
21451
|
-
"aria-controls":
|
|
21451
|
+
"aria-controls": id2
|
|
21452
21452
|
};
|
|
21453
21453
|
if (selected > -1)
|
|
21454
|
-
result["aria-activedescendant"] =
|
|
21454
|
+
result["aria-activedescendant"] = id2 + "-" + selected;
|
|
21455
21455
|
return result;
|
|
21456
21456
|
}
|
|
21457
21457
|
const none = [];
|
|
@@ -23225,6 +23225,1757 @@ const minimalSetup = /* @__PURE__ */ (() => [
|
|
|
23225
23225
|
...historyKeymap
|
|
23226
23226
|
])
|
|
23227
23227
|
])();
|
|
23228
|
+
class Stack {
|
|
23229
|
+
/**
|
|
23230
|
+
@internal
|
|
23231
|
+
*/
|
|
23232
|
+
constructor(p, stack, state, reducePos, pos, score2, buffer, bufferBase, curContext, lookAhead = 0, parent) {
|
|
23233
|
+
this.p = p;
|
|
23234
|
+
this.stack = stack;
|
|
23235
|
+
this.state = state;
|
|
23236
|
+
this.reducePos = reducePos;
|
|
23237
|
+
this.pos = pos;
|
|
23238
|
+
this.score = score2;
|
|
23239
|
+
this.buffer = buffer;
|
|
23240
|
+
this.bufferBase = bufferBase;
|
|
23241
|
+
this.curContext = curContext;
|
|
23242
|
+
this.lookAhead = lookAhead;
|
|
23243
|
+
this.parent = parent;
|
|
23244
|
+
}
|
|
23245
|
+
/**
|
|
23246
|
+
@internal
|
|
23247
|
+
*/
|
|
23248
|
+
toString() {
|
|
23249
|
+
return `[${this.stack.filter((_, i) => i % 3 == 0).concat(this.state)}]@${this.pos}${this.score ? "!" + this.score : ""}`;
|
|
23250
|
+
}
|
|
23251
|
+
// Start an empty stack
|
|
23252
|
+
/**
|
|
23253
|
+
@internal
|
|
23254
|
+
*/
|
|
23255
|
+
static start(p, state, pos = 0) {
|
|
23256
|
+
let cx = p.parser.context;
|
|
23257
|
+
return new Stack(p, [], state, pos, pos, 0, [], 0, cx ? new StackContext(cx, cx.start) : null, 0, null);
|
|
23258
|
+
}
|
|
23259
|
+
/**
|
|
23260
|
+
The stack's current [context](#lr.ContextTracker) value, if
|
|
23261
|
+
any. Its type will depend on the context tracker's type
|
|
23262
|
+
parameter, or it will be `null` if there is no context
|
|
23263
|
+
tracker.
|
|
23264
|
+
*/
|
|
23265
|
+
get context() {
|
|
23266
|
+
return this.curContext ? this.curContext.context : null;
|
|
23267
|
+
}
|
|
23268
|
+
// Push a state onto the stack, tracking its start position as well
|
|
23269
|
+
// as the buffer base at that point.
|
|
23270
|
+
/**
|
|
23271
|
+
@internal
|
|
23272
|
+
*/
|
|
23273
|
+
pushState(state, start) {
|
|
23274
|
+
this.stack.push(this.state, start, this.bufferBase + this.buffer.length);
|
|
23275
|
+
this.state = state;
|
|
23276
|
+
}
|
|
23277
|
+
// Apply a reduce action
|
|
23278
|
+
/**
|
|
23279
|
+
@internal
|
|
23280
|
+
*/
|
|
23281
|
+
reduce(action) {
|
|
23282
|
+
var _a2;
|
|
23283
|
+
let depth = action >> 19, type = action & 65535;
|
|
23284
|
+
let { parser } = this.p;
|
|
23285
|
+
let lookaheadRecord = this.reducePos < this.pos - 25;
|
|
23286
|
+
if (lookaheadRecord)
|
|
23287
|
+
this.setLookAhead(this.pos);
|
|
23288
|
+
let dPrec = parser.dynamicPrecedence(type);
|
|
23289
|
+
if (dPrec)
|
|
23290
|
+
this.score += dPrec;
|
|
23291
|
+
if (depth == 0) {
|
|
23292
|
+
this.pushState(parser.getGoto(this.state, type, true), this.reducePos);
|
|
23293
|
+
if (type < parser.minRepeatTerm)
|
|
23294
|
+
this.storeNode(type, this.reducePos, this.reducePos, lookaheadRecord ? 8 : 4, true);
|
|
23295
|
+
this.reduceContext(type, this.reducePos);
|
|
23296
|
+
return;
|
|
23297
|
+
}
|
|
23298
|
+
let base2 = this.stack.length - (depth - 1) * 3 - (action & 262144 ? 6 : 0);
|
|
23299
|
+
let start = base2 ? this.stack[base2 - 2] : this.p.ranges[0].from, size = this.reducePos - start;
|
|
23300
|
+
if (size >= 2e3 && !((_a2 = this.p.parser.nodeSet.types[type]) === null || _a2 === void 0 ? void 0 : _a2.isAnonymous)) {
|
|
23301
|
+
if (start == this.p.lastBigReductionStart) {
|
|
23302
|
+
this.p.bigReductionCount++;
|
|
23303
|
+
this.p.lastBigReductionSize = size;
|
|
23304
|
+
} else if (this.p.lastBigReductionSize < size) {
|
|
23305
|
+
this.p.bigReductionCount = 1;
|
|
23306
|
+
this.p.lastBigReductionStart = start;
|
|
23307
|
+
this.p.lastBigReductionSize = size;
|
|
23308
|
+
}
|
|
23309
|
+
}
|
|
23310
|
+
let bufferBase = base2 ? this.stack[base2 - 1] : 0, count = this.bufferBase + this.buffer.length - bufferBase;
|
|
23311
|
+
if (type < parser.minRepeatTerm || action & 131072) {
|
|
23312
|
+
let pos = parser.stateFlag(
|
|
23313
|
+
this.state,
|
|
23314
|
+
1
|
|
23315
|
+
/* StateFlag.Skipped */
|
|
23316
|
+
) ? this.pos : this.reducePos;
|
|
23317
|
+
this.storeNode(type, start, pos, count + 4, true);
|
|
23318
|
+
}
|
|
23319
|
+
if (action & 262144) {
|
|
23320
|
+
this.state = this.stack[base2];
|
|
23321
|
+
} else {
|
|
23322
|
+
let baseStateID = this.stack[base2 - 3];
|
|
23323
|
+
this.state = parser.getGoto(baseStateID, type, true);
|
|
23324
|
+
}
|
|
23325
|
+
while (this.stack.length > base2)
|
|
23326
|
+
this.stack.pop();
|
|
23327
|
+
this.reduceContext(type, start);
|
|
23328
|
+
}
|
|
23329
|
+
// Shift a value into the buffer
|
|
23330
|
+
/**
|
|
23331
|
+
@internal
|
|
23332
|
+
*/
|
|
23333
|
+
storeNode(term, start, end, size = 4, mustSink = false) {
|
|
23334
|
+
if (term == 0 && (!this.stack.length || this.stack[this.stack.length - 1] < this.buffer.length + this.bufferBase)) {
|
|
23335
|
+
let cur2 = this, top2 = this.buffer.length;
|
|
23336
|
+
if (top2 == 0 && cur2.parent) {
|
|
23337
|
+
top2 = cur2.bufferBase - cur2.parent.bufferBase;
|
|
23338
|
+
cur2 = cur2.parent;
|
|
23339
|
+
}
|
|
23340
|
+
if (top2 > 0 && cur2.buffer[top2 - 4] == 0 && cur2.buffer[top2 - 1] > -1) {
|
|
23341
|
+
if (start == end)
|
|
23342
|
+
return;
|
|
23343
|
+
if (cur2.buffer[top2 - 2] >= start) {
|
|
23344
|
+
cur2.buffer[top2 - 2] = end;
|
|
23345
|
+
return;
|
|
23346
|
+
}
|
|
23347
|
+
}
|
|
23348
|
+
}
|
|
23349
|
+
if (!mustSink || this.pos == end) {
|
|
23350
|
+
this.buffer.push(term, start, end, size);
|
|
23351
|
+
} else {
|
|
23352
|
+
let index = this.buffer.length;
|
|
23353
|
+
if (index > 0 && this.buffer[index - 4] != 0) {
|
|
23354
|
+
let mustMove = false;
|
|
23355
|
+
for (let scan = index; scan > 0 && this.buffer[scan - 2] > end; scan -= 4) {
|
|
23356
|
+
if (this.buffer[scan - 1] >= 0) {
|
|
23357
|
+
mustMove = true;
|
|
23358
|
+
break;
|
|
23359
|
+
}
|
|
23360
|
+
}
|
|
23361
|
+
if (mustMove)
|
|
23362
|
+
while (index > 0 && this.buffer[index - 2] > end) {
|
|
23363
|
+
this.buffer[index] = this.buffer[index - 4];
|
|
23364
|
+
this.buffer[index + 1] = this.buffer[index - 3];
|
|
23365
|
+
this.buffer[index + 2] = this.buffer[index - 2];
|
|
23366
|
+
this.buffer[index + 3] = this.buffer[index - 1];
|
|
23367
|
+
index -= 4;
|
|
23368
|
+
if (size > 4)
|
|
23369
|
+
size -= 4;
|
|
23370
|
+
}
|
|
23371
|
+
}
|
|
23372
|
+
this.buffer[index] = term;
|
|
23373
|
+
this.buffer[index + 1] = start;
|
|
23374
|
+
this.buffer[index + 2] = end;
|
|
23375
|
+
this.buffer[index + 3] = size;
|
|
23376
|
+
}
|
|
23377
|
+
}
|
|
23378
|
+
// Apply a shift action
|
|
23379
|
+
/**
|
|
23380
|
+
@internal
|
|
23381
|
+
*/
|
|
23382
|
+
shift(action, type, start, end) {
|
|
23383
|
+
if (action & 131072) {
|
|
23384
|
+
this.pushState(action & 65535, this.pos);
|
|
23385
|
+
} else if ((action & 262144) == 0) {
|
|
23386
|
+
let nextState = action, { parser } = this.p;
|
|
23387
|
+
if (end > this.pos || type <= parser.maxNode) {
|
|
23388
|
+
this.pos = end;
|
|
23389
|
+
if (!parser.stateFlag(
|
|
23390
|
+
nextState,
|
|
23391
|
+
1
|
|
23392
|
+
/* StateFlag.Skipped */
|
|
23393
|
+
))
|
|
23394
|
+
this.reducePos = end;
|
|
23395
|
+
}
|
|
23396
|
+
this.pushState(nextState, start);
|
|
23397
|
+
this.shiftContext(type, start);
|
|
23398
|
+
if (type <= parser.maxNode)
|
|
23399
|
+
this.buffer.push(type, start, end, 4);
|
|
23400
|
+
} else {
|
|
23401
|
+
this.pos = end;
|
|
23402
|
+
this.shiftContext(type, start);
|
|
23403
|
+
if (type <= this.p.parser.maxNode)
|
|
23404
|
+
this.buffer.push(type, start, end, 4);
|
|
23405
|
+
}
|
|
23406
|
+
}
|
|
23407
|
+
// Apply an action
|
|
23408
|
+
/**
|
|
23409
|
+
@internal
|
|
23410
|
+
*/
|
|
23411
|
+
apply(action, next, nextStart, nextEnd) {
|
|
23412
|
+
if (action & 65536)
|
|
23413
|
+
this.reduce(action);
|
|
23414
|
+
else
|
|
23415
|
+
this.shift(action, next, nextStart, nextEnd);
|
|
23416
|
+
}
|
|
23417
|
+
// Add a prebuilt (reused) node into the buffer.
|
|
23418
|
+
/**
|
|
23419
|
+
@internal
|
|
23420
|
+
*/
|
|
23421
|
+
useNode(value, next) {
|
|
23422
|
+
let index = this.p.reused.length - 1;
|
|
23423
|
+
if (index < 0 || this.p.reused[index] != value) {
|
|
23424
|
+
this.p.reused.push(value);
|
|
23425
|
+
index++;
|
|
23426
|
+
}
|
|
23427
|
+
let start = this.pos;
|
|
23428
|
+
this.reducePos = this.pos = start + value.length;
|
|
23429
|
+
this.pushState(next, start);
|
|
23430
|
+
this.buffer.push(
|
|
23431
|
+
index,
|
|
23432
|
+
start,
|
|
23433
|
+
this.reducePos,
|
|
23434
|
+
-1
|
|
23435
|
+
/* size == -1 means this is a reused value */
|
|
23436
|
+
);
|
|
23437
|
+
if (this.curContext)
|
|
23438
|
+
this.updateContext(this.curContext.tracker.reuse(this.curContext.context, value, this, this.p.stream.reset(this.pos - value.length)));
|
|
23439
|
+
}
|
|
23440
|
+
// Split the stack. Due to the buffer sharing and the fact
|
|
23441
|
+
// that `this.stack` tends to stay quite shallow, this isn't very
|
|
23442
|
+
// expensive.
|
|
23443
|
+
/**
|
|
23444
|
+
@internal
|
|
23445
|
+
*/
|
|
23446
|
+
split() {
|
|
23447
|
+
let parent = this;
|
|
23448
|
+
let off = parent.buffer.length;
|
|
23449
|
+
while (off > 0 && parent.buffer[off - 2] > parent.reducePos)
|
|
23450
|
+
off -= 4;
|
|
23451
|
+
let buffer = parent.buffer.slice(off), base2 = parent.bufferBase + off;
|
|
23452
|
+
while (parent && base2 == parent.bufferBase)
|
|
23453
|
+
parent = parent.parent;
|
|
23454
|
+
return new Stack(this.p, this.stack.slice(), this.state, this.reducePos, this.pos, this.score, buffer, base2, this.curContext, this.lookAhead, parent);
|
|
23455
|
+
}
|
|
23456
|
+
// Try to recover from an error by 'deleting' (ignoring) one token.
|
|
23457
|
+
/**
|
|
23458
|
+
@internal
|
|
23459
|
+
*/
|
|
23460
|
+
recoverByDelete(next, nextEnd) {
|
|
23461
|
+
let isNode = next <= this.p.parser.maxNode;
|
|
23462
|
+
if (isNode)
|
|
23463
|
+
this.storeNode(next, this.pos, nextEnd, 4);
|
|
23464
|
+
this.storeNode(0, this.pos, nextEnd, isNode ? 8 : 4);
|
|
23465
|
+
this.pos = this.reducePos = nextEnd;
|
|
23466
|
+
this.score -= 190;
|
|
23467
|
+
}
|
|
23468
|
+
/**
|
|
23469
|
+
Check if the given term would be able to be shifted (optionally
|
|
23470
|
+
after some reductions) on this stack. This can be useful for
|
|
23471
|
+
external tokenizers that want to make sure they only provide a
|
|
23472
|
+
given token when it applies.
|
|
23473
|
+
*/
|
|
23474
|
+
canShift(term) {
|
|
23475
|
+
for (let sim = new SimulatedStack(this); ; ) {
|
|
23476
|
+
let action = this.p.parser.stateSlot(
|
|
23477
|
+
sim.state,
|
|
23478
|
+
4
|
|
23479
|
+
/* ParseState.DefaultReduce */
|
|
23480
|
+
) || this.p.parser.hasAction(sim.state, term);
|
|
23481
|
+
if (action == 0)
|
|
23482
|
+
return false;
|
|
23483
|
+
if ((action & 65536) == 0)
|
|
23484
|
+
return true;
|
|
23485
|
+
sim.reduce(action);
|
|
23486
|
+
}
|
|
23487
|
+
}
|
|
23488
|
+
// Apply up to Recover.MaxNext recovery actions that conceptually
|
|
23489
|
+
// inserts some missing token or rule.
|
|
23490
|
+
/**
|
|
23491
|
+
@internal
|
|
23492
|
+
*/
|
|
23493
|
+
recoverByInsert(next) {
|
|
23494
|
+
if (this.stack.length >= 300)
|
|
23495
|
+
return [];
|
|
23496
|
+
let nextStates = this.p.parser.nextStates(this.state);
|
|
23497
|
+
if (nextStates.length > 4 << 1 || this.stack.length >= 120) {
|
|
23498
|
+
let best = [];
|
|
23499
|
+
for (let i = 0, s; i < nextStates.length; i += 2) {
|
|
23500
|
+
if ((s = nextStates[i + 1]) != this.state && this.p.parser.hasAction(s, next))
|
|
23501
|
+
best.push(nextStates[i], s);
|
|
23502
|
+
}
|
|
23503
|
+
if (this.stack.length < 120)
|
|
23504
|
+
for (let i = 0; best.length < 4 << 1 && i < nextStates.length; i += 2) {
|
|
23505
|
+
let s = nextStates[i + 1];
|
|
23506
|
+
if (!best.some((v, i2) => i2 & 1 && v == s))
|
|
23507
|
+
best.push(nextStates[i], s);
|
|
23508
|
+
}
|
|
23509
|
+
nextStates = best;
|
|
23510
|
+
}
|
|
23511
|
+
let result = [];
|
|
23512
|
+
for (let i = 0; i < nextStates.length && result.length < 4; i += 2) {
|
|
23513
|
+
let s = nextStates[i + 1];
|
|
23514
|
+
if (s == this.state)
|
|
23515
|
+
continue;
|
|
23516
|
+
let stack = this.split();
|
|
23517
|
+
stack.pushState(s, this.pos);
|
|
23518
|
+
stack.storeNode(0, stack.pos, stack.pos, 4, true);
|
|
23519
|
+
stack.shiftContext(nextStates[i], this.pos);
|
|
23520
|
+
stack.reducePos = this.pos;
|
|
23521
|
+
stack.score -= 200;
|
|
23522
|
+
result.push(stack);
|
|
23523
|
+
}
|
|
23524
|
+
return result;
|
|
23525
|
+
}
|
|
23526
|
+
// Force a reduce, if possible. Return false if that can't
|
|
23527
|
+
// be done.
|
|
23528
|
+
/**
|
|
23529
|
+
@internal
|
|
23530
|
+
*/
|
|
23531
|
+
forceReduce() {
|
|
23532
|
+
let { parser } = this.p;
|
|
23533
|
+
let reduce = parser.stateSlot(
|
|
23534
|
+
this.state,
|
|
23535
|
+
5
|
|
23536
|
+
/* ParseState.ForcedReduce */
|
|
23537
|
+
);
|
|
23538
|
+
if ((reduce & 65536) == 0)
|
|
23539
|
+
return false;
|
|
23540
|
+
if (!parser.validAction(this.state, reduce)) {
|
|
23541
|
+
let depth = reduce >> 19, term = reduce & 65535;
|
|
23542
|
+
let target = this.stack.length - depth * 3;
|
|
23543
|
+
if (target < 0 || parser.getGoto(this.stack[target], term, false) < 0) {
|
|
23544
|
+
let backup = this.findForcedReduction();
|
|
23545
|
+
if (backup == null)
|
|
23546
|
+
return false;
|
|
23547
|
+
reduce = backup;
|
|
23548
|
+
}
|
|
23549
|
+
this.storeNode(0, this.pos, this.pos, 4, true);
|
|
23550
|
+
this.score -= 100;
|
|
23551
|
+
}
|
|
23552
|
+
this.reducePos = this.pos;
|
|
23553
|
+
this.reduce(reduce);
|
|
23554
|
+
return true;
|
|
23555
|
+
}
|
|
23556
|
+
/**
|
|
23557
|
+
Try to scan through the automaton to find some kind of reduction
|
|
23558
|
+
that can be applied. Used when the regular ForcedReduce field
|
|
23559
|
+
isn't a valid action. @internal
|
|
23560
|
+
*/
|
|
23561
|
+
findForcedReduction() {
|
|
23562
|
+
let { parser } = this.p, seen = [];
|
|
23563
|
+
let explore = (state, depth) => {
|
|
23564
|
+
if (seen.includes(state))
|
|
23565
|
+
return;
|
|
23566
|
+
seen.push(state);
|
|
23567
|
+
return parser.allActions(state, (action) => {
|
|
23568
|
+
if (action & (262144 | 131072)) ;
|
|
23569
|
+
else if (action & 65536) {
|
|
23570
|
+
let rDepth = (action >> 19) - depth;
|
|
23571
|
+
if (rDepth > 1) {
|
|
23572
|
+
let term = action & 65535, target = this.stack.length - rDepth * 3;
|
|
23573
|
+
if (target >= 0 && parser.getGoto(this.stack[target], term, false) >= 0)
|
|
23574
|
+
return rDepth << 19 | 65536 | term;
|
|
23575
|
+
}
|
|
23576
|
+
} else {
|
|
23577
|
+
let found = explore(action, depth + 1);
|
|
23578
|
+
if (found != null)
|
|
23579
|
+
return found;
|
|
23580
|
+
}
|
|
23581
|
+
});
|
|
23582
|
+
};
|
|
23583
|
+
return explore(this.state, 0);
|
|
23584
|
+
}
|
|
23585
|
+
/**
|
|
23586
|
+
@internal
|
|
23587
|
+
*/
|
|
23588
|
+
forceAll() {
|
|
23589
|
+
while (!this.p.parser.stateFlag(
|
|
23590
|
+
this.state,
|
|
23591
|
+
2
|
|
23592
|
+
/* StateFlag.Accepting */
|
|
23593
|
+
)) {
|
|
23594
|
+
if (!this.forceReduce()) {
|
|
23595
|
+
this.storeNode(0, this.pos, this.pos, 4, true);
|
|
23596
|
+
break;
|
|
23597
|
+
}
|
|
23598
|
+
}
|
|
23599
|
+
return this;
|
|
23600
|
+
}
|
|
23601
|
+
/**
|
|
23602
|
+
Check whether this state has no further actions (assumed to be a direct descendant of the
|
|
23603
|
+
top state, since any other states must be able to continue
|
|
23604
|
+
somehow). @internal
|
|
23605
|
+
*/
|
|
23606
|
+
get deadEnd() {
|
|
23607
|
+
if (this.stack.length != 3)
|
|
23608
|
+
return false;
|
|
23609
|
+
let { parser } = this.p;
|
|
23610
|
+
return parser.data[parser.stateSlot(
|
|
23611
|
+
this.state,
|
|
23612
|
+
1
|
|
23613
|
+
/* ParseState.Actions */
|
|
23614
|
+
)] == 65535 && !parser.stateSlot(
|
|
23615
|
+
this.state,
|
|
23616
|
+
4
|
|
23617
|
+
/* ParseState.DefaultReduce */
|
|
23618
|
+
);
|
|
23619
|
+
}
|
|
23620
|
+
/**
|
|
23621
|
+
Restart the stack (put it back in its start state). Only safe
|
|
23622
|
+
when this.stack.length == 3 (state is directly below the top
|
|
23623
|
+
state). @internal
|
|
23624
|
+
*/
|
|
23625
|
+
restart() {
|
|
23626
|
+
this.storeNode(0, this.pos, this.pos, 4, true);
|
|
23627
|
+
this.state = this.stack[0];
|
|
23628
|
+
this.stack.length = 0;
|
|
23629
|
+
}
|
|
23630
|
+
/**
|
|
23631
|
+
@internal
|
|
23632
|
+
*/
|
|
23633
|
+
sameState(other) {
|
|
23634
|
+
if (this.state != other.state || this.stack.length != other.stack.length)
|
|
23635
|
+
return false;
|
|
23636
|
+
for (let i = 0; i < this.stack.length; i += 3)
|
|
23637
|
+
if (this.stack[i] != other.stack[i])
|
|
23638
|
+
return false;
|
|
23639
|
+
return true;
|
|
23640
|
+
}
|
|
23641
|
+
/**
|
|
23642
|
+
Get the parser used by this stack.
|
|
23643
|
+
*/
|
|
23644
|
+
get parser() {
|
|
23645
|
+
return this.p.parser;
|
|
23646
|
+
}
|
|
23647
|
+
/**
|
|
23648
|
+
Test whether a given dialect (by numeric ID, as exported from
|
|
23649
|
+
the terms file) is enabled.
|
|
23650
|
+
*/
|
|
23651
|
+
dialectEnabled(dialectID) {
|
|
23652
|
+
return this.p.parser.dialect.flags[dialectID];
|
|
23653
|
+
}
|
|
23654
|
+
shiftContext(term, start) {
|
|
23655
|
+
if (this.curContext)
|
|
23656
|
+
this.updateContext(this.curContext.tracker.shift(this.curContext.context, term, this, this.p.stream.reset(start)));
|
|
23657
|
+
}
|
|
23658
|
+
reduceContext(term, start) {
|
|
23659
|
+
if (this.curContext)
|
|
23660
|
+
this.updateContext(this.curContext.tracker.reduce(this.curContext.context, term, this, this.p.stream.reset(start)));
|
|
23661
|
+
}
|
|
23662
|
+
/**
|
|
23663
|
+
@internal
|
|
23664
|
+
*/
|
|
23665
|
+
emitContext() {
|
|
23666
|
+
let last = this.buffer.length - 1;
|
|
23667
|
+
if (last < 0 || this.buffer[last] != -3)
|
|
23668
|
+
this.buffer.push(this.curContext.hash, this.pos, this.pos, -3);
|
|
23669
|
+
}
|
|
23670
|
+
/**
|
|
23671
|
+
@internal
|
|
23672
|
+
*/
|
|
23673
|
+
emitLookAhead() {
|
|
23674
|
+
let last = this.buffer.length - 1;
|
|
23675
|
+
if (last < 0 || this.buffer[last] != -4)
|
|
23676
|
+
this.buffer.push(this.lookAhead, this.pos, this.pos, -4);
|
|
23677
|
+
}
|
|
23678
|
+
updateContext(context) {
|
|
23679
|
+
if (context != this.curContext.context) {
|
|
23680
|
+
let newCx = new StackContext(this.curContext.tracker, context);
|
|
23681
|
+
if (newCx.hash != this.curContext.hash)
|
|
23682
|
+
this.emitContext();
|
|
23683
|
+
this.curContext = newCx;
|
|
23684
|
+
}
|
|
23685
|
+
}
|
|
23686
|
+
/**
|
|
23687
|
+
@internal
|
|
23688
|
+
*/
|
|
23689
|
+
setLookAhead(lookAhead) {
|
|
23690
|
+
if (lookAhead > this.lookAhead) {
|
|
23691
|
+
this.emitLookAhead();
|
|
23692
|
+
this.lookAhead = lookAhead;
|
|
23693
|
+
}
|
|
23694
|
+
}
|
|
23695
|
+
/**
|
|
23696
|
+
@internal
|
|
23697
|
+
*/
|
|
23698
|
+
close() {
|
|
23699
|
+
if (this.curContext && this.curContext.tracker.strict)
|
|
23700
|
+
this.emitContext();
|
|
23701
|
+
if (this.lookAhead > 0)
|
|
23702
|
+
this.emitLookAhead();
|
|
23703
|
+
}
|
|
23704
|
+
}
|
|
23705
|
+
class StackContext {
|
|
23706
|
+
constructor(tracker, context) {
|
|
23707
|
+
this.tracker = tracker;
|
|
23708
|
+
this.context = context;
|
|
23709
|
+
this.hash = tracker.strict ? tracker.hash(context) : 0;
|
|
23710
|
+
}
|
|
23711
|
+
}
|
|
23712
|
+
class SimulatedStack {
|
|
23713
|
+
constructor(start) {
|
|
23714
|
+
this.start = start;
|
|
23715
|
+
this.state = start.state;
|
|
23716
|
+
this.stack = start.stack;
|
|
23717
|
+
this.base = this.stack.length;
|
|
23718
|
+
}
|
|
23719
|
+
reduce(action) {
|
|
23720
|
+
let term = action & 65535, depth = action >> 19;
|
|
23721
|
+
if (depth == 0) {
|
|
23722
|
+
if (this.stack == this.start.stack)
|
|
23723
|
+
this.stack = this.stack.slice();
|
|
23724
|
+
this.stack.push(this.state, 0, 0);
|
|
23725
|
+
this.base += 3;
|
|
23726
|
+
} else {
|
|
23727
|
+
this.base -= (depth - 1) * 3;
|
|
23728
|
+
}
|
|
23729
|
+
let goto = this.start.p.parser.getGoto(this.stack[this.base - 3], term, true);
|
|
23730
|
+
this.state = goto;
|
|
23731
|
+
}
|
|
23732
|
+
}
|
|
23733
|
+
class StackBufferCursor {
|
|
23734
|
+
constructor(stack, pos, index) {
|
|
23735
|
+
this.stack = stack;
|
|
23736
|
+
this.pos = pos;
|
|
23737
|
+
this.index = index;
|
|
23738
|
+
this.buffer = stack.buffer;
|
|
23739
|
+
if (this.index == 0)
|
|
23740
|
+
this.maybeNext();
|
|
23741
|
+
}
|
|
23742
|
+
static create(stack, pos = stack.bufferBase + stack.buffer.length) {
|
|
23743
|
+
return new StackBufferCursor(stack, pos, pos - stack.bufferBase);
|
|
23744
|
+
}
|
|
23745
|
+
maybeNext() {
|
|
23746
|
+
let next = this.stack.parent;
|
|
23747
|
+
if (next != null) {
|
|
23748
|
+
this.index = this.stack.bufferBase - next.bufferBase;
|
|
23749
|
+
this.stack = next;
|
|
23750
|
+
this.buffer = next.buffer;
|
|
23751
|
+
}
|
|
23752
|
+
}
|
|
23753
|
+
get id() {
|
|
23754
|
+
return this.buffer[this.index - 4];
|
|
23755
|
+
}
|
|
23756
|
+
get start() {
|
|
23757
|
+
return this.buffer[this.index - 3];
|
|
23758
|
+
}
|
|
23759
|
+
get end() {
|
|
23760
|
+
return this.buffer[this.index - 2];
|
|
23761
|
+
}
|
|
23762
|
+
get size() {
|
|
23763
|
+
return this.buffer[this.index - 1];
|
|
23764
|
+
}
|
|
23765
|
+
next() {
|
|
23766
|
+
this.index -= 4;
|
|
23767
|
+
this.pos -= 4;
|
|
23768
|
+
if (this.index == 0)
|
|
23769
|
+
this.maybeNext();
|
|
23770
|
+
}
|
|
23771
|
+
fork() {
|
|
23772
|
+
return new StackBufferCursor(this.stack, this.pos, this.index);
|
|
23773
|
+
}
|
|
23774
|
+
}
|
|
23775
|
+
function decodeArray(input, Type = Uint16Array) {
|
|
23776
|
+
if (typeof input != "string")
|
|
23777
|
+
return input;
|
|
23778
|
+
let array = null;
|
|
23779
|
+
for (let pos = 0, out = 0; pos < input.length; ) {
|
|
23780
|
+
let value = 0;
|
|
23781
|
+
for (; ; ) {
|
|
23782
|
+
let next = input.charCodeAt(pos++), stop = false;
|
|
23783
|
+
if (next == 126) {
|
|
23784
|
+
value = 65535;
|
|
23785
|
+
break;
|
|
23786
|
+
}
|
|
23787
|
+
if (next >= 92)
|
|
23788
|
+
next--;
|
|
23789
|
+
if (next >= 34)
|
|
23790
|
+
next--;
|
|
23791
|
+
let digit = next - 32;
|
|
23792
|
+
if (digit >= 46) {
|
|
23793
|
+
digit -= 46;
|
|
23794
|
+
stop = true;
|
|
23795
|
+
}
|
|
23796
|
+
value += digit;
|
|
23797
|
+
if (stop)
|
|
23798
|
+
break;
|
|
23799
|
+
value *= 46;
|
|
23800
|
+
}
|
|
23801
|
+
if (array)
|
|
23802
|
+
array[out++] = value;
|
|
23803
|
+
else
|
|
23804
|
+
array = new Type(value);
|
|
23805
|
+
}
|
|
23806
|
+
return array;
|
|
23807
|
+
}
|
|
23808
|
+
class CachedToken {
|
|
23809
|
+
constructor() {
|
|
23810
|
+
this.start = -1;
|
|
23811
|
+
this.value = -1;
|
|
23812
|
+
this.end = -1;
|
|
23813
|
+
this.extended = -1;
|
|
23814
|
+
this.lookAhead = 0;
|
|
23815
|
+
this.mask = 0;
|
|
23816
|
+
this.context = 0;
|
|
23817
|
+
}
|
|
23818
|
+
}
|
|
23819
|
+
const nullToken = new CachedToken();
|
|
23820
|
+
class InputStream {
|
|
23821
|
+
/**
|
|
23822
|
+
@internal
|
|
23823
|
+
*/
|
|
23824
|
+
constructor(input, ranges) {
|
|
23825
|
+
this.input = input;
|
|
23826
|
+
this.ranges = ranges;
|
|
23827
|
+
this.chunk = "";
|
|
23828
|
+
this.chunkOff = 0;
|
|
23829
|
+
this.chunk2 = "";
|
|
23830
|
+
this.chunk2Pos = 0;
|
|
23831
|
+
this.next = -1;
|
|
23832
|
+
this.token = nullToken;
|
|
23833
|
+
this.rangeIndex = 0;
|
|
23834
|
+
this.pos = this.chunkPos = ranges[0].from;
|
|
23835
|
+
this.range = ranges[0];
|
|
23836
|
+
this.end = ranges[ranges.length - 1].to;
|
|
23837
|
+
this.readNext();
|
|
23838
|
+
}
|
|
23839
|
+
/**
|
|
23840
|
+
@internal
|
|
23841
|
+
*/
|
|
23842
|
+
resolveOffset(offset, assoc) {
|
|
23843
|
+
let range = this.range, index = this.rangeIndex;
|
|
23844
|
+
let pos = this.pos + offset;
|
|
23845
|
+
while (pos < range.from) {
|
|
23846
|
+
if (!index)
|
|
23847
|
+
return null;
|
|
23848
|
+
let next = this.ranges[--index];
|
|
23849
|
+
pos -= range.from - next.to;
|
|
23850
|
+
range = next;
|
|
23851
|
+
}
|
|
23852
|
+
while (assoc < 0 ? pos > range.to : pos >= range.to) {
|
|
23853
|
+
if (index == this.ranges.length - 1)
|
|
23854
|
+
return null;
|
|
23855
|
+
let next = this.ranges[++index];
|
|
23856
|
+
pos += next.from - range.to;
|
|
23857
|
+
range = next;
|
|
23858
|
+
}
|
|
23859
|
+
return pos;
|
|
23860
|
+
}
|
|
23861
|
+
/**
|
|
23862
|
+
@internal
|
|
23863
|
+
*/
|
|
23864
|
+
clipPos(pos) {
|
|
23865
|
+
if (pos >= this.range.from && pos < this.range.to)
|
|
23866
|
+
return pos;
|
|
23867
|
+
for (let range of this.ranges)
|
|
23868
|
+
if (range.to > pos)
|
|
23869
|
+
return Math.max(pos, range.from);
|
|
23870
|
+
return this.end;
|
|
23871
|
+
}
|
|
23872
|
+
/**
|
|
23873
|
+
Look at a code unit near the stream position. `.peek(0)` equals
|
|
23874
|
+
`.next`, `.peek(-1)` gives you the previous character, and so
|
|
23875
|
+
on.
|
|
23876
|
+
|
|
23877
|
+
Note that looking around during tokenizing creates dependencies
|
|
23878
|
+
on potentially far-away content, which may reduce the
|
|
23879
|
+
effectiveness incremental parsing—when looking forward—or even
|
|
23880
|
+
cause invalid reparses when looking backward more than 25 code
|
|
23881
|
+
units, since the library does not track lookbehind.
|
|
23882
|
+
*/
|
|
23883
|
+
peek(offset) {
|
|
23884
|
+
let idx = this.chunkOff + offset, pos, result;
|
|
23885
|
+
if (idx >= 0 && idx < this.chunk.length) {
|
|
23886
|
+
pos = this.pos + offset;
|
|
23887
|
+
result = this.chunk.charCodeAt(idx);
|
|
23888
|
+
} else {
|
|
23889
|
+
let resolved = this.resolveOffset(offset, 1);
|
|
23890
|
+
if (resolved == null)
|
|
23891
|
+
return -1;
|
|
23892
|
+
pos = resolved;
|
|
23893
|
+
if (pos >= this.chunk2Pos && pos < this.chunk2Pos + this.chunk2.length) {
|
|
23894
|
+
result = this.chunk2.charCodeAt(pos - this.chunk2Pos);
|
|
23895
|
+
} else {
|
|
23896
|
+
let i = this.rangeIndex, range = this.range;
|
|
23897
|
+
while (range.to <= pos)
|
|
23898
|
+
range = this.ranges[++i];
|
|
23899
|
+
this.chunk2 = this.input.chunk(this.chunk2Pos = pos);
|
|
23900
|
+
if (pos + this.chunk2.length > range.to)
|
|
23901
|
+
this.chunk2 = this.chunk2.slice(0, range.to - pos);
|
|
23902
|
+
result = this.chunk2.charCodeAt(0);
|
|
23903
|
+
}
|
|
23904
|
+
}
|
|
23905
|
+
if (pos >= this.token.lookAhead)
|
|
23906
|
+
this.token.lookAhead = pos + 1;
|
|
23907
|
+
return result;
|
|
23908
|
+
}
|
|
23909
|
+
/**
|
|
23910
|
+
Accept a token. By default, the end of the token is set to the
|
|
23911
|
+
current stream position, but you can pass an offset (relative to
|
|
23912
|
+
the stream position) to change that.
|
|
23913
|
+
*/
|
|
23914
|
+
acceptToken(token, endOffset = 0) {
|
|
23915
|
+
let end = endOffset ? this.resolveOffset(endOffset, -1) : this.pos;
|
|
23916
|
+
if (end == null || end < this.token.start)
|
|
23917
|
+
throw new RangeError("Token end out of bounds");
|
|
23918
|
+
this.token.value = token;
|
|
23919
|
+
this.token.end = end;
|
|
23920
|
+
}
|
|
23921
|
+
/**
|
|
23922
|
+
Accept a token ending at a specific given position.
|
|
23923
|
+
*/
|
|
23924
|
+
acceptTokenTo(token, endPos) {
|
|
23925
|
+
this.token.value = token;
|
|
23926
|
+
this.token.end = endPos;
|
|
23927
|
+
}
|
|
23928
|
+
getChunk() {
|
|
23929
|
+
if (this.pos >= this.chunk2Pos && this.pos < this.chunk2Pos + this.chunk2.length) {
|
|
23930
|
+
let { chunk, chunkPos } = this;
|
|
23931
|
+
this.chunk = this.chunk2;
|
|
23932
|
+
this.chunkPos = this.chunk2Pos;
|
|
23933
|
+
this.chunk2 = chunk;
|
|
23934
|
+
this.chunk2Pos = chunkPos;
|
|
23935
|
+
this.chunkOff = this.pos - this.chunkPos;
|
|
23936
|
+
} else {
|
|
23937
|
+
this.chunk2 = this.chunk;
|
|
23938
|
+
this.chunk2Pos = this.chunkPos;
|
|
23939
|
+
let nextChunk = this.input.chunk(this.pos);
|
|
23940
|
+
let end = this.pos + nextChunk.length;
|
|
23941
|
+
this.chunk = end > this.range.to ? nextChunk.slice(0, this.range.to - this.pos) : nextChunk;
|
|
23942
|
+
this.chunkPos = this.pos;
|
|
23943
|
+
this.chunkOff = 0;
|
|
23944
|
+
}
|
|
23945
|
+
}
|
|
23946
|
+
readNext() {
|
|
23947
|
+
if (this.chunkOff >= this.chunk.length) {
|
|
23948
|
+
this.getChunk();
|
|
23949
|
+
if (this.chunkOff == this.chunk.length)
|
|
23950
|
+
return this.next = -1;
|
|
23951
|
+
}
|
|
23952
|
+
return this.next = this.chunk.charCodeAt(this.chunkOff);
|
|
23953
|
+
}
|
|
23954
|
+
/**
|
|
23955
|
+
Move the stream forward N (defaults to 1) code units. Returns
|
|
23956
|
+
the new value of [`next`](#lr.InputStream.next).
|
|
23957
|
+
*/
|
|
23958
|
+
advance(n = 1) {
|
|
23959
|
+
this.chunkOff += n;
|
|
23960
|
+
while (this.pos + n >= this.range.to) {
|
|
23961
|
+
if (this.rangeIndex == this.ranges.length - 1)
|
|
23962
|
+
return this.setDone();
|
|
23963
|
+
n -= this.range.to - this.pos;
|
|
23964
|
+
this.range = this.ranges[++this.rangeIndex];
|
|
23965
|
+
this.pos = this.range.from;
|
|
23966
|
+
}
|
|
23967
|
+
this.pos += n;
|
|
23968
|
+
if (this.pos >= this.token.lookAhead)
|
|
23969
|
+
this.token.lookAhead = this.pos + 1;
|
|
23970
|
+
return this.readNext();
|
|
23971
|
+
}
|
|
23972
|
+
setDone() {
|
|
23973
|
+
this.pos = this.chunkPos = this.end;
|
|
23974
|
+
this.range = this.ranges[this.rangeIndex = this.ranges.length - 1];
|
|
23975
|
+
this.chunk = "";
|
|
23976
|
+
return this.next = -1;
|
|
23977
|
+
}
|
|
23978
|
+
/**
|
|
23979
|
+
@internal
|
|
23980
|
+
*/
|
|
23981
|
+
reset(pos, token) {
|
|
23982
|
+
if (token) {
|
|
23983
|
+
this.token = token;
|
|
23984
|
+
token.start = pos;
|
|
23985
|
+
token.lookAhead = pos + 1;
|
|
23986
|
+
token.value = token.extended = -1;
|
|
23987
|
+
} else {
|
|
23988
|
+
this.token = nullToken;
|
|
23989
|
+
}
|
|
23990
|
+
if (this.pos != pos) {
|
|
23991
|
+
this.pos = pos;
|
|
23992
|
+
if (pos == this.end) {
|
|
23993
|
+
this.setDone();
|
|
23994
|
+
return this;
|
|
23995
|
+
}
|
|
23996
|
+
while (pos < this.range.from)
|
|
23997
|
+
this.range = this.ranges[--this.rangeIndex];
|
|
23998
|
+
while (pos >= this.range.to)
|
|
23999
|
+
this.range = this.ranges[++this.rangeIndex];
|
|
24000
|
+
if (pos >= this.chunkPos && pos < this.chunkPos + this.chunk.length) {
|
|
24001
|
+
this.chunkOff = pos - this.chunkPos;
|
|
24002
|
+
} else {
|
|
24003
|
+
this.chunk = "";
|
|
24004
|
+
this.chunkOff = 0;
|
|
24005
|
+
}
|
|
24006
|
+
this.readNext();
|
|
24007
|
+
}
|
|
24008
|
+
return this;
|
|
24009
|
+
}
|
|
24010
|
+
/**
|
|
24011
|
+
@internal
|
|
24012
|
+
*/
|
|
24013
|
+
read(from, to) {
|
|
24014
|
+
if (from >= this.chunkPos && to <= this.chunkPos + this.chunk.length)
|
|
24015
|
+
return this.chunk.slice(from - this.chunkPos, to - this.chunkPos);
|
|
24016
|
+
if (from >= this.chunk2Pos && to <= this.chunk2Pos + this.chunk2.length)
|
|
24017
|
+
return this.chunk2.slice(from - this.chunk2Pos, to - this.chunk2Pos);
|
|
24018
|
+
if (from >= this.range.from && to <= this.range.to)
|
|
24019
|
+
return this.input.read(from, to);
|
|
24020
|
+
let result = "";
|
|
24021
|
+
for (let r of this.ranges) {
|
|
24022
|
+
if (r.from >= to)
|
|
24023
|
+
break;
|
|
24024
|
+
if (r.to > from)
|
|
24025
|
+
result += this.input.read(Math.max(r.from, from), Math.min(r.to, to));
|
|
24026
|
+
}
|
|
24027
|
+
return result;
|
|
24028
|
+
}
|
|
24029
|
+
}
|
|
24030
|
+
class TokenGroup {
|
|
24031
|
+
constructor(data, id2) {
|
|
24032
|
+
this.data = data;
|
|
24033
|
+
this.id = id2;
|
|
24034
|
+
}
|
|
24035
|
+
token(input, stack) {
|
|
24036
|
+
let { parser } = stack.p;
|
|
24037
|
+
readToken(this.data, input, stack, this.id, parser.data, parser.tokenPrecTable);
|
|
24038
|
+
}
|
|
24039
|
+
}
|
|
24040
|
+
TokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
|
|
24041
|
+
class LocalTokenGroup {
|
|
24042
|
+
constructor(data, precTable, elseToken) {
|
|
24043
|
+
this.precTable = precTable;
|
|
24044
|
+
this.elseToken = elseToken;
|
|
24045
|
+
this.data = typeof data == "string" ? decodeArray(data) : data;
|
|
24046
|
+
}
|
|
24047
|
+
token(input, stack) {
|
|
24048
|
+
let start = input.pos, skipped = 0;
|
|
24049
|
+
for (; ; ) {
|
|
24050
|
+
let atEof = input.next < 0, nextPos = input.resolveOffset(1, 1);
|
|
24051
|
+
readToken(this.data, input, stack, 0, this.data, this.precTable);
|
|
24052
|
+
if (input.token.value > -1)
|
|
24053
|
+
break;
|
|
24054
|
+
if (this.elseToken == null)
|
|
24055
|
+
return;
|
|
24056
|
+
if (!atEof)
|
|
24057
|
+
skipped++;
|
|
24058
|
+
if (nextPos == null)
|
|
24059
|
+
break;
|
|
24060
|
+
input.reset(nextPos, input.token);
|
|
24061
|
+
}
|
|
24062
|
+
if (skipped) {
|
|
24063
|
+
input.reset(start, input.token);
|
|
24064
|
+
input.acceptToken(this.elseToken, skipped);
|
|
24065
|
+
}
|
|
24066
|
+
}
|
|
24067
|
+
}
|
|
24068
|
+
LocalTokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
|
|
24069
|
+
class ExternalTokenizer {
|
|
24070
|
+
/**
|
|
24071
|
+
Create a tokenizer. The first argument is the function that,
|
|
24072
|
+
given an input stream, scans for the types of tokens it
|
|
24073
|
+
recognizes at the stream's position, and calls
|
|
24074
|
+
[`acceptToken`](#lr.InputStream.acceptToken) when it finds
|
|
24075
|
+
one.
|
|
24076
|
+
*/
|
|
24077
|
+
constructor(token, options = {}) {
|
|
24078
|
+
this.token = token;
|
|
24079
|
+
this.contextual = !!options.contextual;
|
|
24080
|
+
this.fallback = !!options.fallback;
|
|
24081
|
+
this.extend = !!options.extend;
|
|
24082
|
+
}
|
|
24083
|
+
}
|
|
24084
|
+
function readToken(data, input, stack, group, precTable, precOffset) {
|
|
24085
|
+
let state = 0, groupMask = 1 << group, { dialect } = stack.p.parser;
|
|
24086
|
+
scan: for (; ; ) {
|
|
24087
|
+
if ((groupMask & data[state]) == 0)
|
|
24088
|
+
break;
|
|
24089
|
+
let accEnd = data[state + 1];
|
|
24090
|
+
for (let i = state + 3; i < accEnd; i += 2)
|
|
24091
|
+
if ((data[i + 1] & groupMask) > 0) {
|
|
24092
|
+
let term = data[i];
|
|
24093
|
+
if (dialect.allows(term) && (input.token.value == -1 || input.token.value == term || overrides(term, input.token.value, precTable, precOffset))) {
|
|
24094
|
+
input.acceptToken(term);
|
|
24095
|
+
break;
|
|
24096
|
+
}
|
|
24097
|
+
}
|
|
24098
|
+
let next = input.next, low = 0, high = data[state + 2];
|
|
24099
|
+
if (input.next < 0 && high > low && data[accEnd + high * 3 - 3] == 65535) {
|
|
24100
|
+
state = data[accEnd + high * 3 - 1];
|
|
24101
|
+
continue scan;
|
|
24102
|
+
}
|
|
24103
|
+
for (; low < high; ) {
|
|
24104
|
+
let mid = low + high >> 1;
|
|
24105
|
+
let index = accEnd + mid + (mid << 1);
|
|
24106
|
+
let from = data[index], to = data[index + 1] || 65536;
|
|
24107
|
+
if (next < from)
|
|
24108
|
+
high = mid;
|
|
24109
|
+
else if (next >= to)
|
|
24110
|
+
low = mid + 1;
|
|
24111
|
+
else {
|
|
24112
|
+
state = data[index + 2];
|
|
24113
|
+
input.advance();
|
|
24114
|
+
continue scan;
|
|
24115
|
+
}
|
|
24116
|
+
}
|
|
24117
|
+
break;
|
|
24118
|
+
}
|
|
24119
|
+
}
|
|
24120
|
+
function findOffset(data, start, term) {
|
|
24121
|
+
for (let i = start, next; (next = data[i]) != 65535; i++)
|
|
24122
|
+
if (next == term)
|
|
24123
|
+
return i - start;
|
|
24124
|
+
return -1;
|
|
24125
|
+
}
|
|
24126
|
+
function overrides(token, prev, tableData, tableOffset) {
|
|
24127
|
+
let iPrev = findOffset(tableData, tableOffset, prev);
|
|
24128
|
+
return iPrev < 0 || findOffset(tableData, tableOffset, token) < iPrev;
|
|
24129
|
+
}
|
|
24130
|
+
const verbose = typeof process != "undefined" && process.env && /\bparse\b/.test(process.env.LOG);
|
|
24131
|
+
let stackIDs = null;
|
|
24132
|
+
function cutAt(tree, pos, side) {
|
|
24133
|
+
let cursor = tree.cursor(IterMode.IncludeAnonymous);
|
|
24134
|
+
cursor.moveTo(pos);
|
|
24135
|
+
for (; ; ) {
|
|
24136
|
+
if (!(side < 0 ? cursor.childBefore(pos) : cursor.childAfter(pos)))
|
|
24137
|
+
for (; ; ) {
|
|
24138
|
+
if ((side < 0 ? cursor.to < pos : cursor.from > pos) && !cursor.type.isError)
|
|
24139
|
+
return side < 0 ? Math.max(0, Math.min(
|
|
24140
|
+
cursor.to - 1,
|
|
24141
|
+
pos - 25
|
|
24142
|
+
/* Lookahead.Margin */
|
|
24143
|
+
)) : Math.min(tree.length, Math.max(
|
|
24144
|
+
cursor.from + 1,
|
|
24145
|
+
pos + 25
|
|
24146
|
+
/* Lookahead.Margin */
|
|
24147
|
+
));
|
|
24148
|
+
if (side < 0 ? cursor.prevSibling() : cursor.nextSibling())
|
|
24149
|
+
break;
|
|
24150
|
+
if (!cursor.parent())
|
|
24151
|
+
return side < 0 ? 0 : tree.length;
|
|
24152
|
+
}
|
|
24153
|
+
}
|
|
24154
|
+
}
|
|
24155
|
+
class FragmentCursor2 {
|
|
24156
|
+
constructor(fragments, nodeSet2) {
|
|
24157
|
+
this.fragments = fragments;
|
|
24158
|
+
this.nodeSet = nodeSet2;
|
|
24159
|
+
this.i = 0;
|
|
24160
|
+
this.fragment = null;
|
|
24161
|
+
this.safeFrom = -1;
|
|
24162
|
+
this.safeTo = -1;
|
|
24163
|
+
this.trees = [];
|
|
24164
|
+
this.start = [];
|
|
24165
|
+
this.index = [];
|
|
24166
|
+
this.nextFragment();
|
|
24167
|
+
}
|
|
24168
|
+
nextFragment() {
|
|
24169
|
+
let fr = this.fragment = this.i == this.fragments.length ? null : this.fragments[this.i++];
|
|
24170
|
+
if (fr) {
|
|
24171
|
+
this.safeFrom = fr.openStart ? cutAt(fr.tree, fr.from + fr.offset, 1) - fr.offset : fr.from;
|
|
24172
|
+
this.safeTo = fr.openEnd ? cutAt(fr.tree, fr.to + fr.offset, -1) - fr.offset : fr.to;
|
|
24173
|
+
while (this.trees.length) {
|
|
24174
|
+
this.trees.pop();
|
|
24175
|
+
this.start.pop();
|
|
24176
|
+
this.index.pop();
|
|
24177
|
+
}
|
|
24178
|
+
this.trees.push(fr.tree);
|
|
24179
|
+
this.start.push(-fr.offset);
|
|
24180
|
+
this.index.push(0);
|
|
24181
|
+
this.nextStart = this.safeFrom;
|
|
24182
|
+
} else {
|
|
24183
|
+
this.nextStart = 1e9;
|
|
24184
|
+
}
|
|
24185
|
+
}
|
|
24186
|
+
// `pos` must be >= any previously given `pos` for this cursor
|
|
24187
|
+
nodeAt(pos) {
|
|
24188
|
+
if (pos < this.nextStart)
|
|
24189
|
+
return null;
|
|
24190
|
+
while (this.fragment && this.safeTo <= pos)
|
|
24191
|
+
this.nextFragment();
|
|
24192
|
+
if (!this.fragment)
|
|
24193
|
+
return null;
|
|
24194
|
+
for (; ; ) {
|
|
24195
|
+
let last = this.trees.length - 1;
|
|
24196
|
+
if (last < 0) {
|
|
24197
|
+
this.nextFragment();
|
|
24198
|
+
return null;
|
|
24199
|
+
}
|
|
24200
|
+
let top2 = this.trees[last], index = this.index[last];
|
|
24201
|
+
if (index == top2.children.length) {
|
|
24202
|
+
this.trees.pop();
|
|
24203
|
+
this.start.pop();
|
|
24204
|
+
this.index.pop();
|
|
24205
|
+
continue;
|
|
24206
|
+
}
|
|
24207
|
+
let next = top2.children[index];
|
|
24208
|
+
let start = this.start[last] + top2.positions[index];
|
|
24209
|
+
if (start > pos) {
|
|
24210
|
+
this.nextStart = start;
|
|
24211
|
+
return null;
|
|
24212
|
+
}
|
|
24213
|
+
if (next instanceof Tree) {
|
|
24214
|
+
if (start == pos) {
|
|
24215
|
+
if (start < this.safeFrom)
|
|
24216
|
+
return null;
|
|
24217
|
+
let end = start + next.length;
|
|
24218
|
+
if (end <= this.safeTo) {
|
|
24219
|
+
let lookAhead = next.prop(NodeProp.lookAhead);
|
|
24220
|
+
if (!lookAhead || end + lookAhead < this.fragment.to)
|
|
24221
|
+
return next;
|
|
24222
|
+
}
|
|
24223
|
+
}
|
|
24224
|
+
this.index[last]++;
|
|
24225
|
+
if (start + next.length >= Math.max(this.safeFrom, pos)) {
|
|
24226
|
+
this.trees.push(next);
|
|
24227
|
+
this.start.push(start);
|
|
24228
|
+
this.index.push(0);
|
|
24229
|
+
}
|
|
24230
|
+
} else {
|
|
24231
|
+
this.index[last]++;
|
|
24232
|
+
this.nextStart = start + next.length;
|
|
24233
|
+
}
|
|
24234
|
+
}
|
|
24235
|
+
}
|
|
24236
|
+
}
|
|
24237
|
+
class TokenCache {
|
|
24238
|
+
constructor(parser, stream) {
|
|
24239
|
+
this.stream = stream;
|
|
24240
|
+
this.tokens = [];
|
|
24241
|
+
this.mainToken = null;
|
|
24242
|
+
this.actions = [];
|
|
24243
|
+
this.tokens = parser.tokenizers.map((_) => new CachedToken());
|
|
24244
|
+
}
|
|
24245
|
+
getActions(stack) {
|
|
24246
|
+
let actionIndex = 0;
|
|
24247
|
+
let main = null;
|
|
24248
|
+
let { parser } = stack.p, { tokenizers } = parser;
|
|
24249
|
+
let mask = parser.stateSlot(
|
|
24250
|
+
stack.state,
|
|
24251
|
+
3
|
|
24252
|
+
/* ParseState.TokenizerMask */
|
|
24253
|
+
);
|
|
24254
|
+
let context = stack.curContext ? stack.curContext.hash : 0;
|
|
24255
|
+
let lookAhead = 0;
|
|
24256
|
+
for (let i = 0; i < tokenizers.length; i++) {
|
|
24257
|
+
if ((1 << i & mask) == 0)
|
|
24258
|
+
continue;
|
|
24259
|
+
let tokenizer = tokenizers[i], token = this.tokens[i];
|
|
24260
|
+
if (main && !tokenizer.fallback)
|
|
24261
|
+
continue;
|
|
24262
|
+
if (tokenizer.contextual || token.start != stack.pos || token.mask != mask || token.context != context) {
|
|
24263
|
+
this.updateCachedToken(token, tokenizer, stack);
|
|
24264
|
+
token.mask = mask;
|
|
24265
|
+
token.context = context;
|
|
24266
|
+
}
|
|
24267
|
+
if (token.lookAhead > token.end + 25)
|
|
24268
|
+
lookAhead = Math.max(token.lookAhead, lookAhead);
|
|
24269
|
+
if (token.value != 0) {
|
|
24270
|
+
let startIndex = actionIndex;
|
|
24271
|
+
if (token.extended > -1)
|
|
24272
|
+
actionIndex = this.addActions(stack, token.extended, token.end, actionIndex);
|
|
24273
|
+
actionIndex = this.addActions(stack, token.value, token.end, actionIndex);
|
|
24274
|
+
if (!tokenizer.extend) {
|
|
24275
|
+
main = token;
|
|
24276
|
+
if (actionIndex > startIndex)
|
|
24277
|
+
break;
|
|
24278
|
+
}
|
|
24279
|
+
}
|
|
24280
|
+
}
|
|
24281
|
+
while (this.actions.length > actionIndex)
|
|
24282
|
+
this.actions.pop();
|
|
24283
|
+
if (lookAhead)
|
|
24284
|
+
stack.setLookAhead(lookAhead);
|
|
24285
|
+
if (!main && stack.pos == this.stream.end) {
|
|
24286
|
+
main = new CachedToken();
|
|
24287
|
+
main.value = stack.p.parser.eofTerm;
|
|
24288
|
+
main.start = main.end = stack.pos;
|
|
24289
|
+
actionIndex = this.addActions(stack, main.value, main.end, actionIndex);
|
|
24290
|
+
}
|
|
24291
|
+
this.mainToken = main;
|
|
24292
|
+
return this.actions;
|
|
24293
|
+
}
|
|
24294
|
+
getMainToken(stack) {
|
|
24295
|
+
if (this.mainToken)
|
|
24296
|
+
return this.mainToken;
|
|
24297
|
+
let main = new CachedToken(), { pos, p } = stack;
|
|
24298
|
+
main.start = pos;
|
|
24299
|
+
main.end = Math.min(pos + 1, p.stream.end);
|
|
24300
|
+
main.value = pos == p.stream.end ? p.parser.eofTerm : 0;
|
|
24301
|
+
return main;
|
|
24302
|
+
}
|
|
24303
|
+
updateCachedToken(token, tokenizer, stack) {
|
|
24304
|
+
let start = this.stream.clipPos(stack.pos);
|
|
24305
|
+
tokenizer.token(this.stream.reset(start, token), stack);
|
|
24306
|
+
if (token.value > -1) {
|
|
24307
|
+
let { parser } = stack.p;
|
|
24308
|
+
for (let i = 0; i < parser.specialized.length; i++)
|
|
24309
|
+
if (parser.specialized[i] == token.value) {
|
|
24310
|
+
let result = parser.specializers[i](this.stream.read(token.start, token.end), stack);
|
|
24311
|
+
if (result >= 0 && stack.p.parser.dialect.allows(result >> 1)) {
|
|
24312
|
+
if ((result & 1) == 0)
|
|
24313
|
+
token.value = result >> 1;
|
|
24314
|
+
else
|
|
24315
|
+
token.extended = result >> 1;
|
|
24316
|
+
break;
|
|
24317
|
+
}
|
|
24318
|
+
}
|
|
24319
|
+
} else {
|
|
24320
|
+
token.value = 0;
|
|
24321
|
+
token.end = this.stream.clipPos(start + 1);
|
|
24322
|
+
}
|
|
24323
|
+
}
|
|
24324
|
+
putAction(action, token, end, index) {
|
|
24325
|
+
for (let i = 0; i < index; i += 3)
|
|
24326
|
+
if (this.actions[i] == action)
|
|
24327
|
+
return index;
|
|
24328
|
+
this.actions[index++] = action;
|
|
24329
|
+
this.actions[index++] = token;
|
|
24330
|
+
this.actions[index++] = end;
|
|
24331
|
+
return index;
|
|
24332
|
+
}
|
|
24333
|
+
addActions(stack, token, end, index) {
|
|
24334
|
+
let { state } = stack, { parser } = stack.p, { data } = parser;
|
|
24335
|
+
for (let set = 0; set < 2; set++) {
|
|
24336
|
+
for (let i = parser.stateSlot(
|
|
24337
|
+
state,
|
|
24338
|
+
set ? 2 : 1
|
|
24339
|
+
/* ParseState.Actions */
|
|
24340
|
+
); ; i += 3) {
|
|
24341
|
+
if (data[i] == 65535) {
|
|
24342
|
+
if (data[i + 1] == 1) {
|
|
24343
|
+
i = pair(data, i + 2);
|
|
24344
|
+
} else {
|
|
24345
|
+
if (index == 0 && data[i + 1] == 2)
|
|
24346
|
+
index = this.putAction(pair(data, i + 2), token, end, index);
|
|
24347
|
+
break;
|
|
24348
|
+
}
|
|
24349
|
+
}
|
|
24350
|
+
if (data[i] == token)
|
|
24351
|
+
index = this.putAction(pair(data, i + 1), token, end, index);
|
|
24352
|
+
}
|
|
24353
|
+
}
|
|
24354
|
+
return index;
|
|
24355
|
+
}
|
|
24356
|
+
}
|
|
24357
|
+
class Parse2 {
|
|
24358
|
+
constructor(parser, input, fragments, ranges) {
|
|
24359
|
+
this.parser = parser;
|
|
24360
|
+
this.input = input;
|
|
24361
|
+
this.ranges = ranges;
|
|
24362
|
+
this.recovering = 0;
|
|
24363
|
+
this.nextStackID = 9812;
|
|
24364
|
+
this.minStackPos = 0;
|
|
24365
|
+
this.reused = [];
|
|
24366
|
+
this.stoppedAt = null;
|
|
24367
|
+
this.lastBigReductionStart = -1;
|
|
24368
|
+
this.lastBigReductionSize = 0;
|
|
24369
|
+
this.bigReductionCount = 0;
|
|
24370
|
+
this.stream = new InputStream(input, ranges);
|
|
24371
|
+
this.tokens = new TokenCache(parser, this.stream);
|
|
24372
|
+
this.topTerm = parser.top[1];
|
|
24373
|
+
let { from } = ranges[0];
|
|
24374
|
+
this.stacks = [Stack.start(this, parser.top[0], from)];
|
|
24375
|
+
this.fragments = fragments.length && this.stream.end - from > parser.bufferLength * 4 ? new FragmentCursor2(fragments, parser.nodeSet) : null;
|
|
24376
|
+
}
|
|
24377
|
+
get parsedPos() {
|
|
24378
|
+
return this.minStackPos;
|
|
24379
|
+
}
|
|
24380
|
+
// Move the parser forward. This will process all parse stacks at
|
|
24381
|
+
// `this.pos` and try to advance them to a further position. If no
|
|
24382
|
+
// stack for such a position is found, it'll start error-recovery.
|
|
24383
|
+
//
|
|
24384
|
+
// When the parse is finished, this will return a syntax tree. When
|
|
24385
|
+
// not, it returns `null`.
|
|
24386
|
+
advance() {
|
|
24387
|
+
let stacks = this.stacks, pos = this.minStackPos;
|
|
24388
|
+
let newStacks = this.stacks = [];
|
|
24389
|
+
let stopped, stoppedTokens;
|
|
24390
|
+
if (this.bigReductionCount > 300 && stacks.length == 1) {
|
|
24391
|
+
let [s] = stacks;
|
|
24392
|
+
while (s.forceReduce() && s.stack.length && s.stack[s.stack.length - 2] >= this.lastBigReductionStart) {
|
|
24393
|
+
}
|
|
24394
|
+
this.bigReductionCount = this.lastBigReductionSize = 0;
|
|
24395
|
+
}
|
|
24396
|
+
for (let i = 0; i < stacks.length; i++) {
|
|
24397
|
+
let stack = stacks[i];
|
|
24398
|
+
for (; ; ) {
|
|
24399
|
+
this.tokens.mainToken = null;
|
|
24400
|
+
if (stack.pos > pos) {
|
|
24401
|
+
newStacks.push(stack);
|
|
24402
|
+
} else if (this.advanceStack(stack, newStacks, stacks)) {
|
|
24403
|
+
continue;
|
|
24404
|
+
} else {
|
|
24405
|
+
if (!stopped) {
|
|
24406
|
+
stopped = [];
|
|
24407
|
+
stoppedTokens = [];
|
|
24408
|
+
}
|
|
24409
|
+
stopped.push(stack);
|
|
24410
|
+
let tok = this.tokens.getMainToken(stack);
|
|
24411
|
+
stoppedTokens.push(tok.value, tok.end);
|
|
24412
|
+
}
|
|
24413
|
+
break;
|
|
24414
|
+
}
|
|
24415
|
+
}
|
|
24416
|
+
if (!newStacks.length) {
|
|
24417
|
+
let finished = stopped && findFinished(stopped);
|
|
24418
|
+
if (finished) {
|
|
24419
|
+
if (verbose)
|
|
24420
|
+
;
|
|
24421
|
+
return this.stackToTree(finished);
|
|
24422
|
+
}
|
|
24423
|
+
if (this.parser.strict) {
|
|
24424
|
+
if (verbose && stopped)
|
|
24425
|
+
;
|
|
24426
|
+
throw new SyntaxError("No parse at " + pos);
|
|
24427
|
+
}
|
|
24428
|
+
if (!this.recovering)
|
|
24429
|
+
this.recovering = 5;
|
|
24430
|
+
}
|
|
24431
|
+
if (this.recovering && stopped) {
|
|
24432
|
+
let finished = this.stoppedAt != null && stopped[0].pos > this.stoppedAt ? stopped[0] : this.runRecovery(stopped, stoppedTokens, newStacks);
|
|
24433
|
+
if (finished) {
|
|
24434
|
+
if (verbose)
|
|
24435
|
+
;
|
|
24436
|
+
return this.stackToTree(finished.forceAll());
|
|
24437
|
+
}
|
|
24438
|
+
}
|
|
24439
|
+
if (this.recovering) {
|
|
24440
|
+
let maxRemaining = this.recovering == 1 ? 1 : this.recovering * 3;
|
|
24441
|
+
if (newStacks.length > maxRemaining) {
|
|
24442
|
+
newStacks.sort((a, b) => b.score - a.score);
|
|
24443
|
+
while (newStacks.length > maxRemaining)
|
|
24444
|
+
newStacks.pop();
|
|
24445
|
+
}
|
|
24446
|
+
if (newStacks.some((s) => s.reducePos > pos))
|
|
24447
|
+
this.recovering--;
|
|
24448
|
+
} else if (newStacks.length > 1) {
|
|
24449
|
+
outer: for (let i = 0; i < newStacks.length - 1; i++) {
|
|
24450
|
+
let stack = newStacks[i];
|
|
24451
|
+
for (let j = i + 1; j < newStacks.length; j++) {
|
|
24452
|
+
let other = newStacks[j];
|
|
24453
|
+
if (stack.sameState(other) || stack.buffer.length > 500 && other.buffer.length > 500) {
|
|
24454
|
+
if ((stack.score - other.score || stack.buffer.length - other.buffer.length) > 0) {
|
|
24455
|
+
newStacks.splice(j--, 1);
|
|
24456
|
+
} else {
|
|
24457
|
+
newStacks.splice(i--, 1);
|
|
24458
|
+
continue outer;
|
|
24459
|
+
}
|
|
24460
|
+
}
|
|
24461
|
+
}
|
|
24462
|
+
}
|
|
24463
|
+
if (newStacks.length > 12)
|
|
24464
|
+
newStacks.splice(
|
|
24465
|
+
12,
|
|
24466
|
+
newStacks.length - 12
|
|
24467
|
+
/* Rec.MaxStackCount */
|
|
24468
|
+
);
|
|
24469
|
+
}
|
|
24470
|
+
this.minStackPos = newStacks[0].pos;
|
|
24471
|
+
for (let i = 1; i < newStacks.length; i++)
|
|
24472
|
+
if (newStacks[i].pos < this.minStackPos)
|
|
24473
|
+
this.minStackPos = newStacks[i].pos;
|
|
24474
|
+
return null;
|
|
24475
|
+
}
|
|
24476
|
+
stopAt(pos) {
|
|
24477
|
+
if (this.stoppedAt != null && this.stoppedAt < pos)
|
|
24478
|
+
throw new RangeError("Can't move stoppedAt forward");
|
|
24479
|
+
this.stoppedAt = pos;
|
|
24480
|
+
}
|
|
24481
|
+
// Returns an updated version of the given stack, or null if the
|
|
24482
|
+
// stack can't advance normally. When `split` and `stacks` are
|
|
24483
|
+
// given, stacks split off by ambiguous operations will be pushed to
|
|
24484
|
+
// `split`, or added to `stacks` if they move `pos` forward.
|
|
24485
|
+
advanceStack(stack, stacks, split) {
|
|
24486
|
+
let start = stack.pos, { parser } = this;
|
|
24487
|
+
let base2 = verbose ? this.stackID(stack) + " -> " : "";
|
|
24488
|
+
if (this.stoppedAt != null && start > this.stoppedAt)
|
|
24489
|
+
return stack.forceReduce() ? stack : null;
|
|
24490
|
+
if (this.fragments) {
|
|
24491
|
+
let strictCx = stack.curContext && stack.curContext.tracker.strict, cxHash = strictCx ? stack.curContext.hash : 0;
|
|
24492
|
+
for (let cached = this.fragments.nodeAt(start); cached; ) {
|
|
24493
|
+
let match = this.parser.nodeSet.types[cached.type.id] == cached.type ? parser.getGoto(stack.state, cached.type.id) : -1;
|
|
24494
|
+
if (match > -1 && cached.length && (!strictCx || (cached.prop(NodeProp.contextHash) || 0) == cxHash)) {
|
|
24495
|
+
stack.useNode(cached, match);
|
|
24496
|
+
if (verbose)
|
|
24497
|
+
;
|
|
24498
|
+
return true;
|
|
24499
|
+
}
|
|
24500
|
+
if (!(cached instanceof Tree) || cached.children.length == 0 || cached.positions[0] > 0)
|
|
24501
|
+
break;
|
|
24502
|
+
let inner = cached.children[0];
|
|
24503
|
+
if (inner instanceof Tree && cached.positions[0] == 0)
|
|
24504
|
+
cached = inner;
|
|
24505
|
+
else
|
|
24506
|
+
break;
|
|
24507
|
+
}
|
|
24508
|
+
}
|
|
24509
|
+
let defaultReduce = parser.stateSlot(
|
|
24510
|
+
stack.state,
|
|
24511
|
+
4
|
|
24512
|
+
/* ParseState.DefaultReduce */
|
|
24513
|
+
);
|
|
24514
|
+
if (defaultReduce > 0) {
|
|
24515
|
+
stack.reduce(defaultReduce);
|
|
24516
|
+
if (verbose)
|
|
24517
|
+
;
|
|
24518
|
+
return true;
|
|
24519
|
+
}
|
|
24520
|
+
if (stack.stack.length >= 8400) {
|
|
24521
|
+
while (stack.stack.length > 6e3 && stack.forceReduce()) {
|
|
24522
|
+
}
|
|
24523
|
+
}
|
|
24524
|
+
let actions = this.tokens.getActions(stack);
|
|
24525
|
+
for (let i = 0; i < actions.length; ) {
|
|
24526
|
+
let action = actions[i++], term = actions[i++], end = actions[i++];
|
|
24527
|
+
let last = i == actions.length || !split;
|
|
24528
|
+
let localStack = last ? stack : stack.split();
|
|
24529
|
+
let main = this.tokens.mainToken;
|
|
24530
|
+
localStack.apply(action, term, main ? main.start : localStack.pos, end);
|
|
24531
|
+
if (verbose)
|
|
24532
|
+
;
|
|
24533
|
+
if (last)
|
|
24534
|
+
return true;
|
|
24535
|
+
else if (localStack.pos > start)
|
|
24536
|
+
stacks.push(localStack);
|
|
24537
|
+
else
|
|
24538
|
+
split.push(localStack);
|
|
24539
|
+
}
|
|
24540
|
+
return false;
|
|
24541
|
+
}
|
|
24542
|
+
// Advance a given stack forward as far as it will go. Returns the
|
|
24543
|
+
// (possibly updated) stack if it got stuck, or null if it moved
|
|
24544
|
+
// forward and was given to `pushStackDedup`.
|
|
24545
|
+
advanceFully(stack, newStacks) {
|
|
24546
|
+
let pos = stack.pos;
|
|
24547
|
+
for (; ; ) {
|
|
24548
|
+
if (!this.advanceStack(stack, null, null))
|
|
24549
|
+
return false;
|
|
24550
|
+
if (stack.pos > pos) {
|
|
24551
|
+
pushStackDedup(stack, newStacks);
|
|
24552
|
+
return true;
|
|
24553
|
+
}
|
|
24554
|
+
}
|
|
24555
|
+
}
|
|
24556
|
+
runRecovery(stacks, tokens, newStacks) {
|
|
24557
|
+
let finished = null, restarted = false;
|
|
24558
|
+
for (let i = 0; i < stacks.length; i++) {
|
|
24559
|
+
let stack = stacks[i], token = tokens[i << 1], tokenEnd = tokens[(i << 1) + 1];
|
|
24560
|
+
let base2 = verbose ? this.stackID(stack) + " -> " : "";
|
|
24561
|
+
if (stack.deadEnd) {
|
|
24562
|
+
if (restarted)
|
|
24563
|
+
continue;
|
|
24564
|
+
restarted = true;
|
|
24565
|
+
stack.restart();
|
|
24566
|
+
if (verbose)
|
|
24567
|
+
;
|
|
24568
|
+
let done = this.advanceFully(stack, newStacks);
|
|
24569
|
+
if (done)
|
|
24570
|
+
continue;
|
|
24571
|
+
}
|
|
24572
|
+
let force = stack.split(), forceBase = base2;
|
|
24573
|
+
for (let j = 0; force.forceReduce() && j < 10; j++) {
|
|
24574
|
+
if (verbose)
|
|
24575
|
+
;
|
|
24576
|
+
let done = this.advanceFully(force, newStacks);
|
|
24577
|
+
if (done)
|
|
24578
|
+
break;
|
|
24579
|
+
if (verbose)
|
|
24580
|
+
forceBase = this.stackID(force) + " -> ";
|
|
24581
|
+
}
|
|
24582
|
+
for (let insert2 of stack.recoverByInsert(token)) {
|
|
24583
|
+
if (verbose)
|
|
24584
|
+
;
|
|
24585
|
+
this.advanceFully(insert2, newStacks);
|
|
24586
|
+
}
|
|
24587
|
+
if (this.stream.end > stack.pos) {
|
|
24588
|
+
if (tokenEnd == stack.pos) {
|
|
24589
|
+
tokenEnd++;
|
|
24590
|
+
token = 0;
|
|
24591
|
+
}
|
|
24592
|
+
stack.recoverByDelete(token, tokenEnd);
|
|
24593
|
+
if (verbose)
|
|
24594
|
+
;
|
|
24595
|
+
pushStackDedup(stack, newStacks);
|
|
24596
|
+
} else if (!finished || finished.score < stack.score) {
|
|
24597
|
+
finished = stack;
|
|
24598
|
+
}
|
|
24599
|
+
}
|
|
24600
|
+
return finished;
|
|
24601
|
+
}
|
|
24602
|
+
// Convert the stack's buffer to a syntax tree.
|
|
24603
|
+
stackToTree(stack) {
|
|
24604
|
+
stack.close();
|
|
24605
|
+
return Tree.build({
|
|
24606
|
+
buffer: StackBufferCursor.create(stack),
|
|
24607
|
+
nodeSet: this.parser.nodeSet,
|
|
24608
|
+
topID: this.topTerm,
|
|
24609
|
+
maxBufferLength: this.parser.bufferLength,
|
|
24610
|
+
reused: this.reused,
|
|
24611
|
+
start: this.ranges[0].from,
|
|
24612
|
+
length: stack.pos - this.ranges[0].from,
|
|
24613
|
+
minRepeatType: this.parser.minRepeatTerm
|
|
24614
|
+
});
|
|
24615
|
+
}
|
|
24616
|
+
stackID(stack) {
|
|
24617
|
+
let id2 = (stackIDs || (stackIDs = /* @__PURE__ */ new WeakMap())).get(stack);
|
|
24618
|
+
if (!id2)
|
|
24619
|
+
stackIDs.set(stack, id2 = String.fromCodePoint(this.nextStackID++));
|
|
24620
|
+
return id2 + stack;
|
|
24621
|
+
}
|
|
24622
|
+
}
|
|
24623
|
+
function pushStackDedup(stack, newStacks) {
|
|
24624
|
+
for (let i = 0; i < newStacks.length; i++) {
|
|
24625
|
+
let other = newStacks[i];
|
|
24626
|
+
if (other.pos == stack.pos && other.sameState(stack)) {
|
|
24627
|
+
if (newStacks[i].score < stack.score)
|
|
24628
|
+
newStacks[i] = stack;
|
|
24629
|
+
return;
|
|
24630
|
+
}
|
|
24631
|
+
}
|
|
24632
|
+
newStacks.push(stack);
|
|
24633
|
+
}
|
|
24634
|
+
class Dialect {
|
|
24635
|
+
constructor(source, flags, disabled) {
|
|
24636
|
+
this.source = source;
|
|
24637
|
+
this.flags = flags;
|
|
24638
|
+
this.disabled = disabled;
|
|
24639
|
+
}
|
|
24640
|
+
allows(term) {
|
|
24641
|
+
return !this.disabled || this.disabled[term] == 0;
|
|
24642
|
+
}
|
|
24643
|
+
}
|
|
24644
|
+
const id = (x) => x;
|
|
24645
|
+
class ContextTracker {
|
|
24646
|
+
/**
|
|
24647
|
+
Define a context tracker.
|
|
24648
|
+
*/
|
|
24649
|
+
constructor(spec) {
|
|
24650
|
+
this.start = spec.start;
|
|
24651
|
+
this.shift = spec.shift || id;
|
|
24652
|
+
this.reduce = spec.reduce || id;
|
|
24653
|
+
this.reuse = spec.reuse || id;
|
|
24654
|
+
this.hash = spec.hash || (() => 0);
|
|
24655
|
+
this.strict = spec.strict !== false;
|
|
24656
|
+
}
|
|
24657
|
+
}
|
|
24658
|
+
class LRParser extends Parser {
|
|
24659
|
+
/**
|
|
24660
|
+
@internal
|
|
24661
|
+
*/
|
|
24662
|
+
constructor(spec) {
|
|
24663
|
+
super();
|
|
24664
|
+
this.wrappers = [];
|
|
24665
|
+
if (spec.version != 14)
|
|
24666
|
+
throw new RangeError(`Parser version (${spec.version}) doesn't match runtime version (${14})`);
|
|
24667
|
+
let nodeNames = spec.nodeNames.split(" ");
|
|
24668
|
+
this.minRepeatTerm = nodeNames.length;
|
|
24669
|
+
for (let i = 0; i < spec.repeatNodeCount; i++)
|
|
24670
|
+
nodeNames.push("");
|
|
24671
|
+
let topTerms = Object.keys(spec.topRules).map((r) => spec.topRules[r][1]);
|
|
24672
|
+
let nodeProps = [];
|
|
24673
|
+
for (let i = 0; i < nodeNames.length; i++)
|
|
24674
|
+
nodeProps.push([]);
|
|
24675
|
+
function setProp(nodeID, prop, value) {
|
|
24676
|
+
nodeProps[nodeID].push([prop, prop.deserialize(String(value))]);
|
|
24677
|
+
}
|
|
24678
|
+
if (spec.nodeProps)
|
|
24679
|
+
for (let propSpec of spec.nodeProps) {
|
|
24680
|
+
let prop = propSpec[0];
|
|
24681
|
+
if (typeof prop == "string")
|
|
24682
|
+
prop = NodeProp[prop];
|
|
24683
|
+
for (let i = 1; i < propSpec.length; ) {
|
|
24684
|
+
let next = propSpec[i++];
|
|
24685
|
+
if (next >= 0) {
|
|
24686
|
+
setProp(next, prop, propSpec[i++]);
|
|
24687
|
+
} else {
|
|
24688
|
+
let value = propSpec[i + -next];
|
|
24689
|
+
for (let j = -next; j > 0; j--)
|
|
24690
|
+
setProp(propSpec[i++], prop, value);
|
|
24691
|
+
i++;
|
|
24692
|
+
}
|
|
24693
|
+
}
|
|
24694
|
+
}
|
|
24695
|
+
this.nodeSet = new NodeSet(nodeNames.map((name2, i) => NodeType.define({
|
|
24696
|
+
name: i >= this.minRepeatTerm ? void 0 : name2,
|
|
24697
|
+
id: i,
|
|
24698
|
+
props: nodeProps[i],
|
|
24699
|
+
top: topTerms.indexOf(i) > -1,
|
|
24700
|
+
error: i == 0,
|
|
24701
|
+
skipped: spec.skippedNodes && spec.skippedNodes.indexOf(i) > -1
|
|
24702
|
+
})));
|
|
24703
|
+
if (spec.propSources)
|
|
24704
|
+
this.nodeSet = this.nodeSet.extend(...spec.propSources);
|
|
24705
|
+
this.strict = false;
|
|
24706
|
+
this.bufferLength = DefaultBufferLength;
|
|
24707
|
+
let tokenArray = decodeArray(spec.tokenData);
|
|
24708
|
+
this.context = spec.context;
|
|
24709
|
+
this.specializerSpecs = spec.specialized || [];
|
|
24710
|
+
this.specialized = new Uint16Array(this.specializerSpecs.length);
|
|
24711
|
+
for (let i = 0; i < this.specializerSpecs.length; i++)
|
|
24712
|
+
this.specialized[i] = this.specializerSpecs[i].term;
|
|
24713
|
+
this.specializers = this.specializerSpecs.map(getSpecializer);
|
|
24714
|
+
this.states = decodeArray(spec.states, Uint32Array);
|
|
24715
|
+
this.data = decodeArray(spec.stateData);
|
|
24716
|
+
this.goto = decodeArray(spec.goto);
|
|
24717
|
+
this.maxTerm = spec.maxTerm;
|
|
24718
|
+
this.tokenizers = spec.tokenizers.map((value) => typeof value == "number" ? new TokenGroup(tokenArray, value) : value);
|
|
24719
|
+
this.topRules = spec.topRules;
|
|
24720
|
+
this.dialects = spec.dialects || {};
|
|
24721
|
+
this.dynamicPrecedences = spec.dynamicPrecedences || null;
|
|
24722
|
+
this.tokenPrecTable = spec.tokenPrec;
|
|
24723
|
+
this.termNames = spec.termNames || null;
|
|
24724
|
+
this.maxNode = this.nodeSet.types.length - 1;
|
|
24725
|
+
this.dialect = this.parseDialect();
|
|
24726
|
+
this.top = this.topRules[Object.keys(this.topRules)[0]];
|
|
24727
|
+
}
|
|
24728
|
+
createParse(input, fragments, ranges) {
|
|
24729
|
+
let parse = new Parse2(this, input, fragments, ranges);
|
|
24730
|
+
for (let w of this.wrappers)
|
|
24731
|
+
parse = w(parse, input, fragments, ranges);
|
|
24732
|
+
return parse;
|
|
24733
|
+
}
|
|
24734
|
+
/**
|
|
24735
|
+
Get a goto table entry @internal
|
|
24736
|
+
*/
|
|
24737
|
+
getGoto(state, term, loose = false) {
|
|
24738
|
+
let table = this.goto;
|
|
24739
|
+
if (term >= table[0])
|
|
24740
|
+
return -1;
|
|
24741
|
+
for (let pos = table[term + 1]; ; ) {
|
|
24742
|
+
let groupTag = table[pos++], last = groupTag & 1;
|
|
24743
|
+
let target = table[pos++];
|
|
24744
|
+
if (last && loose)
|
|
24745
|
+
return target;
|
|
24746
|
+
for (let end = pos + (groupTag >> 1); pos < end; pos++)
|
|
24747
|
+
if (table[pos] == state)
|
|
24748
|
+
return target;
|
|
24749
|
+
if (last)
|
|
24750
|
+
return -1;
|
|
24751
|
+
}
|
|
24752
|
+
}
|
|
24753
|
+
/**
|
|
24754
|
+
Check if this state has an action for a given terminal @internal
|
|
24755
|
+
*/
|
|
24756
|
+
hasAction(state, terminal) {
|
|
24757
|
+
let data = this.data;
|
|
24758
|
+
for (let set = 0; set < 2; set++) {
|
|
24759
|
+
for (let i = this.stateSlot(
|
|
24760
|
+
state,
|
|
24761
|
+
set ? 2 : 1
|
|
24762
|
+
/* ParseState.Actions */
|
|
24763
|
+
), next; ; i += 3) {
|
|
24764
|
+
if ((next = data[i]) == 65535) {
|
|
24765
|
+
if (data[i + 1] == 1)
|
|
24766
|
+
next = data[i = pair(data, i + 2)];
|
|
24767
|
+
else if (data[i + 1] == 2)
|
|
24768
|
+
return pair(data, i + 2);
|
|
24769
|
+
else
|
|
24770
|
+
break;
|
|
24771
|
+
}
|
|
24772
|
+
if (next == terminal || next == 0)
|
|
24773
|
+
return pair(data, i + 1);
|
|
24774
|
+
}
|
|
24775
|
+
}
|
|
24776
|
+
return 0;
|
|
24777
|
+
}
|
|
24778
|
+
/**
|
|
24779
|
+
@internal
|
|
24780
|
+
*/
|
|
24781
|
+
stateSlot(state, slot) {
|
|
24782
|
+
return this.states[state * 6 + slot];
|
|
24783
|
+
}
|
|
24784
|
+
/**
|
|
24785
|
+
@internal
|
|
24786
|
+
*/
|
|
24787
|
+
stateFlag(state, flag) {
|
|
24788
|
+
return (this.stateSlot(
|
|
24789
|
+
state,
|
|
24790
|
+
0
|
|
24791
|
+
/* ParseState.Flags */
|
|
24792
|
+
) & flag) > 0;
|
|
24793
|
+
}
|
|
24794
|
+
/**
|
|
24795
|
+
@internal
|
|
24796
|
+
*/
|
|
24797
|
+
validAction(state, action) {
|
|
24798
|
+
return !!this.allActions(state, (a) => a == action ? true : null);
|
|
24799
|
+
}
|
|
24800
|
+
/**
|
|
24801
|
+
@internal
|
|
24802
|
+
*/
|
|
24803
|
+
allActions(state, action) {
|
|
24804
|
+
let deflt = this.stateSlot(
|
|
24805
|
+
state,
|
|
24806
|
+
4
|
|
24807
|
+
/* ParseState.DefaultReduce */
|
|
24808
|
+
);
|
|
24809
|
+
let result = deflt ? action(deflt) : void 0;
|
|
24810
|
+
for (let i = this.stateSlot(
|
|
24811
|
+
state,
|
|
24812
|
+
1
|
|
24813
|
+
/* ParseState.Actions */
|
|
24814
|
+
); result == null; i += 3) {
|
|
24815
|
+
if (this.data[i] == 65535) {
|
|
24816
|
+
if (this.data[i + 1] == 1)
|
|
24817
|
+
i = pair(this.data, i + 2);
|
|
24818
|
+
else
|
|
24819
|
+
break;
|
|
24820
|
+
}
|
|
24821
|
+
result = action(pair(this.data, i + 1));
|
|
24822
|
+
}
|
|
24823
|
+
return result;
|
|
24824
|
+
}
|
|
24825
|
+
/**
|
|
24826
|
+
Get the states that can follow this one through shift actions or
|
|
24827
|
+
goto jumps. @internal
|
|
24828
|
+
*/
|
|
24829
|
+
nextStates(state) {
|
|
24830
|
+
let result = [];
|
|
24831
|
+
for (let i = this.stateSlot(
|
|
24832
|
+
state,
|
|
24833
|
+
1
|
|
24834
|
+
/* ParseState.Actions */
|
|
24835
|
+
); ; i += 3) {
|
|
24836
|
+
if (this.data[i] == 65535) {
|
|
24837
|
+
if (this.data[i + 1] == 1)
|
|
24838
|
+
i = pair(this.data, i + 2);
|
|
24839
|
+
else
|
|
24840
|
+
break;
|
|
24841
|
+
}
|
|
24842
|
+
if ((this.data[i + 2] & 65536 >> 16) == 0) {
|
|
24843
|
+
let value = this.data[i + 1];
|
|
24844
|
+
if (!result.some((v, i2) => i2 & 1 && v == value))
|
|
24845
|
+
result.push(this.data[i], value);
|
|
24846
|
+
}
|
|
24847
|
+
}
|
|
24848
|
+
return result;
|
|
24849
|
+
}
|
|
24850
|
+
/**
|
|
24851
|
+
Configure the parser. Returns a new parser instance that has the
|
|
24852
|
+
given settings modified. Settings not provided in `config` are
|
|
24853
|
+
kept from the original parser.
|
|
24854
|
+
*/
|
|
24855
|
+
configure(config2) {
|
|
24856
|
+
let copy = Object.assign(Object.create(LRParser.prototype), this);
|
|
24857
|
+
if (config2.props)
|
|
24858
|
+
copy.nodeSet = this.nodeSet.extend(...config2.props);
|
|
24859
|
+
if (config2.top) {
|
|
24860
|
+
let info = this.topRules[config2.top];
|
|
24861
|
+
if (!info)
|
|
24862
|
+
throw new RangeError(`Invalid top rule name ${config2.top}`);
|
|
24863
|
+
copy.top = info;
|
|
24864
|
+
}
|
|
24865
|
+
if (config2.tokenizers)
|
|
24866
|
+
copy.tokenizers = this.tokenizers.map((t2) => {
|
|
24867
|
+
let found = config2.tokenizers.find((r) => r.from == t2);
|
|
24868
|
+
return found ? found.to : t2;
|
|
24869
|
+
});
|
|
24870
|
+
if (config2.specializers) {
|
|
24871
|
+
copy.specializers = this.specializers.slice();
|
|
24872
|
+
copy.specializerSpecs = this.specializerSpecs.map((s, i) => {
|
|
24873
|
+
let found = config2.specializers.find((r) => r.from == s.external);
|
|
24874
|
+
if (!found)
|
|
24875
|
+
return s;
|
|
24876
|
+
let spec = Object.assign(Object.assign({}, s), { external: found.to });
|
|
24877
|
+
copy.specializers[i] = getSpecializer(spec);
|
|
24878
|
+
return spec;
|
|
24879
|
+
});
|
|
24880
|
+
}
|
|
24881
|
+
if (config2.contextTracker)
|
|
24882
|
+
copy.context = config2.contextTracker;
|
|
24883
|
+
if (config2.dialect)
|
|
24884
|
+
copy.dialect = this.parseDialect(config2.dialect);
|
|
24885
|
+
if (config2.strict != null)
|
|
24886
|
+
copy.strict = config2.strict;
|
|
24887
|
+
if (config2.wrap)
|
|
24888
|
+
copy.wrappers = copy.wrappers.concat(config2.wrap);
|
|
24889
|
+
if (config2.bufferLength != null)
|
|
24890
|
+
copy.bufferLength = config2.bufferLength;
|
|
24891
|
+
return copy;
|
|
24892
|
+
}
|
|
24893
|
+
/**
|
|
24894
|
+
Tells you whether any [parse wrappers](#lr.ParserConfig.wrap)
|
|
24895
|
+
are registered for this parser.
|
|
24896
|
+
*/
|
|
24897
|
+
hasWrappers() {
|
|
24898
|
+
return this.wrappers.length > 0;
|
|
24899
|
+
}
|
|
24900
|
+
/**
|
|
24901
|
+
Returns the name associated with a given term. This will only
|
|
24902
|
+
work for all terms when the parser was generated with the
|
|
24903
|
+
`--names` option. By default, only the names of tagged terms are
|
|
24904
|
+
stored.
|
|
24905
|
+
*/
|
|
24906
|
+
getName(term) {
|
|
24907
|
+
return this.termNames ? this.termNames[term] : String(term <= this.maxNode && this.nodeSet.types[term].name || term);
|
|
24908
|
+
}
|
|
24909
|
+
/**
|
|
24910
|
+
The eof term id is always allocated directly after the node
|
|
24911
|
+
types. @internal
|
|
24912
|
+
*/
|
|
24913
|
+
get eofTerm() {
|
|
24914
|
+
return this.maxNode + 1;
|
|
24915
|
+
}
|
|
24916
|
+
/**
|
|
24917
|
+
The type of top node produced by the parser.
|
|
24918
|
+
*/
|
|
24919
|
+
get topNode() {
|
|
24920
|
+
return this.nodeSet.types[this.top[1]];
|
|
24921
|
+
}
|
|
24922
|
+
/**
|
|
24923
|
+
@internal
|
|
24924
|
+
*/
|
|
24925
|
+
dynamicPrecedence(term) {
|
|
24926
|
+
let prec2 = this.dynamicPrecedences;
|
|
24927
|
+
return prec2 == null ? 0 : prec2[term] || 0;
|
|
24928
|
+
}
|
|
24929
|
+
/**
|
|
24930
|
+
@internal
|
|
24931
|
+
*/
|
|
24932
|
+
parseDialect(dialect) {
|
|
24933
|
+
let values = Object.keys(this.dialects), flags = values.map(() => false);
|
|
24934
|
+
if (dialect)
|
|
24935
|
+
for (let part of dialect.split(" ")) {
|
|
24936
|
+
let id2 = values.indexOf(part);
|
|
24937
|
+
if (id2 >= 0)
|
|
24938
|
+
flags[id2] = true;
|
|
24939
|
+
}
|
|
24940
|
+
let disabled = null;
|
|
24941
|
+
for (let i = 0; i < values.length; i++)
|
|
24942
|
+
if (!flags[i]) {
|
|
24943
|
+
for (let j = this.dialects[values[i]], id2; (id2 = this.data[j++]) != 65535; )
|
|
24944
|
+
(disabled || (disabled = new Uint8Array(this.maxTerm + 1)))[id2] = 1;
|
|
24945
|
+
}
|
|
24946
|
+
return new Dialect(dialect, flags, disabled);
|
|
24947
|
+
}
|
|
24948
|
+
/**
|
|
24949
|
+
Used by the output of the parser generator. Not available to
|
|
24950
|
+
user code. @hide
|
|
24951
|
+
*/
|
|
24952
|
+
static deserialize(spec) {
|
|
24953
|
+
return new LRParser(spec);
|
|
24954
|
+
}
|
|
24955
|
+
}
|
|
24956
|
+
function pair(data, off) {
|
|
24957
|
+
return data[off] | data[off + 1] << 16;
|
|
24958
|
+
}
|
|
24959
|
+
function findFinished(stacks) {
|
|
24960
|
+
let best = null;
|
|
24961
|
+
for (let stack of stacks) {
|
|
24962
|
+
let stopped = stack.p.stoppedAt;
|
|
24963
|
+
if ((stack.pos == stack.p.stream.end || stopped != null && stack.pos > stopped) && stack.p.parser.stateFlag(
|
|
24964
|
+
stack.state,
|
|
24965
|
+
2
|
|
24966
|
+
/* StateFlag.Accepting */
|
|
24967
|
+
) && (!best || best.score < stack.score))
|
|
24968
|
+
best = stack;
|
|
24969
|
+
}
|
|
24970
|
+
return best;
|
|
24971
|
+
}
|
|
24972
|
+
function getSpecializer(spec) {
|
|
24973
|
+
if (spec.external) {
|
|
24974
|
+
let mask = spec.extend ? 1 : 0;
|
|
24975
|
+
return (value, stack) => spec.external(value, stack) << 1 | mask;
|
|
24976
|
+
}
|
|
24977
|
+
return spec.get;
|
|
24978
|
+
}
|
|
23228
24979
|
/**
|
|
23229
24980
|
* vue-codemirror6
|
|
23230
24981
|
*
|
|
@@ -23678,31 +25429,34 @@ var oe = defineComponent({
|
|
|
23678
25429
|
}
|
|
23679
25430
|
});
|
|
23680
25431
|
export {
|
|
23681
|
-
|
|
23682
|
-
|
|
25432
|
+
bracketMatchingHandle as $,
|
|
25433
|
+
languageDataProp as A,
|
|
25434
|
+
ParseContext as B,
|
|
23683
25435
|
Compartment as C,
|
|
23684
|
-
|
|
25436
|
+
keyName as D,
|
|
23685
25437
|
EditorView as E,
|
|
23686
|
-
|
|
23687
|
-
|
|
25438
|
+
base as F,
|
|
25439
|
+
LRParser as G,
|
|
23688
25440
|
HighlightStyle as H,
|
|
23689
|
-
|
|
23690
|
-
|
|
23691
|
-
|
|
25441
|
+
ExternalTokenizer as I,
|
|
25442
|
+
ContextTracker as J,
|
|
25443
|
+
LocalTokenGroup as K,
|
|
23692
25444
|
LanguageDescription as L,
|
|
23693
|
-
|
|
25445
|
+
LRLanguage as M,
|
|
23694
25446
|
NodeType as N,
|
|
23695
|
-
|
|
25447
|
+
continuedIndent as O,
|
|
23696
25448
|
Parser as P,
|
|
23697
|
-
|
|
23698
|
-
|
|
25449
|
+
foldInside as Q,
|
|
25450
|
+
NodeWeakMap as R,
|
|
23699
25451
|
StreamLanguage as S,
|
|
23700
25452
|
Tag as T,
|
|
23701
|
-
|
|
23702
|
-
|
|
23703
|
-
|
|
23704
|
-
|
|
23705
|
-
|
|
25453
|
+
IterMode as U,
|
|
25454
|
+
delimitedIndent as V,
|
|
25455
|
+
flatIndent as W,
|
|
25456
|
+
sublanguageProp as X,
|
|
25457
|
+
snippetCompletion as Y,
|
|
25458
|
+
ifNotIn as Z,
|
|
25459
|
+
completeFromList as _,
|
|
23706
25460
|
LanguageSupport as a,
|
|
23707
25461
|
EditorState as b,
|
|
23708
25462
|
basicSetup as c,
|
|
@@ -23714,19 +25468,19 @@ export {
|
|
|
23714
25468
|
indentWithTab as i,
|
|
23715
25469
|
Tree as j,
|
|
23716
25470
|
keymap as k,
|
|
23717
|
-
|
|
23718
|
-
|
|
23719
|
-
|
|
25471
|
+
Prec as l,
|
|
25472
|
+
Language as m,
|
|
25473
|
+
defineLanguageFacet as n,
|
|
23720
25474
|
oe as o,
|
|
23721
25475
|
parseMixed as p,
|
|
23722
|
-
|
|
23723
|
-
|
|
25476
|
+
foldService as q,
|
|
25477
|
+
syntaxTree as r,
|
|
23724
25478
|
syntaxHighlighting as s,
|
|
23725
25479
|
tags as t,
|
|
23726
|
-
|
|
23727
|
-
|
|
23728
|
-
|
|
23729
|
-
|
|
23730
|
-
|
|
23731
|
-
|
|
25480
|
+
EditorSelection as u,
|
|
25481
|
+
countColumn as v,
|
|
25482
|
+
indentUnit as w,
|
|
25483
|
+
CompletionContext as x,
|
|
25484
|
+
foldNodeProp as y,
|
|
25485
|
+
indentNodeProp as z
|
|
23732
25486
|
};
|