clarity-pattern-parser 11.0.4 → 11.0.5

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.
@@ -2930,12 +2930,12 @@
2930
2930
  this._postfixNames = [];
2931
2931
  this._binaryPatterns = [];
2932
2932
  this._binaryNames = [];
2933
- this.associationMap = {};
2933
+ this._associationMap = {};
2934
2934
  this._precedenceMap = {};
2935
2935
  this._originalPatterns = patterns;
2936
2936
  this._patterns = this._organizePatterns(patterns);
2937
2937
  this._shouldStopParsing = false;
2938
- this._precedenceTree = new PrecedenceTree(this._precedenceMap, this.associationMap);
2938
+ this._precedenceTree = new PrecedenceTree(this._precedenceMap, this._associationMap);
2939
2939
  if (this._atomPatterns.length === 0) {
2940
2940
  throw new Error("Need at least one terminating pattern with an 'expression' pattern.");
2941
2941
  }
@@ -2973,10 +2973,10 @@
2973
2973
  this._binaryPatterns.push(clone);
2974
2974
  this._binaryNames.push(name);
2975
2975
  if (pattern.type === "right-associated") {
2976
- this.associationMap[name] = Association.right;
2976
+ this._associationMap[name] = Association.right;
2977
2977
  }
2978
2978
  else {
2979
- this.associationMap[name] = Association.left;
2979
+ this._associationMap[name] = Association.left;
2980
2980
  }
2981
2981
  finalPatterns.push(clone);
2982
2982
  }
@@ -3221,7 +3221,24 @@
3221
3221
  getTokens() {
3222
3222
  return this.atomPatterns.map(p => p.getTokens()).flat();
3223
3223
  }
3224
- getTokensAfter(_childReference) {
3224
+ getTokensAfter(childReference) {
3225
+ if (this._prefixPatterns.includes(childReference) || this._binaryPatterns.includes(childReference)) {
3226
+ const atomTokens = this._atomPatterns.map(p => p.getTokens()).flat();
3227
+ const prefixTokens = this.prefixPatterns.map(p => p.getTokens()).flat();
3228
+ return [...prefixTokens, ...atomTokens];
3229
+ }
3230
+ if (this._atomPatterns.includes(childReference)) {
3231
+ const postfixTokens = this.prefixPatterns.map(p => p.getTokens()).flat();
3232
+ if (postfixTokens.length === 0) {
3233
+ return this._binaryPatterns.map(p => p.getTokens()).flat();
3234
+ }
3235
+ return postfixTokens;
3236
+ }
3237
+ if (this._postfixPatterns.includes(childReference)) {
3238
+ const postfixTokens = this.postfixPatterns.map(p => p.getTokens()).flat();
3239
+ const binaryTokens = this._binaryPatterns.map(p => p.getTokens()).flat();
3240
+ return [...postfixTokens, ...binaryTokens];
3241
+ }
3225
3242
  return [];
3226
3243
  }
3227
3244
  getNextTokens() {
@@ -3233,7 +3250,24 @@
3233
3250
  getPatterns() {
3234
3251
  return this.atomPatterns.map(p => p.getPatterns()).flat();
3235
3252
  }
3236
- getPatternsAfter(_childReference) {
3253
+ getPatternsAfter(childReference) {
3254
+ if (this._prefixPatterns.includes(childReference) || this._binaryPatterns.includes(childReference)) {
3255
+ const atomPatterns = this._atomPatterns.map(p => p.getPatterns()).flat();
3256
+ const prefixPatterns = this.prefixPatterns.map(p => p.getPatterns()).flat();
3257
+ return [...prefixPatterns, ...atomPatterns];
3258
+ }
3259
+ if (this._atomPatterns.includes(childReference)) {
3260
+ const postfixPatterns = this.prefixPatterns.map(p => p.getPatterns()).flat();
3261
+ if (postfixPatterns.length === 0) {
3262
+ return this._binaryPatterns.map(p => p.getPatterns()).flat();
3263
+ }
3264
+ return postfixPatterns;
3265
+ }
3266
+ if (this._postfixPatterns.includes(childReference)) {
3267
+ const postfixPaterns = this.postfixPatterns.map(p => p.getPatterns()).flat();
3268
+ const binaryPatterns = this._binaryPatterns.map(p => p.getPatterns()).flat();
3269
+ return [...postfixPaterns, ...binaryPatterns];
3270
+ }
3237
3271
  return [];
3238
3272
  }
3239
3273
  getNextPatterns() {