clarity-pattern-parser 11.0.20 → 11.0.21

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.esm.js CHANGED
@@ -3025,7 +3025,9 @@ class Expression {
3025
3025
  pattern = pattern.children[0];
3026
3026
  }
3027
3027
  if (pattern.type === "reference") {
3028
+ pattern.parent = this;
3028
3029
  pattern = pattern.getReferencePatternSafely();
3030
+ pattern.parent = null;
3029
3031
  }
3030
3032
  return pattern;
3031
3033
  }
@@ -3563,16 +3565,18 @@ class Grammar {
3563
3565
  return this._isRecursivePattern(name, pattern);
3564
3566
  }
3565
3567
  _isRecursivePattern(name, pattern) {
3568
+ if (pattern.type === "reference") {
3569
+ return true;
3570
+ }
3566
3571
  if (pattern.children.length === 0) {
3567
3572
  return false;
3568
3573
  }
3569
3574
  const firstChild = pattern.children[0];
3570
3575
  const lastChild = pattern.children[pattern.children.length - 1];
3571
3576
  const isLongEnough = pattern.children.length >= 2;
3572
- return pattern.type === "reference" ||
3573
- (pattern.type === "sequence" && isLongEnough &&
3574
- (firstChild.name === name) ||
3575
- (lastChild.name === name));
3577
+ return (pattern.type === "sequence" && isLongEnough &&
3578
+ (firstChild.name === name) ||
3579
+ (lastChild.name === name));
3576
3580
  }
3577
3581
  _buildPattern(node) {
3578
3582
  const type = node.name;