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.browser.js
CHANGED
|
@@ -2903,6 +2903,7 @@
|
|
|
2903
2903
|
this._name = name;
|
|
2904
2904
|
this._originalName = name;
|
|
2905
2905
|
this._parent = null;
|
|
2906
|
+
this._cachedParent = null;
|
|
2906
2907
|
this._firstIndex = 0;
|
|
2907
2908
|
this._atomPatterns = [];
|
|
2908
2909
|
this._prefixPatterns = [];
|
|
@@ -3053,7 +3054,8 @@
|
|
|
3053
3054
|
return pattern.name === this._originalName;
|
|
3054
3055
|
}
|
|
3055
3056
|
build() {
|
|
3056
|
-
if (!this._hasOrganized) {
|
|
3057
|
+
if (!this._hasOrganized || this._cachedParent !== this.parent) {
|
|
3058
|
+
this._cachedParent = this.parent;
|
|
3057
3059
|
this._hasOrganized = true;
|
|
3058
3060
|
this._organizePatterns(this._originalPatterns);
|
|
3059
3061
|
this._cacheAncestors();
|
|
@@ -3224,18 +3226,20 @@
|
|
|
3224
3226
|
return execPattern(this, text, record);
|
|
3225
3227
|
}
|
|
3226
3228
|
getTokens() {
|
|
3229
|
+
this.build();
|
|
3227
3230
|
const atomTokens = this._atomPatterns.map(p => p.getTokens()).flat();
|
|
3228
3231
|
const prefixTokens = this.prefixPatterns.map(p => p.getTokens()).flat();
|
|
3229
3232
|
return [...prefixTokens, ...atomTokens];
|
|
3230
3233
|
}
|
|
3231
3234
|
getTokensAfter(childReference) {
|
|
3235
|
+
this.build();
|
|
3232
3236
|
if (this._prefixPatterns.includes(childReference) || this._binaryPatterns.includes(childReference)) {
|
|
3233
3237
|
const atomTokens = this._atomPatterns.map(p => p.getTokens()).flat();
|
|
3234
3238
|
const prefixTokens = this.prefixPatterns.map(p => p.getTokens()).flat();
|
|
3235
3239
|
return [...prefixTokens, ...atomTokens];
|
|
3236
3240
|
}
|
|
3237
3241
|
if (this._atomPatterns.includes(childReference)) {
|
|
3238
|
-
const postfixTokens = this.
|
|
3242
|
+
const postfixTokens = this.postfixPatterns.map(p => p.getTokens()).flat();
|
|
3239
3243
|
if (postfixTokens.length === 0) {
|
|
3240
3244
|
return this._binaryPatterns.map(p => p.getTokens()).flat();
|
|
3241
3245
|
}
|
|
@@ -3255,27 +3259,29 @@
|
|
|
3255
3259
|
return this._parent.getTokensAfter(this);
|
|
3256
3260
|
}
|
|
3257
3261
|
getPatterns() {
|
|
3262
|
+
this.build();
|
|
3258
3263
|
const atomPatterns = this._atomPatterns.map(p => p.getPatterns()).flat();
|
|
3259
3264
|
const prefixPatterns = this.prefixPatterns.map(p => p.getPatterns()).flat();
|
|
3260
3265
|
return [...prefixPatterns, ...atomPatterns];
|
|
3261
3266
|
}
|
|
3262
3267
|
getPatternsAfter(childReference) {
|
|
3268
|
+
this.build();
|
|
3263
3269
|
if (this._prefixPatterns.includes(childReference) || this._binaryPatterns.includes(childReference)) {
|
|
3264
3270
|
const atomPatterns = this._atomPatterns.map(p => p.getPatterns()).flat();
|
|
3265
3271
|
const prefixPatterns = this.prefixPatterns.map(p => p.getPatterns()).flat();
|
|
3266
3272
|
return [...prefixPatterns, ...atomPatterns];
|
|
3267
3273
|
}
|
|
3268
3274
|
if (this._atomPatterns.includes(childReference)) {
|
|
3269
|
-
const postfixPatterns = this.
|
|
3275
|
+
const postfixPatterns = this.postfixPatterns.map(p => p.getPatterns()).flat();
|
|
3270
3276
|
if (postfixPatterns.length === 0) {
|
|
3271
3277
|
return this._binaryPatterns.map(p => p.getPatterns()).flat();
|
|
3272
3278
|
}
|
|
3273
3279
|
return postfixPatterns;
|
|
3274
3280
|
}
|
|
3275
3281
|
if (this._postfixPatterns.includes(childReference)) {
|
|
3276
|
-
const
|
|
3282
|
+
const postfixPatterns = this.postfixPatterns.map(p => p.getPatterns()).flat();
|
|
3277
3283
|
const binaryPatterns = this._binaryPatterns.map(p => p.getPatterns()).flat();
|
|
3278
|
-
return [...
|
|
3284
|
+
return [...postfixPatterns, ...binaryPatterns];
|
|
3279
3285
|
}
|
|
3280
3286
|
return [];
|
|
3281
3287
|
}
|