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.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 (
|
|
1010
|
-
|
|
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);
|