(pattern: string)
| 86 | |
| 87 | // @todo: atString()?, or just at()? |
| 88 | match(pattern: string): boolean { |
| 89 | const start = this.pos; |
| 90 | for (const char of pattern) { |
| 91 | if (this.peek() !== char) { |
| 92 | this.pos = start; // Reset position if match fails |
| 93 | return false; |
| 94 | } |
| 95 | this.consume(); // Consume the character |
| 96 | } |
| 97 | return true; |
| 98 | } |
| 99 | |
| 100 | skipWhitespace(): void { |
| 101 | while (!this.atEnd && /\s/.test(this.peek()!)) this.pos += 1; |