| 364 | /\s+|[\p{ID_Start}$_][\p{ID_Continue}$]*|\d[\p{ID_Continue}.]*|"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*'|./suy |
| 365 | |
| 366 | const readBetween = ( |
| 367 | code: string, |
| 368 | start: number, |
| 369 | end: number, |
| 370 | tokens: Token[] |
| 371 | ): void => { |
| 372 | between.lastIndex = start |
| 373 | while (between.lastIndex < end) { |
| 374 | const at = between.lastIndex |
| 375 | let [text] = between.exec(code)! |
| 376 | // a word may run past where the next named token starts |
| 377 | if (at + text.length > end) { |
| 378 | text = text.slice(0, end - at) |
| 379 | between.lastIndex = end |
| 380 | } |
| 381 | if (text.trim()) tokens.push({ start: at, end: at + text.length, text }) |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | // what differs between two lists of tokens: each run of the base's, and the |
| 386 | // run of the other's in its place |