clarity-pattern-parser 3.0.12 → 3.0.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/dist/index.browser.js +20 -7
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +20 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +20 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/TextSuggester.ts +20 -1
- package/src/patterns/Pattern.ts +1 -1
- package/src/patterns/composite/RepeatComposite.ts +2 -2
- package/src/patterns/value/RepeatValue.ts +2 -2
- package/src/tests/TextSuggester.test.ts +45 -1
package/dist/index.browser.js
CHANGED
|
@@ -348,7 +348,7 @@
|
|
|
348
348
|
return nextSibling.getTokens().concat(tokens);
|
|
349
349
|
}
|
|
350
350
|
else if (index === 1) {
|
|
351
|
-
return siblings[0].getTokens()
|
|
351
|
+
return siblings[0].getTokens();
|
|
352
352
|
}
|
|
353
353
|
else {
|
|
354
354
|
return this.getTokens().concat(tokens);
|
|
@@ -909,7 +909,6 @@
|
|
|
909
909
|
else {
|
|
910
910
|
this.nodes.push(node);
|
|
911
911
|
if (node.endIndex === this.cursor.lastIndex()) {
|
|
912
|
-
this.nodes.length = 0;
|
|
913
912
|
this._processMatch();
|
|
914
913
|
break;
|
|
915
914
|
}
|
|
@@ -920,8 +919,9 @@
|
|
|
920
919
|
}
|
|
921
920
|
}
|
|
922
921
|
_processMatch() {
|
|
922
|
+
const endsOnDivider = this.nodes.length % 2 === 0;
|
|
923
923
|
this.cursor.resolveError();
|
|
924
|
-
if (
|
|
924
|
+
if (endsOnDivider) {
|
|
925
925
|
const parseError = new ParseError(`Did not find a repeating match of ${this.name}.`, this.mark, this);
|
|
926
926
|
this.cursor.throwError(parseError);
|
|
927
927
|
this.node = null;
|
|
@@ -1206,7 +1206,6 @@
|
|
|
1206
1206
|
else {
|
|
1207
1207
|
this.nodes.push(node);
|
|
1208
1208
|
if (node.endIndex === this.cursor.lastIndex()) {
|
|
1209
|
-
this.nodes.length = 0;
|
|
1210
1209
|
this._processMatch();
|
|
1211
1210
|
break;
|
|
1212
1211
|
}
|
|
@@ -1217,8 +1216,9 @@
|
|
|
1217
1216
|
}
|
|
1218
1217
|
}
|
|
1219
1218
|
_processMatch() {
|
|
1219
|
+
const endsOnDivider = this.nodes.length % 2 === 0;
|
|
1220
1220
|
this.cursor.resolveError();
|
|
1221
|
-
if (
|
|
1221
|
+
if (endsOnDivider) {
|
|
1222
1222
|
this.cursor.throwError(new ParseError(`Did not find a repeating match of ${this.name}.`, this.mark, this));
|
|
1223
1223
|
this.node = null;
|
|
1224
1224
|
}
|
|
@@ -1506,8 +1506,21 @@
|
|
|
1506
1506
|
};
|
|
1507
1507
|
}
|
|
1508
1508
|
saveOptions() {
|
|
1509
|
-
|
|
1510
|
-
const
|
|
1509
|
+
const parents = new Map();
|
|
1510
|
+
const cursor = this.cursor;
|
|
1511
|
+
if (cursor == null) {
|
|
1512
|
+
this.options = [];
|
|
1513
|
+
return;
|
|
1514
|
+
}
|
|
1515
|
+
const furthestMatches = cursor.history.astNodes.reduce((acc, node, index) => {
|
|
1516
|
+
const pattern = cursor.history.patterns[index];
|
|
1517
|
+
const parent = pattern.parent;
|
|
1518
|
+
if (parent != null) {
|
|
1519
|
+
parents.set(parent, parent);
|
|
1520
|
+
}
|
|
1521
|
+
if (parents.has(pattern)) {
|
|
1522
|
+
return acc;
|
|
1523
|
+
}
|
|
1511
1524
|
if (node.endIndex === acc.furthestTextIndex) {
|
|
1512
1525
|
acc.nodeIndexes.push(index);
|
|
1513
1526
|
}
|