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.js
CHANGED
|
@@ -2800,7 +2800,10 @@ class ExpressionPattern {
|
|
|
2800
2800
|
get children() {
|
|
2801
2801
|
return this._patterns;
|
|
2802
2802
|
}
|
|
2803
|
-
get
|
|
2803
|
+
get unaryPrefixPatterns() {
|
|
2804
|
+
return this._unaryPrefixPatterns;
|
|
2805
|
+
}
|
|
2806
|
+
get atomPatterns() {
|
|
2804
2807
|
return this._atomPatterns;
|
|
2805
2808
|
}
|
|
2806
2809
|
get binaryPatterns() {
|
|
@@ -2845,7 +2848,7 @@ class ExpressionPattern {
|
|
|
2845
2848
|
this._shouldCompactPatternsMap[pattern.name] = pattern.shouldCompactAst;
|
|
2846
2849
|
if (this._isUnary(pattern)) {
|
|
2847
2850
|
const unaryPrefix = this._extractUnaryPrefixPattern(pattern).clone();
|
|
2848
|
-
this._unaryPrefixPatterns.push(
|
|
2851
|
+
this._unaryPrefixPatterns.push(unaryPrefix);
|
|
2849
2852
|
this._unaryPrefixNames.push(pattern.name);
|
|
2850
2853
|
unaryPrefix.parent = this;
|
|
2851
2854
|
finalPatterns.push(unaryPrefix);
|
|
@@ -3050,6 +3053,9 @@ class ExpressionPattern {
|
|
|
3050
3053
|
break;
|
|
3051
3054
|
}
|
|
3052
3055
|
onIndex = cursor.index;
|
|
3056
|
+
if (prefix != null && this._recursivePatterns.length === 0) {
|
|
3057
|
+
lastAtomNode = createNode(prefixName, [prefix, lastAtomNode]);
|
|
3058
|
+
}
|
|
3053
3059
|
for (let i = 0; i < this._recursivePatterns.length; i++) {
|
|
3054
3060
|
const pattern = this._recursivePatterns[i];
|
|
3055
3061
|
const node = pattern.parse(cursor);
|
|
@@ -3214,10 +3220,10 @@ class ExpressionPattern {
|
|
|
3214
3220
|
};
|
|
3215
3221
|
}
|
|
3216
3222
|
getTokens() {
|
|
3217
|
-
return this.
|
|
3223
|
+
return this.atomPatterns.map(p => p.getTokens()).flat();
|
|
3218
3224
|
}
|
|
3219
3225
|
getTokensAfter(childReference) {
|
|
3220
|
-
if (this.
|
|
3226
|
+
if (this.atomPatterns.indexOf(childReference)) {
|
|
3221
3227
|
const recursiveTokens = this._recursivePatterns.map(p => p.getTokens()).flat();
|
|
3222
3228
|
const binaryTokens = this._binaryPatterns.map(p => p.getTokens()).flat();
|
|
3223
3229
|
return [...recursiveTokens, ...binaryTokens];
|
|
@@ -3242,10 +3248,10 @@ class ExpressionPattern {
|
|
|
3242
3248
|
return this._parent.getTokensAfter(this);
|
|
3243
3249
|
}
|
|
3244
3250
|
getPatterns() {
|
|
3245
|
-
return this.
|
|
3251
|
+
return this.atomPatterns.map(p => p.getPatterns()).flat();
|
|
3246
3252
|
}
|
|
3247
3253
|
getPatternsAfter(childReference) {
|
|
3248
|
-
if (this.
|
|
3254
|
+
if (this.atomPatterns.indexOf(childReference)) {
|
|
3249
3255
|
const recursivePatterns = this._recursivePatterns.map(p => p.getPatterns()).flat();
|
|
3250
3256
|
const binaryPatterns = this._binaryPatterns.map(p => p.getPatterns()).flat();
|
|
3251
3257
|
return [...recursivePatterns, ...binaryPatterns];
|