clarity-pattern-parser 10.1.20 → 10.1.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
@@ -1044,8 +1044,11 @@ class Options {
1044
1044
  }
1045
1045
  getTokens() {
1046
1046
  const tokens = [];
1047
- for (const child of this._children) {
1048
- tokens.push(...child.getTokens());
1047
+ for (const pattern of this._children) {
1048
+ if (pattern.type === "reference" && pattern.name === this.name) {
1049
+ continue;
1050
+ }
1051
+ tokens.push(...pattern.getTokens());
1049
1052
  }
1050
1053
  return tokens;
1051
1054
  }
@@ -1064,6 +1067,9 @@ class Options {
1064
1067
  getPatterns() {
1065
1068
  const patterns = [];
1066
1069
  for (const pattern of this._children) {
1070
+ if (pattern.type === "reference" && pattern.name === this.name) {
1071
+ continue;
1072
+ }
1067
1073
  patterns.push(...pattern.getPatterns());
1068
1074
  }
1069
1075
  return patterns;
@@ -1791,9 +1797,12 @@ class Sequence {
1791
1797
  }
1792
1798
  getTokens() {
1793
1799
  const tokens = [];
1794
- for (const child of this._children) {
1795
- tokens.push(...child.getTokens());
1796
- if (child.type !== "optional" && child.type !== "not") {
1800
+ for (const pattern of this._children) {
1801
+ if (pattern.type === "reference" && pattern.name === this.name && pattern === this.children[0]) {
1802
+ return tokens;
1803
+ }
1804
+ tokens.push(...pattern.getTokens());
1805
+ if (pattern.type !== "optional" && pattern.type !== "not") {
1797
1806
  break;
1798
1807
  }
1799
1808
  }
@@ -1813,9 +1822,12 @@ class Sequence {
1813
1822
  }
1814
1823
  getPatterns() {
1815
1824
  const patterns = [];
1816
- for (const child of this._children) {
1817
- patterns.push(...child.getPatterns());
1818
- if (child.type !== "optional" && child.type !== "not") {
1825
+ for (const pattern of this._children) {
1826
+ if (pattern.type === "reference" && pattern.name === this.name && pattern === this.children[0]) {
1827
+ return patterns;
1828
+ }
1829
+ patterns.push(...pattern.getPatterns());
1830
+ if (pattern.type !== "optional" && pattern.type !== "not") {
1819
1831
  break;
1820
1832
  }
1821
1833
  }