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.esm.js
CHANGED
|
@@ -429,7 +429,7 @@ class CursorHistory {
|
|
|
429
429
|
|
|
430
430
|
class Cursor {
|
|
431
431
|
get text() {
|
|
432
|
-
return this.
|
|
432
|
+
return this._chars.join("");
|
|
433
433
|
}
|
|
434
434
|
get isOnFirst() {
|
|
435
435
|
return this._index === 0;
|
|
@@ -477,12 +477,12 @@ class Cursor {
|
|
|
477
477
|
return this._history.error != null;
|
|
478
478
|
}
|
|
479
479
|
get currentChar() {
|
|
480
|
-
return this.
|
|
480
|
+
return this._chars[this._index];
|
|
481
481
|
}
|
|
482
482
|
constructor(text) {
|
|
483
|
-
this.
|
|
483
|
+
this._chars = [...text];
|
|
484
484
|
this._index = 0;
|
|
485
|
-
this._length =
|
|
485
|
+
this._length = this._chars.length;
|
|
486
486
|
this._history = new CursorHistory();
|
|
487
487
|
}
|
|
488
488
|
hasNext() {
|
|
@@ -516,7 +516,7 @@ class Cursor {
|
|
|
516
516
|
return this._length - 1;
|
|
517
517
|
}
|
|
518
518
|
getChars(first, last) {
|
|
519
|
-
return this.
|
|
519
|
+
return this._chars.slice(first, last + 1).join("");
|
|
520
520
|
}
|
|
521
521
|
recordMatch(pattern, node) {
|
|
522
522
|
this._history.recordMatch(pattern, node);
|
|
@@ -765,7 +765,9 @@ class Regex {
|
|
|
765
765
|
}
|
|
766
766
|
processResult(cursor, result) {
|
|
767
767
|
const currentIndex = cursor.index;
|
|
768
|
-
const
|
|
768
|
+
const match = result[0];
|
|
769
|
+
const matchLength = [...match].length;
|
|
770
|
+
const newIndex = currentIndex + matchLength - 1;
|
|
769
771
|
this._node = new Node("regex", this._name, currentIndex, newIndex, undefined, result[0]);
|
|
770
772
|
cursor.moveTo(newIndex);
|
|
771
773
|
cursor.recordMatch(this, this._node);
|