clarity-pattern-parser 10.0.1 → 10.0.3
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/ast/Node.d.ts +1 -0
- package/dist/index.browser.js +12 -11
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +12 -11
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +12 -11
- package/dist/index.js.map +1 -1
- package/dist/patterns/Not.d.ts +0 -1
- package/dist/patterns/Repeat.d.ts +2 -2
- package/package.json +1 -1
- package/src/ast/Node.ts +4 -0
- package/src/grammar/Grammar.test.ts +34 -0
- package/src/grammar/Grammar.ts +1 -1
- package/src/intellisense/AutoComplete.test.ts +1 -1
- package/src/patterns/FiniteRepeat.test.ts +6 -0
- package/src/patterns/FiniteRepeat.ts +1 -1
- package/src/patterns/InfiniteRepeat.test.ts +6 -0
- package/src/patterns/InfiniteRepeat.ts +2 -2
- package/src/patterns/Not.test.ts +0 -1
- package/src/patterns/Not.ts +0 -4
- package/src/patterns/Repeat.ts +2 -2
- package/src/patterns/Sequence.test.ts +3 -2
- package/src/patterns/Sequence.ts +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -219,6 +219,9 @@ class Node {
|
|
|
219
219
|
toJson(space) {
|
|
220
220
|
return JSON.stringify(this.toCycleFreeObject(), null, space);
|
|
221
221
|
}
|
|
222
|
+
isEqual(node) {
|
|
223
|
+
return node.toJson(0) === this.toJson(0);
|
|
224
|
+
}
|
|
222
225
|
static createValueNode(name, value) {
|
|
223
226
|
return new Node("custom-value-node", name, 0, 0, [], value);
|
|
224
227
|
}
|
|
@@ -1130,7 +1133,7 @@ class FiniteRepeat {
|
|
|
1130
1133
|
}
|
|
1131
1134
|
}
|
|
1132
1135
|
if (this._trimDivider && this._hasDivider) {
|
|
1133
|
-
const isDividerLastMatch =
|
|
1136
|
+
const isDividerLastMatch = this.children.length > 1 && nodes[nodes.length - 1].name === this.children[1].name;
|
|
1134
1137
|
if (isDividerLastMatch) {
|
|
1135
1138
|
const node = nodes.pop();
|
|
1136
1139
|
cursor.moveTo(node.firstIndex);
|
|
@@ -1371,7 +1374,7 @@ class InfiniteRepeat {
|
|
|
1371
1374
|
else {
|
|
1372
1375
|
if (dividerNode == null) {
|
|
1373
1376
|
cursor.moveTo(dividerStartIndex);
|
|
1374
|
-
if (
|
|
1377
|
+
if (repeatNode == null) {
|
|
1375
1378
|
// If neither the repeat pattern or divider pattern matched get out.
|
|
1376
1379
|
passed = true;
|
|
1377
1380
|
break;
|
|
@@ -1401,10 +1404,11 @@ class InfiniteRepeat {
|
|
|
1401
1404
|
return passed;
|
|
1402
1405
|
}
|
|
1403
1406
|
_createNode(cursor) {
|
|
1407
|
+
var _a;
|
|
1404
1408
|
const hasDivider = this._divider != null;
|
|
1405
1409
|
if (hasDivider &&
|
|
1406
1410
|
this._trimDivider &&
|
|
1407
|
-
|
|
1411
|
+
this._nodes[this._nodes.length - 1].name === ((_a = this._divider) === null || _a === void 0 ? void 0 : _a.name)) {
|
|
1408
1412
|
const dividerNode = this._nodes.pop();
|
|
1409
1413
|
cursor.moveTo(dividerNode.firstIndex);
|
|
1410
1414
|
}
|
|
@@ -1516,10 +1520,10 @@ class Repeat {
|
|
|
1516
1520
|
return this._children;
|
|
1517
1521
|
}
|
|
1518
1522
|
get min() {
|
|
1519
|
-
return this.
|
|
1523
|
+
return this._options.min;
|
|
1520
1524
|
}
|
|
1521
1525
|
get max() {
|
|
1522
|
-
return this.
|
|
1526
|
+
return this._options.max;
|
|
1523
1527
|
}
|
|
1524
1528
|
constructor(name, pattern, options = {}) {
|
|
1525
1529
|
this._id = `repeat-${idIndex$3++}`;
|
|
@@ -1755,7 +1759,7 @@ class Sequence {
|
|
|
1755
1759
|
const tokens = [];
|
|
1756
1760
|
for (const child of this._children) {
|
|
1757
1761
|
tokens.push(...child.getTokens());
|
|
1758
|
-
if (child.type !== "optional") {
|
|
1762
|
+
if (child.type !== "optional" && child.type !== "not") {
|
|
1759
1763
|
break;
|
|
1760
1764
|
}
|
|
1761
1765
|
}
|
|
@@ -1777,7 +1781,7 @@ class Sequence {
|
|
|
1777
1781
|
const patterns = [];
|
|
1778
1782
|
for (const child of this._children) {
|
|
1779
1783
|
patterns.push(...child.getPatterns());
|
|
1780
|
-
if (child.type !== "optional") {
|
|
1784
|
+
if (child.type !== "optional" && child.type !== "not") {
|
|
1781
1785
|
break;
|
|
1782
1786
|
}
|
|
1783
1787
|
}
|
|
@@ -2201,9 +2205,6 @@ class Not {
|
|
|
2201
2205
|
get children() {
|
|
2202
2206
|
return this._children;
|
|
2203
2207
|
}
|
|
2204
|
-
get isOptional() {
|
|
2205
|
-
return false;
|
|
2206
|
-
}
|
|
2207
2208
|
constructor(name, pattern) {
|
|
2208
2209
|
this._id = `not-${idIndex++}`;
|
|
2209
2210
|
this._type = "not";
|
|
@@ -2858,7 +2859,7 @@ class Grammar {
|
|
|
2858
2859
|
.importedPatternsByName
|
|
2859
2860
|
.values());
|
|
2860
2861
|
const grammar = new Grammar({
|
|
2861
|
-
params: importedValues,
|
|
2862
|
+
params: [...importedValues, ...this._parseContext.paramsByName.values()],
|
|
2862
2863
|
originResource: this._originResource,
|
|
2863
2864
|
resolveImport: this._resolveImport
|
|
2864
2865
|
});
|