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/index.js CHANGED
@@ -433,7 +433,7 @@ class CursorHistory {
433
433
 
434
434
  class Cursor {
435
435
  get text() {
436
- return this._text;
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._text[this._index];
484
+ return this._chars[this._index];
485
485
  }
486
486
  constructor(text) {
487
- this._text = text;
487
+ this._chars = [...text];
488
488
  this._index = 0;
489
- this._length = [...text].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._text.slice(first, last + 1);
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 newIndex = currentIndex + result[0].length - 1;
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);