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.browser.js
CHANGED
|
@@ -2886,7 +2886,7 @@
|
|
|
2886
2886
|
return this._postfixPatterns;
|
|
2887
2887
|
}
|
|
2888
2888
|
get binaryPatterns() {
|
|
2889
|
-
return this.
|
|
2889
|
+
return this._infixPatterns;
|
|
2890
2890
|
}
|
|
2891
2891
|
get originalPatterns() {
|
|
2892
2892
|
return this._originalPatterns;
|
|
@@ -2910,7 +2910,7 @@
|
|
|
2910
2910
|
this._prefixNames = [];
|
|
2911
2911
|
this._postfixPatterns = [];
|
|
2912
2912
|
this._postfixNames = [];
|
|
2913
|
-
this.
|
|
2913
|
+
this._infixPatterns = [];
|
|
2914
2914
|
this._binaryNames = [];
|
|
2915
2915
|
this._associationMap = {};
|
|
2916
2916
|
this._precedenceMap = {};
|
|
@@ -2953,7 +2953,7 @@
|
|
|
2953
2953
|
const binary = this._extractBinary(pattern);
|
|
2954
2954
|
binary.parent = this;
|
|
2955
2955
|
this._precedenceMap[name] = index;
|
|
2956
|
-
this.
|
|
2956
|
+
this._infixPatterns.push(binary);
|
|
2957
2957
|
this._binaryNames.push(name);
|
|
2958
2958
|
if (pattern.type === "right-associated") {
|
|
2959
2959
|
this._associationMap[name] = Association.right;
|
|
@@ -3194,9 +3194,9 @@
|
|
|
3194
3194
|
if (this.binaryPatterns.length === 0) {
|
|
3195
3195
|
this._shouldStopParsing = true;
|
|
3196
3196
|
}
|
|
3197
|
-
for (let i = 0; i < this.
|
|
3197
|
+
for (let i = 0; i < this._infixPatterns.length; i++) {
|
|
3198
3198
|
cursor.moveTo(onIndex);
|
|
3199
|
-
const pattern = this.
|
|
3199
|
+
const pattern = this._infixPatterns[i];
|
|
3200
3200
|
const name = this._binaryNames[i];
|
|
3201
3201
|
const node = pattern.parse(cursor);
|
|
3202
3202
|
if (node != null) {
|
|
@@ -3233,22 +3233,26 @@
|
|
|
3233
3233
|
}
|
|
3234
3234
|
getTokensAfter(childReference) {
|
|
3235
3235
|
this.build();
|
|
3236
|
-
if (this._prefixPatterns.includes(childReference) || this.
|
|
3236
|
+
if (this._prefixPatterns.includes(childReference) || this._infixPatterns.includes(childReference)) {
|
|
3237
3237
|
const atomTokens = this._atomPatterns.map(p => p.getTokens()).flat();
|
|
3238
3238
|
const prefixTokens = this.prefixPatterns.map(p => p.getTokens()).flat();
|
|
3239
3239
|
return [...prefixTokens, ...atomTokens];
|
|
3240
3240
|
}
|
|
3241
3241
|
if (this._atomPatterns.includes(childReference)) {
|
|
3242
3242
|
const postfixTokens = this.postfixPatterns.map(p => p.getTokens()).flat();
|
|
3243
|
-
|
|
3244
|
-
|
|
3243
|
+
const infixTokens = this._infixPatterns.map(p => p.getTokens()).flat();
|
|
3244
|
+
if (this._parent != null) {
|
|
3245
|
+
return [...postfixTokens, ...infixTokens, ...this._parent.getNextTokens()];
|
|
3245
3246
|
}
|
|
3246
|
-
return postfixTokens;
|
|
3247
|
+
return [...postfixTokens, ...infixTokens];
|
|
3247
3248
|
}
|
|
3248
3249
|
if (this._postfixPatterns.includes(childReference)) {
|
|
3249
3250
|
const postfixTokens = this.postfixPatterns.map(p => p.getTokens()).flat();
|
|
3250
|
-
const
|
|
3251
|
-
|
|
3251
|
+
const infixTokens = this._infixPatterns.map(p => p.getTokens()).flat();
|
|
3252
|
+
if (this._parent != null) {
|
|
3253
|
+
return [...postfixTokens, ...infixTokens, ...this._parent.getNextTokens()];
|
|
3254
|
+
}
|
|
3255
|
+
return [...postfixTokens, ...infixTokens];
|
|
3252
3256
|
}
|
|
3253
3257
|
return [];
|
|
3254
3258
|
}
|
|
@@ -3266,22 +3270,26 @@
|
|
|
3266
3270
|
}
|
|
3267
3271
|
getPatternsAfter(childReference) {
|
|
3268
3272
|
this.build();
|
|
3269
|
-
if (this._prefixPatterns.includes(childReference) || this.
|
|
3273
|
+
if (this._prefixPatterns.includes(childReference) || this._infixPatterns.includes(childReference)) {
|
|
3270
3274
|
const atomPatterns = this._atomPatterns.map(p => p.getPatterns()).flat();
|
|
3271
3275
|
const prefixPatterns = this.prefixPatterns.map(p => p.getPatterns()).flat();
|
|
3272
3276
|
return [...prefixPatterns, ...atomPatterns];
|
|
3273
3277
|
}
|
|
3274
3278
|
if (this._atomPatterns.includes(childReference)) {
|
|
3275
3279
|
const postfixPatterns = this.postfixPatterns.map(p => p.getPatterns()).flat();
|
|
3276
|
-
|
|
3277
|
-
|
|
3280
|
+
const infixPatterns = this._infixPatterns.map(p => p.getPatterns()).flat();
|
|
3281
|
+
if (this._parent != null) {
|
|
3282
|
+
return [...postfixPatterns, ...infixPatterns, ...this._parent.getNextPatterns()];
|
|
3278
3283
|
}
|
|
3279
|
-
return postfixPatterns;
|
|
3284
|
+
return [...postfixPatterns, ...infixPatterns];
|
|
3280
3285
|
}
|
|
3281
3286
|
if (this._postfixPatterns.includes(childReference)) {
|
|
3282
3287
|
const postfixPatterns = this.postfixPatterns.map(p => p.getPatterns()).flat();
|
|
3283
|
-
const
|
|
3284
|
-
|
|
3288
|
+
const infixPatterns = this._infixPatterns.map(p => p.getPatterns()).flat();
|
|
3289
|
+
if (this._parent != null) {
|
|
3290
|
+
return [...postfixPatterns, ...infixPatterns, ...this._parent.getNextPatterns()];
|
|
3291
|
+
}
|
|
3292
|
+
return [...postfixPatterns, ...infixPatterns];
|
|
3285
3293
|
}
|
|
3286
3294
|
return [];
|
|
3287
3295
|
}
|