* 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]>)
| 935 | * index to resume from. |
| 936 | */ |
| 937 | function scanAnonymousRecord(s: string, start: number, end: number, ranges: number[], words: Array<[number, number, string]>): number { |
| 938 | if (anonymousRecordDeclStart(s, start) < 0) return end; |
| 939 | const first = lowerWordAt(s, skipTrivia(s, end)); |
| 940 | if (first === '' || NOT_IN_RECORD_FIELDS.has(first)) return end; // `<T: record>`, `R: record;` |
| 941 | const close = recordEnd(s, end); |
| 942 | if (close < 0) return end; |
| 943 | const next = skipTrivia(s, close); |
| 944 | const c = s.charCodeAt(next); |
| 945 | const last = lowerWordAt(s, next) === 'end'; // a last field, whose `;` Pascal lets go but the grammar needs |
| 946 | if (c !== CH_SEMI && c !== CH_EQ && c !== CH_RPAREN && !last) return end; |
| 947 | const packed = wordStartBefore(s, tokenEndBefore(s, start)); |
| 948 | const at = packed >= 0 && lowerWordAt(s, packed) === 'packed' ? packed : start; |
| 949 | words.push([at, at + 6, 'string']); |
| 950 | if (last) { |
| 951 | ranges.push(at + 6, close - 3); |
| 952 | words.push([close - 3, close, ';']); |
| 953 | } else { |
| 954 | ranges.push(at + 6, close); |
| 955 | } |
| 956 | return close; |
| 957 | } |
| 958 | |
| 959 | /** |
| 960 | * `s` with every `[from, to)` range in `ranges` blanked to spaces, newlines kept, and every `[from, to, word]` in |
no test coverage detected