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.js
CHANGED
|
@@ -223,6 +223,9 @@ class Node {
|
|
|
223
223
|
toJson(space) {
|
|
224
224
|
return JSON.stringify(this.toCycleFreeObject(), null, space);
|
|
225
225
|
}
|
|
226
|
+
isEqual(node) {
|
|
227
|
+
return node.toJson(0) === this.toJson(0);
|
|
228
|
+
}
|
|
226
229
|
static createValueNode(name, value) {
|
|
227
230
|
return new Node("custom-value-node", name, 0, 0, [], value);
|
|
228
231
|
}
|
|
@@ -1134,7 +1137,7 @@ class FiniteRepeat {
|
|
|
1134
1137
|
}
|
|
1135
1138
|
}
|
|
1136
1139
|
if (this._trimDivider && this._hasDivider) {
|
|
1137
|
-
const isDividerLastMatch =
|
|
1140
|
+
const isDividerLastMatch = this.children.length > 1 && nodes[nodes.length - 1].name === this.children[1].name;
|
|
1138
1141
|
if (isDividerLastMatch) {
|
|
1139
1142
|
const node = nodes.pop();
|
|
1140
1143
|
cursor.moveTo(node.firstIndex);
|
|
@@ -1375,7 +1378,7 @@ class InfiniteRepeat {
|
|
|
1375
1378
|
else {
|
|
1376
1379
|
if (dividerNode == null) {
|
|
1377
1380
|
cursor.moveTo(dividerStartIndex);
|
|
1378
|
-
if (
|
|
1381
|
+
if (repeatNode == null) {
|
|
1379
1382
|
// If neither the repeat pattern or divider pattern matched get out.
|
|
1380
1383
|
passed = true;
|
|
1381
1384
|
break;
|
|
@@ -1405,10 +1408,11 @@ class InfiniteRepeat {
|
|
|
1405
1408
|
return passed;
|
|
1406
1409
|
}
|
|
1407
1410
|
_createNode(cursor) {
|
|
1411
|
+
var _a;
|
|
1408
1412
|
const hasDivider = this._divider != null;
|
|
1409
1413
|
if (hasDivider &&
|
|
1410
1414
|
this._trimDivider &&
|
|
1411
|
-
|
|
1415
|
+
this._nodes[this._nodes.length - 1].name === ((_a = this._divider) === null || _a === void 0 ? void 0 : _a.name)) {
|
|
1412
1416
|
const dividerNode = this._nodes.pop();
|
|
1413
1417
|
cursor.moveTo(dividerNode.firstIndex);
|
|
1414
1418
|
}
|
|
@@ -1520,10 +1524,10 @@ class Repeat {
|
|
|
1520
1524
|
return this._children;
|
|
1521
1525
|
}
|
|
1522
1526
|
get min() {
|
|
1523
|
-
return this.
|
|
1527
|
+
return this._options.min;
|
|
1524
1528
|
}
|
|
1525
1529
|
get max() {
|
|
1526
|
-
return this.
|
|
1530
|
+
return this._options.max;
|
|
1527
1531
|
}
|
|
1528
1532
|
constructor(name, pattern, options = {}) {
|
|
1529
1533
|
this._id = `repeat-${idIndex$3++}`;
|
|
@@ -1759,7 +1763,7 @@ class Sequence {
|
|
|
1759
1763
|
const tokens = [];
|
|
1760
1764
|
for (const child of this._children) {
|
|
1761
1765
|
tokens.push(...child.getTokens());
|
|
1762
|
-
if (child.type !== "optional") {
|
|
1766
|
+
if (child.type !== "optional" && child.type !== "not") {
|
|
1763
1767
|
break;
|
|
1764
1768
|
}
|
|
1765
1769
|
}
|
|
@@ -1781,7 +1785,7 @@ class Sequence {
|
|
|
1781
1785
|
const patterns = [];
|
|
1782
1786
|
for (const child of this._children) {
|
|
1783
1787
|
patterns.push(...child.getPatterns());
|
|
1784
|
-
if (child.type !== "optional") {
|
|
1788
|
+
if (child.type !== "optional" && child.type !== "not") {
|
|
1785
1789
|
break;
|
|
1786
1790
|
}
|
|
1787
1791
|
}
|
|
@@ -2205,9 +2209,6 @@ class Not {
|
|
|
2205
2209
|
get children() {
|
|
2206
2210
|
return this._children;
|
|
2207
2211
|
}
|
|
2208
|
-
get isOptional() {
|
|
2209
|
-
return false;
|
|
2210
|
-
}
|
|
2211
2212
|
constructor(name, pattern) {
|
|
2212
2213
|
this._id = `not-${idIndex++}`;
|
|
2213
2214
|
this._type = "not";
|
|
@@ -2862,7 +2863,7 @@ class Grammar {
|
|
|
2862
2863
|
.importedPatternsByName
|
|
2863
2864
|
.values());
|
|
2864
2865
|
const grammar = new Grammar({
|
|
2865
|
-
params: importedValues,
|
|
2866
|
+
params: [...importedValues, ...this._parseContext.paramsByName.values()],
|
|
2866
2867
|
originResource: this._originResource,
|
|
2867
2868
|
resolveImport: this._resolveImport
|
|
2868
2869
|
});
|