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.browser.js +8 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +8 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/grammar/Grammar.test.ts +2 -1
- package/src/grammar/Grammar.ts +7 -4
- package/src/patterns/Expression.ts +2 -0
package/dist/index.browser.js
CHANGED
|
@@ -3031,7 +3031,9 @@
|
|
|
3031
3031
|
pattern = pattern.children[0];
|
|
3032
3032
|
}
|
|
3033
3033
|
if (pattern.type === "reference") {
|
|
3034
|
+
pattern.parent = this;
|
|
3034
3035
|
pattern = pattern.getReferencePatternSafely();
|
|
3036
|
+
pattern.parent = null;
|
|
3035
3037
|
}
|
|
3036
3038
|
return pattern;
|
|
3037
3039
|
}
|
|
@@ -3569,16 +3571,18 @@
|
|
|
3569
3571
|
return this._isRecursivePattern(name, pattern);
|
|
3570
3572
|
}
|
|
3571
3573
|
_isRecursivePattern(name, pattern) {
|
|
3574
|
+
if (pattern.type === "reference") {
|
|
3575
|
+
return true;
|
|
3576
|
+
}
|
|
3572
3577
|
if (pattern.children.length === 0) {
|
|
3573
3578
|
return false;
|
|
3574
3579
|
}
|
|
3575
3580
|
const firstChild = pattern.children[0];
|
|
3576
3581
|
const lastChild = pattern.children[pattern.children.length - 1];
|
|
3577
3582
|
const isLongEnough = pattern.children.length >= 2;
|
|
3578
|
-
return pattern.type === "
|
|
3579
|
-
(
|
|
3580
|
-
|
|
3581
|
-
(lastChild.name === name));
|
|
3583
|
+
return (pattern.type === "sequence" && isLongEnough &&
|
|
3584
|
+
(firstChild.name === name) ||
|
|
3585
|
+
(lastChild.name === name));
|
|
3582
3586
|
}
|
|
3583
3587
|
_buildPattern(node) {
|
|
3584
3588
|
const type = node.name;
|