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.js CHANGED
@@ -1048,8 +1048,11 @@ class Options {
1048
1048
  }
1049
1049
  getTokens() {
1050
1050
  const tokens = [];
1051
- for (const child of this._children) {
1052
- tokens.push(...child.getTokens());
1051
+ for (const pattern of this._children) {
1052
+ if (pattern.type === "reference" && pattern.name === this.name) {
1053
+ continue;
1054
+ }
1055
+ tokens.push(...pattern.getTokens());
1053
1056
  }
1054
1057
  return tokens;
1055
1058
  }
@@ -1068,6 +1071,9 @@ class Options {
1068
1071
  getPatterns() {
1069
1072
  const patterns = [];
1070
1073
  for (const pattern of this._children) {
1074
+ if (pattern.type === "reference" && pattern.name === this.name) {
1075
+ continue;
1076
+ }
1071
1077
  patterns.push(...pattern.getPatterns());
1072
1078
  }
1073
1079
  return patterns;
@@ -1795,9 +1801,12 @@ class Sequence {
1795
1801
  }
1796
1802
  getTokens() {
1797
1803
  const tokens = [];
1798
- for (const child of this._children) {
1799
- tokens.push(...child.getTokens());
1800
- if (child.type !== "optional" && child.type !== "not") {
1804
+ for (const pattern of this._children) {
1805
+ if (pattern.type === "reference" && pattern.name === this.name && pattern === this.children[0]) {
1806
+ return tokens;
1807
+ }
1808
+ tokens.push(...pattern.getTokens());
1809
+ if (pattern.type !== "optional" && pattern.type !== "not") {
1801
1810
  break;
1802
1811
  }
1803
1812
  }
@@ -1817,9 +1826,12 @@ class Sequence {
1817
1826
  }
1818
1827
  getPatterns() {
1819
1828
  const patterns = [];
1820
- for (const child of this._children) {
1821
- patterns.push(...child.getPatterns());
1822
- if (child.type !== "optional" && child.type !== "not") {
1829
+ for (const pattern of this._children) {
1830
+ if (pattern.type === "reference" && pattern.name === this.name && pattern === this.children[0]) {
1831
+ return patterns;
1832
+ }
1833
+ patterns.push(...pattern.getPatterns());
1834
+ if (pattern.type !== "optional" && pattern.type !== "not") {
1823
1835
  break;
1824
1836
  }
1825
1837
  }