* At a `record` keyword from `start` to `end`, recognize the declaration of a field, variable or typed constant of * an anonymous record type, followed by its `;`, a typed constant's `=`, or the `)` or `end` after a last field. The * `record` (or the `packed` before it) is written over by `string`
(s: string, start: number, end: number, ranges: number[], words: Array<[number, number, string]>)
| 1005 | * index to resume from. |
| 1006 | */ |
| 1007 | function scanAnonymousRecord(s: string, start: number, end: number, ranges: number[], words: Array<[number, number, string]>): number { |
| 1008 | if (anonymousRecordDeclStart(s, start) < 0) return end; |
| 1009 | const first = lowerWordAt(s, skipTrivia(s, end)); |
| 1010 | if (first === '' || NOT_IN_RECORD_FIELDS.has(first)) return end; // `<T: record>`, `R: record;` |
| 1011 | const close = recordEnd(s, end); |
| 1012 | if (close < 0) return end; |
| 1013 | const next = skipTrivia(s, close); |
| 1014 | const c = s.charCodeAt(next); |
| 1015 | const last = lowerWordAt(s, next) === 'end'; // a last field, whose `;` Pascal lets go but the grammar needs |
| 1016 | if (c !== CH_SEMI && c !== CH_EQ && c !== CH_RPAREN && !last) return end; |
| 1017 | const packed = wordStartBefore(s, tokenEndBefore(s, start)); |
| 1018 | const at = packed >= 0 && lowerWordAt(s, packed) === 'packed' ? packed : start; |
| 1019 | words.push([at, at + 6, 'string']); |
| 1020 | if (last) { |
| 1021 | ranges.push(at + 6, close - 3); |
| 1022 | words.push([close - 3, close, ';']); |
| 1023 | } else { |
| 1024 | ranges.push(at + 6, close); |
| 1025 | } |
| 1026 | return close; |
| 1027 | } |
| 1028 | |
| 1029 | /** |
| 1030 | * `s` with every `[from, to)` range in `ranges` blanked to spaces, newlines kept, and every `[from, to, word]` in |
no test coverage detected