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.esm.js CHANGED
@@ -2880,7 +2880,7 @@ class Expression {
2880
2880
  return this._postfixPatterns;
2881
2881
  }
2882
2882
  get binaryPatterns() {
2883
- return this._binaryPatterns;
2883
+ return this._infixPatterns;
2884
2884
  }
2885
2885
  get originalPatterns() {
2886
2886
  return this._originalPatterns;
@@ -2904,7 +2904,7 @@ class Expression {
2904
2904
  this._prefixNames = [];
2905
2905
  this._postfixPatterns = [];
2906
2906
  this._postfixNames = [];
2907
- this._binaryPatterns = [];
2907
+ this._infixPatterns = [];
2908
2908
  this._binaryNames = [];
2909
2909
  this._associationMap = {};
2910
2910
  this._precedenceMap = {};
@@ -2947,7 +2947,7 @@ class Expression {
2947
2947
  const binary = this._extractBinary(pattern);
2948
2948
  binary.parent = this;
2949
2949
  this._precedenceMap[name] = index;
2950
- this._binaryPatterns.push(binary);
2950
+ this._infixPatterns.push(binary);
2951
2951
  this._binaryNames.push(name);
2952
2952
  if (pattern.type === "right-associated") {
2953
2953
  this._associationMap[name] = Association.right;
@@ -3188,9 +3188,9 @@ class Expression {
3188
3188
  if (this.binaryPatterns.length === 0) {
3189
3189
  this._shouldStopParsing = true;
3190
3190
  }
3191
- for (let i = 0; i < this._binaryPatterns.length; i++) {
3191
+ for (let i = 0; i < this._infixPatterns.length; i++) {
3192
3192
  cursor.moveTo(onIndex);
3193
- const pattern = this._binaryPatterns[i];
3193
+ const pattern = this._infixPatterns[i];
3194
3194
  const name = this._binaryNames[i];
3195
3195
  const node = pattern.parse(cursor);
3196
3196
  if (node != null) {
@@ -3227,22 +3227,26 @@ class Expression {
3227
3227
  }
3228
3228
  getTokensAfter(childReference) {
3229
3229
  this.build();
3230
- if (this._prefixPatterns.includes(childReference) || this._binaryPatterns.includes(childReference)) {
3230
+ if (this._prefixPatterns.includes(childReference) || this._infixPatterns.includes(childReference)) {
3231
3231
  const atomTokens = this._atomPatterns.map(p => p.getTokens()).flat();
3232
3232
  const prefixTokens = this.prefixPatterns.map(p => p.getTokens()).flat();
3233
3233
  return [...prefixTokens, ...atomTokens];
3234
3234
  }
3235
3235
  if (this._atomPatterns.includes(childReference)) {
3236
3236
  const postfixTokens = this.postfixPatterns.map(p => p.getTokens()).flat();
3237
- if (postfixTokens.length === 0) {
3238
- return this._binaryPatterns.map(p => p.getTokens()).flat();
3237
+ const infixTokens = this._infixPatterns.map(p => p.getTokens()).flat();
3238
+ if (this._parent != null) {
3239
+ return [...postfixTokens, ...infixTokens, ...this._parent.getNextTokens()];
3239
3240
  }
3240
- return postfixTokens;
3241
+ return [...postfixTokens, ...infixTokens];
3241
3242
  }
3242
3243
  if (this._postfixPatterns.includes(childReference)) {
3243
3244
  const postfixTokens = this.postfixPatterns.map(p => p.getTokens()).flat();
3244
- const binaryTokens = this._binaryPatterns.map(p => p.getTokens()).flat();
3245
- return [...postfixTokens, ...binaryTokens];
3245
+ const infixTokens = this._infixPatterns.map(p => p.getTokens()).flat();
3246
+ if (this._parent != null) {
3247
+ return [...postfixTokens, ...infixTokens, ...this._parent.getNextTokens()];
3248
+ }
3249
+ return [...postfixTokens, ...infixTokens];
3246
3250
  }
3247
3251
  return [];
3248
3252
  }
@@ -3260,22 +3264,26 @@ class Expression {
3260
3264
  }
3261
3265
  getPatternsAfter(childReference) {
3262
3266
  this.build();
3263
- if (this._prefixPatterns.includes(childReference) || this._binaryPatterns.includes(childReference)) {
3267
+ if (this._prefixPatterns.includes(childReference) || this._infixPatterns.includes(childReference)) {
3264
3268
  const atomPatterns = this._atomPatterns.map(p => p.getPatterns()).flat();
3265
3269
  const prefixPatterns = this.prefixPatterns.map(p => p.getPatterns()).flat();
3266
3270
  return [...prefixPatterns, ...atomPatterns];
3267
3271
  }
3268
3272
  if (this._atomPatterns.includes(childReference)) {
3269
3273
  const postfixPatterns = this.postfixPatterns.map(p => p.getPatterns()).flat();
3270
- if (postfixPatterns.length === 0) {
3271
- return this._binaryPatterns.map(p => p.getPatterns()).flat();
3274
+ const infixPatterns = this._infixPatterns.map(p => p.getPatterns()).flat();
3275
+ if (this._parent != null) {
3276
+ return [...postfixPatterns, ...infixPatterns, ...this._parent.getNextPatterns()];
3272
3277
  }
3273
- return postfixPatterns;
3278
+ return [...postfixPatterns, ...infixPatterns];
3274
3279
  }
3275
3280
  if (this._postfixPatterns.includes(childReference)) {
3276
3281
  const postfixPatterns = this.postfixPatterns.map(p => p.getPatterns()).flat();
3277
- const binaryPatterns = this._binaryPatterns.map(p => p.getPatterns()).flat();
3278
- return [...postfixPatterns, ...binaryPatterns];
3282
+ const infixPatterns = this._infixPatterns.map(p => p.getPatterns()).flat();
3283
+ if (this._parent != null) {
3284
+ return [...postfixPatterns, ...infixPatterns, ...this._parent.getNextPatterns()];
3285
+ }
3286
+ return [...postfixPatterns, ...infixPatterns];
3279
3287
  }
3280
3288
  return [];
3281
3289
  }