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.browser.js +5 -10
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +5 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +5 -10
- package/dist/index.js.map +1 -1
- package/dist/patterns/Cursor.d.ts +2 -1
- package/package.json +1 -1
- package/src/patterns/Cursor.ts +4 -2
- package/src/patterns/Options.test.ts +17 -0
- package/src/patterns/Options.ts +2 -7
package/dist/index.esm.js
CHANGED
|
@@ -373,10 +373,11 @@ class CursorHistory {
|
|
|
373
373
|
}
|
|
374
374
|
|
|
375
375
|
class CyclicalParseError extends Error {
|
|
376
|
-
constructor(patternId, patternName) {
|
|
376
|
+
constructor(patternId, patternName, cursorIndex) {
|
|
377
377
|
super("Cyclical Parse Error");
|
|
378
378
|
this.patternId = patternId;
|
|
379
379
|
this.patternName = patternName;
|
|
380
|
+
this.cursorIndex = cursorIndex;
|
|
380
381
|
}
|
|
381
382
|
}
|
|
382
383
|
class Cursor {
|
|
@@ -490,7 +491,7 @@ class Cursor {
|
|
|
490
491
|
};
|
|
491
492
|
const hasCycle = this._stackTrace.filter(t => t.pattern.id === pattern.id && this.index === t.cursorIndex).length > 1;
|
|
492
493
|
if (hasCycle) {
|
|
493
|
-
throw new CyclicalParseError(pattern.id, pattern.name);
|
|
494
|
+
throw new CyclicalParseError(pattern.id, pattern.name, this.index);
|
|
494
495
|
}
|
|
495
496
|
this._history.pushStackTrace(trace);
|
|
496
497
|
this._stackTrace.push(trace);
|
|
@@ -1002,14 +1003,8 @@ class Options {
|
|
|
1002
1003
|
try {
|
|
1003
1004
|
result = pattern.parse(cursor);
|
|
1004
1005
|
}
|
|
1005
|
-
catch (
|
|
1006
|
-
|
|
1007
|
-
continue;
|
|
1008
|
-
}
|
|
1009
|
-
else {
|
|
1010
|
-
cursor.endParse();
|
|
1011
|
-
throw error;
|
|
1012
|
-
}
|
|
1006
|
+
catch (_a) {
|
|
1007
|
+
continue;
|
|
1013
1008
|
}
|
|
1014
1009
|
if (this._isGreedy) {
|
|
1015
1010
|
results.push(result);
|