clarity-pattern-parser 11.0.19 → 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 +9 -5
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +9 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +9 -5
- 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 +3 -1
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
|
}
|
|
@@ -3036,7 +3038,7 @@ class Expression {
|
|
|
3036
3038
|
if (pattern == null) {
|
|
3037
3039
|
return false;
|
|
3038
3040
|
}
|
|
3039
|
-
return pattern.
|
|
3041
|
+
return pattern.name === this.name;
|
|
3040
3042
|
}
|
|
3041
3043
|
parse(cursor) {
|
|
3042
3044
|
this._firstIndex = cursor.index;
|
|
@@ -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 === "
|
|
3573
|
-
(
|
|
3574
|
-
|
|
3575
|
-
(lastChild.type === "reference" && 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;
|