()
| 260 | } |
| 261 | |
| 262 | skipWhitespace(): void { |
| 263 | while (!this.isAtEnd()) { |
| 264 | const ch = this.currentChar(); |
| 265 | if (/\s/.test(ch)) { |
| 266 | this.index++; |
| 267 | continue; |
| 268 | } |
| 269 | if (ch === '/') { |
| 270 | // Support for comments: either // or /* ... */ |
| 271 | const next = this.peekChar(1); |
| 272 | if (next === '/') { |
| 273 | // Single-line comment |
| 274 | this.index += 2; |
| 275 | while (!this.isAtEnd() && this.currentChar() !== '\n') { |
| 276 | this.index++; |
| 277 | } |
| 278 | continue; |
| 279 | } else if (next === '*') { |
| 280 | // Multi-line comment |
| 281 | this.index += 2; |
| 282 | while ( |
| 283 | !this.isAtEnd() && |
| 284 | !(this.currentChar() === '*' && this.peekChar(1) === '/') |
| 285 | ) { |
| 286 | this.index++; |
| 287 | } |
| 288 | if (this.isAtEnd()) { |
| 289 | throw this.error('Unterminated multi-line comment'); |
| 290 | } |
| 291 | this.index += 2; // consume closing */ |
| 292 | continue; |
| 293 | } |
| 294 | } |
| 295 | break; |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | private expectChar(expected: string): void { |
| 300 | if (this.currentChar() !== expected) { |
no test coverage detected