clarity-pattern-parser 11.4.0 → 11.4.1
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/grammar_v2/patterns/Grammar.d.ts +23 -0
- package/dist/grammar_v2/patterns/patterns/grammar.d.ts +87 -0
- package/dist/grammar_v2/patterns/patterns/grammar.test.d.ts +1 -0
- package/dist/index.browser.js +8 -6
- package/dist/index.browser.js.map +1 -1
- package/dist/index.esm.js +8 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +8 -6
- package/dist/index.js.map +1 -1
- package/dist/patterns/Cursor.d.ts +1 -1
- package/package.json +1 -1
- package/src/grammar_v2/patterns/Grammar.ts +170 -0
- package/src/grammar_v2/patterns/patterns/cpat.cpat +91 -0
- package/src/grammar_v2/patterns/patterns/grammar.test.ts +218 -0
- package/src/grammar_v2/patterns/patterns/grammar.ts +103 -0
- package/src/patterns/Cursor.ts +6 -6
- package/src/patterns/Regex.ts +4 -2
- package/src/patterns/Sequence.test.ts +11 -0
package/dist/index.js
CHANGED
|
@@ -433,7 +433,7 @@ class CursorHistory {
|
|
|
433
433
|
|
|
434
434
|
class Cursor {
|
|
435
435
|
get text() {
|
|
436
|
-
return this.
|
|
436
|
+
return this._chars.join("");
|
|
437
437
|
}
|
|
438
438
|
get isOnFirst() {
|
|
439
439
|
return this._index === 0;
|
|
@@ -481,12 +481,12 @@ class Cursor {
|
|
|
481
481
|
return this._history.error != null;
|
|
482
482
|
}
|
|
483
483
|
get currentChar() {
|
|
484
|
-
return this.
|
|
484
|
+
return this._chars[this._index];
|
|
485
485
|
}
|
|
486
486
|
constructor(text) {
|
|
487
|
-
this.
|
|
487
|
+
this._chars = [...text];
|
|
488
488
|
this._index = 0;
|
|
489
|
-
this._length =
|
|
489
|
+
this._length = this._chars.length;
|
|
490
490
|
this._history = new CursorHistory();
|
|
491
491
|
}
|
|
492
492
|
hasNext() {
|
|
@@ -520,7 +520,7 @@ class Cursor {
|
|
|
520
520
|
return this._length - 1;
|
|
521
521
|
}
|
|
522
522
|
getChars(first, last) {
|
|
523
|
-
return this.
|
|
523
|
+
return this._chars.slice(first, last + 1).join("");
|
|
524
524
|
}
|
|
525
525
|
recordMatch(pattern, node) {
|
|
526
526
|
this._history.recordMatch(pattern, node);
|
|
@@ -769,7 +769,9 @@ class Regex {
|
|
|
769
769
|
}
|
|
770
770
|
processResult(cursor, result) {
|
|
771
771
|
const currentIndex = cursor.index;
|
|
772
|
-
const
|
|
772
|
+
const match = result[0];
|
|
773
|
+
const matchLength = [...match].length;
|
|
774
|
+
const newIndex = currentIndex + matchLength - 1;
|
|
773
775
|
this._node = new Node("regex", this._name, currentIndex, newIndex, undefined, result[0]);
|
|
774
776
|
cursor.moveTo(newIndex);
|
|
775
777
|
cursor.recordMatch(this, this._node);
|