clarity-pattern-parser 11.5.2 → 11.5.3
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 +25 -17
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +25 -17
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +25 -17
- package/dist/index.js.map +1 -1
- package/dist/patterns/Expression.d.ts +1 -1
- package/package.json +1 -1
- package/src/patterns/Expression.ts +28 -18
package/dist/index.js
CHANGED
|
@@ -2884,7 +2884,7 @@ class Expression {
|
|
|
2884
2884
|
return this._postfixPatterns;
|
|
2885
2885
|
}
|
|
2886
2886
|
get binaryPatterns() {
|
|
2887
|
-
return this.
|
|
2887
|
+
return this._infixPatterns;
|
|
2888
2888
|
}
|
|
2889
2889
|
get originalPatterns() {
|
|
2890
2890
|
return this._originalPatterns;
|
|
@@ -2908,7 +2908,7 @@ class Expression {
|
|
|
2908
2908
|
this._prefixNames = [];
|
|
2909
2909
|
this._postfixPatterns = [];
|
|
2910
2910
|
this._postfixNames = [];
|
|
2911
|
-
this.
|
|
2911
|
+
this._infixPatterns = [];
|
|
2912
2912
|
this._binaryNames = [];
|
|
2913
2913
|
this._associationMap = {};
|
|
2914
2914
|
this._precedenceMap = {};
|
|
@@ -2951,7 +2951,7 @@ class Expression {
|
|
|
2951
2951
|
const binary = this._extractBinary(pattern);
|
|
2952
2952
|
binary.parent = this;
|
|
2953
2953
|
this._precedenceMap[name] = index;
|
|
2954
|
-
this.
|
|
2954
|
+
this._infixPatterns.push(binary);
|
|
2955
2955
|
this._binaryNames.push(name);
|
|
2956
2956
|
if (pattern.type === "right-associated") {
|
|
2957
2957
|
this._associationMap[name] = Association.right;
|
|
@@ -3192,9 +3192,9 @@ class Expression {
|
|
|
3192
3192
|
if (this.binaryPatterns.length === 0) {
|
|
3193
3193
|
this._shouldStopParsing = true;
|
|
3194
3194
|
}
|
|
3195
|
-
for (let i = 0; i < this.
|
|
3195
|
+
for (let i = 0; i < this._infixPatterns.length; i++) {
|
|
3196
3196
|
cursor.moveTo(onIndex);
|
|
3197
|
-
const pattern = this.
|
|
3197
|
+
const pattern = this._infixPatterns[i];
|
|
3198
3198
|
const name = this._binaryNames[i];
|
|
3199
3199
|
const node = pattern.parse(cursor);
|
|
3200
3200
|
if (node != null) {
|
|
@@ -3231,22 +3231,26 @@ class Expression {
|
|
|
3231
3231
|
}
|
|
3232
3232
|
getTokensAfter(childReference) {
|
|
3233
3233
|
this.build();
|
|
3234
|
-
if (this._prefixPatterns.includes(childReference) || this.
|
|
3234
|
+
if (this._prefixPatterns.includes(childReference) || this._infixPatterns.includes(childReference)) {
|
|
3235
3235
|
const atomTokens = this._atomPatterns.map(p => p.getTokens()).flat();
|
|
3236
3236
|
const prefixTokens = this.prefixPatterns.map(p => p.getTokens()).flat();
|
|
3237
3237
|
return [...prefixTokens, ...atomTokens];
|
|
3238
3238
|
}
|
|
3239
3239
|
if (this._atomPatterns.includes(childReference)) {
|
|
3240
3240
|
const postfixTokens = this.postfixPatterns.map(p => p.getTokens()).flat();
|
|
3241
|
-
|
|
3242
|
-
|
|
3241
|
+
const infixTokens = this._infixPatterns.map(p => p.getTokens()).flat();
|
|
3242
|
+
if (this._parent != null) {
|
|
3243
|
+
return [...postfixTokens, ...infixTokens, ...this._parent.getNextTokens()];
|
|
3243
3244
|
}
|
|
3244
|
-
return postfixTokens;
|
|
3245
|
+
return [...postfixTokens, ...infixTokens];
|
|
3245
3246
|
}
|
|
3246
3247
|
if (this._postfixPatterns.includes(childReference)) {
|
|
3247
3248
|
const postfixTokens = this.postfixPatterns.map(p => p.getTokens()).flat();
|
|
3248
|
-
const
|
|
3249
|
-
|
|
3249
|
+
const infixTokens = this._infixPatterns.map(p => p.getTokens()).flat();
|
|
3250
|
+
if (this._parent != null) {
|
|
3251
|
+
return [...postfixTokens, ...infixTokens, ...this._parent.getNextTokens()];
|
|
3252
|
+
}
|
|
3253
|
+
return [...postfixTokens, ...infixTokens];
|
|
3250
3254
|
}
|
|
3251
3255
|
return [];
|
|
3252
3256
|
}
|
|
@@ -3264,22 +3268,26 @@ class Expression {
|
|
|
3264
3268
|
}
|
|
3265
3269
|
getPatternsAfter(childReference) {
|
|
3266
3270
|
this.build();
|
|
3267
|
-
if (this._prefixPatterns.includes(childReference) || this.
|
|
3271
|
+
if (this._prefixPatterns.includes(childReference) || this._infixPatterns.includes(childReference)) {
|
|
3268
3272
|
const atomPatterns = this._atomPatterns.map(p => p.getPatterns()).flat();
|
|
3269
3273
|
const prefixPatterns = this.prefixPatterns.map(p => p.getPatterns()).flat();
|
|
3270
3274
|
return [...prefixPatterns, ...atomPatterns];
|
|
3271
3275
|
}
|
|
3272
3276
|
if (this._atomPatterns.includes(childReference)) {
|
|
3273
3277
|
const postfixPatterns = this.postfixPatterns.map(p => p.getPatterns()).flat();
|
|
3274
|
-
|
|
3275
|
-
|
|
3278
|
+
const infixPatterns = this._infixPatterns.map(p => p.getPatterns()).flat();
|
|
3279
|
+
if (this._parent != null) {
|
|
3280
|
+
return [...postfixPatterns, ...infixPatterns, ...this._parent.getNextPatterns()];
|
|
3276
3281
|
}
|
|
3277
|
-
return postfixPatterns;
|
|
3282
|
+
return [...postfixPatterns, ...infixPatterns];
|
|
3278
3283
|
}
|
|
3279
3284
|
if (this._postfixPatterns.includes(childReference)) {
|
|
3280
3285
|
const postfixPatterns = this.postfixPatterns.map(p => p.getPatterns()).flat();
|
|
3281
|
-
const
|
|
3282
|
-
|
|
3286
|
+
const infixPatterns = this._infixPatterns.map(p => p.getPatterns()).flat();
|
|
3287
|
+
if (this._parent != null) {
|
|
3288
|
+
return [...postfixPatterns, ...infixPatterns, ...this._parent.getNextPatterns()];
|
|
3289
|
+
}
|
|
3290
|
+
return [...postfixPatterns, ...infixPatterns];
|
|
3283
3291
|
}
|
|
3284
3292
|
return [];
|
|
3285
3293
|
}
|