clarity-pattern-parser 10.0.4 → 10.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.
package/dist/index.js CHANGED
@@ -377,10 +377,11 @@ class CursorHistory {
377
377
  }
378
378
 
379
379
  class CyclicalParseError extends Error {
380
- constructor(patternId, patternName) {
380
+ constructor(patternId, patternName, cursorIndex) {
381
381
  super("Cyclical Parse Error");
382
382
  this.patternId = patternId;
383
383
  this.patternName = patternName;
384
+ this.cursorIndex = cursorIndex;
384
385
  }
385
386
  }
386
387
  class Cursor {
@@ -494,7 +495,7 @@ class Cursor {
494
495
  };
495
496
  const hasCycle = this._stackTrace.filter(t => t.pattern.id === pattern.id && this.index === t.cursorIndex).length > 1;
496
497
  if (hasCycle) {
497
- throw new CyclicalParseError(pattern.id, pattern.name);
498
+ throw new CyclicalParseError(pattern.id, pattern.name, this.index);
498
499
  }
499
500
  this._history.pushStackTrace(trace);
500
501
  this._stackTrace.push(trace);
@@ -1006,14 +1007,8 @@ class Options {
1006
1007
  try {
1007
1008
  result = pattern.parse(cursor);
1008
1009
  }
1009
- catch (error) {
1010
- if (error.patternId === this._id) {
1011
- continue;
1012
- }
1013
- else {
1014
- cursor.endParse();
1015
- throw error;
1016
- }
1010
+ catch (_a) {
1011
+ continue;
1017
1012
  }
1018
1013
  if (this._isGreedy) {
1019
1014
  results.push(result);