clarity-pattern-parser 10.3.4 → 10.3.6
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 +12 -6
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +12 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/dist/patterns/ExpressionPattern.d.ts +2 -1
- package/package.json +1 -1
- package/src/patterns/ExpressionPattern.ts +14 -6
package/dist/index.esm.js
CHANGED
|
@@ -2796,7 +2796,10 @@ class ExpressionPattern {
|
|
|
2796
2796
|
get children() {
|
|
2797
2797
|
return this._patterns;
|
|
2798
2798
|
}
|
|
2799
|
-
get
|
|
2799
|
+
get unaryPrefixPatterns() {
|
|
2800
|
+
return this._unaryPrefixPatterns;
|
|
2801
|
+
}
|
|
2802
|
+
get atomPatterns() {
|
|
2800
2803
|
return this._atomPatterns;
|
|
2801
2804
|
}
|
|
2802
2805
|
get binaryPatterns() {
|
|
@@ -2841,7 +2844,7 @@ class ExpressionPattern {
|
|
|
2841
2844
|
this._shouldCompactPatternsMap[pattern.name] = pattern.shouldCompactAst;
|
|
2842
2845
|
if (this._isUnary(pattern)) {
|
|
2843
2846
|
const unaryPrefix = this._extractUnaryPrefixPattern(pattern).clone();
|
|
2844
|
-
this._unaryPrefixPatterns.push(
|
|
2847
|
+
this._unaryPrefixPatterns.push(unaryPrefix);
|
|
2845
2848
|
this._unaryPrefixNames.push(pattern.name);
|
|
2846
2849
|
unaryPrefix.parent = this;
|
|
2847
2850
|
finalPatterns.push(unaryPrefix);
|
|
@@ -3046,6 +3049,9 @@ class ExpressionPattern {
|
|
|
3046
3049
|
break;
|
|
3047
3050
|
}
|
|
3048
3051
|
onIndex = cursor.index;
|
|
3052
|
+
if (prefix != null && this._recursivePatterns.length === 0) {
|
|
3053
|
+
lastAtomNode = createNode(prefixName, [prefix, lastAtomNode]);
|
|
3054
|
+
}
|
|
3049
3055
|
for (let i = 0; i < this._recursivePatterns.length; i++) {
|
|
3050
3056
|
const pattern = this._recursivePatterns[i];
|
|
3051
3057
|
const node = pattern.parse(cursor);
|
|
@@ -3210,10 +3216,10 @@ class ExpressionPattern {
|
|
|
3210
3216
|
};
|
|
3211
3217
|
}
|
|
3212
3218
|
getTokens() {
|
|
3213
|
-
return this.
|
|
3219
|
+
return this.atomPatterns.map(p => p.getTokens()).flat();
|
|
3214
3220
|
}
|
|
3215
3221
|
getTokensAfter(childReference) {
|
|
3216
|
-
if (this.
|
|
3222
|
+
if (this.atomPatterns.indexOf(childReference)) {
|
|
3217
3223
|
const recursiveTokens = this._recursivePatterns.map(p => p.getTokens()).flat();
|
|
3218
3224
|
const binaryTokens = this._binaryPatterns.map(p => p.getTokens()).flat();
|
|
3219
3225
|
return [...recursiveTokens, ...binaryTokens];
|
|
@@ -3238,10 +3244,10 @@ class ExpressionPattern {
|
|
|
3238
3244
|
return this._parent.getTokensAfter(this);
|
|
3239
3245
|
}
|
|
3240
3246
|
getPatterns() {
|
|
3241
|
-
return this.
|
|
3247
|
+
return this.atomPatterns.map(p => p.getPatterns()).flat();
|
|
3242
3248
|
}
|
|
3243
3249
|
getPatternsAfter(childReference) {
|
|
3244
|
-
if (this.
|
|
3250
|
+
if (this.atomPatterns.indexOf(childReference)) {
|
|
3245
3251
|
const recursivePatterns = this._recursivePatterns.map(p => p.getPatterns()).flat();
|
|
3246
3252
|
const binaryPatterns = this._binaryPatterns.map(p => p.getPatterns()).flat();
|
|
3247
3253
|
return [...recursivePatterns, ...binaryPatterns];
|