clarity-pattern-parser 10.0.2 → 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.
@@ -52,6 +52,7 @@ export declare class Node {
52
52
  toString(): string;
53
53
  toCycleFreeObject(): CycleFreeNode;
54
54
  toJson(space?: number): string;
55
+ isEqual(node: Node): boolean;
55
56
  static createValueNode(name: string, value: string): Node;
56
57
  static createNode(name: string, children: Node[]): Node;
57
58
  }
@@ -225,6 +225,9 @@
225
225
  toJson(space) {
226
226
  return JSON.stringify(this.toCycleFreeObject(), null, space);
227
227
  }
228
+ isEqual(node) {
229
+ return node.toJson(0) === this.toJson(0);
230
+ }
228
231
  static createValueNode(name, value) {
229
232
  return new Node("custom-value-node", name, 0, 0, [], value);
230
233
  }
@@ -1107,7 +1110,6 @@
1107
1110
  }
1108
1111
  }
1109
1112
  parse(cursor) {
1110
- var _a;
1111
1113
  cursor.startParseWith(this);
1112
1114
  const startIndex = cursor.index;
1113
1115
  const nodes = [];
@@ -1137,7 +1139,7 @@
1137
1139
  }
1138
1140
  }
1139
1141
  if (this._trimDivider && this._hasDivider) {
1140
- const isDividerLastMatch = ((_a = cursor.leafMatch.pattern) === null || _a === void 0 ? void 0 : _a.id) === this.children[1].id;
1142
+ const isDividerLastMatch = this.children.length > 1 && nodes[nodes.length - 1].name === this.children[1].name;
1141
1143
  if (isDividerLastMatch) {
1142
1144
  const node = nodes.pop();
1143
1145
  cursor.moveTo(node.firstIndex);
@@ -1408,10 +1410,11 @@
1408
1410
  return passed;
1409
1411
  }
1410
1412
  _createNode(cursor) {
1413
+ var _a;
1411
1414
  const hasDivider = this._divider != null;
1412
1415
  if (hasDivider &&
1413
1416
  this._trimDivider &&
1414
- cursor.leafMatch.pattern === this._divider) {
1417
+ this._nodes[this._nodes.length - 1].name === ((_a = this._divider) === null || _a === void 0 ? void 0 : _a.name)) {
1415
1418
  const dividerNode = this._nodes.pop();
1416
1419
  cursor.moveTo(dividerNode.firstIndex);
1417
1420
  }
@@ -1523,10 +1526,10 @@
1523
1526
  return this._children;
1524
1527
  }
1525
1528
  get min() {
1526
- return this.children[0].min;
1529
+ return this._options.min;
1527
1530
  }
1528
1531
  get max() {
1529
- return this.children[0].max || Infinity;
1532
+ return this._options.max;
1530
1533
  }
1531
1534
  constructor(name, pattern, options = {}) {
1532
1535
  this._id = `repeat-${idIndex$3++}`;
@@ -1762,7 +1765,7 @@
1762
1765
  const tokens = [];
1763
1766
  for (const child of this._children) {
1764
1767
  tokens.push(...child.getTokens());
1765
- if (child.type !== "optional") {
1768
+ if (child.type !== "optional" && child.type !== "not") {
1766
1769
  break;
1767
1770
  }
1768
1771
  }
@@ -1784,7 +1787,7 @@
1784
1787
  const patterns = [];
1785
1788
  for (const child of this._children) {
1786
1789
  patterns.push(...child.getPatterns());
1787
- if (child.type !== "optional") {
1790
+ if (child.type !== "optional" && child.type !== "not") {
1788
1791
  break;
1789
1792
  }
1790
1793
  }
@@ -2208,9 +2211,6 @@
2208
2211
  get children() {
2209
2212
  return this._children;
2210
2213
  }
2211
- get isOptional() {
2212
- return false;
2213
- }
2214
2214
  constructor(name, pattern) {
2215
2215
  this._id = `not-${idIndex++}`;
2216
2216
  this._type = "not";
@@ -2865,7 +2865,7 @@
2865
2865
  .importedPatternsByName
2866
2866
  .values());
2867
2867
  const grammar = new Grammar({
2868
- params: importedValues,
2868
+ params: [...importedValues, ...this._parseContext.paramsByName.values()],
2869
2869
  originResource: this._originResource,
2870
2870
  resolveImport: this._resolveImport
2871
2871
  });