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.
@@ -2886,7 +2886,7 @@
2886
2886
  return this._postfixPatterns;
2887
2887
  }
2888
2888
  get binaryPatterns() {
2889
- return this._binaryPatterns;
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._binaryPatterns = [];
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._binaryPatterns.push(binary);
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._binaryPatterns.length; i++) {
3197
+ for (let i = 0; i < this._infixPatterns.length; i++) {
3198
3198
  cursor.moveTo(onIndex);
3199
- const pattern = this._binaryPatterns[i];
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._binaryPatterns.includes(childReference)) {
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
- if (postfixTokens.length === 0) {
3244
- return this._binaryPatterns.map(p => p.getTokens()).flat();
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 binaryTokens = this._binaryPatterns.map(p => p.getTokens()).flat();
3251
- return [...postfixTokens, ...binaryTokens];
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._binaryPatterns.includes(childReference)) {
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
- if (postfixPatterns.length === 0) {
3277
- return this._binaryPatterns.map(p => p.getPatterns()).flat();
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 binaryPatterns = this._binaryPatterns.map(p => p.getPatterns()).flat();
3284
- return [...postfixPatterns, ...binaryPatterns];
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
  }