clarity-pattern-parser 11.5.0 → 11.5.2
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 +11 -5
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +11 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/dist/patterns/Expression.d.ts +1 -0
- package/package.json +1 -1
- package/src/patterns/Expression.ts +12 -5
package/dist/index.esm.js
CHANGED
|
@@ -2897,6 +2897,7 @@ class Expression {
|
|
|
2897
2897
|
this._name = name;
|
|
2898
2898
|
this._originalName = name;
|
|
2899
2899
|
this._parent = null;
|
|
2900
|
+
this._cachedParent = null;
|
|
2900
2901
|
this._firstIndex = 0;
|
|
2901
2902
|
this._atomPatterns = [];
|
|
2902
2903
|
this._prefixPatterns = [];
|
|
@@ -3047,7 +3048,8 @@ class Expression {
|
|
|
3047
3048
|
return pattern.name === this._originalName;
|
|
3048
3049
|
}
|
|
3049
3050
|
build() {
|
|
3050
|
-
if (!this._hasOrganized) {
|
|
3051
|
+
if (!this._hasOrganized || this._cachedParent !== this.parent) {
|
|
3052
|
+
this._cachedParent = this.parent;
|
|
3051
3053
|
this._hasOrganized = true;
|
|
3052
3054
|
this._organizePatterns(this._originalPatterns);
|
|
3053
3055
|
this._cacheAncestors();
|
|
@@ -3218,18 +3220,20 @@ class Expression {
|
|
|
3218
3220
|
return execPattern(this, text, record);
|
|
3219
3221
|
}
|
|
3220
3222
|
getTokens() {
|
|
3223
|
+
this.build();
|
|
3221
3224
|
const atomTokens = this._atomPatterns.map(p => p.getTokens()).flat();
|
|
3222
3225
|
const prefixTokens = this.prefixPatterns.map(p => p.getTokens()).flat();
|
|
3223
3226
|
return [...prefixTokens, ...atomTokens];
|
|
3224
3227
|
}
|
|
3225
3228
|
getTokensAfter(childReference) {
|
|
3229
|
+
this.build();
|
|
3226
3230
|
if (this._prefixPatterns.includes(childReference) || this._binaryPatterns.includes(childReference)) {
|
|
3227
3231
|
const atomTokens = this._atomPatterns.map(p => p.getTokens()).flat();
|
|
3228
3232
|
const prefixTokens = this.prefixPatterns.map(p => p.getTokens()).flat();
|
|
3229
3233
|
return [...prefixTokens, ...atomTokens];
|
|
3230
3234
|
}
|
|
3231
3235
|
if (this._atomPatterns.includes(childReference)) {
|
|
3232
|
-
const postfixTokens = this.
|
|
3236
|
+
const postfixTokens = this.postfixPatterns.map(p => p.getTokens()).flat();
|
|
3233
3237
|
if (postfixTokens.length === 0) {
|
|
3234
3238
|
return this._binaryPatterns.map(p => p.getTokens()).flat();
|
|
3235
3239
|
}
|
|
@@ -3249,27 +3253,29 @@ class Expression {
|
|
|
3249
3253
|
return this._parent.getTokensAfter(this);
|
|
3250
3254
|
}
|
|
3251
3255
|
getPatterns() {
|
|
3256
|
+
this.build();
|
|
3252
3257
|
const atomPatterns = this._atomPatterns.map(p => p.getPatterns()).flat();
|
|
3253
3258
|
const prefixPatterns = this.prefixPatterns.map(p => p.getPatterns()).flat();
|
|
3254
3259
|
return [...prefixPatterns, ...atomPatterns];
|
|
3255
3260
|
}
|
|
3256
3261
|
getPatternsAfter(childReference) {
|
|
3262
|
+
this.build();
|
|
3257
3263
|
if (this._prefixPatterns.includes(childReference) || this._binaryPatterns.includes(childReference)) {
|
|
3258
3264
|
const atomPatterns = this._atomPatterns.map(p => p.getPatterns()).flat();
|
|
3259
3265
|
const prefixPatterns = this.prefixPatterns.map(p => p.getPatterns()).flat();
|
|
3260
3266
|
return [...prefixPatterns, ...atomPatterns];
|
|
3261
3267
|
}
|
|
3262
3268
|
if (this._atomPatterns.includes(childReference)) {
|
|
3263
|
-
const postfixPatterns = this.
|
|
3269
|
+
const postfixPatterns = this.postfixPatterns.map(p => p.getPatterns()).flat();
|
|
3264
3270
|
if (postfixPatterns.length === 0) {
|
|
3265
3271
|
return this._binaryPatterns.map(p => p.getPatterns()).flat();
|
|
3266
3272
|
}
|
|
3267
3273
|
return postfixPatterns;
|
|
3268
3274
|
}
|
|
3269
3275
|
if (this._postfixPatterns.includes(childReference)) {
|
|
3270
|
-
const
|
|
3276
|
+
const postfixPatterns = this.postfixPatterns.map(p => p.getPatterns()).flat();
|
|
3271
3277
|
const binaryPatterns = this._binaryPatterns.map(p => p.getPatterns()).flat();
|
|
3272
|
-
return [...
|
|
3278
|
+
return [...postfixPatterns, ...binaryPatterns];
|
|
3273
3279
|
}
|
|
3274
3280
|
return [];
|
|
3275
3281
|
}
|