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